mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-23 19:21:59 +03:00
Merge branch 'master' into esp8266
* master: (414 commits) Don't export sketch if the underlying core does not support it. Fixes #3171 RSyntaxTextArea: using a modified version, tracked at https://github.com/arduino/RSyntaxTextArea. Fixes #3099 Updated keywords.txt New editor on MacOSX: since CMD+J is known as "jump to selection" and the editor has no such feature, CMD+J is disabled on mac. See #3098 Old Preferences class remains for backwards compatibility as a delegate for PreferencesData New Preferences window: renders fine on every OS and it's easier to adapt using NetBeans as visual editor. Fixes #3140 Remove spawn from exec command Removed redundant call to File.deleteIfExists() Removed buggy redundant check in FileUtils.deleteIfExists() Restored current line/current selected lines display on lower left of the IDE. Fixes #3134 Updated cursor.ino New editor on MacOSX: restored CMD+E for finding selected text New editor on MacOSX: CMD+UP/DOWN moves cursor to start or end of sketch. See #3098 New editor on MacOSX: CMD+BACKSPACE deletes current line until cursor position, ALT+BACKSPACE deletes previous word. See #3098 ArduinoIDE is in the default package. Removed Fixes #2969: Fix Uncategorized warning message New editor: ALT+ BACKSPACE deletes next word (OSX only). See #3098 New editor: ALT+ UP/DOWN move current line only if "editor.advanced" (hidden pref) is true. Fixes #3101 New editor: mark occurrences enable when "editor.advanced" (hidden pref) is true. Fixes #3102 ... Conflicts: .gitignore build/build.xml hardware/esp8266com/esp8266/libraries/ESP8266WiFi/keywords.txt hardware/esp8266com/esp8266/libraries/ESP8266WiFi/library.properties hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/ESP8266WiFi.h libraries/WiFi/README.adoc libraries/WiFi/src/WiFi.cpp libraries/WiFi/src/WiFiClient.cpp libraries/WiFi/src/WiFiClient.h libraries/WiFi/src/WiFiServer.cpp libraries/WiFi/src/WiFiUdp.cpp
This commit is contained in:
@ -16,8 +16,6 @@ yun.pid.2=0x0041
|
||||
yun.vid.3=0x2A03
|
||||
yun.pid.3=0x8041
|
||||
|
||||
yun.vid.0x2A03.warning=Uncertified
|
||||
|
||||
yun.upload.tool=avrdude
|
||||
yun.upload.protocol=avr109
|
||||
yun.upload.maximum_size=28672
|
||||
@ -56,8 +54,6 @@ uno.pid.1=0x0001
|
||||
uno.vid.2=0x2A03
|
||||
uno.pid.2=0x0043
|
||||
|
||||
uno.vid.0x2A03.warning=Uncertified
|
||||
|
||||
uno.upload.tool=avrdude
|
||||
uno.upload.protocol=arduino
|
||||
uno.upload.maximum_size=32256
|
||||
@ -182,8 +178,6 @@ mega.pid.2=0x0010
|
||||
mega.vid.3=0x2A03
|
||||
mega.pid.3=0x0042
|
||||
|
||||
mega.vid.0x2A03.warning=Uncertified
|
||||
|
||||
mega.upload.tool=avrdude
|
||||
mega.upload.maximum_data_size=8192
|
||||
|
||||
@ -241,8 +235,6 @@ megaADK.pid.2=0x003f
|
||||
megaADK.vid.3=0x2A03
|
||||
megaADK.pid.3=0x0044
|
||||
|
||||
megaADK.vid.0x2A03.warning=Uncertified
|
||||
|
||||
megaADK.upload.tool=avrdude
|
||||
megaADK.upload.protocol=wiring
|
||||
megaADK.upload.maximum_size=253952
|
||||
@ -275,8 +267,6 @@ leonardo.pid.2=0x0036
|
||||
leonardo.vid.3=0x2A03
|
||||
leonardo.pid.3=0x8036
|
||||
|
||||
leonardo.vid.0x2A03.warning=Uncertified
|
||||
|
||||
leonardo.upload.tool=avrdude
|
||||
leonardo.upload.protocol=avr109
|
||||
leonardo.upload.maximum_size=28672
|
||||
@ -316,8 +306,6 @@ micro.pid.2=0x0037
|
||||
micro.vid.3=0x2A03
|
||||
micro.pid.3=0x8037
|
||||
|
||||
micro.vid.0x2A03.warning=Uncertified
|
||||
|
||||
micro.upload.tool=avrdude
|
||||
micro.upload.protocol=avr109
|
||||
micro.upload.maximum_size=28672
|
||||
@ -357,8 +345,6 @@ esplora.pid.2=0x003C
|
||||
esplora.vid.3=0x2A03
|
||||
esplora.pid.3=0x803C
|
||||
|
||||
esplora.vid.0x2A03.warning=Uncertified
|
||||
|
||||
esplora.upload.tool=avrdude
|
||||
esplora.upload.protocol=avr109
|
||||
esplora.upload.maximum_size=28672
|
||||
@ -739,8 +725,6 @@ robotControl.pid.2=0x0038
|
||||
robotControl.vid.3=0x2A03
|
||||
robotControl.pid.3=0x8038
|
||||
|
||||
robotControl.vid.0x2A03.warning=Uncertified
|
||||
|
||||
robotControl.upload.tool=avrdude
|
||||
robotControl.upload.protocol=avr109
|
||||
robotControl.upload.maximum_size=28672
|
||||
@ -780,8 +764,6 @@ robotMotor.pid.2=0x0039
|
||||
robotMotor.vid.3=0x2A03
|
||||
robotMotor.pid.3=0x8039
|
||||
|
||||
robotMotor.vid.0x2A03.warning=Uncertified
|
||||
|
||||
robotMotor.upload.tool=avrdude
|
||||
robotMotor.upload.protocol=avr109
|
||||
robotMotor.upload.maximum_size=28672
|
||||
@ -809,3 +791,27 @@ robotMotor.build.core=arduino
|
||||
robotMotor.build.variant=robot_motor
|
||||
robotMotor.build.extra_flags={build.usb_flags}
|
||||
|
||||
##############################################################
|
||||
|
||||
gemma.vid.0=0x2341
|
||||
gemma.pid.0=0x0c9f
|
||||
|
||||
gemma.name=Arduino Gemma
|
||||
|
||||
gemma.bootloader.low_fuses=0xF1
|
||||
gemma.bootloader.high_fuses=0xD5
|
||||
gemma.bootloader.extended_fuses=0xFE
|
||||
gemma.bootloader.tool=avrdude
|
||||
gemma.bootloader.lock_bits=
|
||||
gemma.bootloader.unlock_bits=
|
||||
gemma.bootloader.file=gemma/gemma_v1.hex
|
||||
|
||||
gemma.build.mcu=attiny85
|
||||
gemma.build.f_cpu=8000000L
|
||||
gemma.build.core=arduino
|
||||
gemma.build.variant=gemma
|
||||
gemma.build.board=AVR_GEMMA
|
||||
|
||||
gemma.upload.tool=avrdude
|
||||
gemma.upload.maximum_size=5310
|
||||
|
||||
|
14391
hardware/arduino/avr/bootloaders/gemma/avrdude.conf
Normal file
14391
hardware/arduino/avr/bootloaders/gemma/avrdude.conf
Normal file
File diff suppressed because it is too large
Load Diff
182
hardware/arduino/avr/bootloaders/gemma/gemma_v1.hex
Normal file
182
hardware/arduino/avr/bootloaders/gemma/gemma_v1.hex
Normal file
@ -0,0 +1,182 @@
|
||||
:100000005FCA5FCA5FCA5FCA5FCA5FCA5FCA5FCAA8
|
||||
:1014C00033C05FC08BC05DC05CC05BC05AC059C038
|
||||
:1014D00058C057C056C055C054C053C052C009026E
|
||||
:1014E0001200010100803209040000000000000029
|
||||
:1014F00012011001FF00000841239F0C00010102AE
|
||||
:1015000000010C03470065006D006D0061001603CB
|
||||
:10151000410072006400750069006E006F002E00CB
|
||||
:10152000630063000403090411241FBECFE5D2E069
|
||||
:10153000DEBFCDBF84B7877F84BF88E10FB6F89444
|
||||
:1015400081BD11BC0FBE91E080E80FB6F89486BD56
|
||||
:1015500096BD0FBE0AEA0F9310E0A0E6B0E0EEEDF4
|
||||
:10156000FFE102C005900D92A236B107D9F711E054
|
||||
:10157000A2E6B0E001C01D92A832B107E1F7EDD3B9
|
||||
:101580002CC59ECFA82FB92F80E090E041E050EA13
|
||||
:10159000609530E009C02D9182279795879510F0CE
|
||||
:1015A00084279527305EC8F36F5FA8F30895EADFBC
|
||||
:1015B0008D939D930895A6E088279927AA9569F0B1
|
||||
:1015C0000197E1F3B399FCCFB39BFECF81E099275C
|
||||
:1015D000A6B3019611F0A871D9F70895CF93CFB7AC
|
||||
:1015E000CF93C0915F02CA3A21F0CF91CFBFCF9184
|
||||
:1015F00065CFCC27C395B39BE9F7B39B0BC0B39BD7
|
||||
:1016000009C0B39B07C0B39B05C0B39B03C0B39B8A
|
||||
:1016100001C0D3C00F92DF93C0910B01DD27CE5ED6
|
||||
:10162000DE4F012EB39B03C0DF910F90E6CF2F93C7
|
||||
:101630000F931F934F932FEF4F6F06B303FB20F9C8
|
||||
:101640005F933F9350E03BE065C016B301265029FD
|
||||
:1016500053FDC89556B3012703FB25F92F7306B335
|
||||
:10166000B1F05027102713FB26F906B22230F0F014
|
||||
:1016700000C016B3012703FB27F90126502906B243
|
||||
:101680002430E8F54F77206816B30000F6CF5027D6
|
||||
:101690004F7D206206B2102F000000C006B3002666
|
||||
:1016A0005029102713FB26F906B2E2CF4F7B06B371
|
||||
:1016B000206400C0DACF01265029187106B269F102
|
||||
:1016C0004E7F2160012F16B328C0002650294D7F80
|
||||
:1016D00006B22260102F29C0012650294B7F06B286
|
||||
:1016E0002460012F2DC016B301265029477F2860A2
|
||||
:1016F000000006B22EC04F7E06B3206130C04227E4
|
||||
:1017000006B3499300265029102706B24FEF13FB6A
|
||||
:1017100020F9297F16B379F2187159F10126502961
|
||||
:1017200006B2012703FB21F9237F06B371F20026DD
|
||||
:1017300050293150D0F006B2102713FB22F9277E32
|
||||
:1017400016B351F201265029012703FB06B223F9F3
|
||||
:101750002F7C49F2000006B3102713FB24F9002662
|
||||
:10176000502906B22F7939F270CF10E21ABF002744
|
||||
:1017700017C03B503195C31BD04010E21ABF0881FF
|
||||
:10178000033CF9F00B34E9F0209109011981110FA4
|
||||
:101790001213EDCF093651F10D3211F0013E39F738
|
||||
:1017A000009310013F915F914F911F910F912F91E5
|
||||
:1017B000DF910F90CAB7C5FD1DCFCF91CFBFCF919D
|
||||
:1017C000189520911001222369F310910E01112325
|
||||
:1017D00021F5343022F130930E0120930A0110914B
|
||||
:1017E0000B013BE0311B30930B0119C000910E013E
|
||||
:1017F00001309CF40AE53091610034FD11C0009382
|
||||
:101800006100CEEFD0E010C0052710E000C021C07D
|
||||
:10181000052710E0C89508BB14C03AE501C032EDB9
|
||||
:10182000032EC0E0D0E032E017B31861C39A08B3CA
|
||||
:1018300017BB58E120E84FEF20FF052708BB27958D
|
||||
:1018400017951C3F28F700004552B0F720FF0527E9
|
||||
:10185000279508BB17951C3FB8F629913A9561F773
|
||||
:10186000077E10910F01110F08BBC250D04011F03C
|
||||
:101870001093090110E21ABF086017B3177E402FBA
|
||||
:10188000477E54E05A95F1F708BB17BB48BB8ACF97
|
||||
:101890002091F9003091FA002D3B3441B8F421E059
|
||||
:1018A0002093F600F894E091F900F091FA000C0111
|
||||
:1018B00020935700E895112478948091F900909135
|
||||
:1018C000FA0002969093FA008093F90008958091AF
|
||||
:1018D000F600882309F43DC08091F9009091FA0048
|
||||
:1018E000813C944108F035C0F8948091F9009091C2
|
||||
:1018F000FA008238944118F1809166009091670057
|
||||
:101900008F559A409F70906CEEEBF4E121E00C0152
|
||||
:1019100020935700E895112480916E0090916F00FC
|
||||
:101920008C559A409F70906CECEBF4E10C01209385
|
||||
:101930005700E8951124789481E080936400E09149
|
||||
:10194000F900F091FA00329785E080935700E8950E
|
||||
:1019500078941092F6000895FF920F931F93CF93FF
|
||||
:10196000DF9380910E01835087FD5AC190910B0146
|
||||
:10197000ACE0B0E0A91BB109AE5EBE4F31E03093E0
|
||||
:10198000620090910A019D3209F00AC1883009F085
|
||||
:1019900045C183EC8093FE008AE58093610010923C
|
||||
:1019A000FD008C91807609F47DC01092F3001092B6
|
||||
:1019B000F5001092F40011962C911197213009F442
|
||||
:1019C00069C0263021F481E08093FC0067C0273095
|
||||
:1019D00009F040C03093FC0089EE90E090930D0137
|
||||
:1019E00080930C0113969C9113979093EB001092A7
|
||||
:1019F000EC0012968C911297803379F491114CC0BF
|
||||
:101A00001496EC911497F0E0EE0FFF1F81E28093A3
|
||||
:101A10005700E491E093EC003FC08C3A81F4903899
|
||||
:101A2000D9F514968C911497811136C015968C9126
|
||||
:101A30001597811131C081E08093E8002DC08C346E
|
||||
:101A400059F515968C911597811126C081E08093E8
|
||||
:101A5000E70022C0283009F4B6CF14968D919C91EE
|
||||
:101A600015979093FA008093F90016968C9116972B
|
||||
:101A70008093F10087EF820F843080F48FE788BD78
|
||||
:101A80003093FB002093F2002A3051F081E08093E4
|
||||
:101A9000FC0006C021E077C024E075C020E073C0E0
|
||||
:101AA0002FEF68C012969C91129710920701119621
|
||||
:101AB0008C911197811106C01092080187E091E086
|
||||
:101AC00022E052C0853019F490930F013FC0863058
|
||||
:101AD000B9F513968C911397813019F480EF94E146
|
||||
:101AE00004C0823041F48EED94E190930D01809317
|
||||
:101AF0000C0122E121C08330F1F4911108C084E28D
|
||||
:101B000095E190930D0180930C0124E015C0913074
|
||||
:101B100041F48EE095E190930D0180930C0126E154
|
||||
:101B20000BC0923041F482E095E190930D018093D7
|
||||
:101B30000C012CE001C020E080E48093FD0018C07F
|
||||
:101B4000883079F0893031F49093110187E091E089
|
||||
:101B500020E00AC021E08A3009F020E087E091E02F
|
||||
:101B600003C081E191E021E090930D0180930C018D
|
||||
:101B70002F3F49F48C9187FF02C016962C9180E884
|
||||
:101B80008093FD000AC017968C911797811105C0AC
|
||||
:101B900016968C91821708F4282F209360003EC07F
|
||||
:101BA0009091FD0097FF3AC09091F100182F98177F
|
||||
:101BB00008F4192F092F011B0093F1001092FC006B
|
||||
:101BC0008091F2008A3029F0011128C01092600043
|
||||
:101BD00025C0FA2ECA2FDB2F8C2F8F198117A0F763
|
||||
:101BE0008091F9009091FA008034910590F421E001
|
||||
:101BF00020936500FC01EE0FFF1FEA59FF4F28817B
|
||||
:101C000039813183208302969093FA008093F90002
|
||||
:101C100003C0888199813CDE2296DECF10920E01AE
|
||||
:101C20008091610084FF7BC0809160008F3F09F448
|
||||
:101C300076C0182F893008F018E0811B809360006F
|
||||
:101C40008091FE0098E889278093FE00112309F413
|
||||
:101C50005AC08091FD0087FF38C08091F100811744
|
||||
:101C600008F4182F811B8093F1003091F200E0916D
|
||||
:101C7000F900F091FA0020E0AFEFB0E0211700F595
|
||||
:101C80003B3009F4FFCF3930D9F7E034F10560F487
|
||||
:101C9000EF01CC0FDD1FCA59DF4F888199818D93E9
|
||||
:101CA0009D932E5F3296EACFEC3B84E1F80710F06B
|
||||
:101CB0008FEF01C084918C9311962F5F3196DECF08
|
||||
:101CC000F093FA00E093F9001EC0E0910C01F0914E
|
||||
:101CD0000D0186FF0BC08FEF90E0DC0124912D9366
|
||||
:101CE0003196212F280F2A13F9CF09C08FEF90E0EA
|
||||
:101CF000DC0121912D93212F280F2A13FACFF09385
|
||||
:101D00000D01E0930C01612F8FEF90E050DC1C5F20
|
||||
:101D10001C3019F08FEF809360001093610084E114
|
||||
:101D200096B3987131F48150D9F710920F01109247
|
||||
:101D30000901C1E08111C0E0809163008C1739F086
|
||||
:101D4000C11103C0F89401D17894C0936300DF916E
|
||||
:101D5000CF911F910F91FF900895C1B7B99A83E277
|
||||
:101D60008ABD81E083BFAC9A8BB780628BBFBB9A80
|
||||
:101D70002FE132E18AE0215030408040E1F700C09D
|
||||
:101D80000000BB987894E8DD8091E800882321F179
|
||||
:101D900082E090E09093F8008093F70013C0CF01A9
|
||||
:101DA0008F739927892B21F483E080935700E8955E
|
||||
:101DB000D3DD8091F7009091F80002969093F8009F
|
||||
:101DC0008093F700E091F700F091F800E03C94E197
|
||||
:101DD000F90728F31092E8008091E700882329F0A2
|
||||
:101DE000BBDD75DD1092E700B7DD809162008823CE
|
||||
:101DF00041F08091FC00811104C08091FB008111B1
|
||||
:101E0000C2CF80916200882371F08091E600811139
|
||||
:101E10000AC088B5805F88BD88B5811104C08AB5C5
|
||||
:101E200090E189278ABD8091E6008F5F8093E6006C
|
||||
:101E30008EEC90E00197F1F78091F4009091F5001D
|
||||
:101E400001969093F5008093F4002091F3000097A1
|
||||
:101E500011F42F5F00C02093F30030916200311124
|
||||
:101E600005C081323EE4930708F05AC03091FC006F
|
||||
:101E7000332321F08131974208F052C080916200F3
|
||||
:101E8000882309F480CF8091FB0081117CCF23301F
|
||||
:101E900008F479CF45C080916400811149C08CEB72
|
||||
:101EA00094E19093FA008093F90081E08093F6002A
|
||||
:101EB0000EDD3EC0DF01AA0FBB1FAA59BF4F8D9197
|
||||
:101EC0009C919F012B7F232B31F4E054FB4E859195
|
||||
:101ED0009491805A954FDCDCE091F900F091FA0082
|
||||
:101EE000E034F10538F3F3DC10925F0217BA13BE49
|
||||
:101EF0001ABC03C081B78F5F81BF81B78C17D0F345
|
||||
:101F000003C081B7815081BF81B7C817D0F391E07A
|
||||
:101F100080E80FB6F89486BD96BD0FBED0CA13C038
|
||||
:101F200015BA1BBEF894809165008111B4CFDCCF47
|
||||
:101F3000E0E0F0E083E080935700E8951092FA002B
|
||||
:101F40001092F900C9CF80E090E0DF92EF92FF920B
|
||||
:101F50000F931F93CF93DF9390E080E80FB6F89430
|
||||
:101F600086BD96BD0FBE08E010E0F12C80E8E82E9B
|
||||
:101F7000DF2CDE0CD1BE1FDBEC01C43389E0D807B7
|
||||
:101F80000CF4FD2CE694015011090115110581F79F
|
||||
:101F90001F2D8FEF8F0D81BF21B730E0812F90E093
|
||||
:101FA00001968217930784F006DB8453994097FFCC
|
||||
:101FB00003C09195819591098C179D0714F4F1B692
|
||||
:101FC000EC0181B78F5FE7CFF1BEDF91CF911F9119
|
||||
:0E1FD0000F91FF90EF90DF900895F894FFCFEF
|
||||
:021FDE00FF5AA8
|
||||
:04000003000014C025
|
||||
:00000001FF
|
@ -34,12 +34,17 @@
|
||||
// location from which to read.
|
||||
// NOTE: a "power of 2" buffer size is reccomended to dramatically
|
||||
// optimize all the modulo operations for ring buffers.
|
||||
#if !(defined(SERIAL_TX_BUFFER_SIZE) && defined(SERIAL_RX_BUFFER_SIZE))
|
||||
#if !defined(SERIAL_TX_BUFFER_SIZE)
|
||||
#if (RAMEND < 1000)
|
||||
#define SERIAL_TX_BUFFER_SIZE 16
|
||||
#define SERIAL_RX_BUFFER_SIZE 16
|
||||
#else
|
||||
#define SERIAL_TX_BUFFER_SIZE 64
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(SERIAL_RX_BUFFER_SIZE)
|
||||
#if (RAMEND < 1000)
|
||||
#define SERIAL_RX_BUFFER_SIZE 16
|
||||
#else
|
||||
#define SERIAL_RX_BUFFER_SIZE 64
|
||||
#endif
|
||||
#endif
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
Created July 2011
|
||||
parsing functions based on TextFinder library by Michael Margolis
|
||||
|
||||
findMulti/findUntil routines written by Jim Leonard/Xuth
|
||||
*/
|
||||
|
||||
#include "Arduino.h"
|
||||
@ -75,7 +77,7 @@ void Stream::setTimeout(unsigned long timeout) // sets the maximum number of mi
|
||||
// find returns true if the target string is found
|
||||
bool Stream::find(char *target)
|
||||
{
|
||||
return findUntil(target, (char*)"");
|
||||
return findUntil(target, strlen(target), NULL, 0);
|
||||
}
|
||||
|
||||
// reads data from the stream until the target string of given length is found
|
||||
@ -96,32 +98,13 @@ bool Stream::findUntil(char *target, char *terminator)
|
||||
// returns true if target string is found, false if terminated or timed out
|
||||
bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t termLen)
|
||||
{
|
||||
size_t index = 0; // maximum target string length is 64k bytes!
|
||||
size_t termIndex = 0;
|
||||
int c;
|
||||
|
||||
if( *target == 0)
|
||||
return true; // return true if target is a null string
|
||||
while( (c = timedRead()) > 0){
|
||||
|
||||
if(c != target[index])
|
||||
index = 0; // reset index if any char does not match
|
||||
|
||||
if( c == target[index]){
|
||||
//////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);
|
||||
if(++index >= targetLen){ // return true if all chars in the target match
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(termLen > 0 && c == terminator[termIndex]){
|
||||
if(++termIndex >= termLen)
|
||||
return false; // return false if terminate string found before target string
|
||||
}
|
||||
else
|
||||
termIndex = 0;
|
||||
if (terminator == NULL) {
|
||||
MultiTarget t[1] = {{target, targetLen, 0}};
|
||||
return findMulti(t, 1) == 0 ? true : false;
|
||||
} else {
|
||||
MultiTarget t[2] = {{target, targetLen, 0}, {terminator, termLen, 0}};
|
||||
return findMulti(t, 2) == 0 ? true : false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -137,7 +120,7 @@ long Stream::parseInt()
|
||||
// this allows format characters (typically commas) in values to be ignored
|
||||
long Stream::parseInt(char skipChar)
|
||||
{
|
||||
boolean isNegative = false;
|
||||
bool isNegative = false;
|
||||
long value = 0;
|
||||
int c;
|
||||
|
||||
@ -173,10 +156,10 @@ float Stream::parseFloat()
|
||||
// as above but the given skipChar is ignored
|
||||
// this allows format characters (typically commas) in values to be ignored
|
||||
float Stream::parseFloat(char skipChar){
|
||||
boolean isNegative = false;
|
||||
boolean isFraction = false;
|
||||
bool isNegative = false;
|
||||
bool isFraction = false;
|
||||
long value = 0;
|
||||
int c;
|
||||
char c;
|
||||
float fraction = 1.0;
|
||||
|
||||
c = peekNextDigit();
|
||||
@ -268,3 +251,67 @@ String Stream::readStringUntil(char terminator)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Stream::findMulti( struct Stream::MultiTarget *targets, int tCount) {
|
||||
// any zero length target string automatically matches and would make
|
||||
// a mess of the rest of the algorithm.
|
||||
for (struct MultiTarget *t = targets; t < targets+tCount; ++t) {
|
||||
if (t->len <= 0)
|
||||
return t - targets;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
int c = timedRead();
|
||||
if (c < 0)
|
||||
return -1;
|
||||
|
||||
for (struct MultiTarget *t = targets; t < targets+tCount; ++t) {
|
||||
// the simple case is if we match, deal with that first.
|
||||
if (c == t->str[t->index]) {
|
||||
if (++t->index == t->len)
|
||||
return t - targets;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
// if not we need to walk back and see if we could have matched further
|
||||
// down the stream (ie '1112' doesn't match the first position in '11112'
|
||||
// but it will match the second position so we can't just reset the current
|
||||
// index to 0 when we find a mismatch.
|
||||
if (t->index == 0)
|
||||
continue;
|
||||
|
||||
int origIndex = t->index;
|
||||
do {
|
||||
--t->index;
|
||||
// first check if current char works against the new current index
|
||||
if (c != t->str[t->index])
|
||||
continue;
|
||||
|
||||
// if it's the only char then we're good, nothing more to check
|
||||
if (t->index == 0) {
|
||||
t->index++;
|
||||
break;
|
||||
}
|
||||
|
||||
// otherwise we need to check the rest of the found string
|
||||
int diff = origIndex - t->index;
|
||||
size_t i;
|
||||
for (i = 0; i < t->index; ++i) {
|
||||
if (t->str[i] != t->str[i + diff])
|
||||
break;
|
||||
}
|
||||
|
||||
// if we successfully got through the previous loop then our current
|
||||
// index is good.
|
||||
if (i == t->index) {
|
||||
t->index++;
|
||||
break;
|
||||
}
|
||||
|
||||
// otherwise we just try the next index
|
||||
} while (t->index);
|
||||
}
|
||||
}
|
||||
// unreachable
|
||||
return -1;
|
||||
}
|
||||
|
@ -97,6 +97,17 @@ class Stream : public Print
|
||||
// this allows format characters (typically commas) in values to be ignored
|
||||
|
||||
float parseFloat(char skipChar); // as above but the given skipChar is ignored
|
||||
|
||||
struct MultiTarget {
|
||||
const char *str; // string you're searching for
|
||||
size_t len; // length of string you're searching for
|
||||
size_t index; // index used by the search routine.
|
||||
};
|
||||
|
||||
// This allows you to search for an arbitrary number of strings.
|
||||
// Returns index of the target that is found first or -1 if timeout occurs.
|
||||
int findMulti(struct MultiTarget *targets, int tCount);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -30,6 +30,8 @@ Version Modified By Date Comments
|
||||
0006 D Mellis 09/12/29 Replaced objects with functions
|
||||
0007 M Sproul 10/08/29 Changed #ifdefs from cpu to register
|
||||
0008 S Kanemoto 12/06/22 Fixed for Leonardo by @maris_HY
|
||||
0009 J Reucker 15/04/10 Issue #292 Fixed problems with ATmega8 (thanks to Pete62)
|
||||
0010 jipp 15/04/13 added additional define check #2923
|
||||
*************************************************/
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
@ -151,7 +153,7 @@ static int8_t toneBegin(uint8_t _pin)
|
||||
// whereas 16 bit timers are set to either ck/1 or ck/64 prescalar
|
||||
switch (_timer)
|
||||
{
|
||||
#if defined(TCCR0A) && defined(TCCR0B)
|
||||
#if defined(TCCR0A) && defined(TCCR0B) && defined(WGM01)
|
||||
case 0:
|
||||
// 8 bit timer
|
||||
TCCR0A = 0;
|
||||
@ -296,13 +298,13 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
|
||||
#if defined(TCCR0B)
|
||||
if (_timer == 0)
|
||||
{
|
||||
TCCR0B = prescalarbits;
|
||||
TCCR0B = (TCCR0B & 0b11111000) | prescalarbits;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if defined(TCCR2B)
|
||||
{
|
||||
TCCR2B = prescalarbits;
|
||||
TCCR2B = (TCCR2B & 0b11111000) | prescalarbits;
|
||||
}
|
||||
#else
|
||||
{
|
||||
@ -389,7 +391,7 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(TIMSK3)
|
||||
#if defined(OCR3A) && defined(TIMSK3) && defined(OCIE3A)
|
||||
case 3:
|
||||
OCR3A = ocr;
|
||||
timer3_toggle_count = toggle_count;
|
||||
@ -397,7 +399,7 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(TIMSK4)
|
||||
#if defined(OCR4A) && defined(TIMSK4) && defined(OCIE4A)
|
||||
case 4:
|
||||
OCR4A = ocr;
|
||||
timer4_toggle_count = toggle_count;
|
||||
@ -454,21 +456,21 @@ void disableTimer(uint8_t _timer)
|
||||
#endif
|
||||
break;
|
||||
|
||||
#if defined(TIMSK3)
|
||||
#if defined(TIMSK3) && defined(OCIE3A)
|
||||
case 3:
|
||||
TIMSK3 = 0;
|
||||
bitWrite(TIMSK3, OCIE3A, 0);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(TIMSK4)
|
||||
#if defined(TIMSK4) && defined(OCIE4A)
|
||||
case 4:
|
||||
TIMSK4 = 0;
|
||||
bitWrite(TIMSK4, OCIE4A, 0);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(TIMSK5)
|
||||
#if defined(TIMSK5) && defined(OCIE5A)
|
||||
case 5:
|
||||
TIMSK5 = 0;
|
||||
bitWrite(TIMSK5, OCIE5A, 0);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
@ -59,11 +59,16 @@ extern USBDevice_ USBDevice;
|
||||
|
||||
struct ring_buffer;
|
||||
|
||||
#ifndef SERIAL_BUFFER_SIZE
|
||||
#if (RAMEND < 1000)
|
||||
#define SERIAL_BUFFER_SIZE 16
|
||||
#else
|
||||
#define SERIAL_BUFFER_SIZE 64
|
||||
#endif
|
||||
#endif
|
||||
#if (SERIAL_BUFFER_SIZE>256)
|
||||
#error Please lower the CDC Buffer size
|
||||
#endif
|
||||
|
||||
class Serial_ : public Stream
|
||||
{
|
||||
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
EEPROM.cpp - EEPROM library
|
||||
Copyright (c) 2006 David A. Mellis. All right reserved.
|
||||
|
||||
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
* Includes
|
||||
******************************************************************************/
|
||||
|
||||
#include <avr/eeprom.h>
|
||||
#include "Arduino.h"
|
||||
#include "EEPROM.h"
|
||||
|
||||
/******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* Constructors
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
* User API
|
||||
******************************************************************************/
|
||||
|
||||
uint8_t EEPROMClass::read(int address)
|
||||
{
|
||||
return eeprom_read_byte((unsigned char *) address);
|
||||
}
|
||||
|
||||
void EEPROMClass::write(int address, uint8_t value)
|
||||
{
|
||||
eeprom_write_byte((unsigned char *) address, value);
|
||||
}
|
||||
|
||||
EEPROMClass EEPROM;
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
EEPROM.h - EEPROM library
|
||||
Copyright (c) 2006 David A. Mellis. All right reserved.
|
||||
Original Copyright (c) 2006 David A. Mellis. All right reserved.
|
||||
New version by Christopher Andrews 2015.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
@ -21,15 +22,125 @@
|
||||
#define EEPROM_h
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include <avr/io.h>
|
||||
|
||||
class EEPROMClass
|
||||
{
|
||||
public:
|
||||
uint8_t read(int);
|
||||
void write(int, uint8_t);
|
||||
/***
|
||||
EERef class.
|
||||
|
||||
This object references an EEPROM cell.
|
||||
Its purpose is to mimic a typical byte of RAM, however its storage is the EEPROM.
|
||||
This class has an overhead of two bytes, similar to storing a pointer to an EEPROM cell.
|
||||
***/
|
||||
|
||||
struct EERef{
|
||||
|
||||
EERef( const int index )
|
||||
: index( index ) {}
|
||||
|
||||
//Access/read members.
|
||||
uint8_t operator*() const { return eeprom_read_byte( (uint8_t*) index ); }
|
||||
operator const uint8_t() const { return **this; }
|
||||
|
||||
//Assignment/write members.
|
||||
EERef &operator=( const EERef &ref ) { return *this = *ref; }
|
||||
EERef &operator=( uint8_t in ) { return eeprom_write_byte( (uint8_t*) index, in ), *this; }
|
||||
EERef &operator +=( uint8_t in ) { return *this = **this + in; }
|
||||
EERef &operator -=( uint8_t in ) { return *this = **this - in; }
|
||||
EERef &operator *=( uint8_t in ) { return *this = **this * in; }
|
||||
EERef &operator /=( uint8_t in ) { return *this = **this / in; }
|
||||
EERef &operator ^=( uint8_t in ) { return *this = **this ^ in; }
|
||||
EERef &operator %=( uint8_t in ) { return *this = **this % in; }
|
||||
EERef &operator &=( uint8_t in ) { return *this = **this & in; }
|
||||
EERef &operator |=( uint8_t in ) { return *this = **this | in; }
|
||||
EERef &operator <<=( uint8_t in ) { return *this = **this << in; }
|
||||
EERef &operator >>=( uint8_t in ) { return *this = **this >> in; }
|
||||
|
||||
EERef &update( uint8_t in ) { return in != *this ? *this = in : *this; }
|
||||
|
||||
/** Prefix increment/decrement **/
|
||||
EERef& operator++() { return *this += 1; }
|
||||
EERef& operator--() { return *this -= 1; }
|
||||
|
||||
/** Postfix increment/decrement **/
|
||||
uint8_t operator++ (int){
|
||||
uint8_t ret = **this;
|
||||
return ++(*this), ret;
|
||||
}
|
||||
|
||||
uint8_t operator-- (int){
|
||||
uint8_t ret = **this;
|
||||
return --(*this), ret;
|
||||
}
|
||||
|
||||
int index; //Index of current EEPROM cell.
|
||||
};
|
||||
|
||||
extern EEPROMClass EEPROM;
|
||||
/***
|
||||
EEPtr class.
|
||||
|
||||
This object is a bidirectional pointer to EEPROM cells represented by EERef objects.
|
||||
Just like a normal pointer type, this can be dereferenced and repositioned using
|
||||
increment/decrement operators.
|
||||
***/
|
||||
|
||||
#endif
|
||||
struct EEPtr{
|
||||
|
||||
EEPtr( const int index )
|
||||
: index( index ) {}
|
||||
|
||||
operator const int() const { return index; }
|
||||
EEPtr &operator=( int in ) { return index = in, *this; }
|
||||
|
||||
//Iterator functionality.
|
||||
bool operator!=( const EEPtr &ptr ) { return index != ptr.index; }
|
||||
EERef operator*() { return index; }
|
||||
|
||||
/** Prefix & Postfix increment/decrement **/
|
||||
EEPtr& operator++() { return ++index, *this; }
|
||||
EEPtr& operator--() { return --index, *this; }
|
||||
EEPtr operator++ (int) { return index++; }
|
||||
EEPtr operator-- (int) { return index--; }
|
||||
|
||||
int index; //Index of current EEPROM cell.
|
||||
};
|
||||
|
||||
/***
|
||||
EEPROMClass class.
|
||||
|
||||
This object represents the entire EEPROM space.
|
||||
It wraps the functionality of EEPtr and EERef into a basic interface.
|
||||
This class is also 100% backwards compatible with earlier Arduino core releases.
|
||||
***/
|
||||
|
||||
struct EEPROMClass{
|
||||
|
||||
//Basic user access methods.
|
||||
EERef operator[]( const int idx ) { return idx; }
|
||||
uint8_t read( int idx ) { return EERef( idx ); }
|
||||
void write( int idx, uint8_t val ) { (EERef( idx )) = val; }
|
||||
void update( int idx, uint8_t val ) { EERef( idx ).update( val ); }
|
||||
|
||||
//STL and C++11 iteration capability.
|
||||
EEPtr begin() { return 0x00; }
|
||||
EEPtr end() { return length(); } //Standards requires this to be the item after the last valid entry. The returned pointer is invalid.
|
||||
uint16_t length() { return E2END + 1; }
|
||||
|
||||
//Functionality to 'get' and 'put' objects to and from EEPROM.
|
||||
template< typename T > T &get( int idx, T &t ){
|
||||
EEPtr e = idx;
|
||||
uint8_t *ptr = (uint8_t*) &t;
|
||||
for( int count = sizeof(T) ; count ; --count, ++e ) *ptr++ = *e;
|
||||
return t;
|
||||
}
|
||||
|
||||
template< typename T > const T &put( int idx, const T &t ){
|
||||
EEPtr e = idx;
|
||||
const uint8_t *ptr = (const uint8_t*) &t;
|
||||
for( int count = sizeof(T) ; count ; --count, ++e ) (*e).update( *ptr++ );
|
||||
return t;
|
||||
}
|
||||
};
|
||||
|
||||
static EEPROMClass EEPROM;
|
||||
#endif
|
139
hardware/arduino/avr/libraries/EEPROM/README.md
Normal file
139
hardware/arduino/avr/libraries/EEPROM/README.md
Normal file
@ -0,0 +1,139 @@
|
||||
## **EEPROM Library V2.0** for Arduino
|
||||
|
||||
**Written by:** _Christopher Andrews_.
|
||||
|
||||
### **What is the EEPROM library.**
|
||||
|
||||
Th EEPROM library provides an easy to use interface to interact with the internal non-volatile storage found in AVR based Arduino boards. This library will work on many AVR devices like ATtiny and ATmega chips.
|
||||
|
||||
### **How to use it**
|
||||
The EEPROM library is included in your IDE download. To add its functionality to your sketch you'll need to reference the library header file. You do this by adding an include directive to the top of your sketch.
|
||||
|
||||
```Arduino
|
||||
#include <EEPROM.h>
|
||||
|
||||
void setup(){
|
||||
|
||||
}
|
||||
|
||||
void loop(){
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
The library provides a global variable named `EEPROM`, you use this variable to access the library functions. The methods provided in the EEPROM class are listed below.
|
||||
|
||||
You can view all the examples [here](examples/).
|
||||
|
||||
### **Library functions**
|
||||
|
||||
#### **`EEPROM.read( address )`** [[_example_]](examples/eeprom_read/eeprom_read.ino)
|
||||
|
||||
This function allows you to read a single byte of data from the eeprom.
|
||||
Its only parameter is an `int` which should be set to the address you wish to read.
|
||||
|
||||
The function returns an `unsigned char` containing the value read.
|
||||
|
||||
#### **`EEPROM.write( address, value )`** [[_example_]](examples/eeprom_write/eeprom_write.ino)
|
||||
|
||||
The `write()` method allows you to write a single byte of data to the EEPROM.
|
||||
Two parameters are needed. The first is an `int` containing the address that is to be written, and the second is a the data to be written (`unsigned char`).
|
||||
|
||||
This function does not return any value.
|
||||
|
||||
#### **`EEPROM.update( address, value )`** [[_example_]](examples/eeprom_update/eeprom_update.ino)
|
||||
|
||||
This function is similar to `EEPROM.write()` however this method will only write data if the cell contents pointed to by `address` is different to `value`. This method can help prevent unnecessary wear on the EEPROM cells.
|
||||
|
||||
This function does not return any value.
|
||||
|
||||
#### **`EEPROM.get( address, object )`** [[_example_]](examples/eeprom_get/eeprom_get.ino)
|
||||
|
||||
This function will retrieve any object from the EEPROM.
|
||||
Two parameters are needed to call this function. The first is an `int` containing the address that is to be written, and the second is the object you would like to read.
|
||||
|
||||
This function returns a reference to the `object` passed in. It does not need to be used and is only returned for conveience.
|
||||
|
||||
#### **`EEPROM.put( address, object )`** [[_example_]](examples/eeprom_put/eeprom_put.ino)
|
||||
|
||||
This function will write any object to the EEPROM.
|
||||
Two parameters are needed to call this function. The first is an `int` containing the address that is to be written, and the second is the object you would like to write.
|
||||
|
||||
This function uses the _update_ method to write its data, and therefore only rewrites changed cells.
|
||||
|
||||
This function returns a reference to the `object` passed in. It does not need to be used and is only returned for conveience.
|
||||
|
||||
#### **Subscript operator: `EEPROM[address]`** [[_example_]](examples/eeprom_crc/eeprom_crc.ino)
|
||||
|
||||
This operator allows using the identifier `EEPROM` like an array.
|
||||
EEPROM cells can be read _and_ **_written_** directly using this method.
|
||||
|
||||
This operator returns a reference to the EEPROM cell.
|
||||
|
||||
```c++
|
||||
unsigned char val;
|
||||
|
||||
//Read first EEPROM cell.
|
||||
val = EEPROM[ 0 ];
|
||||
|
||||
//Write first EEPROM cell.
|
||||
EEPROM[ 0 ] = val;
|
||||
|
||||
//Compare contents
|
||||
if( val == EEPROM[ 0 ] ){
|
||||
//Do something...
|
||||
}
|
||||
```
|
||||
|
||||
#### **`EEPROM.length()`**
|
||||
|
||||
This function returns an `unsigned int` containing the number of cells in the EEPROM.
|
||||
|
||||
---
|
||||
|
||||
### **Advanced features**
|
||||
|
||||
This library uses a component based approach to provide its functionality. This means you can also use these components to design a customized approach. Two background classes are available for use: `EERef` & `EEPtr`.
|
||||
|
||||
#### **`EERef` class**
|
||||
|
||||
This object references an EEPROM cell.
|
||||
Its purpose is to mimic a typical byte of RAM, however its storage is the EEPROM.
|
||||
This class has an overhead of two bytes, similar to storing a pointer to an EEPROM cell.
|
||||
|
||||
```C++
|
||||
EERef ref = EEPROM[ 10 ]; //Create a reference to 11th cell.
|
||||
|
||||
ref = 4; //write to EEPROM cell.
|
||||
|
||||
unsigned char val = ref; //Read referenced cell.
|
||||
```
|
||||
|
||||
#### **`EEPtr` class**
|
||||
|
||||
This object is a bidirectional pointer to EEPROM cells represented by `EERef` objects.
|
||||
Just like a normal pointer type, this type can be dereferenced and repositioned using
|
||||
increment/decrement operators.
|
||||
|
||||
```C++
|
||||
EEPtr ptr = 10; //Create a pointer to 11th cell.
|
||||
|
||||
*ptr = 4; //dereference and write to EEPROM cell.
|
||||
|
||||
unsigned char val = *ptr; //dereference and read.
|
||||
|
||||
ptr++; //Move to next EEPROM cell.
|
||||
```
|
||||
|
||||
#### **`EEPROM.begin()`**
|
||||
|
||||
This function returns an `EEPtr` pointing to the first cell in the EEPROM.
|
||||
This is useful for STL objects, custom iteration and C++11 style ranged for loops.
|
||||
|
||||
#### **`EEPROM.end()`**
|
||||
|
||||
This function returns an `EEPtr` pointing at the location after the last EEPROM cell.
|
||||
Used with `begin()` to provide custom iteration.
|
||||
|
||||
**Note:** The `EEPtr` returned is invalid as it is out of range. Infact the hardware causes wrapping of the address (overflow) and `EEPROM.end()` actually references the first EEPROM cell.
|
@ -2,22 +2,34 @@
|
||||
* EEPROM Clear
|
||||
*
|
||||
* Sets all of the bytes of the EEPROM to 0.
|
||||
* Please see eeprom_iteration for a more in depth
|
||||
* look at how to traverse the EEPROM.
|
||||
*
|
||||
* This example code is in the public domain.
|
||||
|
||||
*/
|
||||
|
||||
#include <EEPROM.h>
|
||||
|
||||
void setup()
|
||||
{
|
||||
// write a 0 to all 512 bytes of the EEPROM
|
||||
for (int i = 0; i < 512; i++)
|
||||
|
||||
/***
|
||||
Iterate through each byte of the EEPROM storage.
|
||||
|
||||
Larger AVR processors have larger EEPROM sizes, E.g:
|
||||
- Arduno Duemilanove: 512b EEPROM storage.
|
||||
- Arduino Uno: 1kb EEPROM storage.
|
||||
- Arduino Mega: 4kb EEPROM storage.
|
||||
|
||||
Rather than hard-coding the length, you should use the pre-provided length function.
|
||||
This will make your code portable to all AVR processors.
|
||||
***/
|
||||
|
||||
for ( int i = 0 ; i < EEPROM.length() ; i++ )
|
||||
EEPROM.write(i, 0);
|
||||
|
||||
// turn the LED on when we're done
|
||||
digitalWrite(13, HIGH);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
}
|
||||
void loop(){ /** Empty loop. **/ }
|
||||
|
@ -0,0 +1,50 @@
|
||||
/***
|
||||
Written by Christopher Andrews.
|
||||
CRC algorithm generated by pycrc, MIT licence ( https://github.com/tpircher/pycrc ).
|
||||
|
||||
A CRC is a simple way of checking whether data has changed or become corrupted.
|
||||
This example calculates a CRC value directly on the EEPROM values.
|
||||
The purpose of this example is to highlight how the EEPROM object can be used just like an array.
|
||||
***/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <EEPROM.h>
|
||||
|
||||
void setup(){
|
||||
|
||||
//Start serial
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
//Print length of data to run CRC on.
|
||||
Serial.print( "EEPROM length: " );
|
||||
Serial.println( EEPROM.length() );
|
||||
|
||||
//Print the result of calling eeprom_crc()
|
||||
Serial.print( "CRC32 of EEPROM data: 0x" );
|
||||
Serial.println( eeprom_crc(), HEX );
|
||||
Serial.print( "\n\nDone!" );
|
||||
}
|
||||
|
||||
void loop(){ /* Empty loop */ }
|
||||
|
||||
unsigned long eeprom_crc( void ){
|
||||
|
||||
const unsigned long crc_table[16] = {
|
||||
0x00000000, 0x1db71064, 0x3b6e20c8, 0x26d930ac,
|
||||
0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
|
||||
0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
|
||||
0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c
|
||||
};
|
||||
|
||||
unsigned long crc = ~0L;
|
||||
|
||||
for( int index = 0 ; index < EEPROM.length() ; ++index ){
|
||||
crc = crc_table[( crc ^ EEPROM[index] ) & 0x0f] ^ (crc >> 4);
|
||||
crc = crc_table[( crc ^ ( EEPROM[index] >> 4 )) & 0x0f] ^ (crc >> 4);
|
||||
crc = ~crc;
|
||||
}
|
||||
return crc;
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/***
|
||||
eeprom_get example.
|
||||
|
||||
This shows how to use the EEPROM.get() method.
|
||||
|
||||
To pre-set the EEPROM data, run the example sketch eeprom_put.
|
||||
This sketch will run without it, however, the values shown
|
||||
will be shown from what ever is already on the EEPROM.
|
||||
|
||||
This may cause the serial object to print out a large string
|
||||
of garbage if there is no null character inside one of the strings
|
||||
loaded.
|
||||
|
||||
Written by Christopher Andrews 2015
|
||||
Released under MIT licence.
|
||||
***/
|
||||
|
||||
#include <EEPROM.h>
|
||||
|
||||
void setup(){
|
||||
|
||||
float f = 0.00f; //Variable to store data read from EEPROM.
|
||||
int eeAddress = 0; //EEPROM address to start reading from
|
||||
|
||||
Serial.begin( 9600 );
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
Serial.print( "Read float from EEPROM: " );
|
||||
|
||||
//Get the float data from the EEPROM at position 'eeAddress'
|
||||
EEPROM.get( eeAddress, f );
|
||||
Serial.println( f, 3 ); //This may print 'ovf, nan' if the data inside the EEPROM is not a valid float.
|
||||
|
||||
/***
|
||||
As get also returns a reference to 'f', you can use it inline.
|
||||
E.g: Serial.print( EEPROM.get( eeAddress, f ) );
|
||||
***/
|
||||
|
||||
/***
|
||||
Get can be used with custom structures too.
|
||||
I have separated this into an extra function.
|
||||
***/
|
||||
|
||||
secondTest(); //Run the next test.
|
||||
}
|
||||
|
||||
struct MyObject{
|
||||
float field1;
|
||||
byte field2;
|
||||
char name[10];
|
||||
};
|
||||
|
||||
void secondTest(){
|
||||
int eeAddress = sizeof(float); //Move address to the next byte after float 'f'.
|
||||
|
||||
MyObject customVar; //Variable to store custom object read from EEPROM.
|
||||
EEPROM.get( eeAddress, customVar );
|
||||
|
||||
Serial.println( "Read custom object from EEPROM: " );
|
||||
Serial.println( customVar.field1 );
|
||||
Serial.println( customVar.field2 );
|
||||
Serial.println( customVar.name );
|
||||
}
|
||||
|
||||
void loop(){ /* Empty loop */ }
|
@ -0,0 +1,57 @@
|
||||
/***
|
||||
eeprom_iteration example.
|
||||
|
||||
A set of example snippets highlighting the
|
||||
simplest methods for traversing the EEPROM.
|
||||
|
||||
Running this sketch is not necessary, this is
|
||||
simply highlighting certain programming methods.
|
||||
|
||||
Written by Christopher Andrews 2015
|
||||
Released under MIT licence.
|
||||
***/
|
||||
|
||||
#include <EEPROM.h>
|
||||
|
||||
void setup() {
|
||||
|
||||
/***
|
||||
Iterate the EEPROM using a for loop.
|
||||
***/
|
||||
|
||||
for( int index = 0 ; index < EEPROM.length() ; index++ ){
|
||||
|
||||
//Add one to each cell in the EEPROM
|
||||
EEPROM[ index ] += 1;
|
||||
}
|
||||
|
||||
/***
|
||||
Iterate the EEPROM using a while loop.
|
||||
***/
|
||||
|
||||
int index = 0;
|
||||
|
||||
while( index < EEPROM.length() ){
|
||||
|
||||
//Add one to each cell in the EEPROM
|
||||
EEPROM[ index ] += 1;
|
||||
index++;
|
||||
}
|
||||
|
||||
/***
|
||||
Iterate the EEPROM using a do-while loop.
|
||||
***/
|
||||
|
||||
int idx = 0; //Used 'idx' to avoid name conflict with 'index' above.
|
||||
|
||||
do{
|
||||
|
||||
//Add one to each cell in the EEPROM
|
||||
EEPROM[ idx ] += 1;
|
||||
idx++;
|
||||
}while( idx < EEPROM.length() );
|
||||
|
||||
|
||||
} //End of setup function.
|
||||
|
||||
void loop(){}
|
@ -0,0 +1,56 @@
|
||||
/***
|
||||
eeprom_put example.
|
||||
|
||||
This shows how to use the EEPROM.put() method.
|
||||
Also, this sketch will pre-set the EEPROM data for the
|
||||
example sketch eeprom_get.
|
||||
|
||||
Note, unlike the single byte version EEPROM.write(),
|
||||
the put method will use update semantics. As in a byte
|
||||
will only be written to the EEPROM if the data is actually
|
||||
different.
|
||||
|
||||
Written by Christopher Andrews 2015
|
||||
Released under MIT licence.
|
||||
***/
|
||||
|
||||
#include <EEPROM.h>
|
||||
|
||||
struct MyObject{
|
||||
float field1;
|
||||
byte field2;
|
||||
char name[10];
|
||||
};
|
||||
|
||||
void setup(){
|
||||
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
float f = 123.456f; //Variable to store in EEPROM.
|
||||
int eeAddress = 0; //Location we want the data to be put.
|
||||
|
||||
|
||||
//One simple call, with the address first and the object second.
|
||||
EEPROM.put( eeAddress, f );
|
||||
|
||||
Serial.println("Written float data type!");
|
||||
|
||||
/** Put is designed for use with custom structures also. **/
|
||||
|
||||
//Data to store.
|
||||
MyObject customVar = {
|
||||
3.14f,
|
||||
65,
|
||||
"Working!"
|
||||
};
|
||||
|
||||
eeAddress += sizeof(float); //Move address to the next byte after float 'f'.
|
||||
|
||||
EEPROM.put( eeAddress, customVar );
|
||||
Serial.print( "Written custom data type! \n\nView the example sketch eeprom_get to see how you can retrieve the values!" );
|
||||
}
|
||||
|
||||
void loop(){ /* Empty loop */ }
|
@ -31,13 +31,27 @@ void loop()
|
||||
Serial.print(value, DEC);
|
||||
Serial.println();
|
||||
|
||||
// advance to the next address of the EEPROM
|
||||
/***
|
||||
Advance to the next address, when at the end restart at the beginning.
|
||||
|
||||
Larger AVR processors have larger EEPROM sizes, E.g:
|
||||
- Arduno Duemilanove: 512b EEPROM storage.
|
||||
- Arduino Uno: 1kb EEPROM storage.
|
||||
- Arduino Mega: 4kb EEPROM storage.
|
||||
|
||||
Rather than hard-coding the length, you should use the pre-provided length function.
|
||||
This will make your code portable to all AVR processors.
|
||||
***/
|
||||
address = address + 1;
|
||||
|
||||
// there are only 512 bytes of EEPROM, from 0 to 511, so if we're
|
||||
// on address 512, wrap around to address 0
|
||||
if (address == 512)
|
||||
if(address == EEPROM.length())
|
||||
address = 0;
|
||||
|
||||
/***
|
||||
As the EEPROM sizes are powers of two, wrapping (preventing overflow) of an
|
||||
EEPROM address is also doable by a bitwise and of the length - 1.
|
||||
|
||||
++address &= EEPROM.length() - 1;
|
||||
***/
|
||||
|
||||
delay(500);
|
||||
}
|
||||
|
@ -0,0 +1,69 @@
|
||||
/***
|
||||
EEPROM Update method
|
||||
|
||||
Stores values read from analog input 0 into the EEPROM.
|
||||
These values will stay in the EEPROM when the board is
|
||||
turned off and may be retrieved later by another sketch.
|
||||
|
||||
If a value has not changed in the EEPROM, it is not overwritten
|
||||
which would reduce the life span of the EEPROM unnecessarily.
|
||||
|
||||
Released using MIT licence.
|
||||
***/
|
||||
|
||||
#include <EEPROM.h>
|
||||
|
||||
/** the current address in the EEPROM (i.e. which byte we're going to write to next) **/
|
||||
int address = 0;
|
||||
|
||||
void setup(){ /** EMpty setup **/ }
|
||||
|
||||
void loop()
|
||||
{
|
||||
/***
|
||||
need to divide by 4 because analog inputs range from
|
||||
0 to 1023 and each byte of the EEPROM can only hold a
|
||||
value from 0 to 255.
|
||||
***/
|
||||
int val = analogRead(0) / 4;
|
||||
|
||||
/***
|
||||
Update the particular EEPROM cell.
|
||||
these values will remain there when the board is
|
||||
turned off.
|
||||
***/
|
||||
EEPROM.update(address, val);
|
||||
|
||||
/***
|
||||
The function EEPROM.update(address, val) is equivalent to the following:
|
||||
|
||||
if( EEPROM.read(address) != val ){
|
||||
EEPROM.write(address, val);
|
||||
}
|
||||
***/
|
||||
|
||||
|
||||
/***
|
||||
Advance to the next address, when at the end restart at the beginning.
|
||||
|
||||
Larger AVR processors have larger EEPROM sizes, E.g:
|
||||
- Arduno Duemilanove: 512b EEPROM storage.
|
||||
- Arduino Uno: 1kb EEPROM storage.
|
||||
- Arduino Mega: 4kb EEPROM storage.
|
||||
|
||||
Rather than hard-coding the length, you should use the pre-provided length function.
|
||||
This will make your code portable to all AVR processors.
|
||||
***/
|
||||
address = address + 1;
|
||||
if(address == EEPROM.length())
|
||||
address = 0;
|
||||
|
||||
/***
|
||||
As the EEPROM sizes are powers of two, wrapping (preventing overflow) of an
|
||||
EEPROM address is also doable by a bitwise and of the length - 1.
|
||||
|
||||
++address &= EEPROM.length() - 1;
|
||||
***/
|
||||
|
||||
delay(100);
|
||||
}
|
@ -8,31 +8,51 @@
|
||||
|
||||
#include <EEPROM.h>
|
||||
|
||||
// the current address in the EEPROM (i.e. which byte
|
||||
// we're going to write to next)
|
||||
int addr = 0;
|
||||
/** the current address in the EEPROM (i.e. which byte we're going to write to next) **/
|
||||
int addr = 0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
}
|
||||
void setup(){ /** Empty setup. **/}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// need to divide by 4 because analog inputs range from
|
||||
// 0 to 1023 and each byte of the EEPROM can only hold a
|
||||
// value from 0 to 255.
|
||||
/***
|
||||
Need to divide by 4 because analog inputs range from
|
||||
0 to 1023 and each byte of the EEPROM can only hold a
|
||||
value from 0 to 255.
|
||||
***/
|
||||
|
||||
int val = analogRead(0) / 4;
|
||||
|
||||
// write the value to the appropriate byte of the EEPROM.
|
||||
// these values will remain there when the board is
|
||||
// turned off.
|
||||
/***
|
||||
Write the value to the appropriate byte of the EEPROM.
|
||||
these values will remain there when the board is
|
||||
turned off.
|
||||
***/
|
||||
|
||||
EEPROM.write(addr, val);
|
||||
|
||||
// advance to the next address. there are 512 bytes in
|
||||
// the EEPROM, so go back to 0 when we hit 512.
|
||||
/***
|
||||
Advance to the next address, when at the end restart at the beginning.
|
||||
|
||||
Larger AVR processors have larger EEPROM sizes, E.g:
|
||||
- Arduno Duemilanove: 512b EEPROM storage.
|
||||
- Arduino Uno: 1kb EEPROM storage.
|
||||
- Arduino Mega: 4kb EEPROM storage.
|
||||
|
||||
Rather than hard-coding the length, you should use the pre-provided length function.
|
||||
This will make your code portable to all AVR processors.
|
||||
***/
|
||||
addr = addr + 1;
|
||||
if (addr == 512)
|
||||
if(addr == EEPROM.length())
|
||||
addr = 0;
|
||||
|
||||
/***
|
||||
As the EEPROM sizes are powers of two, wrapping (preventing overflow) of an
|
||||
EEPROM address is also doable by a bitwise and of the length - 1.
|
||||
|
||||
++addr &= EEPROM.length() - 1;
|
||||
***/
|
||||
|
||||
|
||||
delay(100);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#######################################
|
||||
# Syntax Coloring Map For Ultrasound
|
||||
# Syntax Coloring Map For EEPROM
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
@ -7,11 +7,15 @@
|
||||
#######################################
|
||||
|
||||
EEPROM KEYWORD1
|
||||
EERef KEYWORD1
|
||||
EEPtr KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
|
||||
update KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
@ -1,8 +1,10 @@
|
||||
name=EEPROM
|
||||
version=1.0
|
||||
author=Arduino
|
||||
version=2.0
|
||||
author=Arduino, Christopher Andrews
|
||||
maintainer=Arduino <info@arduino.cc>
|
||||
sentence=Enables reading and writing to the permanent board storage. For all Arduino boards BUT Arduino DUE.
|
||||
paragraph=
|
||||
url=http://arduino.cc/en/Reference/EEPROM
|
||||
architectures=avr
|
||||
types=Arduino
|
||||
|
||||
|
@ -29,7 +29,15 @@ void SPIClass::begin()
|
||||
noInterrupts(); // Protect from a scheduler and prevent transactionBegin
|
||||
if (!initialized) {
|
||||
// Set SS to high so a connected chip will be "deselected" by default
|
||||
digitalWrite(SS, HIGH);
|
||||
uint8_t port = digitalPinToPort(SS);
|
||||
uint8_t bit = digitalPinToBitMask(SS);
|
||||
volatile uint8_t *reg = portModeRegister(port);
|
||||
|
||||
// if the SS pin is not already configured as an output
|
||||
// then set it high (to enable the internal pull-up resistor)
|
||||
if(!(*reg & bit)){
|
||||
digitalWrite(SS, HIGH);
|
||||
}
|
||||
|
||||
// When the SS pin is set as OUTPUT, it can be used as
|
||||
// a general purpose output port (it doesn't influence
|
||||
|
@ -6,3 +6,5 @@ sentence=Enables the communication with devices that use the Serial Peripheral I
|
||||
paragraph=
|
||||
url=http://arduino.cc/en/Reference/SPI
|
||||
architectures=avr
|
||||
types=Arduino
|
||||
|
||||
|
@ -6,3 +6,5 @@ sentence=Enables serial communication on digital pins. For all Arduino boards, B
|
||||
paragraph=
|
||||
url=http://arduino.cc/en/Reference/SoftwareSerial
|
||||
architectures=avr
|
||||
types=Arduino
|
||||
|
||||
|
@ -20,7 +20,7 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
Wire.requestFrom(2, 6); // request 6 bytes from slave device #2
|
||||
Wire.requestFrom(8, 6); // request 6 bytes from slave device #8
|
||||
|
||||
while (Wire.available()) // slave may send less than requested
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ byte x = 0;
|
||||
|
||||
void loop()
|
||||
{
|
||||
Wire.beginTransmission(4); // transmit to device #4
|
||||
Wire.beginTransmission(8); // transmit to device #8
|
||||
Wire.write("x is "); // sends five bytes
|
||||
Wire.write(x); // sends one byte
|
||||
Wire.endTransmission(); // stop transmitting
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
void setup()
|
||||
{
|
||||
Wire.begin(4); // join i2c bus with address #4
|
||||
Wire.begin(8); // join i2c bus with address #8
|
||||
Wire.onReceive(receiveEvent); // register event
|
||||
Serial.begin(9600); // start serial for output
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
void setup()
|
||||
{
|
||||
Wire.begin(2); // join i2c bus with address #2
|
||||
Wire.begin(8); // join i2c bus with address #8
|
||||
Wire.onRequest(requestEvent); // register event
|
||||
}
|
||||
|
||||
|
@ -6,3 +6,5 @@ sentence=Allows the communication between devices or sensors connected via Two W
|
||||
paragraph=
|
||||
url=http://arduino.cc/en/Reference/Wire
|
||||
architectures=avr
|
||||
types=Arduino
|
||||
|
||||
|
@ -1,27 +1,33 @@
|
||||
|
||||
# Arduino AVR Core and platform.
|
||||
# ------------------------------
|
||||
|
||||
#
|
||||
# For more info:
|
||||
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
|
||||
|
||||
name=Arduino AVR Boards
|
||||
version=1.6.1
|
||||
version=1.6.7
|
||||
|
||||
# AVR compile variables
|
||||
# ---------------------
|
||||
|
||||
compiler.warning_flags=-w
|
||||
compiler.warning_flags.none=-w
|
||||
compiler.warning_flags.default=
|
||||
compiler.warning_flags.more=-Wall
|
||||
compiler.warning_flags.all=-Wall -Wextra
|
||||
|
||||
# Default "compiler.path" is correct, change only if you want to overidde the initial value
|
||||
compiler.path={runtime.ide.path}/hardware/tools/avr/bin/
|
||||
compiler.path={runtime.tools.avr-gcc.path}/bin/
|
||||
compiler.c.cmd=avr-gcc
|
||||
compiler.c.flags=-c -g -Os -w -ffunction-sections -fdata-sections -MMD
|
||||
compiler.c.flags=-c -g -Os {compiler.warning_flags} -ffunction-sections -fdata-sections -MMD
|
||||
# -w flag added to avoid printing a wrong warning http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59396
|
||||
# This is fixed in gcc 4.8.3 and will be removed as soon as we update the toolchain
|
||||
compiler.c.elf.flags=-w -Os -Wl,--gc-sections
|
||||
compiler.c.elf.flags={compiler.warning_flags} -Os -Wl,--gc-sections
|
||||
compiler.c.elf.cmd=avr-gcc
|
||||
compiler.S.flags=-c -g -x assembler-with-cpp
|
||||
compiler.cpp.cmd=avr-g++
|
||||
compiler.cpp.flags=-c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
|
||||
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD
|
||||
compiler.ar.cmd=avr-ar
|
||||
compiler.ar.flags=rcs
|
||||
compiler.objcopy.cmd=avr-objcopy
|
||||
@ -65,6 +71,10 @@ recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.f
|
||||
recipe.objcopy.eep.pattern="{compiler.path}{compiler.objcopy.cmd}" {compiler.objcopy.eep.flags} {compiler.objcopy.eep.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.eep"
|
||||
recipe.objcopy.hex.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.hex"
|
||||
|
||||
## Save hex
|
||||
recipe.output.tmp_file={build.project_name}.hex
|
||||
recipe.output.save_file={build.project_name}.{build.variant}.hex
|
||||
|
||||
## Compute size
|
||||
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
|
||||
recipe.size.regex=^(?:\.text|\.data|\.bootloader)\s+([0-9]+).*
|
||||
@ -75,8 +85,9 @@ recipe.size.regex.eeprom=^(?:\.eeprom)\s+([0-9]+).*
|
||||
# AVR Uploader/Programmers tools
|
||||
# ------------------------------
|
||||
|
||||
tools.avrdude.cmd.path={runtime.ide.path}/hardware/tools/avr/bin/avrdude
|
||||
tools.avrdude.config.path={runtime.ide.path}/hardware/tools/avr/etc/avrdude.conf
|
||||
tools.avrdude.path={runtime.tools.avrdude.path}
|
||||
tools.avrdude.cmd.path={path}/bin/avrdude
|
||||
tools.avrdude.config.path={path}/etc/avrdude.conf
|
||||
|
||||
tools.avrdude.upload.params.verbose=-v
|
||||
tools.avrdude.upload.params.quiet=-q -q
|
||||
|
@ -44,3 +44,10 @@ arduinoasisp.program.protocol=stk500v1
|
||||
arduinoasisp.program.speed=19200
|
||||
arduinoasisp.program.tool=avrdude
|
||||
arduinoasisp.program.extra_params=-P{serial.port} -b{program.speed}
|
||||
|
||||
usbGemma.name=Arduino Gemma
|
||||
usbGemma.protocol=arduinogemma
|
||||
usbGemma.program.tool=avrdude
|
||||
usbGemma.program.extra_params=
|
||||
usbGemma.config.path={runtime.platform.path}/bootloaders/gemma/avrdude.conf
|
||||
|
||||
|
131
hardware/arduino/avr/variants/gemma/pins_arduino.h
Normal file
131
hardware/arduino/avr/variants/gemma/pins_arduino.h
Normal file
@ -0,0 +1,131 @@
|
||||
/*
|
||||
pins_arduino.c - pin definitions for the Arduino board
|
||||
Part of Arduino / Wiring Lite
|
||||
|
||||
Copyright (c) 2005 David A. Mellis
|
||||
|
||||
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
|
||||
|
||||
$Id: pins_arduino.c 565 2009-03-25 10:50:00Z dmellis $
|
||||
|
||||
Modified 28-08-2009 for attiny84 R.Wiersma
|
||||
Modified 09-10-2009 for attiny45 A.Saporetti
|
||||
*/
|
||||
|
||||
#ifndef Pins_Arduino_h
|
||||
#define Pins_Arduino_h
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
// Defines to make D4 support PWM
|
||||
// See for more info: http://forums.adafruit.com/viewtopic.php?f=52&t=43951
|
||||
//#define TCCR1A GTCCR
|
||||
//#define WGM10 PWM1B
|
||||
|
||||
// ATMEL ATTINY45 / ARDUINO
|
||||
//
|
||||
// +-\/-+
|
||||
// Ain0 (D 5) PB5 1| |8 Vcc
|
||||
// Ain3 (D 3) PB3 2| |7 PB2 (D 2) Ain1
|
||||
// Ain2 (D 4) PB4 3| |6 PB1 (D 1) pwm1
|
||||
// GND 4| |5 PB0 (D 0) pwm0
|
||||
// +----+
|
||||
|
||||
static const uint8_t A0 = 6;
|
||||
static const uint8_t A1 = 7;
|
||||
static const uint8_t A2 = 8;
|
||||
static const uint8_t A3 = 9;
|
||||
|
||||
#define digitalPinToPCICR(p) ( ((p) >= 0 && (p) <= 4) ? (&GIMSK) : ((uint8_t *)0) )
|
||||
#define digitalPinToPCICRbit(p) ( PCIE )
|
||||
#define digitalPinToPCMSK(p) ( ((p) <= 4) ? (&PCMSK) : ((uint8_t *)0) )
|
||||
#define digitalPinToPCMSKbit(p) ( (p) )
|
||||
|
||||
#define analogPinToChannel(p) ( (p) < 6 ? (p) : (p) - 6 )
|
||||
|
||||
#define TCCR1A GTCCR
|
||||
|
||||
#ifdef ARDUINO_MAIN
|
||||
|
||||
void initVariant()
|
||||
{
|
||||
GTCCR |= (1 << PWM1B);
|
||||
}
|
||||
|
||||
// these arrays map port names (e.g. port B) to the
|
||||
// appropriate addresses for various functions (e.g. reading
|
||||
// and writing) tiny45 only port B
|
||||
const uint16_t PROGMEM port_to_mode_PGM[] = {
|
||||
NOT_A_PORT,
|
||||
NOT_A_PORT,
|
||||
(uint16_t) &DDRB,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM port_to_output_PGM[] = {
|
||||
NOT_A_PORT,
|
||||
NOT_A_PORT,
|
||||
(uint16_t) &PORTB,
|
||||
};
|
||||
|
||||
const uint16_t PROGMEM port_to_input_PGM[] = {
|
||||
NOT_A_PIN,
|
||||
NOT_A_PIN,
|
||||
(uint16_t) &PINB,
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
|
||||
PB, /* 0 */
|
||||
PB,
|
||||
PB,
|
||||
PB,
|
||||
PB,
|
||||
PB, // 5
|
||||
PB, // A0
|
||||
PB,
|
||||
PB,
|
||||
PB, // A4
|
||||
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
|
||||
_BV(0), /* 0, port B */
|
||||
_BV(1),
|
||||
_BV(2),
|
||||
_BV(3), /* 3 port B */
|
||||
_BV(4),
|
||||
_BV(5),
|
||||
_BV(5),
|
||||
_BV(2),
|
||||
_BV(4),
|
||||
_BV(3),
|
||||
};
|
||||
|
||||
const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
|
||||
TIMER0A, /* OC0A */
|
||||
TIMER0B,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
TIMER1B,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
NOT_ON_TIMER,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -4,7 +4,6 @@ arduino_due_x_dbg.vid.0=0x2341
|
||||
arduino_due_x_dbg.pid.0=0x003d
|
||||
arduino_due_x_dbg.vid.1=0x2A03
|
||||
arduino_due_x_dbg.pid.1=0x003d
|
||||
arduino_due_x_dbg.vid.0x2A03.warning=Uncertified
|
||||
arduino_due_x_dbg.upload.tool=bossac
|
||||
arduino_due_x_dbg.upload.protocol=sam-ba
|
||||
arduino_due_x_dbg.upload.maximum_size=524288
|
||||
@ -28,7 +27,6 @@ arduino_due_x.vid.0=0x2341
|
||||
arduino_due_x.pid.0=0x003e
|
||||
arduino_due_x.vid.1=0x2A03
|
||||
arduino_due_x.pid.1=0x003e
|
||||
arduino_due_x.vid.0x2A03.warning=Uncertified
|
||||
arduino_due_x.upload.tool=bossac
|
||||
arduino_due_x.upload.protocol=sam-ba
|
||||
arduino_due_x.upload.maximum_size=524288
|
||||
|
@ -194,6 +194,8 @@ extern const PinDescription g_APinDescription[] ;
|
||||
#include "wiring_shift.h"
|
||||
#include "WInterrupts.h"
|
||||
|
||||
#include "watchdog.h"
|
||||
|
||||
// USB Device
|
||||
#define USB_VID 0x2341 // arduino LLC vid
|
||||
#define USB_PID_LEONARDO 0x0034
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
Created July 2011
|
||||
parsing functions based on TextFinder library by Michael Margolis
|
||||
|
||||
findMulti/findUntil routines written by Jim Leonard/Xuth
|
||||
*/
|
||||
|
||||
#include "Arduino.h"
|
||||
@ -75,7 +77,7 @@ void Stream::setTimeout(unsigned long timeout) // sets the maximum number of mi
|
||||
// find returns true if the target string is found
|
||||
bool Stream::find(char *target)
|
||||
{
|
||||
return findUntil(target, (char*)"");
|
||||
return findUntil(target, strlen(target), NULL, 0);
|
||||
}
|
||||
|
||||
// reads data from the stream until the target string of given length is found
|
||||
@ -96,32 +98,13 @@ bool Stream::findUntil(char *target, char *terminator)
|
||||
// returns true if target string is found, false if terminated or timed out
|
||||
bool Stream::findUntil(char *target, size_t targetLen, char *terminator, size_t termLen)
|
||||
{
|
||||
size_t index = 0; // maximum target string length is 64k bytes!
|
||||
size_t termIndex = 0;
|
||||
int c;
|
||||
|
||||
if( *target == 0)
|
||||
return true; // return true if target is a null string
|
||||
while( (c = timedRead()) > 0){
|
||||
|
||||
if(c != target[index])
|
||||
index = 0; // reset index if any char does not match
|
||||
|
||||
if( c == target[index]){
|
||||
//////Serial.print("found "); Serial.write(c); Serial.print("index now"); Serial.println(index+1);
|
||||
if(++index >= targetLen){ // return true if all chars in the target match
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(termLen > 0 && c == terminator[termIndex]){
|
||||
if(++termIndex >= termLen)
|
||||
return false; // return false if terminate string found before target string
|
||||
}
|
||||
else
|
||||
termIndex = 0;
|
||||
if (terminator == NULL) {
|
||||
MultiTarget t[1] = {{target, targetLen, 0}};
|
||||
return findMulti(t, 1) == 0 ? true : false;
|
||||
} else {
|
||||
MultiTarget t[2] = {{target, targetLen, 0}, {terminator, termLen, 0}};
|
||||
return findMulti(t, 2) == 0 ? true : false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -137,7 +120,7 @@ long Stream::parseInt()
|
||||
// this allows format characters (typically commas) in values to be ignored
|
||||
long Stream::parseInt(char skipChar)
|
||||
{
|
||||
boolean isNegative = false;
|
||||
bool isNegative = false;
|
||||
long value = 0;
|
||||
int c;
|
||||
|
||||
@ -173,10 +156,10 @@ float Stream::parseFloat()
|
||||
// as above but the given skipChar is ignored
|
||||
// this allows format characters (typically commas) in values to be ignored
|
||||
float Stream::parseFloat(char skipChar){
|
||||
boolean isNegative = false;
|
||||
boolean isFraction = false;
|
||||
bool isNegative = false;
|
||||
bool isFraction = false;
|
||||
long value = 0;
|
||||
int c;
|
||||
char c;
|
||||
float fraction = 1.0;
|
||||
|
||||
c = peekNextDigit();
|
||||
@ -268,3 +251,67 @@ String Stream::readStringUntil(char terminator)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Stream::findMulti( struct Stream::MultiTarget *targets, int tCount) {
|
||||
// any zero length target string automatically matches and would make
|
||||
// a mess of the rest of the algorithm.
|
||||
for (struct MultiTarget *t = targets; t < targets+tCount; ++t) {
|
||||
if (t->len <= 0)
|
||||
return t - targets;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
int c = timedRead();
|
||||
if (c < 0)
|
||||
return -1;
|
||||
|
||||
for (struct MultiTarget *t = targets; t < targets+tCount; ++t) {
|
||||
// the simple case is if we match, deal with that first.
|
||||
if (c == t->str[t->index]) {
|
||||
if (++t->index == t->len)
|
||||
return t - targets;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
// if not we need to walk back and see if we could have matched further
|
||||
// down the stream (ie '1112' doesn't match the first position in '11112'
|
||||
// but it will match the second position so we can't just reset the current
|
||||
// index to 0 when we find a mismatch.
|
||||
if (t->index == 0)
|
||||
continue;
|
||||
|
||||
int origIndex = t->index;
|
||||
do {
|
||||
--t->index;
|
||||
// first check if current char works against the new current index
|
||||
if (c != t->str[t->index])
|
||||
continue;
|
||||
|
||||
// if it's the only char then we're good, nothing more to check
|
||||
if (t->index == 0) {
|
||||
t->index++;
|
||||
break;
|
||||
}
|
||||
|
||||
// otherwise we need to check the rest of the found string
|
||||
int diff = origIndex - t->index;
|
||||
size_t i;
|
||||
for (i = 0; i < t->index; ++i) {
|
||||
if (t->str[i] != t->str[i + diff])
|
||||
break;
|
||||
}
|
||||
|
||||
// if we successfully got through the previous loop then our current
|
||||
// index is good.
|
||||
if (i == t->index) {
|
||||
t->index++;
|
||||
break;
|
||||
}
|
||||
|
||||
// otherwise we just try the next index
|
||||
} while (t->index);
|
||||
}
|
||||
}
|
||||
// unreachable
|
||||
return -1;
|
||||
}
|
||||
|
@ -97,6 +97,16 @@ class Stream : public Print
|
||||
// this allows format characters (typically commas) in values to be ignored
|
||||
|
||||
float parseFloat(char skipChar); // as above but the given skipChar is ignored
|
||||
|
||||
struct MultiTarget {
|
||||
const char *str; // string you're searching for
|
||||
size_t len; // length of string you're searching for
|
||||
size_t index; // index used by the search routine.
|
||||
};
|
||||
|
||||
// This allows you to search for an arbitrary number of strings.
|
||||
// Returns index of the target that is found first or -1 if timeout occurs.
|
||||
int findMulti(struct MultiTarget *targets, int tCount);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -41,6 +41,9 @@ void initVariant() { }
|
||||
*/
|
||||
int main( void )
|
||||
{
|
||||
// Initialize watchdog
|
||||
watchdogSetup();
|
||||
|
||||
init();
|
||||
|
||||
initVariant();
|
||||
|
55
hardware/arduino/sam/cores/arduino/watchdog.cpp
Normal file
55
hardware/arduino/sam/cores/arduino/watchdog.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
Copyright (c) 2014 Arduino. All right reserved.
|
||||
|
||||
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <chip.h>
|
||||
|
||||
#include "watchdog.h"
|
||||
|
||||
|
||||
void watchdogEnable (uint32_t timeout)
|
||||
{
|
||||
/* this assumes the slow clock is running at 32.768 kHz
|
||||
watchdog frequency is therefore 32768 / 128 = 256 Hz */
|
||||
timeout = timeout * 256 / 1000;
|
||||
if (timeout == 0)
|
||||
timeout = 1;
|
||||
else if (timeout > 0xFFF)
|
||||
timeout = 0xFFF;
|
||||
timeout = WDT_MR_WDRSTEN | WDT_MR_WDV(timeout) | WDT_MR_WDD(timeout);
|
||||
WDT_Enable (WDT, timeout);
|
||||
}
|
||||
|
||||
void watchdogDisable(void)
|
||||
{
|
||||
WDT_Disable (WDT);
|
||||
}
|
||||
|
||||
void watchdogReset(void)
|
||||
{
|
||||
WDT_Restart (WDT);
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
void _watchdogDefaultSetup (void)
|
||||
{
|
||||
WDT_Disable (WDT);
|
||||
}
|
||||
void watchdogSetup (void) __attribute__ ((weak, alias("_watchdogDefaultSetup")));
|
||||
|
||||
|
52
hardware/arduino/sam/cores/arduino/watchdog.h
Normal file
52
hardware/arduino/sam/cores/arduino/watchdog.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright (c) 2014 Arduino. All right reserved.
|
||||
|
||||
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _WATCHDOG_
|
||||
#define _WATCHDOG_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Watchdog functions
|
||||
|
||||
/*
|
||||
* \brief Enable the watchdog with the specified timeout. Should only be called once.
|
||||
*
|
||||
* \param timeount in milliseconds.
|
||||
*/
|
||||
void watchdogEnable (uint32_t timeout);
|
||||
|
||||
/*
|
||||
* \brief Disable the watchdog timer. Should only be called once.
|
||||
*
|
||||
*/
|
||||
void watchdogDisable (void);
|
||||
|
||||
/*
|
||||
* \brief Reset the watchdog counter.
|
||||
*
|
||||
*/
|
||||
void watchdogReset (void);
|
||||
|
||||
/*
|
||||
* \brief Watchdog initialize hook. This function is called from init(). If the user does not provide
|
||||
* this function, then the default action is to disable watchdog.
|
||||
*/
|
||||
void watchdogSetup (void);
|
||||
|
||||
#endif /* _WATCHDOG_ */
|
||||
|
@ -6,3 +6,5 @@ sentence=Enables the communication with devices that use the Serial Peripheral I
|
||||
paragraph=
|
||||
url=http://arduino.cc/en/Reference/SPI
|
||||
architectures=sam
|
||||
types=Arduino
|
||||
|
||||
|
@ -6,3 +6,5 @@ sentence=Allows the communication between devices or sensors connected via Two W
|
||||
paragraph=
|
||||
url=http://arduino.cc/en/Reference/Wire
|
||||
architectures=sam
|
||||
types=Arduino
|
||||
|
||||
|
@ -1,23 +1,30 @@
|
||||
|
||||
# Arduino SAM Core and platform.
|
||||
# ------------------------------
|
||||
#
|
||||
# For more info:
|
||||
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification
|
||||
|
||||
name=Arduino ARM (32-bits) Boards
|
||||
version=1.6.1
|
||||
version=1.6.4
|
||||
|
||||
# SAM3 compile variables
|
||||
# ----------------------
|
||||
|
||||
compiler.path={runtime.ide.path}/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin/
|
||||
compiler.warning_flags=-w
|
||||
compiler.warning_flags.none=-w
|
||||
compiler.warning_flags.default=
|
||||
compiler.warning_flags.more=-Wall
|
||||
compiler.warning_flags.all=-Wall -Wextra
|
||||
|
||||
compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/
|
||||
compiler.c.cmd=arm-none-eabi-gcc
|
||||
compiler.c.flags=-c -g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -MMD
|
||||
compiler.c.flags=-c -g -Os {compiler.warning_flags} -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -MMD
|
||||
compiler.c.elf.cmd=arm-none-eabi-gcc
|
||||
compiler.c.elf.flags=-Os -Wl,--gc-sections
|
||||
compiler.S.flags=-c -g -x assembler-with-cpp
|
||||
compiler.cpp.cmd=arm-none-eabi-g++
|
||||
compiler.cpp.flags=-c -g -Os -w -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -MMD
|
||||
compiler.cpp.flags=-c -g -Os {compiler.warning_flags} -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -Dprintf=iprintf -MMD
|
||||
compiler.ar.cmd=arm-none-eabi-ar
|
||||
compiler.ar.flags=rcs
|
||||
compiler.objcopy.cmd=arm-none-eabi-objcopy
|
||||
@ -68,6 +75,10 @@ recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.f
|
||||
## Create output (.bin file)
|
||||
recipe.objcopy.bin.pattern="{compiler.path}{compiler.elf2hex.cmd}" {compiler.elf2hex.flags} {compiler.elf2hex.extra_flags} "{build.path}/{build.project_name}.elf" "{build.path}/{build.project_name}.bin"
|
||||
|
||||
## Save hex
|
||||
recipe.output.tmp_file={build.project_name}.bin
|
||||
recipe.output.save_file={build.project_name}.{build.variant}.bin
|
||||
|
||||
## Compute size
|
||||
recipe.size.pattern="{compiler.path}{compiler.size.cmd}" -A "{build.path}/{build.project_name}.elf"
|
||||
recipe.size.regex=\.text\s+([0-9]+).*
|
||||
@ -76,9 +87,9 @@ recipe.size.regex=\.text\s+([0-9]+).*
|
||||
# SAM3 Uploader tools
|
||||
# -------------------
|
||||
|
||||
tools.bossac.path={runtime.tools.bossac.path}
|
||||
tools.bossac.cmd=bossac
|
||||
tools.bossac.cmd.windows=bossac.exe
|
||||
tools.bossac.path={runtime.ide.path}/hardware/tools
|
||||
|
||||
tools.bossac.upload.params.verbose=-i -d
|
||||
tools.bossac.upload.params.quiet=
|
||||
|
@ -377,9 +377,6 @@ void init( void )
|
||||
while (true);
|
||||
}
|
||||
|
||||
// Disable watchdog
|
||||
WDT_Disable(WDT);
|
||||
|
||||
// Initialize C library
|
||||
__libc_init_array();
|
||||
|
||||
|
Reference in New Issue
Block a user