You can subscribe to this list here.
2009 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(5) |
Jul
(15) |
Aug
(1) |
Sep
(7) |
Oct
(5) |
Nov
(1) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(12) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
(4) |
Aug
(3) |
Sep
(1) |
Oct
(1) |
Nov
|
Dec
|
2011 |
Jan
(2) |
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
(12) |
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(6) |
Nov
|
Dec
|
From: <eig...@us...> - 2012-10-07 18:46:34
|
Revision: 89 http://firmata.svn.sourceforge.net/firmata/?rev=89&view=rev Author: eighthave Date: 2012-10-07 18:46:28 +0000 (Sun, 07 Oct 2012) Log Message: ----------- The project file for MPLab Added Paths: ----------- picduino/trunk/f767duino.mcp Added: picduino/trunk/f767duino.mcp =================================================================== --- picduino/trunk/f767duino.mcp (rev 0) +++ picduino/trunk/f767duino.mcp 2012-10-07 18:46:28 UTC (rev 89) @@ -0,0 +1,30 @@ +[HEADER] +magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13} +file_version=1.0 +[PATH_INFO] +dir_src= +dir_bin= +dir_tmp= +dir_sin= +dir_inc= +dir_lib= +dir_lkr= +[CAT_FILTERS] +filter_src=*.asm +filter_inc=*.h;*.inc +filter_obj=*.o +filter_lib=*.lib +filter_lkr=*.lkr +[OTHER_FILES] +file_000=no +file_001=no +[FILE_INFO] +file_000=f767duino.asm +file_001=P16F767.INC +[SUITE_INFO] +suite_guid={6B3DAA78-59C1-46DD-B6AA-DBDAE4E06484} +suite_state= +[TOOL_SETTINGS] +TS{DD2213A8-6310-47B1-8376-9430CDFC013F}= +TS{BFD27FBA-4A02-4C0E-A5E5-B812F3E7707C}=/o"$(TARGETBASE).cof" /M"$(BINDIR_)$(TARGETBASE).map" +TS{ADE93A55-C7C7-4D4D-A4BA-59305F7D0391}= Property changes on: picduino/trunk/f767duino.mcp ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eig...@us...> - 2012-10-07 18:44:18
|
Revision: 88 http://firmata.svn.sourceforge.net/firmata/?rev=88&view=rev Author: eighthave Date: 2012-10-07 18:44:12 +0000 (Sun, 07 Oct 2012) Log Message: ----------- changed comments Modified Paths: -------------- picduino/trunk/f767duino.asm Modified: picduino/trunk/f767duino.asm =================================================================== --- picduino/trunk/f767duino.asm 2012-10-07 18:40:48 UTC (rev 87) +++ picduino/trunk/f767duino.asm 2012-10-07 18:44:12 UTC (rev 88) @@ -37,8 +37,8 @@ ; * ;************************************************************************************************ ; * -; This is an implementation of the Arduino using a PIC16F767 instead of an ATmega8. * -; See PICduino.CKT for the schematic. * +; This is an implementation of the pd firmware on Arduino using a PIC16F767 instead of an ATmega8.* +; See picduino.png for the schematic. * ; * ;************************************************************************************************ ;___Arduino_Pin_Name____=___PIC_Pin_Name____* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eig...@us...> - 2012-10-07 18:40:54
|
Revision: 87 http://firmata.svn.sourceforge.net/firmata/?rev=87&view=rev Author: eighthave Date: 2012-10-07 18:40:48 +0000 (Sun, 07 Oct 2012) Log Message: ----------- The new hex file. Modified Paths: -------------- picduino/trunk/f767duino.HEX Modified: picduino/trunk/f767duino.HEX =================================================================== --- picduino/trunk/f767duino.HEX 2012-10-07 18:39:31 UTC (rev 86) +++ picduino/trunk/f767duino.HEX 2012-10-07 18:40:48 UTC (rev 87) @@ -9,112 +9,118 @@ :10006000A601A701A801A901AA010130AB00063031 :10007000AC004030D600D700F701F80186018701B7 :10008000FF3083168500F4008600F5008700F60037 -:1000900083129420D1015108D2000030D3000821EE +:1000900083129A20D1015108D2000030D3000E21E2 :1000A000D10A0E305102031C4B28953083169F0055 :1000B000831280309F00283083169B0083121F1408 -:1000C0007E202B1C6B2897308E200730A2207E20AC -:1000D0000030A2207E20AD012C082D0203186028DC -:1000E000CE24A1302D078E202F0D2E0D07398E2006 -:1000F0002F087F398E207E20AD0A6C2856085706BF -:10010000031908005708840000081F22D70A50303E -:100110005706031D7E284030D7007E288316981C82 -:100120008F2883129900080083162F309900181524 -:1001300083129817831698168C16831218160B17AD -:100140008B170800DA01D900D100D501D4010314BE -:10015000D50DD40DD1080319B828D103A828D10A88 -:10016000073051060319C328D90A0310D50DD40D41 -:1001700026085505031DAF2825085405031DAF2883 -:100180008524DA0CAF280310DA0C5A088E200800F8 -:10019000871B03140800071B03140800871A0314A5 -:1001A0000800071A0314080087190314080006182A -:1001B00003140800061A03140800861B0314080021 -:1001C000061B03140800861A0314080007190314F9 -:1001D000080087180314080007180314080086187D -:1001E000031408008530FE288D30FE289530FE2847 -:1001F000A530FE288730FE288F30FE289F001F196B -:10020000FF281E08AE0083161E088312AF000800E8 -:1002100000305306031D4D29982C26102810F61780 -:1002200076088316870083120800A610A810761798 -:10023000102926112811F6161029A611A8117616D4 -:10024000102926122812F6151029A612A8127514C4 -:100250007508831686008312080026132813751666 -:100260002829A613A813F517282925102710751774 -:100270002829A510A710F51628292511271176156C -:100280001029A511A711F61410292512271276148A -:100290001029A512A712F5142829013053060319B5 -:1002A0008429AA2C0800080026152811F612102906 -:1002B000A615A8117612102926162812F611102953 -:1002C000A616A81275102829261728137512282992 -:1002D000A617A813F5132829251427107513282904 -:1002E000A514A710F5122829251527117611102914 -:1002F000A515A711F610102925162712761010291A -:10030000A516A712F5102829023053060319080074 -:10031000BC2C0800080026152815F6121029A61571 -:10032000A8157612102926162816F6111029A616D9 -:10033000A816751028292617281775122829A61718 -:10034000A817F51328292514271475132829A5148F -:10035000A714F51228292515271576111029A5159A -:10036000A715F61010292516271676101029A516A0 -:10037000A716F51028297808870008007708860056 -:100380000800F817031CF813BB297817031C78130F -:10039000BB29F816031CF812BB297816031C781227 -:1003A000BB29F815031CF811BB297714031C77101F -:1003B000BE297716031C7712BE29F717031CF71303 -:1003C000BE297717031C7713BE29F716031CF712F3 -:1003D000BE297815031C7811BB29F814031CF810EA -:1003E000BB297814031C7810BB29F714031CF710E1 -:1003F000BE29AB0108002B14080003010A2A0130B2 -:100400000A2A02300A2A03300A2A04300A2A05304E -:100410000A2A0630AC0008000230A0005808A100EB -:1004200008000130A0005808A100080024140800AA -:10043000F0308E2000308E2001308E200800D80051 -:10044000A0080319462AA003223020078400580878 -:100450008000A10803190800A008031D0800D82C7B -:100460002308D2000230D3000821442A2208D200F7 -:100470000030D3000821442A2308D2000230D300E0 -:100480000821442A442A442AA1010800D81B002C30 -:100490002808FF3A2605D5002708FF3A2505D4008D -:1004A000241C7E2AD51F582A031058180314DD2156 -:1004B000541C5E2A0310D8180314E121D41C642AAA -:1004C000031058190314E521541D6A2A0310D81982 -:1004D0000314E921D41D702A0310581A0314ED21C6 -:1004E000541E762A0310D81A0314F121D41E7C2A34 -:1004F0000310581B0314F521A4010800551C842A7D -:10050000031058180314C121D51C8A2A0310D818C7 -:100510000314C521551D902A031058190314C9212D -:10052000D51D962A0310D8190314CD21551E9C2AD7 -:100530000310581A0314D121D51EA22A0310D81A69 -:100540000314D521551FA82A0310581B0314D921C1 -:020550000800A1 -:1008000004308A0058087F398207080008000D2943 -:10081000152919291D29212925292D29312935296C -:1008200039293D294129452949290800080008009E -:10083000080008000800F929FB2908000800080042 -:1008400008000800080008000800FD29FF29012A07 -:10085000032A052A072A092A0800080008000800B8 +:1000C000FE308316920083120730920084202B1C8E +:1000D0007128973094200730A82084200030A82071 +:1000E0008420AD012C082D0203186628CE24A130EF +:1000F0002D0794202F0D2E0D073994202F087F39BE +:1001000094208420AD0A7228560857060319080067 +:100110005708840000082522D70A50305706031DCF +:1001200084284030D70084288316981C9528831291 +:100130009900080083162F3099001815831298171C +:10014000831698168C16831218160B178B17080037 +:10015000DA01D900D100D501D4010314D50DD40D95 +:10016000D1080319BE28D103AE28D10A07305106A1 +:100170000319C928D90A0310D50DD40D2608550531 +:10018000031DB52825085405031DB5288524DA0C60 +:10019000B5280310DA0C5A0894200800871B0314B2 +:1001A0000800071B03140800871A03140800071A25 +:1001B0000314080087190314080006180314080024 +:1001C000061A03140800861B03140800061B0314F8 +:1001D0000800861A0314080007190314080087187A +:1001E00003140800071803140800861803140800F5 +:1001F000853004298D30042995300429A53004293F +:10020000873004298F3004299F001F1905291E08F3 +:10021000AE0083161E088312AF000800003053069C +:10022000031D5329982C26102810F61776088316DC +:10023000870083120800A610A81076171629261129 +:100240002811F6161629A611A811761616292612B7 +:100250002812F6151629A612A81275147508831609 +:100260008600831208002613281375162E29A6135C +:10027000A813F5172E292510271075172E29A5105C +:10028000A710F5162E292511271176151629A51167 +:10029000A711F61416292512271276141629A5126D +:1002A000A712F5142E290130530603198A29AA2C06 +:1002B0000800080026152811F6121629A615A811FF +:1002C0007612162926162812F6111629A616A81235 +:1002D00075102E292617281375122E29A617A81374 +:1002E000F5132E292514271075132E29A514A710F0 +:1002F000F5122E292515271176111629A515A711F6 +:10030000F61016292516271276101629A516A712FB +:10031000F5102E290230530603190800BC2C0800E2 +:10032000080026152815F6121629A615A815761206 +:10033000162926162816F6111629A616A8167510BF +:100340002E292617281775122E29A617A817F51378 +:100350002E292514271475132E29A514A714F51278 +:100360002E292515271576111629A515A715F6107E +:1003700016292516271676101629A516A716F51084 +:100380002E29780887000800770886000800F817EB +:10039000031CF813C1297817031C7813C129F81618 +:1003A000031CF812C1297816031C7812C129F8150C +:1003B000031CF811C1297714031C7710C429771680 +:1003C000031C7712C429F717031CF713C4297717E6 +:1003D000031C7713C429F716031CF712C4297815D8 +:1003E000031C7811C129F814031CF810C1297814D2 +:1003F000031C7810C129F714031CF710C429AB01A2 +:1004000008002B1408000301102A0130102A0230C2 +:10041000102A0330102A0430102A0530102A063022 +:10042000AC0008000230A0005808A100080001300C +:10043000A0005808A100080024140800F0309420FF +:1004400000309420013094200800D800A00803193F +:100450007A2AA00322302007840058088000A108CF +:1004600003190800A008031D0800D82C0230D3008F +:100470002308D200093C03194F2A013E0319492AD7 +:10048000013E031D782A0E2122089B000C309D009E +:10049000782A0E21220895000C309700782A0E2128 +:1004A0002208831695000C3097008312782A782A48 +:1004B0000030D3002208D200093C03196B2A013E08 +:1004C0000319682A013E031D782A0E219D01782A0E +:1004D0000E219701782A0E21831697018312782A1C +:1004E0002308D2000230D3000E21782A782A782AF5 +:1004F000A1010800D81B002C2808FF3A2605D500CA +:100500002708FF3A2505D400241CB22AD51F8C2ABF +:10051000031058180314E321541C922A0310D8180E +:100520000314E721D41C982A031058190314EB2153 +:10053000541D9E2A0310D8190314EF21D41DA42A98 +:100540000310581A0314F321541EAA2A0310D81AB0 +:100550000314F721D41EB02A0310581B0314FB21E7 +:10056000A4010800551CB82A031058180314C72109 +:10057000D51CBE2A0310D8180314CB21551DC42A3C +:10058000031058190314CF21D51DCA2A0310D819F6 +:100590000314D321551ED02A0310581A0314D7214F +:1005A000D51ED62A0310D81A0314DB21551FDC2AC6 +:0A05B0000310581B0314DF2108009C +:1008000004308A0058087F3982070800080013293D +:100810001B291F29232927292B29332937293B293C +:100820003F29432947294B294F2908000800080080 +:10083000080008000800FF29012A08000800080035 +:1008400008000800080008000800032A052A072AF3 +:10085000092A0B2A0D2A0F2A0800080008000800A0 :100860000800080008000800080008000800080048 :100870000800080008000800080008000800080038 :100880000800080008000800080008000800080028 -:1008900008000800080008000800522953295429BC -:1008A00058295C296029642968296C2970297429D0 -:1008B00078297C2980290800080008000800080021 +:1008900008000800080008000800582959295A29AA +:1008A0005E29622966296A296E29722976297A29A0 +:1008B0007E2982298629080008000800080008000F :1008C00008000800080008000800080008000800E8 -:1008D00008000800162A08000800080008000800A0 -:1008E00008000800080008000800182A080008008E -:1008F0000800080008000800080008000800112A85 -:100900000C2A112A0C2A112A080004308A005908DE -:1009100003108207C828CB28CE28D128D428D7286E -:10092000DA28DD28E028E328E628E928EC28EF2863 -:1009300004308A00520882070D29152919291D291A -:10094000212925292D293129352939293D294129CF -:100950004529492904308A0052088207522953291F -:10096000542958295C296029642968296C2970292F -:10097000742978297C29802904308A00520882074A -:1009800089298A298B298F29932997299B299F298E -:10099000A329A729AB29AF29B329B72904308A0095 -:1009A0002D088207F228F428F628F828FA28FC28CF -:1009B00004308A00FA3021028207362A302A422A7D -:0409C0003C2A432A60 +:1008D000080008001C2A080008000800080008009A +:1008E000080008000800080008001E2A0800080088 +:1008F0000800080008000800080008000800172A7F +:10090000122A172A122A172A080004308A005908C6 +:1009100003108207CE28D128D428D728DA28DD284A +:10092000E028E328E628E928EC28EF28F228F52833 +:1009300004308A005208820713291B291F29232902 +:1009400027292B29332937293B293F29432947299F +:100950004B294F2904308A00520882075829592907 +:100960005A295E29622966296A296E2972297629FF +:100970007A297E298229862904308A005208820732 +:100980008F2990299129952999299D29A129A5295E +:10099000A929AD29B129B529B929BD2904308A0071 +:1009A0002D088207F828FA28FC28FE2800290229A9 +:1009B00004308A00FA3021028207582A362A762A21 +:0409C000702A772AF8 :02400E00A23FCF :02401000BC3FB3 :00000001FF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eig...@us...> - 2012-10-07 18:39:37
|
Revision: 86 http://firmata.svn.sourceforge.net/firmata/?rev=86&view=rev Author: eighthave Date: 2012-10-07 18:39:31 +0000 (Sun, 07 Oct 2012) Log Message: ----------- Added hardware PWM on digital pins 9,10,11 Modified Paths: -------------- picduino/trunk/f767duino.asm Modified: picduino/trunk/f767duino.asm =================================================================== --- picduino/trunk/f767duino.asm 2012-10-07 18:37:47 UTC (rev 85) +++ picduino/trunk/f767duino.asm 2012-10-07 18:39:31 UTC (rev 86) @@ -1,6 +1,10 @@ ;******************************************************** ; * ; Filename: f767duino.asm * +; Date: 20061023 * +; File Version: 0.7 * +; implement analogWrite for hardware pwm on * +; digital pins 9,10 and 11. * ; Date: 20061016 * ; File Version: 0.6 * ; Fixed a bug in receive interrupt handler and * @@ -60,11 +64,17 @@ ; AnalogInput5 = RB3/AN9 * ; VRef = RA3/AN3 * ; * -; Timing parameters: +; Timing parameters using PIC16F767: ; FOsc = 14745600Hz -; TOsc = 67.8ns -; Tad = 2.17us, Tcnv = 26.04us +; TOsc = 67.8168ns +; Tad = 32*TOsc = 2.17014us, Tcnv = 12*Tad = 26.0417us Taqu = 12*Tad = 26.0417us ; ADC needs 20us (~10Tad) to charge the sampling capacitor + 2Tad(~5us) after each conversion +; Total adc time = 26*Tad = 56.4236us +; Maximum ADC rate (1 channel) = 17723.1 conversions per second +; +; Baud rate is 19200 +; ADC conversion packet length 3 bytes = 30 bits +; Time to transmit 30 bits at 19200 baud: 0.0015625s = 640 results per second ;******************************************** ; This is based on Pd_firmware_pde ; Copyright (C) 2006 Hans-Christoph Steiner @@ -427,6 +437,15 @@ ;6. Read A/D Result registers (ADRESH:ADRESL); clear bit ADIF (if required). ;7. For next conversion, go to step 1 or step 2 as required. The A/D conversion time per bit is ; defined as TAD. A minimum wait of 2 TAD is required before the next acquisition starts. +; +; Setup Timer2 for hardware PWM (1.002kHz: timer prescale 1:16, PR2=254) + movlw d'254' ; 903.53Hz + bsf STATUS,RP0 ; bank 1 + movwf PR2 + bcf STATUS,RP0 ; bank 0 + movlw b'00000111' ; timer on, prescale 1:16 + movwf T2CON +; ; } ;} ; @@ -1342,25 +1361,136 @@ mb_enablePwm ; case ENABLE_PWM: ; 251 ; setPinMode(storedInputData[1],PWM); + movlw PWM + movwf mode movf storedInputData1,w movwf pin - movlw PWM - movwf mode + sublw d'9' ; 9-PIN pins 9,10,11 only + btfsc STATUS,Z + goto setPWM9 + addlw d'1' + btfsc STATUS,Z + goto setPWM10 + addlw d'1' + btfss STATUS,Z + goto pi_6 ; not a hardware PWM pin +setPWM11 call setPinMode + movf storedInputData0,w + movwf CCPR2L + movlw b'00001100' ; PWM mode, PWM LSBs=00 + movwf CCP2CON + goto pi_6 +setPWM10 + call setPinMode + movf storedInputData0,w + movwf CCPR1L + movlw b'00001100' ; PWM mode, PWM LSBs=00 + movwf CCP1CON + goto pi_6 +setPWM9 + call setPinMode + movf storedInputData0,w + bsf STATUS,RP0 ; bank 1 + movwf CCPR3L + movlw b'00001100' ; PWM mode, PWM LSBs=00 + movwf CCP3CON + bcf STATUS,RP0 ; bank 0 + goto pi_6 + ; analogWrite(storedInputData[1], storedInputData[0]); +; analogWrite from wiring.c (http://svn.berlios.de/svnroot/repos/arduino/trunk/targets/arduino/wiring.c): +;// Right now, PWM output only works on the pins with +;// hardware support. These are defined in the appropriate +;// pins_*.c file. For the rest of the pins, we default +;// to digital output. +;void analogWrite(int pin, int val) +;{ +; // We need to make sure the PWM output is enabled for those pins +; // that support it, as we turn it off when digitally reading or +; // writing with them. Also, make sure the pin is in output mode +; // for consistenty with Wiring, which doesn't require a pinMode +; // call for the analog output pins. +; pinMode(pin, OUTPUT); +; +; if (analogOutPinToTimer(pin) == TIMER1A) { +; // connect pwm to pin on timer 1, channel A +; sbi(TCCR1A, COM1A1); +; // set pwm duty +; OCR1A = val; +; } else if (analogOutPinToTimer(pin) == TIMER1B) { +; // connect pwm to pin on timer 1, channel B +; sbi(TCCR1A, COM1B1); +; // set pwm duty +; OCR1B = val; +;#if defined(__AVR_ATmega168__) +; } else if (analogOutPinToTimer(pin) == TIMER0A) { +; // connect pwm to pin on timer 0, channel A +; sbi(TCCR0A, COM0A1); +; // set pwm duty +; OCR0A = val; +; } else if (analogOutPinToTimer(pin) == TIMER0B) { +; // connect pwm to pin on timer 0, channel B +; sbi(TCCR0A, COM0B1); +; // set pwm duty +; OCR0B = val; +; } else if (analogOutPinToTimer(pin) == TIMER2A) { +; // connect pwm to pin on timer 2, channel A +; sbi(TCCR2A, COM2A1); +; // set pwm duty +; OCR2A = val; +; } else if (analogOutPinToTimer(pin) == TIMER2B) { +; // connect pwm to pin on timer 2, channel B +; sbi(TCCR2A, COM2B1); +; // set pwm duty +; OCR2B = val; +;#else +; } else if (analogOutPinToTimer(pin) == TIMER2) { +; // connect pwm to pin on timer 2, channel B +; sbi(TCCR2, COM21); +; // set pwm duty +; OCR2 = val; +;#endif +; } else if (val < 128) +; digitalWrite(pin, LOW); +; else +; digitalWrite(pin, HIGH); +;} +; end of analogWrite() from wiring.c ; break; goto pi_6 ; ------------------------------------------------------------------------- mb_disablePwm ; case DISABLE_PWM: ; 250 ; setPinMode(storedInputData[0],INPUT); + movlw INPUT + movwf mode movf storedInputData0,w movwf pin - movlw INPUT - movwf mode + sublw d'9' ; 9 - PIN, pins 9,10,11 only + btfsc STATUS,Z + goto disPWM9 + addlw d'1' + btfsc STATUS,Z + goto disPWM10 + addlw d'1' + btfss STATUS,Z + goto pi_6 ; not a hardware PWM pin +disPWM11 call setPinMode + clrf CCP2CON + goto pi_6 ; not a hardware PWM pin +disPWM10 + call setPinMode + clrf CCP1CON + goto pi_6 ; not a hardware PWM pin +disPWM9 + call setPinMode + bsf STATUS,RP0 ; bank 1 + clrf CCP3CON + bcf STATUS,RP0 ; bank 0 + goto pi_6 ; not a hardware PWM pin ; break; - goto pi_6 ; ------------------------------------------------------------------------- mb_enableSoftPwm ; case ENABLE_SOFTWARE_PWM: ; 253 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eig...@us...> - 2012-10-07 18:37:55
|
Revision: 85 http://firmata.svn.sourceforge.net/firmata/?rev=85&view=rev Author: eighthave Date: 2012-10-07 18:37:47 +0000 (Sun, 07 Oct 2012) Log Message: ----------- The PIC version of the arduino Added Paths: ----------- picduino/trunk/P16F767.INC picduino/trunk/f767duino.HEX picduino/trunk/f767duino.asm picduino/trunk/f767duino.mcw picduino/trunk/picduino.png Added: picduino/trunk/P16F767.INC =================================================================== --- picduino/trunk/P16F767.INC (rev 0) +++ picduino/trunk/P16F767.INC 2012-10-07 18:37:47 UTC (rev 85) @@ -0,0 +1,502 @@ + LIST +; P16F767.INC Standard Header File, Version 1.00 Microchip Technology, Inc. + NOLIST + +; This header file defines configurations, registers, and other useful bits of +; information for the PIC16F767 microcontroller. These names are taken to match +; the data sheets as closely as possible. + +; Note that the processor must be selected before this file is +; included. The processor may be selected the following ways: + +; 1. Command line switch: +; C:\ MPASM MYFILE.ASM /PIC16F767 +; 2. LIST directive in the source file +; LIST P=PIC16F767 +; 3. Processor Type entry in the MPASM full-screen interface + +;========================================================================== +; +; Revision History +; +;========================================================================== + +;Rev: Date: Reason: +;1.00 05/05/03 Initial Release +;1.01 10/21/03 Made changes to Program Memory register names. +;1.02 04/07/04 Added INT0IE & INT0IF bit names. + +;========================================================================== +; +; Verify Processor +; +;========================================================================== + + IFNDEF __16F767 + MESSG "Processor-header file mismatch. Verify selected processor." + ENDIF + +;========================================================================== +; +; Register Definitions +; +;========================================================================== + +W EQU H'0000' +F EQU H'0001' + +;----- Register Files------------------------------------------------------ + +INDF EQU H'0000' +TMR0 EQU H'0001' +PCL EQU H'0002' +STATUS EQU H'0003' +FSR EQU H'0004' +PORTA EQU H'0005' +PORTB EQU H'0006' +PORTC EQU H'0007' +PORTE EQU H'0009' +PCLATH EQU H'000A' +INTCON EQU H'000B' +PIR1 EQU H'000C' +PIR2 EQU H'000D' +TMR1L EQU H'000E' +TMR1H EQU H'000F' +T1CON EQU H'0010' +TMR2 EQU H'0011' +T2CON EQU H'0012' +SSPBUF EQU H'0013' +SSPCON EQU H'0014' +CCPR1L EQU H'0015' +CCPR1H EQU H'0016' +CCP1CON EQU H'0017' +RCSTA EQU H'0018' +TXREG EQU H'0019' +RCREG EQU H'001A' +CCPR2L EQU H'001B' +CCPR2H EQU H'001C' +CCP2CON EQU H'001D' +ADRESH EQU H'001E' +ADCON0 EQU H'001F' + +OPTION_REG EQU H'0081' +TRISA EQU H'0085' +TRISB EQU H'0086' +TRISC EQU H'0087' +TRISE EQU H'0089' +PIE1 EQU H'008C' +PIE2 EQU H'008D' +PCON EQU H'008E' +OSCCON EQU H'008F' +OSCTUNE EQU H'0090' +SSPCON2 EQU H'0091' +PR2 EQU H'0092' +SSPADD EQU H'0093' +SSPSTAT EQU H'0094' +CCPR3L EQU H'0095' +CCPR3H EQU H'0096' +CCP3CON EQU H'0097' +TXSTA EQU H'0098' +SPBRG EQU H'0099' +ADCON2 EQU H'009B' +CMCON EQU H'009C' +CVRCON EQU H'009D' +ADRESL EQU H'009E' +ADCON1 EQU H'009F' + +WDTCON EQU H'0105' +LVDCON EQU H'0109' +PMDATA EQU H'010C' +PMADR EQU H'010D' +PMDATH EQU H'010E' +PMADRH EQU H'010F' + +PMCON1 EQU H'018C' + +;----- STATUS Bits -------------------------------------------------------- + +IRP EQU H'0007' +RP1 EQU H'0006' +RP0 EQU H'0005' +NOT_TO EQU H'0004' +NOT_PD EQU H'0003' +Z EQU H'0002' +DC EQU H'0001' +C EQU H'0000' + +;----- INTCON Bits -------------------------------------------------------- + +GIE EQU H'0007' +PEIE EQU H'0006' +T0IE EQU H'0005' +TMR0IE EQU H'0005' +INTE EQU H'0004' +INT0IE EQU H'0004' +RBIE EQU H'0003' +T0IF EQU H'0002' +TMR0IF EQU H'0002' +INTF EQU H'0001' +INT0IF EQU H'0001' +RBIF EQU H'0000' + +;----- PIR1 Bits ---------------------------------------------------------- + +PSPIF EQU H'0007' +ADIF EQU H'0006' +RCIF EQU H'0005' +TXIF EQU H'0004' +SSPIF EQU H'0003' +CCP1IF EQU H'0002' +TMR2IF EQU H'0001' +TMR1IF EQU H'0000' + +;----- PIR2 Bits ---------------------------------------------------------- + +OSFIF EQU H'0007' +CMIF EQU H'0006' +LVDIF EQU H'0005' +BCLIF EQU H'0003' +CCP3IF EQU H'0001' +CCP2IF EQU H'0000' + +;----- T1CON Bits --------------------------------------------------------- + +T1RUN EQU H'0006' +T1CKPS1 EQU H'0005' +T1CKPS0 EQU H'0004' +T1OSCEN EQU H'0003' +NOT_T1SYNC EQU H'0002' +T1INSYNC EQU H'0002' ; Backward compatibility only +T1SYNC EQU H'0002' +TMR1CS EQU H'0001' +TMR1ON EQU H'0000' + +;----- T2CON Bits --------------------------------------------------------- + +TOUTPS3 EQU H'0006' +TOUTPS2 EQU H'0005' +TOUTPS1 EQU H'0004' +TOUTPS0 EQU H'0003' +TMR2ON EQU H'0002' +T2CKPS1 EQU H'0001' +T2CKPS0 EQU H'0000' + +;----- SSPCON Bits -------------------------------------------------------- + +WCOL EQU H'0007' +SSPOV EQU H'0006' +SSPEN EQU H'0005' +CKP EQU H'0004' +SSPM3 EQU H'0003' +SSPM2 EQU H'0002' +SSPM1 EQU H'0001' +SSPM0 EQU H'0000' + +;----- CCP1CON Bits ------------------------------------------------------- + +CCP1X EQU H'0005' +CCP1Y EQU H'0004' +CCP1M3 EQU H'0003' +CCP1M2 EQU H'0002' +CCP1M1 EQU H'0001' +CCP1M0 EQU H'0000' + +;----- RCSTA Bits --------------------------------------------------------- + +SPEN EQU H'0007' +RX9 EQU H'0006' +RC9 EQU H'0006' ; Backward compatibility only +NOT_RC8 EQU H'0006' ; Backward compatibility only +RC8_9 EQU H'0006' ; Backward compatibility only +SREN EQU H'0005' +CREN EQU H'0004' +ADDEN EQU H'0003' +FERR EQU H'0002' +OERR EQU H'0001' +RX9D EQU H'0000' +RCD8 EQU H'0000' ; Backward compatibility only + +;----- CCP2CON Bits ------------------------------------------------------- + +CCP2X EQU H'0005' +CCP2Y EQU H'0004' +CCP2M3 EQU H'0003' +CCP2M2 EQU H'0002' +CCP2M1 EQU H'0001' +CCP2M0 EQU H'0000' + +;----- ADCON0 Bits -------------------------------------------------------- + +ADCS1 EQU H'0007' +ADCS0 EQU H'0006' +CHS2 EQU H'0005' +CHS1 EQU H'0004' +CHS0 EQU H'0003' +GO EQU H'0002' +NOT_DONE EQU H'0002' +GO_DONE EQU H'0002' +CHS3 EQU H'0001' +ADON EQU H'0000' + +;----- OPTION_REG Bits ----------------------------------------------------- + +NOT_RBPU EQU H'0007' +INTEDG EQU H'0006' +T0CS EQU H'0005' +T0SE EQU H'0004' +PSA EQU H'0003' +PS2 EQU H'0002' +PS1 EQU H'0001' +PS0 EQU H'0000' + +;----- TRISE Bits --------------------------------------------------------- + +IBF EQU H'0007' +OBF EQU H'0006' +IBOV EQU H'0005' +PSPMODE EQU H'0004' +TRISE3 EQU H'0003' +TRISE2 EQU H'0002' +TRISE1 EQU H'0001' +TRISE0 EQU H'0000' + +;----- PIE1 Bits ---------------------------------------------------------- + +PSPIE EQU H'0007' +ADIE EQU H'0006' +RCIE EQU H'0005' +TXIE EQU H'0004' +SSPIE EQU H'0003' +CCP1IE EQU H'0002' +TMR2IE EQU H'0001' +TMR1IE EQU H'0000' + +;----- PIE2 Bits ---------------------------------------------------------- + +OSFIE EQU H'0007' +CMIE EQU H'0006' +LVDIE EQU H'0005' +BCLIE EQU H'0003' +CCP3IE EQU H'0001' +CCP2IE EQU H'0000' + +;----- PCON Bits ---------------------------------------------------------- + +SBOREN EQU H'0002' +NOT_POR EQU H'0001' +NOT_BO EQU H'0000' +NOT_BOR EQU H'0000' + +;----- OSCCON Bits ------------------------------------------------------- +IRCF2 EQU H'0006' +IRCF1 EQU H'0005' +IRCF0 EQU H'0004' +OSTS EQU H'0003' +IOFS EQU H'0002' +SCS1 EQU H'0001' +SCS0 EQU H'0000' + +;----- OSCTUNE Bits ------------------------------------------------------- +TUN5 EQU H'0005' +TUN4 EQU H'0004' +TUN3 EQU H'0003' +TUN2 EQU H'0002' +TUN1 EQU H'0001' +TUN0 EQU H'0000' + +;----- SSPCON2 Bits -------------------------------------------------------- + +GCEN EQU H'0007' +ACKSTAT EQU H'0006' +ACKDT EQU H'0005' +ACKEN EQU H'0004' +RCEN EQU H'0003' +PEN EQU H'0002' +RSEN EQU H'0001' +SEN EQU H'0000' + +;----- SSPSTAT Bits ------------------------------------------------------- + +SMP EQU H'0007' +CKE EQU H'0006' +D EQU H'0005' +I2C_DATA EQU H'0005' +NOT_A EQU H'0005' +NOT_ADDRESS EQU H'0005' +D_A EQU H'0005' +DATA_ADDRESS EQU H'0005' +P EQU H'0004' +I2C_STOP EQU H'0004' +S EQU H'0003' +I2C_START EQU H'0003' +R EQU H'0002' +I2C_READ EQU H'0002' +NOT_W EQU H'0002' +NOT_WRITE EQU H'0002' +R_W EQU H'0002' +READ_WRITE EQU H'0002' +UA EQU H'0001' +BF EQU H'0000' + +;----- CCP3CON Bits ------------------------------------------------------- + +CCP3X EQU H'0005' +CCP3Y EQU H'0004' +CCP3M3 EQU H'0003' +CCP3M2 EQU H'0002' +CCP3M1 EQU H'0001' +CCP3M0 EQU H'0000' + +;----- TXSTA Bits --------------------------------------------------------- + +CSRC EQU H'0007' +TX9 EQU H'0006' +NOT_TX8 EQU H'0006' ; Backward compatibility only +TX8_9 EQU H'0006' ; Backward compatibility only +TXEN EQU H'0005' +SYNC EQU H'0004' +BRGH EQU H'0002' +TRMT EQU H'0001' +TX9D EQU H'0000' +TXD8 EQU H'0000' ; Backward compatibility only + +;----- ADCON2 Bits --------------------------------------------------------- + +ACQT2 EQU H'0005' +ACQT1 EQU H'0004' +ACQT0 EQU H'0003' + +;----- CMCON Bits --------------------------------------------------------- + +C2OUT EQU H'0007' +C1OUT EQU H'0006' +C2INV EQU H'0005' +C1INV EQU H'0004' +CIS EQU H'0003' +CM2 EQU H'0002' +CM1 EQU H'0001' +CM0 EQU H'0000' + +;----- CVRCON Bits -------------------------------------------------------- + +CVREN EQU H'0007' +CVROE EQU H'0006' +CVRR EQU H'0005' +CVR3 EQU H'0003' +CVR2 EQU H'0002' +CVR1 EQU H'0001' +CVR0 EQU H'0000' + +;----- ADCON1 Bits -------------------------------------------------------- + +ADFM EQU H'0007' +ADCS2 EQU H'0006' +VCFG1 EQU H'0005' +VCFG0 EQU H'0004' +PCFG3 EQU H'0003' +PCFG2 EQU H'0002' +PCFG1 EQU H'0001' +PCFG0 EQU H'0000' + +;----- WDTCON Bits -------------------------------------------------------- + +WDTPS3 EQU H'0004' +WDTPS2 EQU H'0003' +WDTPS1 EQU H'0002' +WDTPS0 EQU H'0001' +SWDTEN EQU H'0000' +SWDTE EQU H'0000' + +;----- LVDCON Bits -------------------------------------------------------- + +IRVST EQU H'0005' +LVDEN EQU H'0004' +LVDL3 EQU H'0003' +LVDL2 EQU H'0002' +LVDL1 EQU H'0001' +LVDL0 EQU H'0000' + +;----- PMCON1 Bits -------------------------------------------------------- + +RD EQU H'0000' + + +;========================================================================== +; +; RAM Definition +; +;========================================================================== + + __MAXRAM H'1FF' + __BADRAM H'08' + __BADRAM H'88', H'9A' + __BADRAM H'107'-H'108' + __BADRAM H'185', H'187'-H'189', H'18D'-H'18F' + +;========================================================================== +; +; Configuration Bits +; +;========================================================================== + +_CONFIG1 EQU H'2007' +_CONFIG2 EQU H'2008' + +;Configuration Byte 1 Options +_CP_ALL EQU H'1FFF' +_CP_OFF EQU H'3FFF' +_CCP2_RC1 EQU H'3FFF' +_CCP2_RB3 EQU H'2FFF' +_DEBUG_OFF EQU H'3FFF' +_DEBUG_ON EQU H'37FF' +_VBOR_2_0 EQU H'3FFF' +_VBOR_2_7 EQU H'3F7F' +_VBOR_4_2 EQU H'3EFF' +_VBOR_4_5 EQU H'3E7F' +_BOREN_1 EQU H'3FFF' ;MUST BE CONFIGURED IN CONJUCTION W/ BORSEN (CONFIG2) +_BOREN_0 EQU H'3FBF' ;MUST BE CONFIGURED IN CONJUCTION W/ BORSEN (CONFIG2) +_MCLR_ON EQU H'3FFF' +_MCLR_OFF EQU H'3FDF' +_PWRTE_OFF EQU H'3FFF' +_PWRTE_ON EQU H'3FF7' +_WDT_ON EQU H'3FFF' +_WDT_OFF EQU H'3FFB' +_EXTRC_CLKOUT EQU H'3FFF' +_EXTRC_IO EQU H'3FFE' +_INTRC_CLKOUT EQU H'3FFD' +_INTRC_IO EQU H'3FFC' +_EXTCLK EQU H'3FEF' +_HS_OSC EQU H'3FEE' +_XT_OSC EQU H'3FED' +_LP_OSC EQU H'3FEC' + +;Configuration Byte 2 Options +_BORSEN_1 EQU H'3FFF' ;MUST BE CONFIGURED IN CONJUCTION W/ BOREN (CONFIG1) +_BORSEN_0 EQU H'3FBF' ;MUST BE CONFIGURED IN CONJUCTION W/ BOREN (CONFIG1) +_IESO_ON EQU H'3FFF' +_IESO_OFF EQU H'3FFD' +_FCMEN_ON EQU H'3FFF' +_FCMEN_OFF EQU H'3FFE' + + +;**** Brown-out Reset configurations **** (Refer to the 16F7x7 Data Sheet for more details) +;BOREN_1 & BORSEN_1 = BOR enabled and always on +;BOREN_1 & BORSEN_0 = BOR enabled during operation and disabled during sleep by hardware +;BOREN_0 & BORSEN_1 = BOR controlled by software bit SBOREN (PCON,2) +;BOREN_0 & BORSEN_0 = BOR disabled + + +; To use the Configuration Bits, place the following lines in your source code +; in the following format, and change the configuration value to the desired +; setting (such as CP_OFF to CP_ALL). These are currently commented out here +; and each __CONFIG line should have the preceding semicolon removed when +; pasted into your source code. + +;Program Configuration Register 1 +; __CONFIG _CONFIG1, _CP_OFF & _CCP2_RC1 & _DEBUG_OFF & _VBOR_2_0 & BOREN_1 & _MCLR_OFF & _PWRTE_OFF & _WDT_OFF & _HS_OSC + +;Program Configuration Register 2 +; __CONFIG _CONFIG2, _BORSEN_1 & _IESO_OFF & _FCMEN_OFF + + + LIST Added: picduino/trunk/f767duino.HEX =================================================================== --- picduino/trunk/f767duino.HEX (rev 0) +++ picduino/trunk/f767duino.HEX 2012-10-07 18:37:47 UTC (rev 85) @@ -0,0 +1,120 @@ +:020000040000FA +:020000002A28AC +:08000800F1000308F2000A08F0 +:10001000F3008C1E1F28831218080639031D26289A +:100020000408F000560884001A0880007008840054 +:10003000D60A50305606031D1F284030D6007308DC +:100040008A0072088300F10E710E090018121A0856 +:1000500018161F28A001A101A201A301A401A50156 +:10006000A601A701A801A901AA010130AB00063031 +:10007000AC004030D600D700F701F80186018701B7 +:10008000FF3083168500F4008600F5008700F60037 +:1000900083129420D1015108D2000030D3000821EE +:1000A000D10A0E305102031C4B28953083169F0055 +:1000B000831280309F00283083169B0083121F1408 +:1000C0007E202B1C6B2897308E200730A2207E20AC +:1000D0000030A2207E20AD012C082D0203186028DC +:1000E000CE24A1302D078E202F0D2E0D07398E2006 +:1000F0002F087F398E207E20AD0A6C2856085706BF +:10010000031908005708840000081F22D70A50303E +:100110005706031D7E284030D7007E288316981C82 +:100120008F2883129900080083162F309900181524 +:1001300083129817831698168C16831218160B17AD +:100140008B170800DA01D900D100D501D4010314BE +:10015000D50DD40DD1080319B828D103A828D10A88 +:10016000073051060319C328D90A0310D50DD40D41 +:1001700026085505031DAF2825085405031DAF2883 +:100180008524DA0CAF280310DA0C5A088E200800F8 +:10019000871B03140800071B03140800871A0314A5 +:1001A0000800071A0314080087190314080006182A +:1001B00003140800061A03140800861B0314080021 +:1001C000061B03140800861A0314080007190314F9 +:1001D000080087180314080007180314080086187D +:1001E000031408008530FE288D30FE289530FE2847 +:1001F000A530FE288730FE288F30FE289F001F196B +:10020000FF281E08AE0083161E088312AF000800E8 +:1002100000305306031D4D29982C26102810F61780 +:1002200076088316870083120800A610A810761798 +:10023000102926112811F6161029A611A8117616D4 +:10024000102926122812F6151029A612A8127514C4 +:100250007508831686008312080026132813751666 +:100260002829A613A813F517282925102710751774 +:100270002829A510A710F51628292511271176156C +:100280001029A511A711F61410292512271276148A +:100290001029A512A712F5142829013053060319B5 +:1002A0008429AA2C0800080026152811F612102906 +:1002B000A615A8117612102926162812F611102953 +:1002C000A616A81275102829261728137512282992 +:1002D000A617A813F5132829251427107513282904 +:1002E000A514A710F5122829251527117611102914 +:1002F000A515A711F610102925162712761010291A +:10030000A516A712F5102829023053060319080074 +:10031000BC2C0800080026152815F6121029A61571 +:10032000A8157612102926162816F6111029A616D9 +:10033000A816751028292617281775122829A61718 +:10034000A817F51328292514271475132829A5148F +:10035000A714F51228292515271576111029A5159A +:10036000A715F61010292516271676101029A516A0 +:10037000A716F51028297808870008007708860056 +:100380000800F817031CF813BB297817031C78130F +:10039000BB29F816031CF812BB297816031C781227 +:1003A000BB29F815031CF811BB297714031C77101F +:1003B000BE297716031C7712BE29F717031CF71303 +:1003C000BE297717031C7713BE29F716031CF712F3 +:1003D000BE297815031C7811BB29F814031CF810EA +:1003E000BB297814031C7810BB29F714031CF710E1 +:1003F000BE29AB0108002B14080003010A2A0130B2 +:100400000A2A02300A2A03300A2A04300A2A05304E +:100410000A2A0630AC0008000230A0005808A100EB +:1004200008000130A0005808A100080024140800AA +:10043000F0308E2000308E2001308E200800D80051 +:10044000A0080319462AA003223020078400580878 +:100450008000A10803190800A008031D0800D82C7B +:100460002308D2000230D3000821442A2208D200F7 +:100470000030D3000821442A2308D2000230D300E0 +:100480000821442A442A442AA1010800D81B002C30 +:100490002808FF3A2605D5002708FF3A2505D4008D +:1004A000241C7E2AD51F582A031058180314DD2156 +:1004B000541C5E2A0310D8180314E121D41C642AAA +:1004C000031058190314E521541D6A2A0310D81982 +:1004D0000314E921D41D702A0310581A0314ED21C6 +:1004E000541E762A0310D81A0314F121D41E7C2A34 +:1004F0000310581B0314F521A4010800551C842A7D +:10050000031058180314C121D51C8A2A0310D818C7 +:100510000314C521551D902A031058190314C9212D +:10052000D51D962A0310D8190314CD21551E9C2AD7 +:100530000310581A0314D121D51EA22A0310D81A69 +:100540000314D521551FA82A0310581B0314D921C1 +:020550000800A1 +:1008000004308A0058087F398207080008000D2943 +:10081000152919291D29212925292D29312935296C +:1008200039293D294129452949290800080008009E +:10083000080008000800F929FB2908000800080042 +:1008400008000800080008000800FD29FF29012A07 +:10085000032A052A072A092A0800080008000800B8 +:100860000800080008000800080008000800080048 +:100870000800080008000800080008000800080038 +:100880000800080008000800080008000800080028 +:1008900008000800080008000800522953295429BC +:1008A00058295C296029642968296C2970297429D0 +:1008B00078297C2980290800080008000800080021 +:1008C00008000800080008000800080008000800E8 +:1008D00008000800162A08000800080008000800A0 +:1008E00008000800080008000800182A080008008E +:1008F0000800080008000800080008000800112A85 +:100900000C2A112A0C2A112A080004308A005908DE +:1009100003108207C828CB28CE28D128D428D7286E +:10092000DA28DD28E028E328E628E928EC28EF2863 +:1009300004308A00520882070D29152919291D291A +:10094000212925292D293129352939293D294129CF +:100950004529492904308A0052088207522953291F +:10096000542958295C296029642968296C2970292F +:10097000742978297C29802904308A00520882074A +:1009800089298A298B298F29932997299B299F298E +:10099000A329A729AB29AF29B329B72904308A0095 +:1009A0002D088207F228F428F628F828FA28FC28CF +:1009B00004308A00FA3021028207362A302A422A7D +:0409C0003C2A432A60 +:02400E00A23FCF +:02401000BC3FB3 +:00000001FF Added: picduino/trunk/f767duino.asm =================================================================== --- picduino/trunk/f767duino.asm (rev 0) +++ picduino/trunk/f767duino.asm 2012-10-07 18:37:47 UTC (rev 85) @@ -0,0 +1,1810 @@ +;******************************************************** +; * +; Filename: f767duino.asm * +; Date: 20061016 * +; File Version: 0.6 * +; Fixed a bug in receive interrupt handler and * +; buffer increment * +; Date: 20061012 * +; File Version: 0.5 * +; Using shadow registers for tris * +; registers to avoid bcf and bsf instructions * +; Date: 20061012 * +; File Version: 0.4 * +; Fixed another bug. Digital out still doesn't * +; work. Next try using shadow registers for tris * +; registers to avoid bcf and bsf instructions * +; Date: 20061011 * +; File Version: 0.3 * +; fixed a couple of bugs. Now analog input works * +; Date: 20060927 * +; File Version: 0.2 * +; completed port to PIC asm * +; Date: 20060921 * +; File Version: 0.1 * +; * +; Author: Martin Peach * +; * +; * +;******************************************************** +; * +; Files required: P16F767.INC * +; * +; * +;************************************************************************************************ +; * +; This is an implementation of the Arduino using a PIC16F767 instead of an ATmega8. * +; See PICduino.CKT for the schematic. * +; * +;************************************************************************************************ +;___Arduino_Pin_Name____=___PIC_Pin_Name____* +; DigitalPin0 RXD = RC7 * +; DigitalPin1 TXD = RC6 * +; DigitalPin2 = RC5 * +; DigitalPin3 = RC4 * +; DigitalPin4 = RC3 * +; DigitalPin5 = RB0 * +; DigitalPin6 = RB4 * +; DigitalPin7 = RB7 * +; DigitalPin8 = RB6 * +; DigitalPin9 PWM = RB5 * +; DigitalPin10 PWM = RC2 * +; DigitalPin11 PWM = RC1 * +; DigitalPin12 = RC0 * +; DigitalPin13 = RB1 * +; AnalogInput0 = RA0/AN0 * +; AnalogInput1 = RA1/AN1 * +; AnalogInput2 = RA2/AN2 * +; AnalogInput3 = RA5/AN4 * +; AnalogInput4 = RB2/AN8 * +; AnalogInput5 = RB3/AN9 * +; VRef = RA3/AN3 * +; * +; Timing parameters: +; FOsc = 14745600Hz +; TOsc = 67.8ns +; Tad = 2.17us, Tcnv = 26.04us +; ADC needs 20us (~10Tad) to charge the sampling capacitor + 2Tad(~5us) after each conversion +;******************************************** +; This is based on Pd_firmware_pde +; Copyright (C) 2006 Hans-Christoph Steiner +; This library is free software; you can redistribute it and/or +; modify it under the terms of the GNU Lesser General Public +; License as published by the Free Software Foundation; either +; version 2.1 of the License, or (at your option) any later version. +; +; This library is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +; Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General +; Public License along with this library; if not, write to the +; Free Software Foundation, Inc., 59 Temple Place, Suite 330, +; Boston, MA 02111-1307 USA +; +; ----------------------------- +; Firmata, the Arduino firmware +; ----------------------------- +; +; Firmata turns the Arduino into a Plug-n-Play sensorbox, servo +; controller, and/or PWM motor/lamp controller. +; +; It was originally designed to work with the Pd object [arduino] +; which is included in Pd-extended. This firmware is intended to +; work with any host computer software package. It can easily be +; used with other programs like Max/MSP, Processing, or whatever can +; do serial communications.; +; @authors: Hans-Christoph Steiner <ha...@at...> +; help with protocol redesign: Jamie Allen <ja...@he...> +; key bugfixes: Georg Holzmann <gr...@mu...> +; Gerda Strobl <ger...@st...> +; @date: 2006-05-19 +; @locations: STEIM, Amsterdam, Netherlands +; IDMI/Polytechnic University, Brookyn, NY, USA +; Electrolobby Ars Electronica, Linz, Austria +; +; +; TODO: add pulseIn functionality +; TODO: add software PWM for servos, etc (servo.h or pulse.h) +; TODO: redesign protocol to accomodate boards with more I/Os +; TODO: +; TODO: add "outputMode all 0/1" command +; TODO: add cycle markers to mark start of analog, digital, pulseIn, and PWM +; +; ========================================================================= + list p=16f767 ; list directive to define processor + #include <P16F767.inc> ; processor specific variable definitions + + __CONFIG _CONFIG1, _CP_OFF & _CCP2_RC1 & _DEBUG_OFF & _VBOR_2_0 & _BOREN_0 & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _HS_OSC + __CONFIG _CONFIG2, _BORSEN_0 & _IESO_OFF & _FCMEN_OFF + +; === CONSTANTS =========================================================== +B19200 equ d'47' ; time constant for baud rate generator +B9600 equ d'95' ; time constant for baud rate generator +; firmware version numbers. The protocol is still changing, so these version +; numbers are important +MAJOR_VERSION equ 0 +MINOR_VERSION equ 1 +; firmata protocol +; =============== +; data: 0-127 +; control: 128-255 +; computer->Arduino commands +; -------------------- +; 128-129 UNUSED +SET_PIN_ZERO_TO_IN equ d'130' ; set digital pin 0 to INPUT +SET_PIN_ONE_TO_IN equ d'131' ; set digital pin 1 to INPUT +SET_PIN_TWO_TO_IN equ d'132' ; set digital pin 2 to INPUT +SET_PIN_THREE_TO_IN equ d'133' ; set digital pin 3 to INPUT +SET_PIN_FOUR_TO_IN equ d'134' ; set digital pin 4 to INPUT +SET_PIN_FIVE_TO_IN equ d'135' ; set digital pin 5 to INPUT +SET_PIN_SIX_TO_IN equ d'136' ; set digital pin 6 to INPUT +SET_PIN_SEVEN_TO_IN equ d'137' ; set digital pin 7 to INPUT +SET_PIN_EIGHT_TO_IN equ d'138' ; set digital pin 8 to INPUT +SET_PIN_NINE_TO_IN equ d'139' ; set digital pin 9 to INPUT +SET_PIN_TEN_TO_IN equ d'140' ; set digital pin 10 to INPUT +SET_PIN_ELEVEN_TO_IN equ d'141' ; set digital pin 11 to INPUT +SET_PIN_TWELVE_TO_IN equ d'142' ; set digital pin 12 to INPUT +SET_PIN_THIRTEEN_TO_IN equ d'143' ; set digital pin 13 to INPUT +; 144-149 UNUSED +DISABLE_DIGITAL_INPUTS equ d'150' ; disable reporting of digital inputs +ENABLE_DIGITAL_INPUTS equ d'151' ; enable reporting of digital inputs +; 152-159 UNUSED +ZERO_ANALOG_INS equ d'160' ; disable reporting on all analog ins +ONE_ANALOG_IN equ d'161' ; enable reporting for 1 analog in (0) +TWO_ANALOG_INS equ d'162' ; enable reporting for 2 analog ins (0,1) +THREE_ANALOG_INS equ d'163' ; enable reporting for 3 analog ins (0-2) +FOUR_ANALOG_INS equ d'164' ; enable reporting for 4 analog ins (0-3) +FIVE_ANALOG_INS equ d'165' ; enable reporting for 5 analog ins (0-4) +SIX_ANALOG_INS equ d'166' ; enable reporting for 6 analog ins (0-5) +; 167-199 UNUSED +SET_PIN_ZERO_TO_OUT equ d'200' ; set digital pin 0 to OUTPUT +SET_PIN_ONE_TO_OUT equ d'201' ; set digital pin 1 to OUTPUT +SET_PIN_TWO_TO_OUT equ d'202' ; set digital pin 2 to OUTPUT +SET_PIN_THREE_TO_OUT equ d'203' ; set digital pin 3 to OUTPUT +SET_PIN_FOUR_TO_OUT equ d'204' ; set digital pin 4 to OUTPUT +SET_PIN_FIVE_TO_OUT equ d'205' ; set digital pin 5 to OUTPUT +SET_PIN_SIX_TO_OUT equ d'206' ; set digital pin 6 to OUTPUT +SET_PIN_SEVEN_TO_OUT equ d'207' ; set digital pin 7 to OUTPUT +SET_PIN_EIGHT_TO_OUT equ d'208' ; set digital pin 8 to OUTPUT +SET_PIN_NINE_TO_OUT equ d'209' ; set digital pin 9 to OUTPUT +SET_PIN_TEN_TO_OUT equ d'210' ; set digital pin 10 to OUTPUT +SET_PIN_ELEVEN_TO_OUT equ d'211' ; set digital pin 11 to OUTPUT +SET_PIN_TWELVE_TO_OUT equ d'212' ; set digital pin 12 to OUTPUT +SET_PIN_THIRTEEN_TO_OUT equ d'213' ; set digital pin 13 to OUTPUT +; 214-228 UNUSED +OUTPUT_TO_DIGITAL_PINS equ d'229' ; next two bytes set digital output data +; 230-239 UNUSED +REPORT_VERSION equ d'240' ; return the firmware version +; 240-249 UNUSED +DISABLE_PWM equ d'250' ; next byte sets pin # to disable +ENABLE_PWM equ d'251' ; next two bytes set pin # and duty cycle +DISABLE_SOFTWARE_PWM equ d'252' ; next byte sets pin # to disable +ENABLE_SOFTWARE_PWM equ d'253' ; next two bytes set pin # and duty cycle +SET_SOFTWARE_PWM_FREQ equ d'254' ; set master frequency for software PWMs +; 255 UNUSED +;*************** +; two byte digital output data format +; ---------------------- +; 0 get ready for digital input bytes (229) +; 1 digitalOut 7-13 bitmask +; 2 digitalOut 0-6 bitmask +; two byte PWM data format +; ---------------------- +; 0 get ready for digital input bytes (ENABLE_SOFTWARE_PWM/ENABLE_PWM) +; 1 pin # +; 2 duty cycle expressed as 1 byte (255 = 100%) +; digital input message format +; ---------------------- +; 0 digital input marker (255/11111111) +; 1 digital read from Arduino // 7-13 bitmask +; 2 digital read from Arduino // 0-6 bitmask +; analog input message format +; ---------------------- +; 0 analog input marker +; 1 high byte from analog input pin 0 +; 2 low byte from analog input pin 0 +; 3 high byte from analog input pin 1 +; 4 low byte from analog input pin 1 +; 5 high byte from analog input pin 2 +; 6 low byte from analog input pin 2 +; 7 high byte from analog input pin 3 +; 8 low byte from analog input pin 3 +; 9 high byte from analog input pin 4 +; 10 low byte from analog input pin 4 +; 11 high byte from analog input pin 5 +; 12 low byte from analog input pin 5 +TOTAL_DIGITAL_PINS equ d'14' + +INPUT equ d'0' ; these aren't defined in Pd_firmware.pde +OUTPUT equ d'1' ; these aren't defined in Pd_firmware.pde +; for comparing along with INPUT and OUTPUT +PWM equ d'2' + +; maximum number of post-command data bytes +MAX_DATA_BYTES equ d'2' + +; == VARIABLES ============================================================ +; this flag says the next serial input will be data +;byte waitForData = 0; +waitForData equ 0x20 ; initialize to 0; +;byte executeMultiByteCommand = 0; // command to execute after getting multi-byte data +executeMultiByteCommand equ 0x21 ; initialize to 0 +;byte storedInputData[MAX_DATA_BYTES] = {0,0}; // multi-byte data +storedInputData0 equ 0x22 ; initialize to 0,0 +storedInputData1 equ 0x23 ; initialize to 0,0 +; this flag says the first data byte for the digital outs is next +;boolean firstInputByte = false; +firstInputByte equ 0x24 ; initialize to 0 +; this int serves as a bit-wise array to store pin status +; 0 = INPUT, 1 = OUTPUT +; int digitalPinStatus; +digitalPinStatusHi equ 0x25 ; initialize to 0,0 +digitalPinStatusLo equ 0x26 ; initialize to 0,0 +; this byte stores the status of whether PWM is on or not +; bit 9 = PWM0, bit 10 = PWM1, bit 11 = PWM2 +; the rest of the bits are unused and should remain 0 +;int pwmStatus; +pwmStatusHi equ 0x27 ; initialize to 0,0 +pwmStatusLo equ 0x28 ; initialize to 0,0 +; this byte stores the status of whether software PWM is on or not +; 00000010 00000000 means bit 10 is softWarePWM enabled +;int softPwmStatus; +softPwmStatusHi equ 0x29 ; initialize to 0,0 +softPwmStatusLo equ 0x2A ; initialize to 0,0 +;boolean digitalInputsEnabled = true; +digitalInputsEnabled equ 0x2B ; initialize to 1 +;byte analogInputsEnabled = 6; +analogInputsEnabled equ 0x2C ; initialize to 6; +;byte analogPin; +analogPin equ 0x2D ; +;int analogData; +analogDataHi equ 0x2E ; +analogDataLo equ 0x2F ; +rxBuf equ 0x40 ; +rxBufEnd equ 0x50 ; +i equ 0x51 ; local variable in setup() +pin equ 0x52 ; pin number for pinMode() +mode equ 0x53 ; pin mode for pinMode() +maskHi equ 0x54 +maskLo equ 0x55 +rxWrPtr equ 0x56 +rxRdPtr equ 0x57 +inputData equ 0x58 +digitalPin equ 0x59 +transmitByte equ 0x5A +digitalData equ 0x5B +fsr_temp equ 0x70 ; variable used for context saving +w_temp equ 0x71 ; variable used for context saving +status_temp equ 0x72 ; variable used for context saving +pclath_temp equ 0x73 ; variable used for context saving +trisa_shadow equ 0x74 +trisb_shadow equ 0x75 +trisc_shadow equ 0x76 +portb_shadow equ 0x77 +portc_shadow equ 0x78 +; ========================================================================= + ORG 0x000 ; processor reset vector + goto setup ; go to beginning of program +; ========================================================================= + ORG 0x004 ; interrupt vector location + movwf w_temp ; save off current W register contents + movf STATUS,w ; move status register into W register + movwf status_temp ; save off contents of STATUS register + movf PCLATH,w ; move pclath register into w register + movwf pclath_temp ; save off contents of PCLATH register + + btfss PIR1,RCIF + goto intout +;receive interrupt +; 6. Flag bit RCIF will be set when reception is complete and an interrupt will be generated if enable bit RCIE is set. +; 7. Read the RCSTA register to get the ninth bit (if enabled) and determine if any error occurred during reception. + bcf STATUS,RP0 ; bank 0 + movf RCSTA,w + andlw b'00000110' ; Framing, Overrun Errors + btfss STATUS,Z + goto RxError +; 8. Read the 8-bit received data by reading the RCREG register. +; handle the character by saving it into rxBuf and incrementing rxWrPtr + movf FSR,w ; first save FSR + movwf fsr_temp + movf rxWrPtr,w ; get the pointer to the buffer + movwf FSR ; into FSR + movf RCREG,w ; read the character + movwf INDF ; store it in the buffer + movf fsr_temp,w ; restore FSR + movwf FSR + incf rxWrPtr,f ; point to next slot in buffer + movlw rxBufEnd ; check for end of buffer + xorwf rxWrPtr,w + btfss STATUS,Z + goto intout ; not yet at end + movlw rxBuf ; reset pointer to start of buffer + movwf rxWrPtr +intout + movf pclath_temp,w ; retrieve copy of PCLATH register + movwf PCLATH ; restore pre-isr PCLATH register contents + movf status_temp,w ; retrieve copy of STATUS register + movwf STATUS ; restore pre-isr STATUS register contents + swapf w_temp,f + swapf w_temp,w ; restore pre-isr W register contents + retfie ; return from interrupt +; 9. If any error occurred, clear the error by clearing enable bit CREN. +RxError + bcf RCSTA,CREN + movf RCREG,w + bsf RCSTA,CREN + goto intout + +; ========================================================================= +; +; ------------------------------------------------------------------------- +;void setup() +;{ +setup + clrf waitForData ; init all the variables + clrf executeMultiByteCommand + clrf storedInputData0 + clrf storedInputData1 + clrf firstInputByte + clrf digitalPinStatusHi + clrf digitalPinStatusLo + clrf pwmStatusHi + clrf pwmStatusLo + clrf softPwmStatusHi + clrf softPwmStatusLo + movlw 1 + movwf digitalInputsEnabled ; initialize to 1 + movlw 6 + movwf analogInputsEnabled ; initialize to 6; + movlw rxBuf + movwf rxWrPtr + movwf rxRdPtr + clrf portb_shadow + clrf portc_shadow + clrf PORTB ; PORTB is cleared anyway at reset + clrf PORTC ; PORTC is cleared anyway at reset + movlw 0xFF ; all inputs (they are anyway after reset) + bsf STATUS,RP0 ; bank 1 + movwf TRISA + movwf trisa_shadow + movwf TRISB + movwf trisb_shadow + movwf TRISC + movwf trisc_shadow + bcf STATUS,RP0 ; bank 0 +; byte i; +; +; beginSerial(19200); + call beginSerial_19200 +; for(i=0; i<TOTAL_DIGITAL_PINS; ++i) +; { + clrf i +; setPinMode(i,INPUT); +slp_1 + movf i,w + movwf pin + movlw INPUT + movwf mode + call setPinMode + incf i,f + movlw TOTAL_DIGITAL_PINS + subwf i,w + btfss STATUS,C + goto slp_1 +; setup analog pins +;The following steps should be followed to do an A/D conversion: +;1. Configure the A/D module: +; Configure analog pins, voltage reference and digital I/O (ADCON1) + movlw b'10010101' ; right-justified 10-bit result. VRef+ = RA3, AN0-AN9 analog + bsf STATUS,RP0 ; bank 1 + movwf ADCON1 + bcf STATUS,RP0 ; bank 0 +; Select A/D input channel (ADCON0) + movlw b'10000000' ; start with channel 0, 32 Tosc conversion, module off + movwf ADCON0 +; Select A/D acquisition time (ADCON2) + movlw b'00101000' ; wait 12Tad + bsf STATUS,RP0 ; bank 1 + movwf ADCON2 + bcf STATUS,RP0 ; bank 0 +; Select A/D conversion clock (ADCON0) +; Turn on A/D module (ADCON0) + bsf ADCON0,ADON +;2. Configure A/D interrupt (if desired): +; Clear ADIF bit +; Set ADIE bit +; Set PEIE bit +; Set GIE bit +;3. Wait the required acquisition time (if required). +;4. Start conversion: +; Set GO/DONE bit (ADCON0 register) +;5. Wait for A/D conversion to complete, by either: +; Polling for the GO/DONE bit to be cleared +;OR +; Waiting for the A/D interrupt +;6. Read A/D Result registers (ADRESH:ADRESL); clear bit ADIF (if required). +;7. For next conversion, go to step 1 or step 2 as required. The A/D conversion time per bit is +; defined as TAD. A minimum wait of 2 TAD is required before the next acquisition starts. +; } +;} +; +; setup falls through into loop and stays there forever... +; +; ------------------------------------------------------------------------- +;void loop() +;{ +loop +; checkForInput(); + call checkForInput +; +; // read all digital pins, in enabled +; if(digitalInputsEnabled) + btfss digitalInputsEnabled,0 + goto lp_1 +; { +; printByte(ENABLE_DIGITAL_INPUTS); + movlw ENABLE_DIGITAL_INPUTS + call printByte +; transmitDigitalInput(7); + movlw d'7' + call transmitDigitalInput +; checkForInput(); + call checkForInput +; transmitDigitalInput(0); + movlw d'0' + call transmitDigitalInput +; checkForInput(); + call checkForInput +; } +lp_1 +; +; /* get analog in, for the number enabled */ +; for(analogPin=0; analogPin<analogInputsEnabled; ++analogPin) + clrf analogPin +lp_2 + movf analogInputsEnabled,w + subwf analogPin,w + btfsc STATUS,C + goto loop +; { +; analogData = analogRead(analogPin); + call analogRead ; analogRead sets analogDataHi and analogDataLo according to analogPin +; // these two bytes get converted back into the whole number in Pd +; // the higher bits should be zeroed so that the 8th bit doesn't get set +; printByte(ONE_ANALOG_IN + analogPin); + movlw ONE_ANALOG_IN + addwf analogPin,w + call printByte +; printByte(analogData >> 7); // bitshift the big stuff into the output byte + rlf analogDataLo,w ; bit7 into C + rlf analogDataHi,w ; C into bit0 + andlw b'00000111' ; only 10 bits + call printByte +; printByte(analogData % 128); // mod by 32 for the small byte + movf analogDataLo,w + andlw b'01111111' + call printByte +; checkForInput(); + call checkForInput + incf analogPin,f + goto lp_2 +; } +;} +; +; ============subroutines====================================================== +; +; ------------------------------------------------------------------------- +; this function checks to see if there is data waiting on the serial port +; then processes all of the stored data +;void checkForInput() +;{ +checkForInput + movf rxWrPtr,w + xorwf rxRdPtr,w + btfsc STATUS,Z + return +; if(serialAvailable()) +; { +; while(serialAvailable()) +; { + movf rxRdPtr,w + movwf FSR + movf INDF,w +; processInput( (byte)serialRead() ); + call processInput + incf rxRdPtr,f + movlw rxBufEnd + xorwf rxRdPtr,w + btfss STATUS,Z + goto checkForInput + movlw rxBuf ; wrap to start of buffer + movwf rxRdPtr + goto checkForInput +; } +; } +;} +; ------------------------------------------------------------------------- +; printByte: on entry w contains the byte to send +printByte + bsf STATUS,RP0 ; bank 1 + btfss TXSTA,TRMT + goto $-1 + bcf STATUS,RP0 ; bank 0 + movwf TXREG + return +; ------------------------------------------------------------------------- +beginSerial_19200 ; setup USART for 19200 asynchronous receive and transmit, 8bitsNoParity1Stop +; Bits TRISC<7:6> have to be set in order to configure pins RC6/TX/CK and RC7/RX/DT as the USART. +; (They are set at reset) + bsf STATUS,RP0 ; bank 1 +; When setting up an Asynchronous Transmission, follow these steps: +; 1. Initialize the SPBRG register for the appropriate baud rate. If a high-speed baud rate is desired, +; set bit BRGH (see Section 11.1 \x93AUSART Baud Rate Generator (BRG)\x94). +; * * * For 14.745600MHz crystal clock, SPBRG=47, BRGH=1 gives 19200 baud. * * * + movlw B19200 ; = d'47' + movwf SPBRG + bsf TXSTA,BRGH +; 2. Enable the asynchronous serial port by clearing bit SYNC and setting bit SPEN. + bcf STATUS,RP0 ; bank 0 + bsf RCSTA,SPEN +; 3. If interrupts are desired, then set enable bit TXIE. +; 4. If 9-bit transmission is desired, then set transmit bit TX9. +; 5. Enable the transmission by setting bit TXEN which will also set bit TXIF. + bsf STATUS,RP0 ; bank 1 + bsf TXSTA,TXEN +; 6. If 9-bit transmission is selected, the ninth bit should be loaded in bit TX9D. +; 7. Load data to the TXREG register (starts transmission). +; 8. If using interrupts, ensure that GIE and PEIE (bits 7 and 6) of the INTCON register are set. +;When setting up an Asynchronous Reception, follow these steps: +; 1. Initialize the SPBRG register for the appropriate baud rate. If a high-speed baud rate is desired, +; set bit BRGH (see Section 11.1 \x93AUSART Baud Rate Generator (BRG)\x94). +; 2. Enable the asynchronous serial port by clearing bit SYNC and setting bit SPEN. +; 3. If interrupts are desired, then set enable bit RCIE. + bsf PIE1,RCIE +; 4. If 9-bit reception is desired, then set bit RX9. +; 5. Enable the reception by setting bit CREN. + bcf STATUS,RP0 ; bank 0 + bsf RCSTA,CREN +; 6. Flag bit RCIF will be set when reception is complete and an interrupt will be generated if enable bit RCIE is set. +; 7. Read the RCSTA register to get the ninth bit (if enabled) and determine if any error occurred during reception. +; 8. Read the 8-bit received data by reading the RCREG register. +; 9. If any error occurred, clear the error by clearing enable bit CREN. +; 10. If using interrupts, ensure that GIE and PEIE (bits 7 and 6) of the INTCON register are set. + bsf INTCON,PEIE + bsf INTCON,GIE + return +; ------------------------------------------------------------------------- +;void transmitDigitalInput(byte startPin) +;{ +transmitDigitalInput ; on entry w contains startPin +; byte i; +; byte digitalPin; +;// byte digitalPinBit; +; byte transmitByte = 0; + clrf transmitByte +; byte digitalData; +; + movwf digitalPin + movwf i + clrf maskLo + clrf maskHi + bsf STATUS,C +tdilp_1 ; set up the mask with bit startPin set + rlf maskLo,f + rlf maskHi,f + movf i,f + btfsc STATUS,Z + goto tdi_1 ; mask is at startPin + decf i,f + goto tdilp_1 +; for(i=0;i<7;++i) +; { +tdi_2 +; digitalPin = i+startPin; + incf i,f ; ++i + movlw d'7' + xorwf i,w ; i == 7? + btfsc STATUS,Z + goto tdi_3 ; yes + incf digitalPin,f ; no + bcf STATUS,C + rlf maskLo,f + rlf maskHi,f +;/* digitalPinBit = OUTPUT << digitalPin; +;// only read the pin if its set to input +;if(digitalPinStatus & digitalPinBit) { +;digitalData = 0; // pin set to OUTPUT, don't read +;} +;else if( (digitalPin >= 9) && (pwmStatus & (1 << digitalPin)) ) { +;digitalData = 0; // pin set to PWM, don't read +;}*/ +; if( !(digitalPinStatus & (1 << digitalPin)) ) +tdi_1 + movf digitalPinStatusLo,w + andwf maskLo,w ; maskLo is lowbyte of 1<<digitalPin + btfss STATUS,Z + goto tdi_2 + movf digitalPinStatusHi,w + andwf maskHi,w + btfss STATUS,Z + goto tdi_2 +; { +; +; digitalData = (byte) digitalRead(digitalPin); + call digitalRead ; sets carry to match pin w input data +; transmitByte = transmitByte + ((1 << i) * digitalData); +; rlf transmitByte,f ; carry bit shifts into transmitByte + rrf transmitByte,f ; carry bit shifts into transmitByte + goto tdi_2 +; } +; } +; printByte(transmitByte); +tdi_3 + bcf STATUS,C ; shift 0 into high bit + rrf transmitByte,f + movf transmitByte,w + call printByte +;} + return +; +; ------------------------------------------------------------------------- +digitalRead0 + btfsc PORTC,7 + bsf STATUS,C + return +; ------------------------------------------------------------------------- +digitalRead1 + btfsc PORTC,6 + bsf STATUS,C + return +; ------------------------------------------------------------------------- +digitalRead2 + btfsc PORTC,5 + bsf STATUS,C + return +; ------------------------------------------------------------------------- +digitalRead3 + btfsc PORTC,4 + bsf STATUS,C + return +; ------------------------------------------------------------------------- +digitalRead4 + btfsc PORTC,3 + bsf STATUS,C + return +; ------------------------------------------------------------------------- +digitalRead5 + btfsc PORTB,0 + bsf STATUS,C + return +; ------------------------------------------------------------------------- +digitalRead6 + btfsc PORTB,4 + bsf STATUS,C + return +; ------------------------------------------------------------------------- +digitalRead7 + btfsc PORTB,7 + bsf STATUS,C + return +; ------------------------------------------------------------------------- +digitalRead8 + btfsc PORTB,6 + bsf STATUS,C + return +; ------------------------------------------------------------------------- +digitalRead9 + btfsc PORTB,5 + bsf STATUS,C + return +; ------------------------------------------------------------------------- +digitalRead10 + btfsc PORTC,2 + bsf STATUS,C + return +; ------------------------------------------------------------------------- +digitalRead11 + btfsc PORTC,1 + bsf STATUS,C + return +; ------------------------------------------------------------------------- +digitalRead12 + btfsc PORTC,0 + bsf STATUS,C + return +; ------------------------------------------------------------------------- +digitalRead13 + btfsc PORTB,1 + bsf STATUS,C + return +; +; ------------------------------------------------------------------------- +analogRead0 ; AN0 + movlw b'10000101' ; Fosc/32 channel0 Go On + goto analogWait +; ------------------------------------------------------------------------- +analogRead1 ; AN1 + movlw b'10001101' ; Fosc/32 channel1 Go On + goto analogWait +; ------------------------------------------------------------------------- +analogRead2 ; AN2 + movlw b'10010101' ; Fosc/32 channel2 Go On + goto analogWait +; ------------------------------------------------------------------------- +analogRead3 ; AN4 + movlw b'10100101' ; Fosc/32 channel4 Go On + goto analogWait +; ------------------------------------------------------------------------- +analogRead4 ; AN8 + movlw b'10000111' ; Fosc/32 channel8 Go On + goto analogWait +; ------------------------------------------------------------------------- +analogRead5 ; AN9 + movlw b'10001111' ; Fosc/32 channel9 Go On + goto analogWait +; ------------------------------------------------------------------------- +analogWait + movwf ADCON0 +;3. Wait the required acquisition time (if required). +; we set 12Tad in ADCON2 +;4. Start conversion: +; Set GO/DONE bit (ADCON0 register) +;5. Wait for A/D conversion to complete, by either: +; Polling for the GO/DONE bit to be cleared + btfsc ADCON0,GO_DONE + goto $-1 +;OR +; Waiting for the A/D interrupt +;6. Read A/D Result registers (ADRESH:ADRESL); clear bit ADIF (if required). + movf ADRESH,w + movwf analogDataHi + bsf STATUS,RP0 ; bank 1 + movf ADRESL,w + bcf STATUS,RP0 ; bank 0 + movwf analogDataLo +;7. For next conversion, go to step 1 or step 2 as required. The A/D conversion time per bit is +; defined as TAD. A minimum wait of 2 TAD is required before the next acquisition starts. + return +; ------------------------------------------------------------------------- +; this function sets the pin mode to the correct state and sets the relevant +; bits in the two bit-arrays that track Digital I/O and PWM status +;void setPinMode(int pin, int mode) +;{ +; if(mode == INPUT) +; { +setPinMode ; on entry pin contains the digital pin number, mode contains the mode + movlw INPUT + xorwf mode,w + btfss STATUS,Z + goto setPinToOutOrPwm + goto setPinToIn +; digitalPinStatus = digitalPinStatus &~ (1 << pin); +; pwmStatus = pwmStatus &~ (1 << pin); +; pinMode(pin,INPUT); +; ------------------------------------------------------------------------- +setPinZeroToIn ; pin0 is RX!!! + bcf digitalPinStatusLo,0 + bcf pwmStatusLo,0 + bsf trisc_shadow,7 +write_trisc + movf trisc_shadow,w + bsf STATUS,RP0 ; bank 1 + movwf TRISC ; was bsf TRISC,7 + bcf STATUS,RP0 ; bank 0 + return +; ------------------------------------------------------------------------- +setPinOneToIn ; pin1 is TX!!!! + bcf digitalPinStatusLo,1 + bcf pwmStatusLo,1 + bsf trisc_shadow,6 + goto write_trisc +; ------------------------------------------------------------------------- +setPinTwoToIn + bcf digitalPinStatusLo,2 + bcf pwmStatusLo,2 + bsf trisc_shadow,5 + goto write_trisc +; ------------------------------------------------------------------------- +setPinThreeToIn + bcf digitalPinStatusLo,3 + bcf pwmStatusLo,3 + bsf trisc_shadow,4 + goto write_trisc +; ------------------------------------------------------------------------- +setPinFourToIn + bcf digitalPinStatusLo,4 + bcf pwmStatusLo,4 + bsf trisc_shadow,3 + goto write_trisc +; ------------------------------------------------------------------------- +setPinFiveToIn + bcf digitalPinStatusLo,5 + bcf pwmStatusLo,5 + bsf trisb_shadow,0 +write_trisb + movf trisb_shadow,w + bsf STATUS,RP0 ; bank 1 + movwf TRISB ; was bsf TRISB,0 + bcf STATUS,RP0 ; bank 0 + return +; ------------------------------------------------------------------------- +setPinSixToIn + bcf digitalPinStatusLo,6 + bcf pwmStatusLo,6 + bsf trisb_shadow,4 + goto write_trisb +; ------------------------------------------------------------------------- +setPinSevenToIn + bcf digitalPinStatusLo,7 + bcf pwmStatusLo,7 + bsf trisb_shadow,7 + goto write_trisb +; ------------------------------------------------------------------------- +setPinEightToIn + bcf digitalPinStatusHi,0 + bcf pwmStatusHi,0 + bsf trisb_shadow,6 + goto write_trisb +; ------------------------------------------------------------------------- +setPinNineToIn + bcf digitalPinStatusHi,1 + bcf pwmStatusHi,1 + bsf trisb_shadow,5 + goto write_trisb +; ------------------------------------------------------------------------- +setPinTenToIn + bcf digitalPinStatusHi,2 + bcf pwmStatusHi,2 + bsf trisc_shadow,2 + goto write_trisc +; ------------------------------------------------------------------------- +setPinElevenToIn + bcf digitalPinStatusHi,3 + bcf pwmStatusHi,3 + bsf trisc_shadow,1 + goto write_trisc +; ------------------------------------------------------------------------- +setPinTwelveToIn + bcf digitalPinStatusHi,4 + bcf pwmStatusHi,4 + bsf trisc_shadow,0 + goto write_trisc +; ------------------------------------------------------------------------- +setPinThirteenToIn + bcf digitalPinStatusHi,5 + bcf pwmStatusHi,5 + bsf trisb_shadow,1 + goto write_trisb +; } +; else if(mode == OUTPUT) +; { +; ------------------------------------------------------------------------- +setPinToOutOrPwm + movlw OUTPUT + xorwf mode,w + btfsc STATUS,Z + goto setPinToPwmOrNo + goto setPinToOut +; digitalPinStatus = digitalPinStatus | (1 << pin); +; pwmStatus = pwmStatus &~ (1 << pin); +; pinMode(pin,OUTPUT); +; ------------------------------------------------------------------------- +setPinZeroToOut ; pin0 is RX!!! Don't allow this to happen! TRISC.7 must be 1 +; bsf digitalPinStatusLo,0 +; bcf pwmStatusLo,0 +; bcf trisc_shadow,7 +; goto write_trisc + return +; ------------------------------------------------------------------------- +setPinOneToOut ; pin1 is TX!!!! Don't allow this to happen! TRISC.6 must be 1 +; bsf digitalPinStatusLo,1 +; bcf pwmStatusLo,1 +; bcf trisc_shadow,6 +; goto write_trisc + return +; ------------------------------------------------------------------------- +setPinTwoToOut + bsf digitalPinStatusLo,2 + bcf pwmStatusLo,2 + bcf trisc_shadow,5 + goto write_trisc +; ------------------------------------------------------------------------- +setPinThreeToOut + bsf digitalPinStatusLo,3 + bcf pwmStatusLo,3 + bcf trisc_shadow,4 + goto write_trisc +; ------------------------------------------------------------------------- +setPinFourToOut + bsf digitalPinStatusLo,4 + bcf pwmStatusLo,4 + bcf trisc_shadow,3 + goto write_trisc +; ------------------------------------------------------------------------- +setPinFiveToOut + bsf digitalPinStatusLo,5 + bcf pwmStatusLo,5 + bcf trisb_shadow,0 + goto write_trisb +; ------------------------------------------------------------------------- +setPinSixToOut + bsf digitalPinStatusLo,6 + bcf pwmStatusLo,6 + bcf trisb_shadow,4 + goto write_trisb +; ------------------------------------------------------------------------- +setPinSevenToOut + bsf digitalPinStatusLo,7 + bcf pwmStatusLo,7 + bcf trisb_shadow,7 + goto write_trisb +; ------------------------------------------------------------------------- +setPinEightToOut + bsf digitalPinStatusHi,0 + bcf pwmStatusHi,0 + bcf trisb_shadow,6 + goto write_trisb +; ------------------------------------------------------------------------- +setPinNineToOut + bsf digitalPinStatusHi,1 + bcf pwmStatusHi,1 + bcf trisb_shadow,5 + goto write_trisb +; ------------------------------------------------------------------------- +setPinTenToOut + bsf digitalPinStatusHi,2 + bcf pwmStatusHi,2 + bcf trisc_shadow,2 + goto write_trisc +; ------------------------------------------------------------------------- +setPinElevenToOut + bsf digitalPinStatusHi,3 + bcf pwmStatusHi,3 + bcf trisc_shadow,1 + goto write_trisc +; ------------------------------------------------------------------------- +setPinTwelveToOut + bsf digitalPinStatusHi,4 + bcf pwmStatusHi,4 + bcf trisc_shadow,0 + goto write_tr... [truncated message content] |
From: <eig...@us...> - 2012-10-07 18:35:21
|
Revision: 84 http://firmata.svn.sourceforge.net/firmata/?rev=84&view=rev Author: eighthave Date: 2012-10-07 18:35:15 +0000 (Sun, 07 Oct 2012) Log Message: ----------- set up repo for PICduino, which I'm moving from http://pure-data.svn.sourceforge.net/viewvc/pure-data/trunk/externals/hardware/arduino/PICduino/?view=log&pathrev=6210 Added Paths: ----------- picduino/ picduino/branches/ picduino/tags/ picduino/trunk/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2011-09-10 04:21:45
|
Revision: 83 http://firmata.svn.sourceforge.net/firmata/?rev=83&view=rev Author: mayfair Date: 2011-09-10 04:21:39 +0000 (Sat, 10 Sep 2011) Log Message: ----------- Removed I2CFirmata, since I2C related functions are already integrated to StandardFirmata Removed Paths: ------------- arduino/trunk/Firmata/examples/I2CFirmata/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sou...@us...> - 2011-09-09 02:32:39
|
Revision: 82 http://firmata.svn.sourceforge.net/firmata/?rev=82&view=rev Author: soundanalogous Date: 2011-09-09 02:32:33 +0000 (Fri, 09 Sep 2011) Log Message: ----------- bug fix: missing brackets in if statement in SAMPLING_INTERVAL case. also commented out meaningless error message in same code block Modified Paths: -------------- arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde Modified: arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-09-08 13:23:23 UTC (rev 81) +++ arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-09-09 02:32:33 UTC (rev 82) @@ -437,13 +437,14 @@ } break; case SAMPLING_INTERVAL: - if (argc > 1) + if (argc > 1) { samplingInterval = argv[0] + (argv[1] << 7); if (samplingInterval < MINIMUM_SAMPLING_INTERVAL) { samplingInterval = MINIMUM_SAMPLING_INTERVAL; } - else - Firmata.sendString("Not enough data"); + } else { + //Firmata.sendString("Not enough data"); + } break; case EXTENDED_ANALOG: if (argc > 1) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2011-09-08 13:23:29
|
Revision: 81 http://firmata.svn.sourceforge.net/firmata/?rev=81&view=rev Author: pjs Date: 2011-09-08 13:23:23 +0000 (Thu, 08 Sep 2011) Log Message: ----------- remove out-of-date comment - no actual code change Modified Paths: -------------- arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde Modified: arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-09-08 13:18:46 UTC (rev 80) +++ arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-09-08 13:23:23 UTC (rev 81) @@ -429,7 +429,6 @@ int maxPulse = argv[3] + (argv[4] << 7); if (IS_PIN_SERVO(pin)) { - // servos are pins from 2 to 13, so offset for array if (servos[PIN_TO_SERVO(pin)].attached()) servos[PIN_TO_SERVO(pin)].detach(); servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin), minPulse, maxPulse); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2011-09-08 13:18:53
|
Revision: 80 http://firmata.svn.sourceforge.net/firmata/?rev=80&view=rev Author: pjs Date: 2011-09-08 13:18:46 +0000 (Thu, 08 Sep 2011) Log Message: ----------- remove useless servo error message Modified Paths: -------------- arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde Modified: arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-09-07 20:33:18 UTC (rev 79) +++ arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-09-08 13:18:46 UTC (rev 80) @@ -228,8 +228,6 @@ pinConfig[pin] = SERVO; if (!servos[PIN_TO_SERVO(pin)].attached()) { servos[PIN_TO_SERVO(pin)].attach(PIN_TO_DIGITAL(pin)); - } else { - Firmata.sendString("Servo only on pins from 2 to 13"); } } break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2011-09-07 20:33:24
|
Revision: 79 http://firmata.svn.sourceforge.net/firmata/?rev=79&view=rev Author: pjs Date: 2011-09-07 20:33:18 +0000 (Wed, 07 Sep 2011) Log Message: ----------- system reset message to reset all pins to default config Modified Paths: -------------- arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde Modified: arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-09-07 10:40:18 UTC (rev 78) +++ arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-09-07 20:33:18 UTC (rev 79) @@ -539,41 +539,25 @@ // Wire.end(); } +/*============================================================================== + * SETUP() + *============================================================================*/ + void systemResetCallback() { + // initialize a defalt state + // TODO: option to load config from EEPROM instead of default if (isI2CEnabled) { disableI2CPins(); } -} - - -/*============================================================================== - * SETUP() - *============================================================================*/ -void setup() -{ - byte i; - - Firmata.setFirmwareVersion(FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION); - - Firmata.attach(ANALOG_MESSAGE, analogWriteCallback); - Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback); - Firmata.attach(REPORT_ANALOG, reportAnalogCallback); - Firmata.attach(REPORT_DIGITAL, reportDigitalCallback); - Firmata.attach(SET_PIN_MODE, setPinModeCallback); - Firmata.attach(START_SYSEX, sysexCallback); - Firmata.attach(SYSTEM_RESET, systemResetCallback); - - // TODO: load state from EEPROM here - - /* these are initialized to zero by the compiler startup code - for (i=0; i < TOTAL_PORTS; i++) { - reportPINs[i] = false; - portConfigInputs[i] = 0; + for (byte i=0; i < TOTAL_PORTS; i++) { + reportPINs[i] = false; // by default, reporting off + portConfigInputs[i] = 0; // until activated previousPINs[i] = 0; } - */ - for (i=0; i < TOTAL_PINS; i++) { + // pins with analog capability default to analog input + // otherwise, pins default to digital output + for (byte i=0; i < TOTAL_PINS; i++) { if (IS_PIN_ANALOG(i)) { // turns off pullup, configures everything setPinModeCallback(i, ANALOG); @@ -582,18 +566,36 @@ setPinModeCallback(i, OUTPUT); } } - // by defult, do not report any analog inputs + // by default, do not report any analog inputs analogInputsToReport = 0; - Firmata.begin(57600); - /* send digital inputs to set the initial state on the host computer, * since once in the loop(), this firmware will only send on change */ - for (i=0; i < TOTAL_PORTS; i++) { + /* + TODO: this can never execute, since no pins default to digital input + but it will be needed when/if we support EEPROM stored config + for (byte i=0; i < TOTAL_PORTS; i++) { outputPort(i, readPort(i, portConfigInputs[i]), true); } + */ } +void setup() +{ + Firmata.setFirmwareVersion(FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION); + + Firmata.attach(ANALOG_MESSAGE, analogWriteCallback); + Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback); + Firmata.attach(REPORT_ANALOG, reportAnalogCallback); + Firmata.attach(REPORT_DIGITAL, reportDigitalCallback); + Firmata.attach(SET_PIN_MODE, setPinModeCallback); + Firmata.attach(START_SYSEX, sysexCallback); + Firmata.attach(SYSTEM_RESET, systemResetCallback); + + Firmata.begin(57600); + systemResetCallback(); // reset to default config +} + /*============================================================================== * LOOP() *============================================================================*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2011-09-07 10:40:25
|
Revision: 78 http://firmata.svn.sourceforge.net/firmata/?rev=78&view=rev Author: pjs Date: 2011-09-07 10:40:18 +0000 (Wed, 07 Sep 2011) Log Message: ----------- correctly identify PWM pins when core provides digitalPinHasPWM macro Modified Paths: -------------- arduino/trunk/Firmata/Boards.h Modified: arduino/trunk/Firmata/Boards.h =================================================================== --- arduino/trunk/Firmata/Boards.h 2011-09-06 21:09:35 UTC (rev 77) +++ arduino/trunk/Firmata/Boards.h 2011-09-07 10:40:18 UTC (rev 78) @@ -124,6 +124,10 @@ * Board Specific Configuration *============================================================================*/ +#ifndef digitalPinHasPWM +#define digitalPinHasPWM(p) IS_PIN_DIGITAL(p) +#endif + // Arduino Duemilanove, Diecimila, and NG #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) #if defined(NUM_ANALOG_INPUTS) && NUM_ANALOG_INPUTS == 6 @@ -136,7 +140,7 @@ #define VERSION_BLINK_PIN 13 #define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) <= 19) #define IS_PIN_ANALOG(p) ((p) >= 14 && (p) < 14 + TOTAL_ANALOG_PINS) -#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_PWM(p) digitalPinHasPWM(p) #define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) - 2 < MAX_SERVOS) #define IS_PIN_I2C(p) ((p) == 18 || (p) == 19) #define PIN_TO_DIGITAL(p) (p) @@ -151,7 +155,7 @@ #define VERSION_BLINK_PIN WLED #define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS) #define IS_PIN_ANALOG(p) ((p) >= FIRST_ANALOG_PIN && (p) < (FIRST_ANALOG_PIN+TOTAL_ANALOG_PINS)) -#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_PWM(p) digitalPinHasPWM(p) #define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) #define IS_PIN_I2C(p) ((p) == SDA || (p) == SCL) #define PIN_TO_DIGITAL(p) (p) @@ -167,7 +171,7 @@ #define VERSION_BLINK_PIN 13 #define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) <= 19) #define IS_PIN_ANALOG(p) ((p) >= 14 && (p) <= 19) -#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_PWM(p) digitalPinHasPWM(p) #define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) - 2 < MAX_SERVOS) #define IS_PIN_I2C(p) ((p) == 18 || (p) == 19) #define PIN_TO_DIGITAL(p) (p) @@ -184,7 +188,7 @@ #define VERSION_BLINK_PIN 13 #define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) < TOTAL_PINS) #define IS_PIN_ANALOG(p) ((p) >= 54 && (p) < TOTAL_PINS) -#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_PWM(p) digitalPinHasPWM(p) #define IS_PIN_SERVO(p) ((p) >= 2 && (p) - 2 < MAX_SERVOS) #define IS_PIN_I2C(p) ((p) == 20 || (p) == 21) #define PIN_TO_DIGITAL(p) (p) @@ -200,7 +204,7 @@ #define VERSION_BLINK_PIN 6 #define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS) #define IS_PIN_ANALOG(p) (0) -#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_PWM(p) digitalPinHasPWM(p) #define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) #define IS_PIN_I2C(p) (0) #define PIN_TO_DIGITAL(p) (p) @@ -216,7 +220,7 @@ #define VERSION_BLINK_PIN 11 #define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS) #define IS_PIN_ANALOG(p) ((p) >= 11 && (p) <= 22) -#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_PWM(p) digitalPinHasPWM(p) #define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) #define IS_PIN_I2C(p) ((p) == 5 || (p) == 6) #define PIN_TO_DIGITAL(p) (p) @@ -232,7 +236,7 @@ #define VERSION_BLINK_PIN 6 #define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS) #define IS_PIN_ANALOG(p) ((p) >= 38 && (p) < TOTAL_PINS) -#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_PWM(p) digitalPinHasPWM(p) #define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) #define IS_PIN_I2C(p) ((p) == 0 || (p) == 1) #define PIN_TO_DIGITAL(p) (p) @@ -248,7 +252,7 @@ #define VERSION_BLINK_PIN 0 #define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) < TOTAL_PINS) #define IS_PIN_ANALOG(p) ((p) >= 24 && (p) < TOTAL_PINS) -#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_PWM(p) digitalPinHasPWM(p) #define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) #define IS_PIN_I2C(p) ((p) == 16 || (p) == 17) #define PIN_TO_DIGITAL(p) (p) @@ -264,7 +268,7 @@ #define VERSION_BLINK_PIN 13 #define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) < TOTAL_PINS) #define IS_PIN_ANALOG(p) ((p) >= 36 && (p) < TOTAL_PINS) -#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_PWM(p) digitalPinHasPWM(p) #define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) #define IS_PIN_I2C(p) ((p) == 4 || (p) == 5) #define PIN_TO_DIGITAL(p) (p) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2011-09-06 21:09:41
|
Revision: 77 http://firmata.svn.sourceforge.net/firmata/?rev=77&view=rev Author: pjs Date: 2011-09-06 21:09:35 +0000 (Tue, 06 Sep 2011) Log Message: ----------- shorten version blink time at startup (rather than completely remove it, for now...) Modified Paths: -------------- arduino/trunk/Firmata/Firmata.cpp Modified: arduino/trunk/Firmata/Firmata.cpp =================================================================== --- arduino/trunk/Firmata/Firmata.cpp 2011-09-06 20:08:25 UTC (rev 76) +++ arduino/trunk/Firmata/Firmata.cpp 2011-09-06 21:09:35 UTC (rev 77) @@ -68,7 +68,6 @@ Serial.begin(speed); FirmataSerial = Serial; blinkVersion(); - delay(300); printVersion(); printFirmwareVersion(); } @@ -92,11 +91,10 @@ { // flash the pin with the protocol version pinMode(VERSION_BLINK_PIN,OUTPUT); - pin13strobe(FIRMATA_MAJOR_VERSION, 200, 400); - delay(300); - pin13strobe(2,1,4); // separator, a quick burst - delay(300); - pin13strobe(FIRMATA_MINOR_VERSION, 200, 400); + pin13strobe(FIRMATA_MAJOR_VERSION, 40, 210); + delay(250); + pin13strobe(FIRMATA_MINOR_VERSION, 40, 210); + delay(125); } void FirmataClass::printFirmwareVersion(void) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2011-09-06 20:08:31
|
Revision: 76 http://firmata.svn.sourceforge.net/firmata/?rev=76&view=rev Author: pjs Date: 2011-09-06 20:08:25 +0000 (Tue, 06 Sep 2011) Log Message: ----------- Add MEGA2560 to Boards.h Modified Paths: -------------- arduino/trunk/Firmata/Boards.h Modified: arduino/trunk/Firmata/Boards.h =================================================================== --- arduino/trunk/Firmata/Boards.h 2011-09-06 03:18:13 UTC (rev 75) +++ arduino/trunk/Firmata/Boards.h 2011-09-06 20:08:25 UTC (rev 76) @@ -178,7 +178,7 @@ // Arduino Mega -#elif defined(__AVR_ATmega1280__) +#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #define TOTAL_ANALOG_PINS 16 #define TOTAL_PINS 70 // 54 digital + 16 analog #define VERSION_BLINK_PIN 13 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dm...@us...> - 2011-09-06 03:18:22
|
Revision: 75 http://firmata.svn.sourceforge.net/firmata/?rev=75&view=rev Author: dmellis Date: 2011-09-06 03:18:13 +0000 (Tue, 06 Sep 2011) Log Message: ----------- Adding library.properties. Modified Paths: -------------- processing/trunk/Arduino.xcodeproj/project.pbxproj processing/trunk/build.xml Added Paths: ----------- processing/trunk/library.properties Modified: processing/trunk/Arduino.xcodeproj/project.pbxproj =================================================================== --- processing/trunk/Arduino.xcodeproj/project.pbxproj 2011-09-05 18:49:09 UTC (rev 74) +++ processing/trunk/Arduino.xcodeproj/project.pbxproj 2011-09-06 03:18:13 UTC (rev 75) @@ -13,6 +13,7 @@ 0A8B99880B8F55EC003CD01B /* resources */ = {isa = PBXFileReference; lastKnownFileType = folder; path = resources; sourceTree = "<group>"; }; 0A8B99B20B8F56A4003CD01B /* build.xml */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = build.xml; sourceTree = "<group>"; }; 0A8B99E90B8F5855003CD01B /* jars */ = {isa = PBXFileReference; lastKnownFileType = folder; path = jars; sourceTree = "<group>"; }; + 8120E8FC1415C6DF00A529B3 /* library.properties */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = library.properties; sourceTree = "<group>"; }; 817E2C8C105D52CF00425757 /* arduino */ = {isa = PBXFileReference; lastKnownFileType = folder; path = arduino; sourceTree = "<group>"; }; /* End PBXFileReference section */ @@ -20,6 +21,7 @@ 00E6828FFEC88D1A11DB9C8B = { isa = PBXGroup; children = ( + 8120E8FC1415C6DF00A529B3 /* library.properties */, 817E2C8C105D52CF00425757 /* arduino */, 0A8B99B20B8F56A4003CD01B /* build.xml */, 0A8B99840B8F55E8003CD01B /* src */, @@ -53,7 +55,11 @@ isa = PBXProject; buildConfigurationList = 0AE31F6908BBAC2E002AF232 /* Build configuration list for PBXProject "Arduino" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; + knownRegions = ( + en, + ); mainGroup = 00E6828FFEC88D1A11DB9C8B; productRefGroup = 00E6828FFEC88D1A11DB9C8B; projectDirPath = ""; Modified: processing/trunk/build.xml =================================================================== --- processing/trunk/build.xml 2011-09-05 18:49:09 UTC (rev 74) +++ processing/trunk/build.xml 2011-09-06 03:18:13 UTC (rev 75) @@ -65,6 +65,8 @@ <copy toDir="${dist}/src"> <fileset dir="${src}"/> </copy> + <!-- Copy library.properties --> + <copy toDir="${dist}" file="library.properties" /> </target> Added: processing/trunk/library.properties =================================================================== --- processing/trunk/library.properties (rev 0) +++ processing/trunk/library.properties 2011-09-06 03:18:13 UTC (rev 75) @@ -0,0 +1,45 @@ +# UTF-8 supported. + +# The name of your library as you want it formatted +name = Arduino (Firmata) + +# List of authors. Links can be provided using the syntax [author name](url) +authorList = [David A. Mellis](http://dam.mellis.org/) + +# A web page for your library, NOT a direct link to where to download it +url = http://arduino.cc/playground/Interfacing/Processing + +# The category of your library, must be one of the following: +# "Sound" "Import / Export" "Simulation / Math" +# "Tools" "Hardware Interface" "Typography / Geometry" +# "Animation" "Graphic Interface" "Computer Vision / Video" +# "3D" "Compilation" "Data / Protocols" +# +# If a value other than those listed is used, your library will listed as "Other." +category = Hardware Interface + +# A short sentence (or fragment) to summarize the library's function. This will be +# shown from inside the PDE when the library is being installed. Avoid repeating +# the name of your library here. Also, avoid saying anything redundant like +# mentioning that its a library. This should start with a capitalized letter, and +# end with a period. +sentence = Controls Arduino boards running the Firmata firmware. + +# Additional information suitable for the Processing website. The value of +# 'sentence' always will be prepended, so you should start by writing the +# second sentence here. If your library only works on certain operating systems, +# mention it here. +paragraph = Works with the StandardFirmata example included in the Arduino software distribution. To use Firmata with other software, see [the Firmata homepage](http://firmata.org/) + +# Links in the 'sentence' and 'paragraph' attributes can be inserted using the +# same syntax as for authors. That is, [here is a link to Processing](http://processing.org/) + + +# A version number that increments once with each release. This +# is used to compare different versions of the same library, and +# check if an update is available. You should think of it as a +# counter, counting the total number of releases you've had. +version = 1 # This must be parsable as an int + +# The version as the user will see it. If blank, the version attribute will be used here +prettyVersion = 2.2 # This is treated as a String \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sou...@us...> - 2011-09-05 18:49:15
|
Revision: 74 http://firmata.svn.sourceforge.net/firmata/?rev=74&view=rev Author: soundanalogous Date: 2011-09-05 18:49:09 +0000 (Mon, 05 Sep 2011) Log Message: ----------- Fixed bug in setting i2c pin mode and also bug in setting delayTime. Added ability to stop read continuous mode for a specific device rather than all devices simultaneously. Modified Paths: -------------- arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde Modified: arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-09-05 17:30:22 UTC (rev 73) +++ arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-09-05 18:49:09 UTC (rev 74) @@ -78,9 +78,8 @@ i2c_device_info query[MAX_QUERIES]; byte i2cRxData[32]; -boolean readingContinuously = false; boolean isI2CEnabled = false; -byte queryIndex = 0; +signed char queryIndex = -1; unsigned int i2cReadDelayTime = 0; // default delay time between i2c read request and Wire.requestFrom() Servo servos[MAX_SERVOS]; @@ -174,12 +173,10 @@ */ void setPinModeCallback(byte pin, int mode) { - if (pinConfig[pin] == I2C && mode != I2C) { - isI2CEnabled = false; - // uncomment the following once end() method is added to Wire library - // Wire.end(); - Firmata.sendString("Once I2C is enabled, the I2C pins cannot be changed to another mode"); - return; + if (pinConfig[pin] == I2C && isI2CEnabled && mode != I2C) { + // disable i2c so pins can be used for other functions + // the following if statements should reconfigure the pins properly + disableI2CPins(); } if (IS_PIN_SERVO(pin) && mode != SERVO && servos[PIN_TO_SERVO(pin)].attached()) { servos[PIN_TO_SERVO(pin)].detach(); @@ -238,9 +235,9 @@ break; case I2C: if (IS_PIN_I2C(pin)) { + // mark the pin as i2c + // the user must call I2C_CONFIG to enable I2C for a device pinConfig[pin] = I2C; - // TODO: if not enabled call enableI2CPins()? - // or does user have to call I2C config again in order to reenable I2C? } break; default: @@ -378,32 +375,49 @@ Firmata.sendString("too many queries"); break; } + queryIndex++; query[queryIndex].addr = slaveAddress; query[queryIndex].reg = argv[2] + (argv[3] << 7); query[queryIndex].bytes = argv[4] + (argv[5] << 7); - readingContinuously = true; - queryIndex++; break; case I2C_STOP_READING: - readingContinuously = false; - queryIndex = 0; + byte queryIndexToSkip; + // if read continuous mode is enabled for only 1 i2c device, disable + // read continuous reporting for that device + if (queryIndex <= 0) { + queryIndex = -1; + } else { + // if read continuous mode is enabled for multiple devices, + // determine which device to stop reading and remove it's data from + // the array, shifiting other array data to fill the space + for (byte i = 0; i < queryIndex + 1; i++) { + if (query[i].addr = slaveAddress) { + queryIndexToSkip = i; + break; + } + } + + for (byte i = queryIndexToSkip; i<queryIndex + 1; i++) { + if (i < MAX_QUERIES) { + query[i].addr = query[i+1].addr; + query[i].reg = query[i+1].addr; + query[i].bytes = query[i+1].bytes; + } + } + queryIndex--; + } break; default: break; } break; case I2C_CONFIG: - delayTime = (argv[4] + (argv[5] << 7)); // MSB - delayTime = (delayTime << 8) + (argv[2] + (argv[3] << 7)); // add LSB + delayTime = (argv[0] + (argv[1] << 7)); if(delayTime > 0) { i2cReadDelayTime = delayTime; } - if(argc > 6) { - // If you extend I2C_Config, handle your data here - } - if (!isI2CEnabled) { enableI2CPins(); } @@ -516,11 +530,20 @@ Wire.begin(); } +/* disable the i2c pins so they can be used for other functions */ +void disableI2CPins() { + isI2CEnabled = false; + // disable read continuous mode for all devices + queryIndex = -1; + // uncomment the following if or when the end() method is added to Wire library + // Wire.end(); +} + void systemResetCallback() { - // clear i2c read continuous data - readingContinuously = false; - queryIndex = 0; + if (isI2CEnabled) { + disableI2CPins(); + } } @@ -603,9 +626,9 @@ } } } - // report i2c data if read continuous mode is enabled - if (readingContinuously) { - for (byte i = 0; i < queryIndex; i++) { + // report i2c data for all device with read continuous mode enabled + if (queryIndex > -1) { + for (byte i = 0; i < queryIndex + 1; i++) { readAndReportData(query[i].addr, query[i].reg, query[i].bytes); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2011-09-05 17:30:28
|
Revision: 73 http://firmata.svn.sourceforge.net/firmata/?rev=73&view=rev Author: pjs Date: 2011-09-05 17:30:22 +0000 (Mon, 05 Sep 2011) Log Message: ----------- Add I2C to StandardFirmata Modified Paths: -------------- arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde Modified: arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-09-03 23:36:10 UTC (rev 72) +++ arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-09-05 17:30:22 UTC (rev 73) @@ -11,6 +11,9 @@ /* Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved. + Copyright (C) 2010-2011 Paul Stoffregen. All rights reserved. + Copyright (C) 2009 Shigeru Kobayashi. All rights reserved. + Copyright (C) 2009-2011 Jeff Hoefs. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -27,8 +30,22 @@ */ #include <Servo.h> +#include <Wire.h> #include <Firmata.h> +// move the following defines to Firmata.h? +#define I2C_WRITE B00000000 +#define I2C_READ B00001000 +#define I2C_READ_CONTINUOUSLY B00010000 +#define I2C_STOP_READING B00011000 +#define I2C_READ_WRITE_MODE_MASK B00011000 +#define I2C_10BIT_ADDRESS_MODE_MASK B00100000 + +#define MAX_QUERIES 8 +#define MINIMUM_SAMPLING_INTERVAL 10 + +#define REGISTER_NOT_SPECIFIED -1 + /*============================================================================== * GLOBAL VARIABLES *============================================================================*/ @@ -50,12 +67,70 @@ unsigned long previousMillis; // for comparison with currentMillis int samplingInterval = 19; // how often to run the main loop (in ms) +/* i2c data */ +struct i2c_device_info { + byte addr; + byte reg; + byte bytes; +}; + +/* for i2c read continuous more */ +i2c_device_info query[MAX_QUERIES]; + +byte i2cRxData[32]; +boolean readingContinuously = false; +boolean isI2CEnabled = false; +byte queryIndex = 0; +unsigned int i2cReadDelayTime = 0; // default delay time between i2c read request and Wire.requestFrom() + Servo servos[MAX_SERVOS]; - /*============================================================================== * FUNCTIONS *============================================================================*/ +void readAndReportData(byte address, int theRegister, byte numBytes) { + // allow I2C requests that don't require a register read + // for example, some devices using an interrupt pin to signify new data available + // do not always require the register read so upon interrupt you call Wire.requestFrom() + if (theRegister != REGISTER_NOT_SPECIFIED) { + Wire.beginTransmission(address); + #if ARDUINO >= 100 + Wire.write((byte)theRegister); + #else + Wire.send((byte)theRegister); + #endif + Wire.endTransmission(); + delayMicroseconds(i2cReadDelayTime); // delay is necessary for some devices such as WiiNunchuck + } else { + theRegister = 0; // fill the register with a dummy value + } + + Wire.requestFrom(address, numBytes); // all bytes are returned in requestFrom + + // check to be sure correct number of bytes were returned by slave + if(numBytes == Wire.available()) { + i2cRxData[0] = address; + i2cRxData[1] = theRegister; + for (int i = 0; i < numBytes; i++) { + #if ARDUINO >= 100 + i2cRxData[2 + i] = Wire.read(); + #else + i2cRxData[2 + i] = Wire.receive(); + #endif + } + } + else { + if(numBytes > Wire.available()) { + Firmata.sendString("I2C Read Error: Too many bytes received"); + } else { + Firmata.sendString("I2C Read Error: Too few bytes received"); + } + } + + // send slave address, register and received bytes + Firmata.sendSysex(SYSEX_I2C_REPLY, numBytes + 2, i2cRxData); +} + void outputPort(byte portNumber, byte portValue, byte forceSend) { // pins not configured as INPUT are cleared to zeros @@ -99,6 +174,13 @@ */ void setPinModeCallback(byte pin, int mode) { + if (pinConfig[pin] == I2C && mode != I2C) { + isI2CEnabled = false; + // uncomment the following once end() method is added to Wire library + // Wire.end(); + Firmata.sendString("Once I2C is enabled, the I2C pins cannot be changed to another mode"); + return; + } if (IS_PIN_SERVO(pin) && mode != SERVO && servos[PIN_TO_SERVO(pin)].attached()) { servos[PIN_TO_SERVO(pin)].detach(); } @@ -155,8 +237,11 @@ } break; case I2C: - pinConfig[pin] = mode; - Firmata.sendString("I2C mode not yet supported"); + if (IS_PIN_I2C(pin)) { + pinConfig[pin] = I2C; + // TODO: if not enabled call enableI2CPins()? + // or does user have to call I2C config again in order to reenable I2C? + } break; default: Firmata.sendString("Unknown pin mode"); // TODO: put error msgs in EEPROM @@ -243,7 +328,87 @@ void sysexCallback(byte command, byte argc, byte *argv) { + byte mode; + byte slaveAddress; + byte slaveRegister; + byte data; + unsigned int delayTime; + switch(command) { + case I2C_REQUEST: + mode = argv[1] & I2C_READ_WRITE_MODE_MASK; + if (argv[1] & I2C_10BIT_ADDRESS_MODE_MASK) { + Firmata.sendString("10-bit addressing mode is not yet supported"); + return; + } + else { + slaveAddress = argv[0]; + } + + switch(mode) { + case I2C_WRITE: + Wire.beginTransmission(slaveAddress); + for (byte i = 2; i < argc; i += 2) { + data = argv[i] + (argv[i + 1] << 7); + #if ARDUINO >= 100 + Wire.write(data); + #else + Wire.send(data); + #endif + } + Wire.endTransmission(); + delayMicroseconds(70); + break; + case I2C_READ: + if (argc == 6) { + // a slave register is specified + slaveRegister = argv[2] + (argv[3] << 7); + data = argv[4] + (argv[5] << 7); // bytes to read + readAndReportData(slaveAddress, (int)slaveRegister, data); + } + else { + // a slave register is NOT specified + data = argv[2] + (argv[3] << 7); // bytes to read + readAndReportData(slaveAddress, (int)REGISTER_NOT_SPECIFIED, data); + } + break; + case I2C_READ_CONTINUOUSLY: + if ((queryIndex + 1) >= MAX_QUERIES) { + // too many queries, just ignore + Firmata.sendString("too many queries"); + break; + } + query[queryIndex].addr = slaveAddress; + query[queryIndex].reg = argv[2] + (argv[3] << 7); + query[queryIndex].bytes = argv[4] + (argv[5] << 7); + readingContinuously = true; + queryIndex++; + break; + case I2C_STOP_READING: + readingContinuously = false; + queryIndex = 0; + break; + default: + break; + } + break; + case I2C_CONFIG: + delayTime = (argv[4] + (argv[5] << 7)); // MSB + delayTime = (delayTime << 8) + (argv[2] + (argv[3] << 7)); // add LSB + + if(delayTime > 0) { + i2cReadDelayTime = delayTime; + } + + if(argc > 6) { + // If you extend I2C_Config, handle your data here + } + + if (!isI2CEnabled) { + enableI2CPins(); + } + + break; case SERVO_CONFIG: if(argc > 4) { // these vars are here for clarity, they'll optimized away by the compiler @@ -263,6 +428,9 @@ case SAMPLING_INTERVAL: if (argc > 1) samplingInterval = argv[0] + (argv[1] << 7); + if (samplingInterval < MINIMUM_SAMPLING_INTERVAL) { + samplingInterval = MINIMUM_SAMPLING_INTERVAL; + } else Firmata.sendString("Not enough data"); break; @@ -296,6 +464,10 @@ Serial.write(SERVO); Serial.write(14); } + if (IS_PIN_I2C(pin)) { + Serial.write(I2C); + Serial.write(1); // to do: determine appropriate value + } Serial.write(127); } Serial.write(END_SYSEX); @@ -326,7 +498,32 @@ } } +void enableI2CPins() +{ + byte i; + // is there a faster way to do this? would probaby require importing + // Arduino.h to get SCL and SDA pins + for (i=0; i < TOTAL_PINS; i++) { + if(IS_PIN_I2C(i)) { + // mark pins as i2c so they are ignore in non i2c data requests + setPinModeCallback(i, I2C); + } + } + + isI2CEnabled = true; + + // is there enough time before the first I2C request to call this here? + Wire.begin(); +} +void systemResetCallback() +{ + // clear i2c read continuous data + readingContinuously = false; + queryIndex = 0; +} + + /*============================================================================== * SETUP() *============================================================================*/ @@ -342,6 +539,7 @@ Firmata.attach(REPORT_DIGITAL, reportDigitalCallback); Firmata.attach(SET_PIN_MODE, setPinModeCallback); Firmata.attach(START_SYSEX, sysexCallback); + Firmata.attach(SYSTEM_RESET, systemResetCallback); // TODO: load state from EEPROM here @@ -365,7 +563,7 @@ analogInputsToReport = 0; Firmata.begin(57600); - + /* send digital inputs to set the initial state on the host computer, * since once in the loop(), this firmware will only send on change */ for (i=0; i < TOTAL_PORTS; i++) { @@ -405,5 +603,11 @@ } } } + // report i2c data if read continuous mode is enabled + if (readingContinuously) { + for (byte i = 0; i < queryIndex; i++) { + readAndReportData(query[i].addr, query[i].reg, query[i].bytes); + } + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2011-09-03 23:36:22
|
Revision: 72 http://firmata.svn.sourceforge.net/firmata/?rev=72&view=rev Author: mayfair Date: 2011-09-03 23:36:10 +0000 (Sat, 03 Sep 2011) Log Message: ----------- Added a short description of Firmata and a link to the download page. Modified Paths: -------------- arduino/trunk/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde arduino/trunk/Firmata/examples/AnalogFirmata/AnalogFirmata.pde arduino/trunk/Firmata/examples/EchoString/EchoString.pde arduino/trunk/Firmata/examples/I2CFirmata/I2CFirmata.pde arduino/trunk/Firmata/examples/OldStandardFirmata/OldStandardFirmata.pde arduino/trunk/Firmata/examples/ServoFirmata/ServoFirmata.pde arduino/trunk/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.pde arduino/trunk/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde Modified: arduino/trunk/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde 2011-08-30 19:01:24 UTC (rev 71) +++ arduino/trunk/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde 2011-09-03 23:36:10 UTC (rev 72) @@ -1,3 +1,14 @@ +/* + * Firmata is a generic protocol for communicating with microcontrollers + * from software on a host computer. It is intended to work with + * any host computer software package. + * + * To download a host software package, please clink on the following link + * to open the download page in your default browser. + * + * http://firmata.org/wiki/Download + */ + /* * This firmware reads all inputs and sends them as fast as it can. It was * inspired by the ease-of-use of the Arduino2Max program. Modified: arduino/trunk/Firmata/examples/AnalogFirmata/AnalogFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/AnalogFirmata/AnalogFirmata.pde 2011-08-30 19:01:24 UTC (rev 71) +++ arduino/trunk/Firmata/examples/AnalogFirmata/AnalogFirmata.pde 2011-09-03 23:36:10 UTC (rev 72) @@ -1,3 +1,14 @@ +/* + * Firmata is a generic protocol for communicating with microcontrollers + * from software on a host computer. It is intended to work with + * any host computer software package. + * + * To download a host software package, please clink on the following link + * to open the download page in your default browser. + * + * http://firmata.org/wiki/Download + */ + /* This firmware supports as many analog ports as possible, all analog inputs, * four PWM outputs, and two with servo support. * Modified: arduino/trunk/Firmata/examples/EchoString/EchoString.pde =================================================================== --- arduino/trunk/Firmata/examples/EchoString/EchoString.pde 2011-08-30 19:01:24 UTC (rev 71) +++ arduino/trunk/Firmata/examples/EchoString/EchoString.pde 2011-09-03 23:36:10 UTC (rev 72) @@ -1,3 +1,14 @@ +/* + * Firmata is a generic protocol for communicating with microcontrollers + * from software on a host computer. It is intended to work with + * any host computer software package. + * + * To download a host software package, please clink on the following link + * to open the download page in your default browser. + * + * http://firmata.org/wiki/Download + */ + /* This sketch accepts strings and raw sysex messages and echos them back. * * This example code is in the public domain. Modified: arduino/trunk/Firmata/examples/I2CFirmata/I2CFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/I2CFirmata/I2CFirmata.pde 2011-08-30 19:01:24 UTC (rev 71) +++ arduino/trunk/Firmata/examples/I2CFirmata/I2CFirmata.pde 2011-09-03 23:36:10 UTC (rev 72) @@ -1,4 +1,15 @@ /* + * Firmata is a generic protocol for communicating with microcontrollers + * from software on a host computer. It is intended to work with + * any host computer software package. + * + * To download a host software package, please clink on the following link + * to open the download page in your default browser. + * + * http://firmata.org/wiki/Download + */ + +/* Copyright (C) 2009 Jeff Hoefs. All rights reserved. Copyright (C) 2009 Shigeru Kobayashi. All rights reserved. Modified: arduino/trunk/Firmata/examples/OldStandardFirmata/OldStandardFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/OldStandardFirmata/OldStandardFirmata.pde 2011-08-30 19:01:24 UTC (rev 71) +++ arduino/trunk/Firmata/examples/OldStandardFirmata/OldStandardFirmata.pde 2011-09-03 23:36:10 UTC (rev 72) @@ -1,4 +1,15 @@ /* + * Firmata is a generic protocol for communicating with microcontrollers + * from software on a host computer. It is intended to work with + * any host computer software package. + * + * To download a host software package, please clink on the following link + * to open the download page in your default browser. + * + * http://firmata.org/wiki/Download + */ + +/* Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved. This library is free software; you can redistribute it and/or Modified: arduino/trunk/Firmata/examples/ServoFirmata/ServoFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/ServoFirmata/ServoFirmata.pde 2011-08-30 19:01:24 UTC (rev 71) +++ arduino/trunk/Firmata/examples/ServoFirmata/ServoFirmata.pde 2011-09-03 23:36:10 UTC (rev 72) @@ -1,3 +1,14 @@ +/* + * Firmata is a generic protocol for communicating with microcontrollers + * from software on a host computer. It is intended to work with + * any host computer software package. + * + * To download a host software package, please clink on the following link + * to open the download page in your default browser. + * + * http://firmata.org/wiki/Download + */ + /* This firmware supports as many servos as possible using the Servo library * included in Arduino 0017 * Modified: arduino/trunk/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.pde 2011-08-30 19:01:24 UTC (rev 71) +++ arduino/trunk/Firmata/examples/SimpleAnalogFirmata/SimpleAnalogFirmata.pde 2011-09-03 23:36:10 UTC (rev 72) @@ -1,3 +1,14 @@ +/* + * Firmata is a generic protocol for communicating with microcontrollers + * from software on a host computer. It is intended to work with + * any host computer software package. + * + * To download a host software package, please clink on the following link + * to open the download page in your default browser. + * + * http://firmata.org/wiki/Download + */ + /* Supports as many analog inputs and analog PWM outputs as possible. * * This example code is in the public domain. Modified: arduino/trunk/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde 2011-08-30 19:01:24 UTC (rev 71) +++ arduino/trunk/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde 2011-09-03 23:36:10 UTC (rev 72) @@ -1,3 +1,14 @@ +/* + * Firmata is a generic protocol for communicating with microcontrollers + * from software on a host computer. It is intended to work with + * any host computer software package. + * + * To download a host software package, please clink on the following link + * to open the download page in your default browser. + * + * http://firmata.org/wiki/Download + */ + /* Supports as many digital inputs and outputs as possible. * * This example code is in the public domain. Modified: arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-08-30 19:01:24 UTC (rev 71) +++ arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-09-03 23:36:10 UTC (rev 72) @@ -1,4 +1,15 @@ /* + * Firmata is a generic protocol for communicating with microcontrollers + * from software on a host computer. It is intended to work with + * any host computer software package. + * + * To download a host software package, please clink on the following link + * to open the download page in your default browser. + * + * http://firmata.org/wiki/Download + */ + +/* Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved. This library is free software; you can redistribute it and/or This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2011-08-30 19:01:31
|
Revision: 71 http://firmata.svn.sourceforge.net/firmata/?rev=71&view=rev Author: pjs Date: 2011-08-30 19:01:24 +0000 (Tue, 30 Aug 2011) Log Message: ----------- add I2C pins to Boards.h Modified Paths: -------------- arduino/trunk/Firmata/Boards.h Modified: arduino/trunk/Firmata/Boards.h =================================================================== --- arduino/trunk/Firmata/Boards.h 2011-08-30 01:23:52 UTC (rev 70) +++ arduino/trunk/Firmata/Boards.h 2011-08-30 19:01:24 UTC (rev 71) @@ -138,7 +138,7 @@ #define IS_PIN_ANALOG(p) ((p) >= 14 && (p) < 14 + TOTAL_ANALOG_PINS) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) #define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) - 2 < MAX_SERVOS) -#define IS_PIN_I2C(p) (0) +#define IS_PIN_I2C(p) ((p) == 18 || (p) == 19) #define PIN_TO_DIGITAL(p) (p) #define PIN_TO_ANALOG(p) ((p) - 14) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) @@ -153,7 +153,7 @@ #define IS_PIN_ANALOG(p) ((p) >= FIRST_ANALOG_PIN && (p) < (FIRST_ANALOG_PIN+TOTAL_ANALOG_PINS)) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) #define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) -#define IS_PIN_I2C(p) (0) +#define IS_PIN_I2C(p) ((p) == SDA || (p) == SCL) #define PIN_TO_DIGITAL(p) (p) #define PIN_TO_ANALOG(p) ((p) - FIRST_ANALOG_PIN) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) @@ -169,7 +169,7 @@ #define IS_PIN_ANALOG(p) ((p) >= 14 && (p) <= 19) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) #define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) - 2 < MAX_SERVOS) -#define IS_PIN_I2C(p) (0) +#define IS_PIN_I2C(p) ((p) == 18 || (p) == 19) #define PIN_TO_DIGITAL(p) (p) #define PIN_TO_ANALOG(p) ((p) - 14) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) @@ -186,7 +186,7 @@ #define IS_PIN_ANALOG(p) ((p) >= 54 && (p) < TOTAL_PINS) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) #define IS_PIN_SERVO(p) ((p) >= 2 && (p) - 2 < MAX_SERVOS) -#define IS_PIN_I2C(p) (0) +#define IS_PIN_I2C(p) ((p) == 20 || (p) == 21) #define PIN_TO_DIGITAL(p) (p) #define PIN_TO_ANALOG(p) ((p) - 54) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) @@ -218,7 +218,7 @@ #define IS_PIN_ANALOG(p) ((p) >= 11 && (p) <= 22) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) #define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) -#define IS_PIN_I2C(p) (0) +#define IS_PIN_I2C(p) ((p) == 5 || (p) == 6) #define PIN_TO_DIGITAL(p) (p) #define PIN_TO_ANALOG(p) (((p)<22)?21-(p):11) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) @@ -234,7 +234,7 @@ #define IS_PIN_ANALOG(p) ((p) >= 38 && (p) < TOTAL_PINS) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) #define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) -#define IS_PIN_I2C(p) (0) +#define IS_PIN_I2C(p) ((p) == 0 || (p) == 1) #define PIN_TO_DIGITAL(p) (p) #define PIN_TO_ANALOG(p) ((p) - 38) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) @@ -250,7 +250,7 @@ #define IS_PIN_ANALOG(p) ((p) >= 24 && (p) < TOTAL_PINS) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) #define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) -#define IS_PIN_I2C(p) (0) +#define IS_PIN_I2C(p) ((p) == 16 || (p) == 17) #define PIN_TO_DIGITAL(p) (p) #define PIN_TO_ANALOG(p) ((p) - 24) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) @@ -266,7 +266,7 @@ #define IS_PIN_ANALOG(p) ((p) >= 36 && (p) < TOTAL_PINS) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) #define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) -#define IS_PIN_I2C(p) (0) +#define IS_PIN_I2C(p) ((p) == 4 || (p) == 5) #define PIN_TO_DIGITAL(p) (p) #define PIN_TO_ANALOG(p) ((p) - 36) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2011-08-30 01:23:58
|
Revision: 70 http://firmata.svn.sourceforge.net/firmata/?rev=70&view=rev Author: pjs Date: 2011-08-30 01:23:52 +0000 (Tue, 30 Aug 2011) Log Message: ----------- Change pins on Arduino boards to match Arduino's pinouts (eliminate unused pins 14 & 15) Increase Firmata version to 2.3 Modified Paths: -------------- arduino/trunk/Firmata/Boards.h arduino/trunk/Firmata/Firmata.h arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde Modified: arduino/trunk/Firmata/Boards.h =================================================================== --- arduino/trunk/Firmata/Boards.h 2011-08-29 04:21:16 UTC (rev 69) +++ arduino/trunk/Firmata/Boards.h 2011-08-30 01:23:52 UTC (rev 70) @@ -126,16 +126,21 @@ // Arduino Duemilanove, Diecimila, and NG #if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) +#if defined(NUM_ANALOG_INPUTS) && NUM_ANALOG_INPUTS == 6 +#define TOTAL_ANALOG_PINS 6 +#define TOTAL_PINS 20 // 14 digital + 6 analog +#else #define TOTAL_ANALOG_PINS 8 -#define TOTAL_PINS 24 // 14 digital + 2 unused + 8 analog +#define TOTAL_PINS 22 // 14 digital + 8 analog +#endif #define VERSION_BLINK_PIN 13 -#define IS_PIN_DIGITAL(p) (((p) >= 2 && (p) <= 13) || ((p) >= 16 && (p) <= 21)) -#define IS_PIN_ANALOG(p) ((p) >= 16 && (p) <= 23) +#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) <= 19) +#define IS_PIN_ANALOG(p) ((p) >= 14 && (p) < 14 + TOTAL_ANALOG_PINS) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) -#define IS_PIN_SERVO(p) ((p) >= 2 && (p) <= 13 && (p) - 2 < MAX_SERVOS) +#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) - 2 < MAX_SERVOS) #define IS_PIN_I2C(p) (0) -#define PIN_TO_DIGITAL(p) (((p) < 16) ? (p) : (p) - 2) -#define PIN_TO_ANALOG(p) ((p) - 16) +#define PIN_TO_DIGITAL(p) (p) +#define PIN_TO_ANALOG(p) ((p) - 14) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) #define PIN_TO_SERVO(p) ((p) - 2) #define ARDUINO_PINOUT_OPTIMIZE 1 @@ -158,15 +163,15 @@ // old Arduinos #elif defined(__AVR_ATmega8__) #define TOTAL_ANALOG_PINS 6 -#define TOTAL_PINS 22 // 14 digital + 2 unused + 6 analog +#define TOTAL_PINS 20 // 14 digital + 6 analog #define VERSION_BLINK_PIN 13 -#define IS_PIN_DIGITAL(p) (((p) >= 2 && (p) <= 13) || ((p) >= 16 && (p) <= 21)) -#define IS_PIN_ANALOG(p) ((p) >= 16 && (p) <= 21) +#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) <= 19) +#define IS_PIN_ANALOG(p) ((p) >= 14 && (p) <= 19) #define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) -#define IS_PIN_SERVO(p) ((p) >= 2 && (p) <= 13 && (p) - 2 < MAX_SERVOS) +#define IS_PIN_SERVO(p) (IS_PIN_DIGITAL(p) && (p) - 2 < MAX_SERVOS) #define IS_PIN_I2C(p) (0) -#define PIN_TO_DIGITAL(p) (((p) < 16) ? (p) : (p) - 2) -#define PIN_TO_ANALOG(p) ((p) - 16) +#define PIN_TO_DIGITAL(p) (p) +#define PIN_TO_ANALOG(p) ((p) - 14) #define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) #define PIN_TO_SERVO(p) ((p) - 2) #define ARDUINO_PINOUT_OPTIMIZE 1 @@ -282,9 +287,9 @@ static inline unsigned char readPort(byte port, byte bitmask) { #if defined(ARDUINO_PINOUT_OPTIMIZE) - if (port == 0) return PIND & B11111100 & bitmask; // ignore Rx/Tx 0/1 - if (port == 1) return PINB & B00111111 & bitmask; // pins 8-13 (14,15 are disabled for the crystal) - if (port == 2) return PINC & bitmask; + if (port == 0) return (PIND & 0xFC) & bitmask; // ignore Rx/Tx 0/1 + if (port == 1) return ((PINB & 0x3F) | ((PINC & 0x03) << 6)) & bitmask; + if (port == 2) return ((PINC & 0x3C) >> 2) & bitmask; return 0; #else unsigned char out=0, pin=port*8; @@ -309,17 +314,27 @@ { #if defined(ARDUINO_PINOUT_OPTIMIZE) if (port == 0) { - bitmask = bitmask & 0xFC; // Tx & Rx pins + bitmask = bitmask & 0xFC; // do not touch Tx & Rx pins + byte valD = value & bitmask; + byte maskD = ~bitmask; cli(); - PORTD = (PORTD & ~bitmask) | (bitmask & value); + PORTD = (PORTD & maskD) | valD; sei(); } else if (port == 1) { + byte valB = (value & bitmask) & 0x3F; + byte valC = (value & bitmask) >> 6; + byte maskB = ~(bitmask & 0x3F); + byte maskC = ~((bitmask & 0xC0) >> 6); cli(); - PORTB = (PORTB & ~bitmask) | (bitmask & value); + PORTB = (PORTB & maskB) | valB; + PORTC = (PORTC & maskC) | valC; sei(); } else if (port == 2) { + bitmask = bitmask & 0x0F; + byte valC = (value & bitmask) << 2; + byte maskC = ~(bitmask << 2); cli(); - PORTC = (PORTC & ~bitmask) | (bitmask & value); + PORTC = (PORTC & maskC) | valC; sei(); } #else Modified: arduino/trunk/Firmata/Firmata.h =================================================================== --- arduino/trunk/Firmata/Firmata.h 2011-08-29 04:21:16 UTC (rev 69) +++ arduino/trunk/Firmata/Firmata.h 2011-08-30 01:23:52 UTC (rev 70) @@ -20,7 +20,7 @@ * software can test whether it will be compatible with the currently * installed firmware. */ #define FIRMATA_MAJOR_VERSION 2 // for non-compatible changes -#define FIRMATA_MINOR_VERSION 2 // for backwards compatible changes +#define FIRMATA_MINOR_VERSION 3 // for backwards compatible changes #define FIRMATA_BUGFIX_VERSION 1 // for bugfix releases #define MAX_DATA_BYTES 32 // max number of data bytes in non-Sysex messages Modified: arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-08-29 04:21:16 UTC (rev 69) +++ arduino/trunk/Firmata/examples/StandardFirmata/StandardFirmata.pde 2011-08-30 01:23:52 UTC (rev 70) @@ -323,7 +323,7 @@ { byte i; - Firmata.setFirmwareVersion(2, 2); + Firmata.setFirmwareVersion(FIRMATA_MAJOR_VERSION, FIRMATA_MINOR_VERSION); Firmata.attach(ANALOG_MESSAGE, analogWriteCallback); Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ma...@us...> - 2011-08-29 04:21:22
|
Revision: 69 http://firmata.svn.sourceforge.net/firmata/?rev=69&view=rev Author: mayfair Date: 2011-08-29 04:21:16 +0000 (Mon, 29 Aug 2011) Log Message: ----------- Modified to be compiled on both Arduino 0022 and 1.0 (r68 or greater) Revision Links: -------------- http://firmata.svn.sourceforge.net/firmata/?rev=68&view=rev Modified Paths: -------------- arduino/trunk/Firmata/examples/EchoString/EchoString.pde arduino/trunk/Firmata/examples/I2CFirmata/I2CFirmata.pde Modified: arduino/trunk/Firmata/examples/EchoString/EchoString.pde =================================================================== --- arduino/trunk/Firmata/examples/EchoString/EchoString.pde 2011-04-30 12:31:16 UTC (rev 68) +++ arduino/trunk/Firmata/examples/EchoString/EchoString.pde 2011-08-29 04:21:16 UTC (rev 69) @@ -14,12 +14,7 @@ void sysexCallback(byte command, byte argc, byte*argv) { - Serial.print(START_SYSEX, BYTE); - Serial.print(command, BYTE); - for(byte i=0; i<argc; i++) { - Serial.print(argv[i], BYTE); - } - Serial.print(END_SYSEX, BYTE); + Firmata.sendSysex(command, argc, argv); } void setup() Modified: arduino/trunk/Firmata/examples/I2CFirmata/I2CFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/I2CFirmata/I2CFirmata.pde 2011-04-30 12:31:16 UTC (rev 68) +++ arduino/trunk/Firmata/examples/I2CFirmata/I2CFirmata.pde 2011-08-29 04:21:16 UTC (rev 69) @@ -48,7 +48,7 @@ { if (theRegister != REGISTER_NOT_SPECIFIED) { Wire.beginTransmission(address); - Wire.send((byte)theRegister); + Wire.write((byte)theRegister); Wire.endTransmission(); delayMicroseconds(i2cReadDelayTime); // delay is necessary for some devices such as WiiNunchuck } @@ -63,7 +63,7 @@ i2cRxData[0] = address; i2cRxData[1] = theRegister; for (int i = 0; i < numBytes; i++) { - i2cRxData[2 + i] = Wire.receive(); + i2cRxData[2 + i] = Wire.read(); } // send slave address, register and received bytes Firmata.sendSysex(I2C_REPLY, numBytes + 2, i2cRxData); @@ -95,7 +95,7 @@ Wire.beginTransmission(slaveAddress); for (byte i = 2; i < argc; i += 2) { data = argv[i] + (argv[i + 1] << 7); - Wire.send(data); + Wire.write(data); } Wire.endTransmission(); delayMicroseconds(70); // TODO is this needed? This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pj...@us...> - 2011-04-30 12:31:23
|
Revision: 68 http://firmata.svn.sourceforge.net/firmata/?rev=68&view=rev Author: pjs Date: 2011-04-30 12:31:16 +0000 (Sat, 30 Apr 2011) Log Message: ----------- Compatibility with Arduino new-extension branch begin(stream) - ability to communicate on anything other than Serial definitions for Wiring in Boards.h Modified Paths: -------------- arduino/trunk/Firmata/Boards.h arduino/trunk/Firmata/Firmata.cpp arduino/trunk/Firmata/Firmata.h Modified: arduino/trunk/Firmata/Boards.h =================================================================== --- arduino/trunk/Firmata/Boards.h 2011-01-03 04:18:27 UTC (rev 67) +++ arduino/trunk/Firmata/Boards.h 2011-04-30 12:31:16 UTC (rev 68) @@ -3,8 +3,14 @@ #ifndef Firmata_Boards_h #define Firmata_Boards_h -#include <WProgram.h> // for digitalRead, digitalWrite, etc +#include <inttypes.h> +#if defined(ARDUINO) && ARDUINO >= 100 +#include "Arduino.h" // for digitalRead, digitalWrite, etc +#else +#include "WProgram.h" +#endif + // Normally Servo.h must be included before Firmata.h (which then includes // this file). If Servo.h wasn't included, this allows the code to still // compile, but without support for any Servos. Hopefully that's what the @@ -135,6 +141,20 @@ #define ARDUINO_PINOUT_OPTIMIZE 1 +// Wiring (and board) +#elif defined(WIRING) +#define VERSION_BLINK_PIN WLED +#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) < TOTAL_PINS) +#define IS_PIN_ANALOG(p) ((p) >= FIRST_ANALOG_PIN && (p) < (FIRST_ANALOG_PIN+TOTAL_ANALOG_PINS)) +#define IS_PIN_PWM(p) IS_PIN_DIGITAL(p) +#define IS_PIN_SERVO(p) ((p) >= 0 && (p) < MAX_SERVOS) +#define IS_PIN_I2C(p) (0) +#define PIN_TO_DIGITAL(p) (p) +#define PIN_TO_ANALOG(p) ((p) - FIRST_ANALOG_PIN) +#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p) +#define PIN_TO_SERVO(p) (p) + + // old Arduinos #elif defined(__AVR_ATmega8__) #define TOTAL_ANALOG_PINS 6 @@ -168,14 +188,6 @@ #define PIN_TO_SERVO(p) ((p) - 2) -// Wiring -#elif defined(__AVR_ATmega128__) -#define TOTAL_ANALOG_PINS 8 -#define TOTAL_PINS 51 -#define VERSION_BLINK_PIN 48 -// TODO: hardware abstraction for wiring board - - // Teensy 1.0 #elif defined(__AVR_AT90USB162__) #define TOTAL_ANALOG_PINS 0 Modified: arduino/trunk/Firmata/Firmata.cpp =================================================================== --- arduino/trunk/Firmata/Firmata.cpp 2011-01-03 04:18:27 UTC (rev 67) +++ arduino/trunk/Firmata/Firmata.cpp 2011-04-30 12:31:16 UTC (rev 68) @@ -14,9 +14,8 @@ //* Includes //****************************************************************************** -#include "WProgram.h" +#include "Firmata.h" #include "HardwareSerial.h" -#include "Firmata.h" extern "C" { #include <string.h> @@ -27,27 +26,27 @@ //* Support Functions //****************************************************************************** -void sendValueAsTwo7bitBytes(int value) +void FirmataClass::sendValueAsTwo7bitBytes(int value) { - Serial.print(value & B01111111, BYTE); // LSB - Serial.print(value >> 7 & B01111111, BYTE); // MSB + FirmataSerial.write(value & B01111111); // LSB + FirmataSerial.write(value >> 7 & B01111111); // MSB } -void startSysex(void) +void FirmataClass::startSysex(void) { - Serial.print(START_SYSEX, BYTE); + FirmataSerial.write(START_SYSEX); } -void endSysex(void) +void FirmataClass::endSysex(void) { - Serial.print(END_SYSEX, BYTE); + FirmataSerial.write(END_SYSEX); } //****************************************************************************** //* Constructors //****************************************************************************** -FirmataClass::FirmataClass(void) +FirmataClass::FirmataClass(Stream &s) : FirmataSerial(s) { firmwareVersionCount = 0; systemReset(); @@ -67,17 +66,26 @@ void FirmataClass::begin(long speed) { Serial.begin(speed); + FirmataSerial = Serial; blinkVersion(); delay(300); printVersion(); printFirmwareVersion(); } +void FirmataClass::begin(Stream &s) +{ + FirmataSerial = s; + systemReset(); + printVersion(); + printFirmwareVersion(); +} + // output the protocol version message to the serial port void FirmataClass::printVersion(void) { - Serial.print(REPORT_VERSION, BYTE); - Serial.print(FIRMATA_MAJOR_VERSION, BYTE); - Serial.print(FIRMATA_MINOR_VERSION, BYTE); + FirmataSerial.write(REPORT_VERSION); + FirmataSerial.write(FIRMATA_MAJOR_VERSION); + FirmataSerial.write(FIRMATA_MINOR_VERSION); } void FirmataClass::blinkVersion(void) @@ -97,9 +105,9 @@ if(firmwareVersionCount) { // make sure that the name has been set before reporting startSysex(); - Serial.print(REPORT_FIRMWARE, BYTE); - Serial.print(firmwareVersionVector[0]); // major version number - Serial.print(firmwareVersionVector[1]); // minor version number + FirmataSerial.write(REPORT_FIRMWARE); + FirmataSerial.write(firmwareVersionVector[0]); // major version number + FirmataSerial.write(firmwareVersionVector[1]); // minor version number for(i=2; i<firmwareVersionCount; ++i) { sendValueAsTwo7bitBytes(firmwareVersionVector[i]); } @@ -137,7 +145,7 @@ int FirmataClass::available(void) { - return Serial.available(); + return FirmataSerial.available(); } @@ -171,7 +179,7 @@ void FirmataClass::processInput(void) { - int inputData = Serial.read(); // this is 'int' to handle -1 when no data + int inputData = FirmataSerial.read(); // this is 'int' to handle -1 when no data int command; // TODO make sure it handles -1 properly @@ -263,7 +271,7 @@ void FirmataClass::sendAnalog(byte pin, int value) { // pin can only be 0-15, so chop higher bits - Serial.print(ANALOG_MESSAGE | (pin & 0xF), BYTE); + FirmataSerial.write(ANALOG_MESSAGE | (pin & 0xF)); sendValueAsTwo7bitBytes(value); } @@ -294,9 +302,9 @@ // send an 8-bit port in a single digital message (protocol v2) void FirmataClass::sendDigitalPort(byte portNumber, int portData) { - Serial.print(DIGITAL_MESSAGE | (portNumber & 0xF),BYTE); - Serial.print((byte)portData % 128, BYTE); // Tx bits 0-6 - Serial.print(portData >> 7, BYTE); // Tx bits 7-13 + FirmataSerial.write(DIGITAL_MESSAGE | (portNumber & 0xF)); + FirmataSerial.write((byte)portData % 128); // Tx bits 0-6 + FirmataSerial.write(portData >> 7); // Tx bits 7-13 } @@ -304,7 +312,7 @@ { byte i; startSysex(); - Serial.print(command, BYTE); + FirmataSerial.write(command); for(i=0; i<bytec; i++) { sendValueAsTwo7bitBytes(bytev[i]); } @@ -433,6 +441,6 @@ // make one instance for the user to use -FirmataClass Firmata; +FirmataClass Firmata(Serial); Modified: arduino/trunk/Firmata/Firmata.h =================================================================== --- arduino/trunk/Firmata/Firmata.h 2011-01-03 04:18:27 UTC (rev 67) +++ arduino/trunk/Firmata/Firmata.h 2011-04-30 12:31:16 UTC (rev 68) @@ -13,10 +13,8 @@ #ifndef Firmata_h #define Firmata_h -#include <WProgram.h> -#include <inttypes.h> +#include "Boards.h" /* Hardware Abstraction Layer + Wiring/Arduino */ - /* Version numbers for the protocol. The protocol is still changing, so these * version numbers are important. This number can be queried so that host * software can test whether it will be compatible with the currently @@ -89,10 +87,11 @@ class FirmataClass { public: - FirmataClass(); + FirmataClass(Stream &s); /* Arduino constructors */ void begin(); void begin(long); + void begin(Stream &s); /* querying functions */ void printVersion(void); void blinkVersion(void); @@ -117,6 +116,7 @@ void detach(byte command); private: + Stream &FirmataSerial; /* firmware name and version */ byte firmwareVersionCount; byte *firmwareVersionVector; @@ -142,6 +142,9 @@ void processSysexMessage(void); void systemReset(void); void pin13strobe(int count, int onInterval, int offInterval); + void sendValueAsTwo7bitBytes(int value); + void startSysex(void); + void endSysex(void); }; extern FirmataClass Firmata; @@ -156,8 +159,5 @@ */ #define setFirmwareVersion(x, y) setFirmwareNameAndVersion(__FILE__, x, y) -/* Hardware Abstraction Layer */ -#include "Boards.h" - #endif /* Firmata_h */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eig...@us...> - 2011-01-03 04:18:33
|
Revision: 67 http://firmata.svn.sourceforge.net/firmata/?rev=67&view=rev Author: eighthave Date: 2011-01-03 04:18:27 +0000 (Mon, 03 Jan 2011) Log Message: ----------- added bugfix version number Modified Paths: -------------- arduino/trunk/Firmata/Firmata.h Modified: arduino/trunk/Firmata/Firmata.h =================================================================== --- arduino/trunk/Firmata/Firmata.h 2011-01-03 04:10:48 UTC (rev 66) +++ arduino/trunk/Firmata/Firmata.h 2011-01-03 04:18:27 UTC (rev 67) @@ -23,6 +23,7 @@ * installed firmware. */ #define FIRMATA_MAJOR_VERSION 2 // for non-compatible changes #define FIRMATA_MINOR_VERSION 2 // for backwards compatible changes +#define FIRMATA_BUGFIX_VERSION 1 // for bugfix releases #define MAX_DATA_BYTES 32 // max number of data bytes in non-Sysex messages This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eig...@us...> - 2011-01-03 04:10:56
|
Revision: 66 http://firmata.svn.sourceforge.net/firmata/?rev=66&view=rev Author: eighthave Date: 2011-01-03 04:10:48 +0000 (Mon, 03 Jan 2011) Log Message: ----------- tagging Firmata 2.2 for Arduino, Teensy, Wiring, etc. Added Paths: ----------- arduino/tags/2.2/ Property changes on: arduino/tags/2.2 ___________________________________________________________________ Added: svn:mergeinfo + /arduino/branches/hardwareAbstraction:53-57 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <eig...@us...> - 2010-10-26 20:07:24
|
Revision: 65 http://firmata.svn.sourceforge.net/firmata/?rev=65&view=rev Author: eighthave Date: 2010-10-26 20:07:17 +0000 (Tue, 26 Oct 2010) Log Message: ----------- updated example sketches to use readPort() from Boards.h, which now has 2 args not 1 Modified Paths: -------------- arduino/trunk/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde arduino/trunk/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde Modified: arduino/trunk/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde 2010-09-03 23:58:40 UTC (rev 64) +++ arduino/trunk/Firmata/examples/AllInputsFirmata/AllInputsFirmata.pde 2010-10-26 20:07:17 UTC (rev 65) @@ -56,7 +56,7 @@ byte i; for (i=0; i<TOTAL_PORTS; i++) { - sendPort(i, readPort(i)); + sendPort(i, readPort(i, 0xff)); } /* make sure that the FTDI buffer doesn't go over 60 bytes, otherwise you get long, random delays. So only read analogs every 20ms or so */ Modified: arduino/trunk/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde =================================================================== --- arduino/trunk/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde 2010-09-03 23:58:40 UTC (rev 64) +++ arduino/trunk/Firmata/examples/SimpleDigitalFirmata/SimpleDigitalFirmata.pde 2010-10-26 20:07:17 UTC (rev 65) @@ -52,7 +52,7 @@ byte i; for (i=0; i<TOTAL_PORTS; i++) { - outputPort(i, readPort(i)); + outputPort(i, readPort(i, 0xff)); } while(Firmata.available()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |