aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--boards.txt10
-rw-r--r--bootloaders/diskloader/DiskLoader-Leonardo.hex289
-rw-r--r--bootloaders/diskloader/DiskLoader-Micro.hex113
-rw-r--r--bootloaders/diskloader/Makefile198
-rw-r--r--bootloaders/diskloader/src/CDC.cpp93
-rw-r--r--bootloaders/diskloader/src/DiskLoader.cpp301
-rw-r--r--bootloaders/diskloader/src/Platform.h59
-rw-r--r--bootloaders/diskloader/src/USBAPI.h64
-rw-r--r--bootloaders/diskloader/src/USBCore.cpp589
-rw-r--r--bootloaders/diskloader/src/USBCore.h88
-rw-r--r--bootloaders/diskloader/src/USBDesc.cpp82
-rw-r--r--bootloaders/diskloader/src/USBDesc.h45
-rwxr-xr-xbootloaders/stk500v2/stk500boot.c3
-rw-r--r--bootloaders/stk500v2/stk500boot_v2_mega2560.hex648
-rw-r--r--cores/arduino/CDC.cpp2
-rw-r--r--cores/arduino/HardwareSerial.h14
-rwxr-xr-xcores/arduino/Print.cpp207
-rw-r--r--cores/arduino/WString.h255
18 files changed, 1356 insertions, 1704 deletions
diff --git a/boards.txt b/boards.txt
index baf4338..aa5c70d 100644
--- a/boards.txt
+++ b/boards.txt
@@ -10,7 +10,7 @@ uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
-uno.bootloader.lock_bits=0x0F
+uno.bootloader.lock_bits=0x2F
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
@@ -146,13 +146,13 @@ mega.build.variant=mega
leonardo.name=Arduino Leonardo
leonardo.upload.protocol=arduino
-leonardo.upload.maximum_size=30720
+leonardo.upload.maximum_size=28672
leonardo.upload.speed=1200
leonardo.bootloader.low_fuses=0xde
-leonardo.bootloader.high_fuses=0xda
+leonardo.bootloader.high_fuses=0xd8
leonardo.bootloader.extended_fuses=0xcb
-leonardo.bootloader.path=diskloader
-leonardo.bootloader.file=DiskLoader-Leonardo.hex
+leonardo.bootloader.path=nuevo_diskloader
+leonardo.bootloader.file=DiskLoader.hex
leonardo.bootloader.unlock_bits=0x3F
leonardo.bootloader.lock_bits=0x2F
leonardo.build.mcu=atmega32u4
diff --git a/bootloaders/diskloader/DiskLoader-Leonardo.hex b/bootloaders/diskloader/DiskLoader-Leonardo.hex
index 4528a8b..b5b257f 100644
--- a/bootloaders/diskloader/DiskLoader-Leonardo.hex
+++ b/bootloaders/diskloader/DiskLoader-Leonardo.hex
@@ -1,113 +1,178 @@
-:1078000011241FBECFEFDAE0DEBFCDBFF2C04101D1
-:1078100042144505560455026403740300001E9586
-:1078200087020110030000C18081C106C0FF0A0069
-:107830000CA10185037508150026FF00954009017C
-:107840008102954009029102C004030904380341F2
-:107850000072006400750069006E006F0020004C2B
-:107860000065006F006E006100720064006F002010
-:107870000062006F006F0074006C006F00610064B4
-:107880000065007200180341007200640075006911
-:10789000006E006F0020004C004C004300120100FD
-:1078A00002020000404123340000010102000112E5
-:1078B00001000200000040412334000001010200E9
-:1078C00001090264000301008032080B0002020279
-:1078D000010009040000010202000005240010015B
-:1078E0000524010101042402020524060001070504
-:1078F000810310004009040100020A00000007058E
-:107900000202400000070583024000000904020053
-:107910000103000000092101010001221E000705EA
-:1079200084034000400020918A0130918B012C5F3C
-:107930003F4F30938B0120938A01C901892F9927EA
-:107940008695982F803418F08FE7891B982F990F10
-:10795000921710F447980895479A08955D9A289AC7
-:1079600081E08093E0001092E200EE27FF27099467
-:1079700008950F931F93CF93DF93982FEB01042F5C
-:1079800010E088E76030780730F411E083E0FB0115
-:1079900080935700E895892F68E071E0402FF8D078
-:1079A000112311F107B600FCFDCF402F4695FE01D3
-:1079B000A8E0B1E020E031E009C08D919D910C017B
-:1079C00030935700E895112432962F5F2417A8F3BF
-:1079D00085E0FE0180935700E89507B600FCFDCFD7
-:1079E00081E180935700E895DF91CF911F910F912E
-:1079F000089588E10FB6F8948093600010926000BB
-:107A00000FBE5D9A289A47983F9A209A559A90E817
-:107A1000909361001092610081E885BF95BF9FD06F
-:107A200084E18093880180E180938901E0E0F0E0C7
-:107A3000859194918F5F9F4F19F081E080938F0122
-:107A4000EE24FF24BB24B39454EFC52E51E0D52E71
-:107A50000ED2082F8EE098E7FC0124913196029611
-:107A60004491201711F02223B9F71092910110923E
-:107A7000900182E068E071E08BD0013479F460918C
-:107A800008016058633028F0683111F064E001C0EB
-:107A900063E0C62FD0E0CF5DD7480EC0063571F445
-:107AA00080910801803311F011E022C080910A0119
-:107AB000C82FD0E0C25ED74811E022C0053721F4BC
-:107AC00013E0CEE1D8E71CC0053539F4E090080199
-:107AD000F0900901EE0CFF1C0AC0043631F482E07C
-:107AE000B7014091090145DF02C0043721F010E0E1
-:107AF000C5E2D8E705C010910901E701E10EF11CCC
-:107B0000B6D18097B1F483E068E871E041E050E0DD
-:107B100059D0112329F0412F50E083E8BE0152D003
-:107B200083E469E871E041E050E04CD0013509F0B0
-:107B30008FCFD0929101C0929001B0928F01EE242C
-:107B4000FF2486CFFC01289884E680938D0104C031
-:107B50008091F100819361506623D1F708951092CE
-:107B600091011092900110928E0110928F0181E08C
-:107B70008093D70080EA8093D80082E189BD09B460
-:107B800000FEFDCF80E98093D8001092E0000895B8
-:107B9000FB018093E90024E69BE611C08091E80098
-:107BA00085FFFCCF289820938D018091F10081936F
-:107BB0008091E80085FD02C09093E8004150442385
-:107BC00069F70895982FFB01282F20728770809302
-:107BD000E90064E63AE317C08091E80085FFFCCF36
-:107BE00097FF02C0849101C080813196211180E00D
-:107BF0005D9860938C018093F1008091E80085FD91
-:107C000002C03093E800415050408FEF4F3F58077B
-:107C100019F796FF03C08AE38093E80008958091E6
-:107C20009301813299F45D9884E680938C0120E081
-:107C300030E003C080818093F100F901E050FF4FF4
-:107C40002F5F3F4F28303105A9F714C0803261F40F
-:107C50008091E80082FFFCCF80E091E067E072DF76
-:107C60008BEF8093E80006C0823221F4809194016A
-:107C70008093070181E0089520919501223261F1FE
-:107C8000213081F48091980190919901089711F425
-:107C900020939A0180919A01882309F04AC0EFEA63
-:107CA000F8E749C0223021F484E6E1ECF8E717C098
-:107CB000233009F03CC080919401882319F4E9E451
-:107CC000F8E739C0823019F4EDE4F8E734C08130C8
-:107CD00071F5E5E8F8E72FC081E0EBE2F8E7909175
-:107CE0009801382F981708F4392F90918C0120E0D3
-:107CF0004EEF8091E8008570E1F38091E80082FD0D
-:107D000012C02F5F84915D988093F100822F8F7352
-:107D100011F44093E800319694E6231750F39093C2
-:107D20008C0181E0089590938C0180E0089580E0BB
-:107D30000895EDE9F8E78491D2CF1092E90080919F
-:107D4000E80083FF61C082E991E068E0FBDE82EF3A
-:107D50008093E8008091920187FF05C08091E80040
-:107D600080FFFCCF03C08EEF8093E80080919301E9
-:107D7000853051F48091E80080FFFCCF8091940120
-:107D800080688093E30039C08930E1F480919401E8
-:107D900080938E01E7E2F8E791E031E026E39093EB
-:107DA000E9003093EB0084918093EC002093ED0088
-:107DB0009F5F3196953099F78EE78093EA00109295
-:107DC000EA001BC0883049F490918E015D9884E6EA
-:107DD00080938C019093F10010C0882339F45D9852
-:107DE00084E680938C011092F10007C0863011F474
-:107DF00043DF01C014DF882321F08EEF8093E80079
-:107E0000089581E28093EB0008958091E100109243
-:107E1000E100282F83FF0CC01092E90081E08093DD
-:107E2000EB001092EC0082E38093ED0010928E0143
-:107E300022FF1CC080918C01882331F081508093F7
-:107E40008C01882309F45D9A80918D01882331F09B
-:107E5000815080938D01882309F4289A80918F01A5
-:107E6000882321F4109291011092900108951F939C
-:107E7000CF93DF9312E0C0E9D1E05FDFC6DF10935C
-:107E8000E9008091E80085FF13C0289884E680937C
-:107E90008D019091F1008091E80085FD03C08BE693
-:107EA0008093E800892F90E0DF91CF911F91089592
-:107EB000809190019091910101979093910180930D
-:107EC00090018091900190919101892B09F446DDF8
-:0A7ED000CE010197F1F727DDD0CFB6
-:087EDA0000E1000000000000BF
-:040000030000780081
+:10700000BDC00000E0C00000DEC00000DCC0000029
+:10701000DAC00000D8C00000D6C00000D4C0000014
+:10702000D2C00000D0C00000BCC300002EC40000CD
+:10703000CAC00000C8C00000C6C00000C4C0000034
+:10704000C2C00000C0C00000BEC00000BCC0000044
+:10705000BAC00000B8C00000B6C00000B4C0000054
+:10706000B2C00000B0C00000AEC00000ACC0000064
+:10707000AAC00000A8C00000A6C00000A4C0000074
+:10708000A2C00000A0C000009EC000009CC0000084
+:107090009AC0000098C0000096C0000094C0000094
+:1070A00092C0000090C000008EC0000011241FBEDE
+:1070B000CFEFDAE0DEBFCDBF23C1080B0002020232
+:1070C0000100090400000102020000052400100173
+:1070D0000524010101042402060524060001070518
+:1070E000810310004009040100020A0000000705A6
+:1070F00002024000000705830240000041014214E3
+:107100004505560455026403740300001E9587026A
+:10711000011003000403090422034100720064000B
+:10712000750069006E006F0020004C0065006F0064
+:107130006E006100720064006F001803410072006D
+:107140006400750069006E006F0020004C004C0068
+:1071500043001201000200000040412334000001FE
+:10716000010200011201000202000040412334002C
+:1071700000010102000100C18081353C11241FBEC5
+:10718000CFEFDAE0DEBFCDBF11E0A0E0B1E0E6EE88
+:10719000FAE702C005900D92A830B107D9F711E0C7
+:1071A000A8E0B1E001C01D92A739B107E1F711E7EE
+:1071B000CCE7D1E703C02297FE018FD4CA37D107AD
+:1071C000D1F79ED08EC41CCFFC0180818E5F80835E
+:1071D00080E86AEB70E742E450E095C2FC018181EF
+:1071E0009081913A49F48132C1F480E060E071E02D
+:1071F00047E050E088D20FC0913279F4803231F408
+:1072000080E091E067E070E0BAD205C0823229F4F4
+:1072100082818093070181E0089580E008952091A4
+:107220008C0130918D012F5F3F4F30938D01209362
+:107230008C01C901892F99278695982F803418F0E1
+:107240008FE7891B982F990F921710F4479808958C
+:10725000479A08954798289A769AF89401E005BFCE
+:1072600000E005BF81E08093E0001092E200EE278D
+:10727000FF2709940895FF920F931F93CF93DF93F5
+:10728000982F8B01FF2480E76030780738F4FF24C3
+:10729000F39483E0FB0180935700E895C42FD0E07E
+:1072A000892F68E071E0AE0120D1FF2019F107B607
+:1072B00000FCFDCFD595C7954C2FF801A8E0B1E0B3
+:1072C00020E031E009C08D919D910C013093570071
+:1072D000E895112432962F5F2417A8F385E0F80172
+:1072E00080935700E89507B600FCFDCF81E18093BD
+:1072F0005700E895DF91CF911F910F91FF9008956E
+:1073000088E10FB6F89480936000109260000FBE81
+:107310003F9A209A6E9A90E89093610010926100D3
+:1073200081E885BF95BF01E005BF02E005BF769A01
+:10733000289A479886E991E082D2789484E18093F4
+:10734000880180E180938901CC24DD2470E9A72E97
+:1073500071E0B72E02C0CC24DD2482E0BDD08823AA
+:1073600009F492C082E016D1E82E8CEF90E7FC0180
+:1073700024913196029644912E1511F02223B9F7EB
+:1073800010928B0110928A0150E082E068E071E077
+:10739000ACD0F1E4EF1679F46091080160586330E5
+:1073A00028F0683111F064E001C063E0062F10E0BE
+:1073B000015F1E4809C026E5E21681F480910801AC
+:1073C000803329F003E111E7FF24F3942EC080916C
+:1073D0000A01082F10E0045F1E48F6CF85E7E81683
+:1073E00029F40CE011E763E0F62E1FC0E5E5EE1688
+:1073F00039F4C0900801D0900901CC0CDD1C0CC000
+:10740000F4E6EF1631F482E0B6014091090133DF72
+:1074100003C024E7E21621F003E111E7FF2405C0D1
+:10742000F09009018601CF0CD11CC8E8D3E1219767
+:10743000C930D10509F43BC082E04ED0882309F061
+:1074400036C0F5CF809709F086CF83E068E871E019
+:1074500041E050E0C7D0FF2029F04F2D50E083E8F5
+:10746000B801C0D083E469E871E041E050E0BAD0EF
+:1074700081E5E81609F071CF88EE93E0F5013197C8
+:10748000F1F70197D9F711C0CADEC5010197F1F7ED
+:1074900080918A0190918B01019790938B01809349
+:1074A0008A010196019709F058CFD4DE56CF82E0C9
+:1074B00071D0EFEF8F3F9E0709F0C4CFC6CFFC011C
+:1074C00004C08091F100819361506623D1F7289820
+:1074D00084E680938F0108959FB7F8948770809316
+:1074E000E9008091F2009FBF0895FB019FB7F894D7
+:1074F00087708093E90034E62BE610C08091E800A5
+:1075000085FFFCCF289830938F018091F100819303
+:107510008091E80085FD02C02093E8004150504072
+:107520008FEF4F3F580751F79FBF0895282F809145
+:1075300090018823C1F057FF1AC015C02898909376
+:107540008F018091F1008193E217F307B9F741159C
+:10755000510539F08091F200882319F48BE680936D
+:10756000E800AFBF02C04FEF5FEFCA010895AFB7A9
+:10757000F89427702093E9008091F200282F30E0E2
+:10758000241735070CF4A901FB019B01240F311DC1
+:1075900094E6DACFDF93CF930F92CDB7DEB7BE017B
+:1075A0006F5F7F4F41E050E0C1DF019719F08FEF2F
+:1075B0009FEF02C0898190E00F90CF91DF910895F5
+:1075C0002FB7F89487708093E9008091E80085FDDB
+:1075D00002C090E004C08091F20090E4981B2FBF9D
+:1075E000892F08955F926F927F928F929F92AF92B0
+:1075F000BF92CF92DF92EF92FF920F931F93CF93A0
+:10760000DF93F82E6A0180919001882319F44FEFDF
+:107610005FEF68C08B01EA0157E0E52EEF208F2D68
+:1076200090E040E2842E912C882299223AE3532E56
+:1076300020E4A22EB12CA822B92280EA682E8FE085
+:10764000782E43C08F2DBCDF282F882321F4C3015F
+:107650000197F1F73AC090E0C817D9070CF42C2F26
+:10766000C21BD1094FB7F894E092E900811491044C
+:1076700021F406C01092F10021502223D9F719C03D
+:10768000F7FC03C0F801922F10C0C801322F06C0CA
+:10769000FC010196E491E093F10031503323C1F7EE
+:1076A00006C081918093F10091509923D1F7020F88
+:1076B000111D8091E80085FF05C0209729F4A114D1
+:1076C000B10411F05092E8004FBF209709F0BACFF3
+:1076D000F6FE03C08AE38093E800769884E6809300
+:1076E0008E01A601CA01DF91CF911F910F91FF90EA
+:1076F000EF90DF90CF90BF90AF909F908F907F9052
+:107700006F905F9008950F931F93182FFB01A09126
+:107710009301B0919401BA010EEF2AC017FF02C085
+:10772000949101C0908120919101309192012A178A
+:107730003B07ACF48091E8008570E1F38091E800AC
+:1077400082FF03C04FEF5FEF16C09093F100C901B5
+:1077500001968F739070892B11F40093E8002F5FCE
+:107760003F4F3093920120939101615070403196C8
+:107770006115710599F6CA011F910F910895CF9374
+:10778000DF939C01EB018091E80082FFFCCFC901EF
+:107790006C2F95DE8BEF8093E800CE01DF91CF91C7
+:1077A00008951F920F920FB60F9211242F933F93BB
+:1077B0008F938091E1001092E100282F83FF0FC08A
+:1077C0001092E90081E08093EB001092EC0082E3DC
+:1077D0008093ED001092900188E08093F00022FFEA
+:1077E00026C083E08093E9008091F200882319F09D
+:1077F0008AE38093E80080918E01882351F0809184
+:107800008E01815080938E0180918E01882309F42E
+:10781000769A80918F01882351F080918F01815059
+:1078200080938F0180918F01882309F4289A8F918A
+:107830003F912F910F900FBE0F901F9018951092AF
+:10784000900181E08093D70080EA8093D80082E1A4
+:1078500089BD09B400FEFDCF80E98093D8008CE09B
+:107860008093E2001092E00008950895DF93CF9393
+:107870000F92CDB7DEB71982CE010196A5DC8981C2
+:1078800090E00F90CF91DF9108951F920F920FB665
+:107890000F921124EF92FF921F932F933F934F93D8
+:1078A0005F936F937F938F939F93AF93BF93EF9368
+:1078B000FF93DF93CF93CDB7DEB76197DEBFCDBF28
+:1078C0001092E9008091E80083FFECC0CE010196A0
+:1078D00068E0F5DD82EF8093E800998197FF05C0AD
+:1078E0008091E80080FFFCCF03C08EEF8093E8001A
+:1078F000292F30E0C90180769070892B09F0B3C040
+:107900008A81882329F41092F1001092F100BFC0FF
+:10791000813009F4BCC0833009F4B9C0853049F422
+:107920008091E80080FFFCCF8B8180688093E3002A
+:10793000AEC0863009F06DC01C81EF80F884123033
+:10794000A9F51092E9001092920110929101109203
+:107950009401109293018ADF99E0FE013996DF01CC
+:10796000292F1D922A95E9F799871A8791E09E871A
+:1079700090E8988B9AEF998B209191013091920128
+:10798000275F3F4F3C872B878D871092E90010922D
+:10799000920110929101F0929401E092930180E0A3
+:1079A000BF0149E050E0AFDE61DF71C01092E90035
+:1079B0001092920110929101F0929401E092930141
+:1079C000113071F488E0E816F10411F41093950178
+:1079D00080919501882309F062C0E2E5F1E713C0C8
+:1079E000133009F058C08B81882319F4E4E1F1E7E2
+:1079F0000AC0823019F4E8E1F1E705C0813009F0EE
+:107A00004AC0EAE3F1E7449150E080E8BF017BDE41
+:107A10003EC0873009F43FC0883021F481E0809374
+:107A2000F10035C0893099F523703070232B99F51A
+:107A3000E7E7F1E791E031E026E39093E900309346
+:107A4000EB0084918093EC002093ED009F5F3196D2
+:107A5000943099F78EE78093EA001092EA008B81C8
+:107A60008093900114C08F8198851092E900109244
+:107A700092011092910190939401809393018D81D2
+:107A8000882349F4CE010196A9DB882321F08EEFEB
+:107A90008093E80007C081E28093EB0003C0E4E636
+:107AA000F1E7B1CF6196DEBFCDBFCF91DF91FF91FE
+:107AB000EF91BF91AF919F918F917F916F915F9166
+:107AC0004F913F912F911F91FF90EF900F900FBE1C
+:107AD0000F901F901895EE0FFF1F0590F491E02D69
+:067AE0000994F894FFCFA9
+:087AE60000E1000000000000B7
+:040000030000700089
:00000001FF
diff --git a/bootloaders/diskloader/DiskLoader-Micro.hex b/bootloaders/diskloader/DiskLoader-Micro.hex
deleted file mode 100644
index fbbcc52..0000000
--- a/bootloaders/diskloader/DiskLoader-Micro.hex
+++ /dev/null
@@ -1,113 +0,0 @@
-:1078000011241FBECFEFDAE0DEBFCDBFF2C04101D1
-:1078100042144505560455026403740300001E9586
-:1078200087020110030000C18081C106C0FF0A0069
-:107830000CA10185037508150026FF00954009017C
-:107840008102954009029102C004030904380341F2
-:107850000072006400750069006E006F0020004D2A
-:10786000006900630072006F00200062006F006F0B
-:107870000074006C006F00610064006500720020FD
-:1078800000200020001803410072006400750069A8
-:10789000006E006F0020004C004C004300120100FD
-:1078A00002020000404123350000010102000112E4
-:1078B00001000200000040412335000001010200E8
-:1078C00001090264000301008032080B0002020279
-:1078D000010009040000010202000005240010015B
-:1078E0000524010101042402020524060001070504
-:1078F000810310004009040100020A00000007058E
-:107900000202400000070583024000000904020053
-:107910000103000000092101010001221E000705EA
-:1079200084034000400020918A0130918B012C5F3C
-:107930003F4F30938B0120938A01C901892F9927EA
-:107940008695982F803418F08FE7891B982F990F10
-:10795000921710F447980895479A08955D9A289AC7
-:1079600081E08093E0001092E200EE27FF27099467
-:1079700008950F931F93CF93DF93982FEB01042F5C
-:1079800010E088E76030780730F411E083E0FB0115
-:1079900080935700E895892F68E071E0402FF8D078
-:1079A000112311F107B600FCFDCF402F4695FE01D3
-:1079B000A8E0B1E020E031E009C08D919D910C017B
-:1079C00030935700E895112432962F5F2417A8F3BF
-:1079D00085E0FE0180935700E89507B600FCFDCFD7
-:1079E00081E180935700E895DF91CF911F910F912E
-:1079F000089588E10FB6F8948093600010926000BB
-:107A00000FBE5D9A289A47983F9A209A559A90E817
-:107A1000909361001092610081E885BF95BF9FD06F
-:107A200084E18093880180E180938901E0E0F0E0C7
-:107A3000859194918F5F9F4F19F081E080938F0122
-:107A4000EE24FF24BB24B39454EFC52E51E0D52E71
-:107A50000ED2082F8EE098E7FC0124913196029611
-:107A60004491201711F02223B9F71092910110923E
-:107A7000900182E068E071E08BD0013479F460918C
-:107A800008016058633028F0683111F064E001C0EB
-:107A900063E0C62FD0E0CF5DD7480EC0063571F445
-:107AA00080910801803311F011E022C080910A0119
-:107AB000C82FD0E0C25ED74811E022C0053721F4BC
-:107AC00013E0CEE1D8E71CC0053539F4E090080199
-:107AD000F0900901EE0CFF1C0AC0043631F482E07C
-:107AE000B7014091090145DF02C0043721F010E0E1
-:107AF000C5E2D8E705C010910901E701E10EF11CCC
-:107B0000B6D18097B1F483E068E871E041E050E0DD
-:107B100059D0112329F0412F50E083E8BE0152D003
-:107B200083E469E871E041E050E04CD0013509F0B0
-:107B30008FCFD0929101C0929001B0928F01EE242C
-:107B4000FF2486CFFC01289884E680938D0104C031
-:107B50008091F100819361506623D1F708951092CE
-:107B600091011092900110928E0110928F0181E08C
-:107B70008093D70080EA8093D80082E189BD09B460
-:107B800000FEFDCF80E98093D8001092E0000895B8
-:107B9000FB018093E90024E69BE611C08091E80098
-:107BA00085FFFCCF289820938D018091F10081936F
-:107BB0008091E80085FD02C09093E8004150442385
-:107BC00069F70895982FFB01282F20728770809302
-:107BD000E90064E63AE317C08091E80085FFFCCF36
-:107BE00097FF02C0849101C080813196211180E00D
-:107BF0005D9860938C018093F1008091E80085FD91
-:107C000002C03093E800415050408FEF4F3F58077B
-:107C100019F796FF03C08AE38093E80008958091E6
-:107C20009301813299F45D9884E680938C0120E081
-:107C300030E003C080818093F100F901E050FF4FF4
-:107C40002F5F3F4F28303105A9F714C0803261F40F
-:107C50008091E80082FFFCCF80E091E067E072DF76
-:107C60008BEF8093E80006C0823221F4809194016A
-:107C70008093070181E0089520919501223261F1FE
-:107C8000213081F48091980190919901089711F425
-:107C900020939A0180919A01882309F04AC0EFEA63
-:107CA000F8E749C0223021F484E6E1ECF8E717C098
-:107CB000233009F03CC080919401882319F4E9E451
-:107CC000F8E739C0823019F4EDE4F8E734C08130C8
-:107CD00071F5E5E8F8E72FC081E0EBE2F8E7909175
-:107CE0009801382F981708F4392F90918C0120E0D3
-:107CF0004EEF8091E8008570E1F38091E80082FD0D
-:107D000012C02F5F84915D988093F100822F8F7352
-:107D100011F44093E800319694E6231750F39093C2
-:107D20008C0181E0089590938C0180E0089580E0BB
-:107D30000895EDE9F8E78491D2CF1092E90080919F
-:107D4000E80083FF61C082E991E068E0FBDE82EF3A
-:107D50008093E8008091920187FF05C08091E80040
-:107D600080FFFCCF03C08EEF8093E80080919301E9
-:107D7000853051F48091E80080FFFCCF8091940120
-:107D800080688093E30039C08930E1F480919401E8
-:107D900080938E01E7E2F8E791E031E026E39093EB
-:107DA000E9003093EB0084918093EC002093ED0088
-:107DB0009F5F3196953099F78EE78093EA00109295
-:107DC000EA001BC0883049F490918E015D9884E6EA
-:107DD00080938C019093F10010C0882339F45D9852
-:107DE00084E680938C011092F10007C0863011F474
-:107DF00043DF01C014DF882321F08EEF8093E80079
-:107E0000089581E28093EB0008958091E100109243
-:107E1000E100282F83FF0CC01092E90081E08093DD
-:107E2000EB001092EC0082E38093ED0010928E0143
-:107E300022FF1CC080918C01882331F081508093F7
-:107E40008C01882309F45D9A80918D01882331F09B
-:107E5000815080938D01882309F4289A80918F01A5
-:107E6000882321F4109291011092900108951F939C
-:107E7000CF93DF9312E0C0E9D1E05FDFC6DF10935C
-:107E8000E9008091E80085FF13C0289884E680937C
-:107E90008D019091F1008091E80085FD03C08BE693
-:107EA0008093E800892F90E0DF91CF911F91089592
-:107EB000809190019091910101979093910180930D
-:107EC00090018091900190919101892B09F446DDF8
-:0A7ED000CE010197F1F727DDD0CFB6
-:087EDA0000E1000000000000BF
-:040000030000780081
-:00000001FF
diff --git a/bootloaders/diskloader/Makefile b/bootloaders/diskloader/Makefile
index 6ac3db3..0ae99e8 100644
--- a/bootloaders/diskloader/Makefile
+++ b/bootloaders/diskloader/Makefile
@@ -1,105 +1,103 @@
-###############################################################################
-# Makefile for DiskLoader
-###############################################################################
-
-## General Flags
-PROJECT = DiskLoader
-TARGET = DiskLoader.elf
-CC = avr-gcc
-
-# BOARD2
-MCU = atmega32u4
-AVR_FREQ = 16000000L
-
+###############################################################################
+# Makefile for DiskLoader
+###############################################################################
+
+## General Flags
+PROJECT = DiskLoader
+TARGET = DiskLoader.elf
+CC = avr-gcc
+
+# BOARD2
+MCU = atmega32u4
+AVR_FREQ = 16000000L
+
# Specify the Arduino model using the assigned PID. This is used by Descriptors.c
# to set PID and product descriptor string
# Arduino Leonardo PID
ARDUINO_MODEL_PID = 0x0034
# Arduino Micro PID
-#ARDUINO_MODEL_PID = 0x0035
-
-# Change if your programmer is different
-AVRDUDE_PROGRAMMER = avrispmkII
-AVRDUDE_PORT = usb
-
-# program name should not be changed...
-PROGRAM = DiskLoader
-
-AVRDUDE = avrdude
-AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -p $(MCU)
-
-## Options common to compile, link and assembly rules
-COMMON = -mmcu=$(MCU)
-
-override CFLAGS = -g -Wall -Os -mmcu=$(MCU) -DF_CPU=$(AVR_FREQ) -DARDUINO_MODEL_PID=$(ARDUINO_MODEL_PID) $(DEFS) -ffunction-sections -gdwarf-2 -fdata-sections -fno-split-wide-types
-
-## Assembly specific flags
-ASMFLAGS = $(COMMON)
-ASMFLAGS += $(CFLAGS)
-ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
-
-## Linker flags
-LDFLAGS = $(COMMON)
-LDFLAGS += -Wl,-gc-sections,-Map=DiskLoader.map,--section-start=.text=0x7800,--relax
-LDFLAGS += -nodefaultlibs -nostartfiles
-
-
-## Intel Hex file production flags
-HEX_EEPROM_FLAGS = -j .eeprom
-HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
-HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
-
-## Objects explicitly added by the user
-LINKONLYOBJECTS =
-
-MODULES := .
-SRC_DIR := $(addprefix src/,$(MODULES))
-BUILD_DIR := $(addprefix build/,$(MODULES))
-
-SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp))
-OBJ := $(patsubst src/%.cpp,build/%.o,$(SRC))
-DEP := $(OBJ:%.o=%.d)
-INCLUDES := $(addprefix -I,$(SRC_DIR))
-
-vpath %.cpp $(SRC_DIR)
-
-.PHONY: all checkdirs clean
-
-all: checkdirs $(TARGET) DiskLoader.hex DiskLoader.lss size
-
--include $(DEP)
-
-checkdirs: $(BUILD_DIR)
-
-$(BUILD_DIR):
- @mkdir -p $@
-
-clean:
- @rm -rf build/
- @rm -f *.hex
- @rm -f *.elf
- @rm -f *.lss
- @rm -f *.map
-
-define make-goal
-$1/%.o: %.cpp
- $(CC) $(INCLUDES) $(CFLAGS) -c $$< -MD -o $$@
-endef
-
-$(foreach bdir,$(BUILD_DIR),$(eval $(call make-goal,$(bdir))))
-
-$(TARGET): $(OBJ)
- $(CC) $(LDFLAGS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) $^ -o $@
-
-%.hex: $(TARGET)
- avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@
-
-%.lss: $(TARGET)
- avr-objdump -h -S $< > $@
-
-size: $(TARGET)
- @echo
-# @avr-size -C --mcu=${MCU} ${TARGET}.elf
-
-program: $(TARGET).hex
- $(AVRDUDE) $(AVRDUDE_FLAGS) -B 5 -u -U flash:w:$(TARGET).hex \ No newline at end of file
+#ARDUINO_MODEL_PID = 0x0035
+
+# Change if your programmer is different
+AVRDUDE_PROGRAMMER = avrispmkII
+AVRDUDE_PORT = usb
+
+# program name should not be changed...
+PROGRAM = DiskLoader
+
+AVRDUDE = avrdude
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -p $(MCU)
+
+## Options common to compile, link and assembly rules
+COMMON = -mmcu=$(MCU)
+
+override CFLAGS = -g -Wall -Os -mmcu=$(MCU) -DF_CPU=$(AVR_FREQ) -DARDUINO_MODEL_PID=$(ARDUINO_MODEL_PID) $(DEFS) -ffunction-sections -gdwarf-2 -fdata-sections -fno-split-wide-types
+
+## Assembly specific flags
+ASMFLAGS = $(COMMON)
+ASMFLAGS += $(CFLAGS)
+ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
+
+## Linker flags
+LDFLAGS = $(COMMON)
+LDFLAGS += -Wl,-gc-sections,-Map=DiskLoader.map,--section-start=.text=0x7000,--relax
+
+## Intel Hex file production flags
+HEX_EEPROM_FLAGS = -j .eeprom
+HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
+HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
+
+## Objects explicitly added by the user
+LINKONLYOBJECTS =
+
+MODULES := .
+SRC_DIR := $(addprefix src/,$(MODULES))
+BUILD_DIR := $(addprefix build/,$(MODULES))
+
+SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp))
+OBJ := $(patsubst src/%.cpp,build/%.o,$(SRC))
+DEP := $(OBJ:%.o=%.d)
+INCLUDES := $(addprefix -I,$(SRC_DIR))
+
+vpath %.cpp $(SRC_DIR)
+
+.PHONY: all checkdirs clean
+
+all: checkdirs $(TARGET) DiskLoader.hex DiskLoader.lss size
+
+-include $(DEP)
+
+checkdirs: $(BUILD_DIR)
+
+$(BUILD_DIR):
+ @mkdir -p $@
+
+clean:
+ @rm -rf build/
+ @rm -f *.hex
+ @rm -f *.elf
+ @rm -f *.lss
+ @rm -f *.map
+
+define make-goal
+$1/%.o: %.cpp
+ $(CC) $(INCLUDES) $(CFLAGS) -c $$< -MD -o $$@
+endef
+
+$(foreach bdir,$(BUILD_DIR),$(eval $(call make-goal,$(bdir))))
+
+$(TARGET): $(OBJ)
+ $(CC) $(LDFLAGS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) $^ -o $@
+
+%.hex: $(TARGET)
+ avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@
+
+%.lss: $(TARGET)
+ avr-objdump -h -S $< > $@
+
+size: $(TARGET)
+ @echo
+# @avr-size -C --mcu=${MCU} ${TARGET}.elf
+
+program: $(TARGET).hex
+ $(AVRDUDE) $(AVRDUDE_FLAGS) -B 1 -u -U flash:w:$(TARGET).hex
diff --git a/bootloaders/diskloader/src/CDC.cpp b/bootloaders/diskloader/src/CDC.cpp
new file mode 100644
index 0000000..4496a9c
--- /dev/null
+++ b/bootloaders/diskloader/src/CDC.cpp
@@ -0,0 +1,93 @@
+
+
+/* Copyright (c) 2011, Peter Barrett
+**
+** Permission to use, copy, modify, and/or distribute this software for
+** any purpose with or without fee is hereby granted, provided that the
+** above copyright notice and this permission notice appear in all copies.
+**
+** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
+** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
+** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+** SOFTWARE.
+*/
+
+#include "Platform.h"
+#include "USBAPI.h"
+#include <avr/wdt.h>
+
+#if defined(USBCON)
+
+typedef struct
+{
+ u32 dwDTERate;
+ u8 bCharFormat;
+ u8 bParityType;
+ u8 bDataBits;
+ u8 lineState;
+} LineInfo;
+
+static volatile LineInfo _usbLineInfo = { 57600, 0x00, 0x00, 0x00, 0x00 };
+
+#define WEAK __attribute__ ((weak))
+
+extern const CDCDescriptor _cdcInterface PROGMEM;
+const CDCDescriptor _cdcInterface =
+{
+ D_IAD(0,2,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,1),
+
+ // CDC communication interface
+ D_INTERFACE(CDC_ACM_INTERFACE,1,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0),
+ D_CDCCS(CDC_HEADER,0x10,0x01), // Header (1.10 bcd)
+ D_CDCCS(CDC_CALL_MANAGEMENT,1,1), // Device handles call management (not)
+ D_CDCCS4(CDC_ABSTRACT_CONTROL_MANAGEMENT,6), // SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported
+ D_CDCCS(CDC_UNION,CDC_ACM_INTERFACE,CDC_DATA_INTERFACE), // Communication interface is master, data interface is slave 0
+ D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_ACM),USB_ENDPOINT_TYPE_INTERRUPT,0x10,0x40),
+
+ // CDC data interface
+ D_INTERFACE(CDC_DATA_INTERFACE,2,CDC_DATA_INTERFACE_CLASS,0,0),
+ D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,0x40,0),
+ D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,0x40,0)
+};
+
+int WEAK CDC_GetInterface(u8* interfaceNum)
+{
+ interfaceNum[0] += 2; // uses 2
+ return USB_SendControl(TRANSFER_PGM,&_cdcInterface,sizeof(_cdcInterface));
+}
+
+bool WEAK CDC_Setup(Setup& setup)
+{
+ u8 r = setup.bRequest;
+ u8 requestType = setup.bmRequestType;
+
+ if (REQUEST_DEVICETOHOST_CLASS_INTERFACE == requestType)
+ {
+ if (CDC_GET_LINE_CODING == r)
+ {
+ USB_SendControl(0,(void*)&_usbLineInfo,7);
+ return true;
+ }
+ }
+
+ if (REQUEST_HOSTTODEVICE_CLASS_INTERFACE == requestType)
+ {
+ if (CDC_SET_LINE_CODING == r)
+ {
+ USB_RecvControl((void*)&_usbLineInfo,7);
+ return true;
+ }
+
+ if (CDC_SET_CONTROL_LINE_STATE == r)
+ {
+ _usbLineInfo.lineState = setup.wValueL;
+ return true;
+ }
+ }
+ return false;
+}
+#endif /* if defined(USBCON) */
diff --git a/bootloaders/diskloader/src/DiskLoader.cpp b/bootloaders/diskloader/src/DiskLoader.cpp
index 6580618..30ac1b6 100644
--- a/bootloaders/diskloader/src/DiskLoader.cpp
+++ b/bootloaders/diskloader/src/DiskLoader.cpp
@@ -1,64 +1,67 @@
-
+/*
+ * DiskLoader.cpp
+ */
#include "Platform.h"
-// This bootloader creates a composite Serial device
-//
-// The serial interface supports a STK500v1 protocol that is very similar to optiboot
-//
-// The bootloader will timeout and start the firmware after a few hundred milliseconds
-// if a usb connection is not detected.
-//
-// The tweakier code is to keep the bootloader below 2k (no interrupt table, for example)
-
extern "C"
void entrypoint(void) __attribute__ ((naked)) __attribute__ ((section (".vectors")));
void entrypoint(void)
{
asm volatile (
- "eor r1, r1\n" // Zero register
- "out 0x3F, r1\n" // SREG
- "ldi r28, 0xFF\n"
- "ldi r29, 0x0A\n"
- "out 0x3E, r29\n" // SPH
- "out 0x3D, r28\n" // SPL
- "rjmp main" // Stack is all set up, start the main code
- ::);
+ "eor r1, r1\n" // Zero register
+ "out 0x3F, r1\n" // SREG
+ "ldi r28, 0xFF\n" // Y-register
+ "ldi r29, 0x0A\n" // Y-register
+ "out 0x3E, r29\n" // SPH
+ "out 0x3D, r28\n" // SPL
+ "rjmp main" // Stack is all set up, start the main code
+ ::);
}
u8 _flashbuf[128];
u8 _inSync;
u8 _ok;
-extern volatile u8 _ejected;
-extern volatile u16 _timeout;
+u16 do_reset = 0;
+volatile u16 _timeout = 0;
void Program(u8 ep, u16 page, u8 count)
{
- u8 write = page < 30*1024; // Don't write over firmware please
+ u8 write = page < 28*1024; // Don't write over bootloader please
if (write)
boot_page_erase(page);
-
- Recv(ep,_flashbuf,count); // Read while page is erasing
-
+
+ USB_Recv_block(ep,_flashbuf,count); // Read while page is erasing
+
if (!write)
return;
-
+
boot_spm_busy_wait(); // Wait until the memory is erased.
-
+
count >>= 1;
u16* p = (u16*)page;
u16* b = (u16*)_flashbuf;
for (u8 i = 0; i < count; i++)
boot_page_fill(p++, b[i]);
-
+
boot_page_write(page);
boot_spm_busy_wait();
boot_rww_enable ();
}
-
-int USBGetChar();
-#define getch USBGetChar
+u16 _pulse;
+void LEDPulse()
+{
+ _pulse += 1;
+ u8 p = _pulse >> 9;
+ if (p > 63)
+ p = 127-p;
+ p += p;
+ if (((u8)_pulse) > p)
+ L_LED_OFF();
+ else
+ L_LED_ON();
+}
#define HW_VER 0x02
#define SW_MAJOR 0x01
@@ -104,136 +107,144 @@ const u8 _consts[] =
0x00, //
};
+void start_sketch()
+{
+ L_LED_OFF();
+ RX_LED_OFF();
+ TX_LED_OFF();
+ /* move interrupts to application section:
+ * uses inline assembly because the procedure must be completed in four cycles.
+ */
+ cli(); // disable interrupts first
+ asm volatile (
+ "ldi r16, 0x01\n" // (1<<IVCE) /* Enable change of interrupt vectors */
+ "out 0x35, r16\n" // MCUCR
+ "ldi r16, 0x00\n" // (1<<IVSEL) /* Move interrupts to application flash section */
+ "out 0x35, r16\n" // MCUCR
+ );
+ UDCON = 1; // Detatch USB
+ UDIEN = 0;
+ asm volatile ( // Reset vector to run firmware
+ "clr r30\n"
+ "clr r31\n"
+ "ijmp\n"
+ ::);
+}
-void USBInit(void);
int main(void) __attribute__ ((naked));
-
-// STK500v1 main loop, very similar to optiboot in protocol and implementation
-int main()
-{
+int main()
+{
wdt_disable();
- TXLED0;
- RXLED0;
- LED0;
BOARD_INIT();
- USBInit();
-
+ /* move interrupts to boot section:
+ * uses inline assembly because the procedure must be completed in four cycles.
+ * seems to fail if called before disabling WDT and calling BOARD_INIT()
+ */
+ asm volatile (
+ "ldi r16, 0x01\n" // (1<<IVCE) /* Enable change of interrupt vectors */
+ "out 0x35, r16\n" // MCUCR
+ "ldi r16, 0x02\n" // (1<<IVSEL) /* Move interrupts to boot flash section */
+ "out 0x35, r16\n" // MCUCR
+ );
+ TX_LED_OFF();
+ RX_LED_OFF();
+ L_LED_OFF();
+ USB.attach();
+ sei();
+
_inSync = STK_INSYNC;
_ok = STK_OK;
-
- if (pgm_read_word(0) != -1)
- _ejected = 1;
-
- for(;;)
+
+ for (;;)
{
u8* packet = _flashbuf;
u16 address = 0;
for (;;)
- {
- u8 cmd = getch();
-
- // Read packet contents
- u8 len;
- const u8* rs = _readSize;
- for(;;)
+ {
+ if (USB_Available(CDC_RX))
{
- u8 c = pgm_read_byte(rs++);
- len = pgm_read_byte(rs++);
- if (c == cmd || c == 0)
+ u8 cmd = USB_Recv(CDC_RX);
+
+ // Read packet contents
+ u8 len;
+ const u8* rs = _readSize;
+ for (;;)
+ {
+ u8 c = pgm_read_byte(rs++);
+ len = pgm_read_byte(rs++);
+ if (c == cmd || c == 0)
+ break;
+ }
+ _timeout = 0;
+ // Read params
+ USB_Recv_block(CDC_RX, packet, len);
+
+ // Send a response
+ u8 send = 0;
+ const u8* pgm = _consts+7;
+ if (STK_GET_PARAMETER == cmd)
+ {
+ u8 i = packet[0] - 0x80;
+ if (i > 2)
+ i = (i==0x18) ? 3 : 4;
+ pgm = _consts + i + 3;
+ send = 1;
+ }
+ else if (STK_UNIVERSAL == cmd)
+ {
+ if (packet[0] == 0x30)
+ pgm = _consts + packet[2];
+ send = 1;
+ }
+ else if (STK_READ_SIGN == cmd)
+ {
+ pgm = _consts;
+ send = 3;
+ }
+ else if (STK_LOAD_ADDRESS == cmd)
+ {
+ address = *((u16*)packet); // word address
+ address += address;
+ }
+ else if (STK_PROG_PAGE == cmd)
+ {
+ Program(CDC_RX, address, packet[1]);
+ }
+ else if (STK_READ_PAGE == cmd)
+ {
+ send = packet[1];
+ pgm = (const u8*)address;
+ address += send;
+ }
+
+ u16 countdown = 5000;
+ while (countdown-- > 10 && !USB_Available(CDC_RX))
+ ;
+ int x = USB_Recv(CDC_RX);
+ if (x != -1 && x != ' ')
break;
+
+ USB_Send(CDC_TX, &_inSync, 1);
+
+ if (send)
+ USB_Send(CDC_TX|TRANSFER_PGM, pgm, send);
+
+ // Send ok
+ USB_Send(CDC_TX|TRANSFER_RELEASE, &_ok, 1);
+
+ if ('Q' == cmd)
+ {
+ _delay_ms(100);
+ start_sketch();
+ }
}
- _timeout = 0;
- // Read params
- Recv(CDC_RX,packet,len);
-
- // Send a response
- u8 send = 0;
- const u8* pgm = _consts+7; // 0
- if (STK_GET_PARAMETER == cmd)
+ else
{
- u8 i = packet[0] - 0x80;
- if (i > 2)
- i = (i == 0x18) ? 3 : 4; // 0x80:HW_VER,0x81:SW_MAJOR,0x82:SW_MINOR,0x18:3 or 0
- pgm = _consts + i + 3;
- send = 1;
+ LEDPulse();
+ _delay_us(100);
+ if (_timeout-- == 1)
+ start_sketch();
}
-
- else if (STK_UNIVERSAL == cmd)
- {
- if (packet[0] == 0x30)
- pgm = _consts + packet[2]; // read signature
- send = 1;
- }
-
- // Read signature bytes
- else if (STK_READ_SIGN == cmd)
- {
- pgm = _consts;
- send = 3;
- }
-
- else if (STK_LOAD_ADDRESS == cmd)
- {
- address = *((u16*)packet); // word addresses
- address += address;
- }
-
- else if (STK_PROG_PAGE == cmd)
- {
- Program(CDC_RX,address,packet[1]);
- }
-
- else if (STK_READ_PAGE == cmd)
- {
- send = packet[1];
- pgm = (const u8*)address;
- address += send; // not sure of this is required
- }
-
- // Check sync
- if (getch() != ' ')
- break;
- Transfer(CDC_TX,&_inSync,1);
-
- // Send result
- if (send)
- Transfer(CDC_TX|TRANSFER_PGM,pgm,send); // All from pgm memory
-
- // Send ok
- Transfer(CDC_TX|TRANSFER_RELEASE,&_ok,1);
-
- if (cmd == 'Q')
- break;
}
- _timeout = 500; // wait a moment before exiting the bootloader - may need to finish responding to 'Q' for example
- _ejected = 1;
}
}
-
-// Nice breathing LED indicates we are in the firmware
-u16 _pulse;
-void LEDPulse()
-{
- _pulse += 4;
- u8 p = _pulse >> 9;
- if (p > 63)
- p = 127-p;
- p += p;
- if (((u8)_pulse) > p)
- LED0;
- else
- LED1;
-}
-
-void Reboot()
-{
- TXLED0; // switch off the RX and TX LEDs before starting the user sketch
- RXLED0;
- UDCON = 1; // Detatch USB
- UDIEN = 0;
- asm volatile ( // Reset vector to run firmware
- "clr r30\n"
- "clr r31\n"
- "ijmp\n"
- ::);
-}
diff --git a/bootloaders/diskloader/src/Platform.h b/bootloaders/diskloader/src/Platform.h
index 6acbf39..f1194a5 100644
--- a/bootloaders/diskloader/src/Platform.h
+++ b/bootloaders/diskloader/src/Platform.h
@@ -1,3 +1,9 @@
+/*
+ * Platform.h
+ */
+
+#ifndef __PLATFORM_H__
+#define __PLATFORM_H__
#include <inttypes.h>
#include <avr/io.h>
@@ -11,39 +17,50 @@
#include <stdlib.h>
#include <string.h>
+#ifdef __cplusplus
+extern "C"{
+#endif
+
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;
-
-#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
-#define DISABLE_JTAG() MCUCR = (1 << JTD) | (1 << IVCE) | (0 << PUD); MCUCR = (1 << JTD) | (0 << IVSEL) | (0 << IVCE) | (0 << PUD);
-
#define USB_PID_LEONARDO 0x0034
#define USB_PID_MICRO 0x0035
#define USB_VID 0x2341 // arduino LLC vid
#define USB_PID ARDUINO_MODEL_PID // passed in by Makefile - 0x0034 for Leonardo, 0x0035 for MIcro
-#define OEM_NAME 'l','e','o','n','a','r','d','o' // 8 chars
-#define BOARD_INIT() DDRC |= (1<<7); DDRB |= (1<<0); DDRD |= (1<<5); CPU_PRESCALE(0); DISABLE_JTAG();
-#define LED0 PORTC &= ~(1<<7)
-#define LED1 PORTC |= (1<<7)
-#define TXLED0 PORTD |= (1<<5)
-#define TXLED1 PORTD &= ~(1<<5)
-#define RXLED0 PORTB |= (1<<0)
-#define RXLED1 PORTB &= ~(1<<0)
+#define min(a,b) ((a)<(b)?(a):(b))
-#define TRANSFER_PGM 0x80
-#define TRANSFER_RELEASE 0x40
-#define TRANSFER_ZERO 0x20
+#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
+#define DISABLE_JTAG() MCUCR = (1 << JTD) | (1 << IVCE) | (0 << PUD); MCUCR = (1 << JTD) | (0 << IVSEL) | (0 << IVCE) | (0 << PUD)
-void Transfer(u8 ep, const u8* data, int len);
-void Recv(u8 ep, u8* dst, u8 len);
-void Program(u8 ep, u16 page, u8 count);
+#define BOARD_INIT() DDRC |= (1<<7); DDRB |= (1<<0); DDRE |= (1<<6); CPU_PRESCALE(0); DISABLE_JTAG(); // for XXX-series boards
+//#define BOARD_INIT() DDRC |= (1<<7); DDRB |= (1<<0); DDRD |= (1<<5); CPU_PRESCALE(0); DISABLE_JTAG(); // for non-XXX boards
-#define CDC_ENABLED
+// for XXX-series boards
+#define TX_LED_OFF() PORTE |= (1<<6)
+#define TX_LED_ON() PORTE &= ~(1<<6)
+#define RX_LED_OFF() PORTB |= (1<<0)
+#define RX_LED_ON() PORTB &= ~(1<<0)
+#define L_LED_OFF() PORTC &= ~(1<<7)
+#define L_LED_ON() PORTC |= (1<<7)
+#define L_LED_TOGGLE() PORTC ^= (1<<7)
-#include "USBCore.h"
-#include "USBDesc.h"
+// these for non-XXX boards
+//#define LED0 PORTC &= ~(1<<7)
+//#define LED1 PORTC |= (1<<7)
+//#define TXLED0 PORTD |= (1<<5)
+//#define TXLED1 PORTD &= ~(1<<5)
+//#define RXLED0 PORTB |= (1<<0)
+//#define RXLED1 PORTB &= ~(1<<0)
+#ifdef __cplusplus
+} /* extern "C"{ */
+#endif
+
+#include "USBDesc.h"
+#include "USBCore.h"
+#include "USBAPI.h"
+#endif /* __PLATFORM_H__ */
diff --git a/bootloaders/diskloader/src/USBAPI.h b/bootloaders/diskloader/src/USBAPI.h
new file mode 100644
index 0000000..f8d71c8
--- /dev/null
+++ b/bootloaders/diskloader/src/USBAPI.h
@@ -0,0 +1,64 @@
+
+
+#ifndef __USBAPI__
+#define __USBAPI__
+
+#if defined(USBCON)
+
+//================================================================================
+//================================================================================
+// USB
+
+class USB_
+{
+public:
+ USB_();
+ bool configured();
+
+ void attach();
+ void detach(); // Serial port goes down too...
+ void poll();
+};
+extern USB_ USB;
+
+//================================================================================
+//================================================================================
+// Low level API
+
+typedef struct
+{
+ uint8_t bmRequestType;
+ uint8_t bRequest;
+ uint8_t wValueL;
+ uint8_t wValueH;
+ uint16_t wIndex;
+ uint16_t wLength;
+} Setup;
+
+//================================================================================
+//================================================================================
+// CDC 'Driver'
+
+int CDC_GetInterface(uint8_t* interfaceNum);
+int CDC_GetDescriptor(int i);
+bool CDC_Setup(Setup& setup);
+
+//================================================================================
+//================================================================================
+
+#define TRANSFER_PGM 0x80
+#define TRANSFER_RELEASE 0x40
+#define TRANSFER_ZERO 0x20
+
+int USB_SendControl(uint8_t flags, const void* d, int len);
+int USB_RecvControl(void* d, int len);
+
+uint8_t USB_Available(uint8_t ep);
+int USB_Send(uint8_t ep, const void* data, int len); // blocking
+int USB_Recv(uint8_t ep, void* data, int len); // non-blocking
+void USB_Recv_block(u8 ep, u8* dst, int len); // blocking
+int USB_Recv(uint8_t ep); // non-blocking
+void USB_Flush(uint8_t ep);
+
+#endif
+#endif /* if defined(USBCON) */
diff --git a/bootloaders/diskloader/src/USBCore.cpp b/bootloaders/diskloader/src/USBCore.cpp
index ca74721..6518ae9 100644
--- a/bootloaders/diskloader/src/USBCore.cpp
+++ b/bootloaders/diskloader/src/USBCore.cpp
@@ -1,5 +1,4 @@
-
/* Copyright (c) 2010, Peter Barrett
**
** Permission to use, copy, modify, and/or distribute this software for
@@ -17,9 +16,10 @@
*/
#include "Platform.h"
+#include "USBAPI.h"
+#include "USBDesc.h"
-#define CDC_TX CDC_ENDPOINT_IN
-#define CDC_RX CDC_ENDPOINT_OUT
+#if defined(USBCON)
#define EP_TYPE_CONTROL 0x00
#define EP_TYPE_BULK_IN 0x81
@@ -31,32 +31,50 @@
/** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */
#define TX_RX_LED_PULSE_MS 100
-u8 TxLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */
-u8 RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */
-
-void Reboot();
+volatile u8 TxLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */
+volatile u8 RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */
//==================================================================
//==================================================================
-typedef struct
-{
- u32 dwDTERate;
- u8 bCharFormat;
- u8 bParityType;
- u8 bDataBits;
- u8 lineState;
-} LineInfo;
+extern const u16 STRING_LANGUAGE[] PROGMEM;
+extern const u16 STRING_IPRODUCT[] PROGMEM;
+extern const u16 STRING_IMANUFACTURER[] PROGMEM;
+extern const DeviceDescriptor USB_DeviceDescriptor PROGMEM;
+extern const DeviceDescriptor USB_DeviceDescriptorA PROGMEM;
-static volatile LineInfo _usbLineInfo = { 57600, 0x00, 0x00, 0x00, 0x00 };
+const u16 STRING_LANGUAGE[2] = {
+ (3<<8) | (2+2),
+ 0x0409 // English
+};
+
+const u16 STRING_IPRODUCT[17] = {
+ (3<<8) | (2+2*16),
+#if USB_PID == USB_PID_LEONARDO
+ 'A','r','d','u','i','n','o',' ','L','e','o','n','a','r','d','o'
+#elif USB_PID == USB_PID_MICRO
+ 'A','r','d','u','i','n','o',' ','M','i','c','r','o',' ',' ',' '
+#endif
+};
+
+const u16 STRING_IMANUFACTURER[12] = {
+ (3<<8) | (2+2*11),
+ 'A','r','d','u','i','n','o',' ','L','L','C'
+};
+
+#define DEVICE_CLASS 0x02
+
+// DEVICE DESCRIPTOR
+const DeviceDescriptor USB_DeviceDescriptor =
+ D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
+
+const DeviceDescriptor USB_DeviceDescriptorA =
+ D_DEVICE(DEVICE_CLASS,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
//==================================================================
//==================================================================
-// 4 bytes of RAM
-volatile u8 _usbConfiguration;
-volatile u8 _ejected;
-volatile u16 _timeout;
+volatile u8 _usbConfiguration = 0;
static inline void WaitIN(void)
{
@@ -86,34 +104,25 @@ static inline void ClearOUT(void)
UEINTX = ~(1<<RXOUTI);
}
-static
-void Send(volatile const u8* data, u8 count)
-{
- TXLED1; // light the TX LED
- TxLEDPulse = TX_RX_LED_PULSE_MS;
- while (count--)
- UEDATX = *data++;
-}
-
void Recv(volatile u8* data, u8 count)
{
- RXLED1; // light the RX LED
- RxLEDPulse = TX_RX_LED_PULSE_MS;
while (count--)
*data++ = UEDATX;
+
+ RX_LED_ON();
+ RxLEDPulse = TX_RX_LED_PULSE_MS;
}
static inline u8 Recv8()
{
- RXLED1; // light the RX LED
+ RX_LED_ON();
RxLEDPulse = TX_RX_LED_PULSE_MS;
- return UEDATX;
+
+ return UEDATX;
}
static inline void Send8(u8 d)
{
- TXLED1; // light the TX LED
- TxLEDPulse = TX_RX_LED_PULSE_MS;
UEDATX = d;
}
@@ -175,48 +184,37 @@ static inline u8 FrameNumber()
//==================================================================
//==================================================================
-#define EP_SINGLE_64 0x32 // EP0
-#define EP_DOUBLE_64 0x36 // Other endpoints
-
-static void InitEP(u8 index, u8 type, u8 size)
-{
- UENUM = index;
- UECONX = 1;
- UECFG0X = type;
- UECFG1X = size;
-}
-
-// API
-void USBInit(void)
-{
- _timeout = 0;
- _usbConfiguration = 0;
- _ejected = 0;
-
- UHWCON = 0x01; // power internal reg (don't need this?)
- USBCON = (1<<USBE)|(1<<FRZCLK); // clock frozen, usb enabled
- PLLCSR = 0x12; // Need 16 MHz xtal
- while (!(PLLCSR & (1<<PLOCK))) // wait for lock pll
- ;
- USBCON = ((1<<USBE)|(1<<OTGPADE)); // start USB clock
- UDCON = 0; // enable attach resistor
-}
-
u8 USBGetConfiguration(void)
{
return _usbConfiguration;
}
-u8 HasData(u8 ep)
+#define USB_RECV_TIMEOUT
+class LockEP
{
- SetEP(ep);
- return ReadWriteAllowed(); // count in fifo
+ u8 _sreg;
+public:
+ LockEP(u8 ep) : _sreg(SREG)
+ {
+ cli();
+ SetEP(ep & 7);
+ }
+ ~LockEP()
+ {
+ SREG = _sreg;
+ }
+};
+
+// Number of bytes, assumes a rx endpoint
+u8 USB_Available(u8 ep)
+{
+ LockEP lock(ep);
+ return FifoByteCount();
}
-int USBGetChar();
-void Recv(u8 ep, u8* dst, u8 len)
+void USB_Recv_block(u8 ep, u8* dst, int len)
{
- SetEP(ep);
+ LockEP lock(ep);
while (len--)
{
while (!ReadWriteAllowed())
@@ -224,47 +222,119 @@ void Recv(u8 ep, u8* dst, u8 len)
*dst++ = Recv8();
if (!ReadWriteAllowed()) // release empty buffer
ReleaseRX();
- }
+ }
}
-// Transmit a packet to endpoint
-void Transfer(u8 ep, const u8* data, int len)
+// Non Blocking receive
+// Return number of bytes read
+int USB_Recv(u8 ep, void* d, int len)
{
- u8 zero = ep & TRANSFER_ZERO;
- SetEP(ep & 7);
- while (len--)
- {
- while (!ReadWriteAllowed())
- ; // TODO Check for STALL etc
+ if (!_usbConfiguration || len < 0)
+ return -1;
+
+ LockEP lock(ep);
+ u8 n = FifoByteCount();
+ len = min(n,len);
+ n = len;
+ u8* dst = (u8*)d;
+ while (n--)
+ *dst++ = Recv8();
+ if (len && !FifoByteCount()) // release empty buffer
+ ReleaseRX();
+
+ return len;
+}
- u8 d = (ep & TRANSFER_PGM) ? pgm_read_byte(data) : data[0];
- data++;
- if (zero)
- d = 0;
- Send8(d);
+// Recv 1 byte if ready
+int USB_Recv(u8 ep)
+{
+ u8 c;
+ if (USB_Recv(ep,&c,1) != 1)
+ return -1;
+ return c;
+}
+
+// Space in send EP
+u8 USB_SendSpace(u8 ep)
+{
+ LockEP lock(ep);
+ if (!ReadWriteAllowed())
+ return 0;
+ return 64 - FifoByteCount();
+}
+
+// Blocking Send of data to an endpoint
+int USB_Send(u8 ep, const void* d, int len)
+{
+ if (!_usbConfiguration)
+ return -1;
+
+ int r = len;
+ const u8* data = (const u8*)d;
+ while (len)
+ {
+ u8 n = USB_SendSpace(ep);
+ if (n == 0)
+ {
+ _delay_ms(1);
+ continue;
+ }
- if (!ReadWriteAllowed())
- ReleaseTX();
+ if (n > len)
+ n = len;
+ len -= n;
+ {
+ LockEP lock(ep);
+ if (ep & TRANSFER_ZERO)
+ {
+ while (n--)
+ Send8(0);
+ }
+ else if (ep & TRANSFER_PGM)
+ {
+ while (n--)
+ Send8(pgm_read_byte(data++));
+ }
+ else
+ {
+ while (n--)
+ Send8(*data++);
+ }
+ if (!ReadWriteAllowed() || ((len == 0) && (ep & TRANSFER_RELEASE))) // Release full buffer
+ ReleaseTX();
+ }
}
if (ep & TRANSFER_RELEASE)
ReleaseTX();
+
+ TX_LED_ON();
+ TxLEDPulse = TX_RX_LED_PULSE_MS;
+ return r;
}
extern const u8 _initEndpoints[] PROGMEM;
const u8 _initEndpoints[] =
{
0,
-
-#ifdef CDC_ENABLED
EP_TYPE_INTERRUPT_IN, // CDC_ENDPOINT_ACM
EP_TYPE_BULK_OUT, // CDC_ENDPOINT_OUT
EP_TYPE_BULK_IN, // CDC_ENDPOINT_IN
-#endif
-
- EP_TYPE_INTERRUPT_IN, // HID_ENDPOINT_INT
};
-static void InitEndpoints()
+#define EP_SINGLE_64 0x32 // EP0
+#define EP_DOUBLE_64 0x36 // Other endpoints
+
+static
+void InitEP(u8 index, u8 type, u8 size)
+{
+ UENUM = index;
+ UECONX = 1;
+ UECFG0X = type;
+ UECFG1X = size;
+}
+
+static
+void InitEndpoints()
{
for (u8 i = 1; i < sizeof(_initEndpoints); i++)
{
@@ -277,99 +347,113 @@ static void InitEndpoints()
UERST = 0;
}
-typedef struct
+// Handle CLASS_INTERFACE requests
+static
+bool ClassInterfaceRequest(Setup& setup)
{
- u8 bmRequestType;
- u8 bRequest;
- u8 wValueL;
- u8 wValueH;
- u16 wIndex;
- u16 wLength;
-} Setup;
-Setup _setup;
+ u8 i = setup.wIndex;
-//bool USBHook(Setup& setup)
-bool USBHook()
-{
- Setup& setup = _setup;
- u8 r = setup.bRequest;
+ if (CDC_ACM_INTERFACE == i)
+ return CDC_Setup(setup);
- // CDC Requests
- if (CDC_GET_LINE_CODING == r)
- {
- Send((const volatile u8*)&_usbLineInfo,7);
- }
+ return false;
+}
+
+int _cmark;
+int _cend;
+void InitControl(int end)
+{
+ SetEP(0);
+ _cmark = 0;
+ _cend = end;
+}
- else if (CDC_SET_LINE_CODING == r)
+static
+bool SendControl(u8 d)
+{
+ if (_cmark < _cend)
{
- WaitOUT();
- Recv((volatile u8*)&_usbLineInfo,7);
- ClearOUT();
+ if (!WaitForINOrOUT())
+ return false;
+ Send8(d);
+ if (!((_cmark + 1) & 0x3F))
+ ClearIN(); // Fifo is full, release this packet
}
+ _cmark++;
+ return true;
+};
- else if (CDC_SET_CONTROL_LINE_STATE == r)
+// Clipped by _cmark/_cend
+int USB_SendControl(u8 flags, const void* d, int len)
+{
+ int sent = len;
+ const u8* data = (const u8*)d;
+ bool pgm = flags & TRANSFER_PGM;
+ while (len--)
{
- _usbLineInfo.lineState = setup.wValueL;
+ u8 c = pgm ? pgm_read_byte(data++) : *data++;
+ if (!SendControl(c))
+ return -1;
}
-
- return true;
+ return sent;
}
-extern const u8 _rawHID[] PROGMEM;
-#define LSB(_x) ((_x) & 0xFF)
-#define MSB(_x) ((_x) >> 8)
-
-#define RAWHID_USAGE_PAGE 0xFFC0
-#define RAWHID_USAGE 0x0C00
-#define RAWHID_TX_SIZE 64
-#define RAWHID_RX_SIZE 64
-
-const u8 _rawHID[] =
+// Does not timeout or cross fifo boundaries
+// Will only work for transfers <= 64 bytes
+// TODO
+int USB_RecvControl(void* d, int len)
{
- // RAW HID
- 0x06, LSB(RAWHID_USAGE_PAGE), MSB(RAWHID_USAGE_PAGE), // 30
- 0x0A, LSB(RAWHID_USAGE), MSB(RAWHID_USAGE),
+ WaitOUT();
+ Recv((u8*)d,len);
+ ClearOUT();
+ return len;
+}
- 0xA1, 0x01, // Collection 0x01
- 0x85, 0x03, // REPORT_ID (3)
- 0x75, 0x08, // report size = 8 bits
- 0x15, 0x00, // logical minimum = 0
- 0x26, 0xFF, 0x00, // logical maximum = 255
+int SendInterfaces()
+{
+ int total = 0;
+ u8 interfaces = 0;
+ total = CDC_GetInterface(&interfaces);
+ return interfaces;
+}
- 0x95, 64, // report count TX
- 0x09, 0x01, // usage
- 0x81, 0x02, // Input (array)
+// Construct a dynamic configuration descriptor
+// This really needs dynamic endpoint allocation etc
+// TODO
+static
+bool SendConfiguration(int maxlen)
+{
+ // Count and measure interfaces
+ InitControl(0);
+ int interfaces = SendInterfaces();
+ ConfigDescriptor config = D_CONFIG(_cmark + sizeof(ConfigDescriptor),interfaces);
- 0x95, 64, // report count RX
- 0x09, 0x02, // usage
- 0x91, 0x02, // Output (array)
- 0xC0 // end collection
-};
+ // Now send them
+ InitControl(maxlen);
+ USB_SendControl(0,&config,sizeof(ConfigDescriptor));
+ SendInterfaces();
+ return true;
+}
u8 _cdcComposite = 0;
-bool SendDescriptor()
+static
+bool SendDescriptor(Setup& setup)
{
- Setup& setup = _setup;
+ u8 t = setup.wValueH;
+ if (USB_CONFIGURATION_DESCRIPTOR_TYPE == t)
+ return SendConfiguration(setup.wLength);
+
+ InitControl(setup.wLength);
+
u8 desc_length = 0;
const u8* desc_addr = 0;
-
- u8 t = setup.wValueH;
- if (0x22 == t)
- {
- desc_addr = _rawHID;
- desc_length = sizeof(desc_length);
- } else if (USB_DEVICE_DESCRIPTOR_TYPE == t)
+ if (USB_DEVICE_DESCRIPTOR_TYPE == t)
{
if (setup.wLength == 8)
_cdcComposite = 1;
desc_addr = _cdcComposite ? (const u8*)&USB_DeviceDescriptorA : (const u8*)&USB_DeviceDescriptor;
}
- else if (USB_CONFIGURATION_DESCRIPTOR_TYPE == t)
- {
- desc_addr = (const u8*)&USB_ConfigDescriptor;
- desc_length = sizeof(USB_ConfigDescriptor);
- }
else if (USB_STRING_DESCRIPTOR_TYPE == t)
{
if (setup.wValueL == 0)
@@ -380,81 +464,106 @@ bool SendDescriptor()
desc_addr = (const u8*)&STRING_IMANUFACTURER;
else
return false;
- } else
- return false;
+ }
+ if (desc_addr == 0)
+ return false;
if (desc_length == 0)
desc_length = pgm_read_byte(desc_addr);
- if ((u8)setup.wLength < desc_length) // bit of a cheat limiting to 255 bytes TODO (saved 8 bytes)
- desc_length = (u8)setup.wLength;
-
- // Send descriptor
- // EP0 is 64 bytes long
- // RWAL and FIFOCON don't work on EP0
- u8 n = 0;
- do
- {
- if (!WaitForINOrOUT())
- return false;
- Send8(pgm_read_byte(&desc_addr[n++]));
- u8 clr = n & 0x3F;
- if (!clr)
- ClearIN(); // Fifo is full, release this packet
- } while (n < desc_length);
+
+ USB_SendControl(TRANSFER_PGM,desc_addr,desc_length);
return true;
}
-void USBSetupInterrupt()
+// Endpoint 0 interrupt
+ISR(USB_COM_vect)
{
SetEP(0);
if (!ReceivedSetupInt())
return;
- Setup& setup = _setup; // global saves ~30 bytes
+ Setup setup;
Recv((u8*)&setup,8);
ClearSetupInt();
- if (setup.bmRequestType & DEVICETOHOST)
+ u8 requestType = setup.bmRequestType;
+ if (requestType & REQUEST_DEVICETOHOST)
WaitIN();
else
ClearIN();
bool ok = true;
- u8 r = setup.bRequest;
- if (SET_ADDRESS == r)
- {
- WaitIN();
- UDADDR = setup.wValueL | (1<<ADDEN);
- }
- else if (SET_CONFIGURATION == r)
- {
- _usbConfiguration = setup.wValueL;
- InitEndpoints();
- }
- else if (GET_CONFIGURATION == r)
- {
- Send8(_usbConfiguration);
- }
- else if (GET_STATUS == r)
+ if (REQUEST_STANDARD == (requestType & REQUEST_TYPE))
{
- Send8(0); // All good as far as I know
- }
- else if (GET_DESCRIPTOR == r)
- {
- ok = SendDescriptor();
+ // Standard Requests
+ u8 r = setup.bRequest;
+ if (GET_STATUS == r)
+ {
+ Send8(0); // TODO
+ Send8(0);
+ }
+ else if (CLEAR_FEATURE == r)
+ {
+ }
+ else if (SET_FEATURE == r)
+ {
+ }
+ else if (SET_ADDRESS == r)
+ {
+ WaitIN();
+ UDADDR = setup.wValueL | (1<<ADDEN);
+ }
+ else if (GET_DESCRIPTOR == r)
+ {
+ ok = SendDescriptor(setup);
+ }
+ else if (SET_DESCRIPTOR == r)
+ {
+ ok = false;
+ }
+ else if (GET_CONFIGURATION == r)
+ {
+ Send8(1);
+ }
+ else if (SET_CONFIGURATION == r)
+ {
+ if (REQUEST_DEVICE == (requestType & REQUEST_RECIPIENT))
+ {
+ InitEndpoints();
+ _usbConfiguration = setup.wValueL;
+ } else
+ ok = false;
+ }
+ else if (GET_INTERFACE == r)
+ {
+ }
+ else if (SET_INTERFACE == r)
+ {
+ }
}
else
{
- ok = USBHook();
+ InitControl(setup.wLength); // Max length of transfer
+ ok = ClassInterfaceRequest(setup);
}
if (ok)
ClearIN();
else
+ {
Stall();
+ }
}
-void USBGeneralInterrupt()
+void USB_Flush(u8 ep)
+{
+ SetEP(ep);
+ if (FifoByteCount())
+ ReleaseTX();
+}
+
+// General interrupt
+ISR(USB_GEN_vect)
{
u8 udint = UDINT;
UDINT = 0;
@@ -464,45 +573,67 @@ void USBGeneralInterrupt()
{
InitEP(0,EP_TYPE_CONTROL,EP_SINGLE_64); // init ep0
_usbConfiguration = 0; // not configured yet
+ UEIENX = 1 << RXSTPE; // Enable interrupts for ep0
}
// Start of Frame - happens every millisecond so we use it for TX and RX LED one-shot timing, too
if (udint & (1<<SOFI))
{
+ USB_Flush(CDC_TX); // Send a tx frame if found
+
// check whether the one-shot period has elapsed. if so, turn off the LED
if (TxLEDPulse && !(--TxLEDPulse))
- TXLED0;
+ TX_LED_OFF();
if (RxLEDPulse && !(--RxLEDPulse))
- RXLED0;
-
- if (!_ejected)
- _timeout = 0;
+ RX_LED_OFF();
}
}
-void LEDPulse();
-int USBGetChar()
+// VBUS or counting frames
+// Any frame counting?
+u8 USBConnected()
{
- for(;;)
- {
- USBSetupInterrupt();
- USBGeneralInterrupt();
+ u8 f = UDFNUML;
+// delay(3);
+ _delay_ms(3);
+ return f != UDFNUML;
+}
- // Read a char
- if (HasData(CDC_RX))
- {
- u8 c = Recv8();
- if (!ReadWriteAllowed())
- ReleaseRX();
- return c;
- }
-
- if (!--_timeout) {
- Reboot(); // USB not connected, run firmware
- }
-
- _delay_us(100); // stretch out the bootloader period to about 5 seconds after enumeration
- LEDPulse();
- }
- return -1;
+//=======================================================================
+//=======================================================================
+
+USB_ USB;
+
+USB_::USB_()
+{
}
+
+void USB_::attach()
+{
+ _usbConfiguration = 0;
+ UHWCON = 0x01; // power internal reg
+ USBCON = (1<<USBE)|(1<<FRZCLK); // clock frozen, usb enabled
+ PLLCSR = 0x12; // Need 16 MHz xtal
+ while (!(PLLCSR & (1<<PLOCK))) // wait for lock pll
+ ;
+ USBCON = ((1<<USBE)|(1<<OTGPADE)); // start USB clock
+ UDIEN = (1<<EORSTE)|(1<<SOFE); // Enable interrupts for EOR (End of Reset) and SOF (start of frame)
+ UDCON = 0; // enable attach resistor
+}
+
+void USB_::detach()
+{
+}
+
+// Check for interrupts
+// TODO: VBUS detection
+bool USB_::configured()
+{
+ return _usbConfiguration;
+}
+
+void USB_::poll()
+{
+}
+
+#endif /* if defined(USBCON) */
diff --git a/bootloaders/diskloader/src/USBCore.h b/bootloaders/diskloader/src/USBCore.h
index 537c0ec..511b57c 100644
--- a/bootloaders/diskloader/src/USBCore.h
+++ b/bootloaders/diskloader/src/USBCore.h
@@ -18,29 +18,42 @@
#ifndef __USBCORE_H__
#define __USBCORE_H__
+// Standard requests
#define GET_STATUS 0
#define CLEAR_FEATURE 1
#define SET_FEATURE 3
#define SET_ADDRESS 5
#define GET_DESCRIPTOR 6
+#define SET_DESCRIPTOR 7
#define GET_CONFIGURATION 8
#define SET_CONFIGURATION 9
#define GET_INTERFACE 10
#define SET_INTERFACE 11
+
// bmRequestType
-#define HOSTTODEVICE 0x00
-#define DEVICETOHOST 0x80
-#define STANDARD 0x00
-#define CLASS 0x20
-#define VENDOR 0x40
-#define DEVICE 0x00
-#define INTERFACE 0x01
-#define ENDPOINT 0x02
-#define OTHER 0x03
-
-#define CDC_SET_LINE_CODING 0x20
-#define CDC_GET_LINE_CODING 0x21
+#define REQUEST_HOSTTODEVICE 0x00
+#define REQUEST_DEVICETOHOST 0x80
+#define REQUEST_DIRECTION 0x80
+
+#define REQUEST_STANDARD 0x00
+#define REQUEST_CLASS 0x20
+#define REQUEST_VENDOR 0x40
+#define REQUEST_TYPE 0x60
+
+#define REQUEST_DEVICE 0x00
+#define REQUEST_INTERFACE 0x01
+#define REQUEST_ENDPOINT 0x02
+#define REQUEST_OTHER 0x03
+#define REQUEST_RECIPIENT 0x03
+
+#define REQUEST_DEVICETOHOST_CLASS_INTERFACE (REQUEST_DEVICETOHOST + REQUEST_CLASS + REQUEST_INTERFACE)
+#define REQUEST_HOSTTODEVICE_CLASS_INTERFACE (REQUEST_HOSTTODEVICE + REQUEST_CLASS + REQUEST_INTERFACE)
+
+// Class requests
+
+#define CDC_SET_LINE_CODING 0x20
+#define CDC_GET_LINE_CODING 0x21
#define CDC_SET_CONTROL_LINE_STATE 0x22
// Descriptors
@@ -94,7 +107,6 @@
#define CDC_CS_ENDPOINT 0x25
#define CDC_DATA_INTERFACE_CLASS 0x0A
-
// Device
typedef struct {
u8 len; // 18
@@ -186,14 +198,32 @@ typedef struct
typedef struct
{
+ u8 len;
+ u8 dtype; // 0x24
+ u8 subtype; // 1
+ u8 bmCapabilities;
+ u8 bDataInterface;
+} CMFunctionalDescriptor;
+
+typedef struct
+{
+ u8 len;
+ u8 dtype; // 0x24
+ u8 subtype; // 1
+ u8 bmCapabilities;
+} ACMFunctionalDescriptor;
+
+typedef struct
+{
+ // IAD
IADDescriptor iad; // Only needed on compound device
// Control
InterfaceDescriptor cif; //
CDCCSInterfaceDescriptor header;
- CDCCSInterfaceDescriptor callManagement;
- CDCCSInterfaceDescriptor4 controlManagement;
- CDCCSInterfaceDescriptor functionalDescriptor;
+ CMFunctionalDescriptor callManagement; // Call Management
+ ACMFunctionalDescriptor controlManagement; // ACM
+ CDCCSInterfaceDescriptor functionalDescriptor; // CDC_UNION
EndpointDescriptor cifin;
// Data
@@ -202,31 +232,11 @@ typedef struct
EndpointDescriptor out;
} CDCDescriptor;
-typedef struct
-{
- u8 len; // 9
- u8 dtype; // 0x21
- u8 addr;
- u8 versionL; // 0x101
- u8 versionH; // 0x101
- u8 country;
- u8 desctype; // 0x22 report
- u8 descLenL;
- u8 descLenH;
-} HIDDescDescriptor;
-
-typedef struct
-{
- InterfaceDescriptor hid;
- HIDDescDescriptor desc;
- EndpointDescriptor in;
-} HIDDescriptor;
-
#define D_DEVICE(_class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs) \
{ 18, 1, 0x200, _class,_subClass,_proto,_packetSize0,_vid,_pid,_version,_im,_ip,_is,_configs }
#define D_CONFIG(_totalLength,_interfaces) \
- { 9, 2, _totalLength,_interfaces, 1, 0, USB_CONFIG_BUS_POWERED, USB_CONFIG_POWER_MA(100) }
+ { 9, 2, _totalLength,_interfaces, 1, 0, USB_CONFIG_BUS_POWERED, USB_CONFIG_POWER_MA(500) }
#define D_INTERFACE(_n,_numEndpoints,_class,_subClass,_protocol) \
{ 9, 4, _n, 0, _numEndpoints, _class,_subClass, _protocol, 0 }
@@ -237,10 +247,8 @@ typedef struct
#define D_IAD(_firstInterface, _count, _class, _subClass, _protocol) \
{ 8, 11, _firstInterface, _count, _class, _subClass, _protocol, 0 }
-#define D_HIDREPORT(_descriptorLength) \
- { 9, 0x21, 0x1, 0x1, 0, 1, 0x22, _descriptorLength, 0 }
-
#define D_CDCCS(_subtype,_d0,_d1) { 5, 0x24, _subtype, _d0, _d1 }
#define D_CDCCS4(_subtype,_d0) { 4, 0x24, _subtype, _d0 }
+
#endif \ No newline at end of file
diff --git a/bootloaders/diskloader/src/USBDesc.cpp b/bootloaders/diskloader/src/USBDesc.cpp
deleted file mode 100644
index c8ea9c6..0000000
--- a/bootloaders/diskloader/src/USBDesc.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-/* Copyright (c) 2011, Peter Barrett
-**
-** Permission to use, copy, modify, and/or distribute this software for
-** any purpose with or without fee is hereby granted, provided that the
-** above copyright notice and this permission notice appear in all copies.
-**
-** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
-** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
-** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
-** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
-** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-** SOFTWARE.
-*/
-
-#include "Platform.h"
-
-//====================================================================================================
-//====================================================================================================
-// Actual device descriptors
-
-const u16 STRING_LANGUAGE[2] = {
- (3<<8) | (2+2),
- 0x0409 // English
-};
-
-
-const u16 STRING_IPRODUCT[28] = {
- (3<<8) | (2+2*27),
-#if USB_PID == USB_PID_LEONARDO
- 'A','r','d','u','i','n','o',' ','L','e','o','n','a','r','d','o',' ','b','o','o','t','l','o','a','d','e','r'
-#elif USB_PID == USB_PID_MICRO
- 'A','r','d','u','i','n','o',' ','M','i','c','r','o',' ','b','o','o','t','l','o','a','d','e','r',' ',' ',' '
-#endif
-};
-
-const u16 STRING_IMANUFACTURER[12] = {
- (3<<8) | (2+2*11),
- 'A','r','d','u','i','n','o',' ','L','L','C'
-};
-
-
-//#ifdef CDC_ENABLED
-DeviceDescriptor USB_DeviceDescriptorA = D_DEVICE(0X02,0X00,0X00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
-//#else
-DeviceDescriptor USB_DeviceDescriptor = D_DEVICE(0x00,0x00,0x00,64,USB_VID,USB_PID,0x100,IMANUFACTURER,IPRODUCT,0,1);
-//#endif
-
-Config USB_ConfigDescriptor =
-{
- D_CONFIG(sizeof(Config),INTERFACE_COUNT),
-
-#ifdef CDC_ENABLED
- // CDC
- {
- D_IAD(0,2,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,1),
-
- // CDC communication interface
- D_INTERFACE(CDC_ACM_INTERFACE,1,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0),
- D_CDCCS(CDC_HEADER,0x10,0x01), // Header (1.10 bcd)
- D_CDCCS(CDC_CALL_MANAGEMENT,1,1), // Device handles call management
- D_CDCCS4(CDC_ABSTRACT_CONTROL_MANAGEMENT,2), // SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported
- D_CDCCS(CDC_UNION,CDC_ACM_INTERFACE,CDC_DATA_INTERFACE), // Communication interface is master, data interface is slave 0
- D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_ACM),USB_ENDPOINT_TYPE_INTERRUPT,0x10,0x40),
-
- // CDC data interface
- D_INTERFACE(CDC_DATA_INTERFACE,2,CDC_DATA_INTERFACE_CLASS,0,0),
- D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,0x40,0),
- D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,0x40,0)
- },
-#endif
- // HID
- {
- D_INTERFACE(HID_INTERFACE,1,3,0,0),
- D_HIDREPORT(30),
- D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x40)
- }
-};
-
diff --git a/bootloaders/diskloader/src/USBDesc.h b/bootloaders/diskloader/src/USBDesc.h
index 094dba5..588a40c 100644
--- a/bootloaders/diskloader/src/USBDesc.h
+++ b/bootloaders/diskloader/src/USBDesc.h
@@ -16,48 +16,19 @@
** SOFTWARE.
*/
-
-#ifdef CDC_ENABLED
+#define CDC_INTERFACE_COUNT 2
+#define CDC_ENPOINT_COUNT 3
#define CDC_ACM_INTERFACE 0 // CDC ACM
#define CDC_DATA_INTERFACE 1 // CDC Data
-#define CDC_ENDPOINT_ACM 1
-#define CDC_ENDPOINT_OUT 2
-#define CDC_ENDPOINT_IN 3
-
-#define HID_INTERFACE 2 // HID Interface
-#define HID_ENDPOINT_INT 4
-
-#define INTERFACE_COUNT 3 // 2 for cdc + 1 for hid
-
-#else
-
-#define HID_INTERFACE 2 // HID Interface
-#define HID_ENDPOINT_INT 4
-
-#define INTERFACE_COUNT 1 // 1 for hid
+#define CDC_FIRST_ENDPOINT 1
+#define CDC_ENDPOINT_ACM (CDC_FIRST_ENDPOINT) // CDC First
+#define CDC_ENDPOINT_OUT (CDC_FIRST_ENDPOINT+1)
+#define CDC_ENDPOINT_IN (CDC_FIRST_ENDPOINT+2)
-#endif
-
-typedef struct
-{
- ConfigDescriptor config;
-#ifdef CDC_ENABLED
- CDCDescriptor cdc;
-#endif
- HIDDescriptor hid;
-} Config;
-
-extern Config USB_ConfigDescriptor PROGMEM;
-extern DeviceDescriptor USB_DeviceDescriptor PROGMEM;
-extern DeviceDescriptor USB_DeviceDescriptorA PROGMEM;
-
-extern const u16 STRING_LANGUAGE[2] PROGMEM;
-extern const u16 STRING_IPRODUCT[28] PROGMEM;
-extern const u16 STRING_IMANUFACTURER[12] PROGMEM;
+#define CDC_RX CDC_ENDPOINT_OUT
+#define CDC_TX CDC_ENDPOINT_IN
#define IMANUFACTURER 1
#define IPRODUCT 2
-#define CDC_TX CDC_ENDPOINT_IN
-#define CDC_RX CDC_ENDPOINT_OUT \ No newline at end of file
diff --git a/bootloaders/stk500v2/stk500boot.c b/bootloaders/stk500v2/stk500boot.c
index 13dec89..3d5b095 100755
--- a/bootloaders/stk500v2/stk500boot.c
+++ b/bootloaders/stk500v2/stk500boot.c
@@ -95,7 +95,8 @@ LICENSE:
#include "command.h"
-#if defined(_MEGA_BOARD_) || defined(_BOARD_AMBER128_) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
+//#if defined(_MEGA_BOARD_) || defined(_BOARD_AMBER128_) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
+#if 0
#define ENABLE_MONITOR
static void RunMonitor(void);
#endif
diff --git a/bootloaders/stk500v2/stk500boot_v2_mega2560.hex b/bootloaders/stk500v2/stk500boot_v2_mega2560.hex
index 4f36699..ace9cb1 100644
--- a/bootloaders/stk500v2/stk500boot_v2_mega2560.hex
+++ b/bootloaders/stk500v2/stk500boot_v2_mega2560.hex
@@ -1,513 +1,141 @@
:020000023000CC
-:10E000000D94F6F20D941FF30D941FF30D941FF36E
-:10E010000D941FF30D941FF30D941FF30D941FF334
-:10E020000D941FF30D941FF30D941FF30D941FF324
-:10E030000D941FF30D941FF30D941FF30D941FF314
-:10E040000D941FF30D941FF30D941FF30D941FF304
-:10E050000D941FF30D941FF30D941FF30D941FF3F4
-:10E060000D941FF30D941FF30D941FF30D941FF3E4
-:10E070000D941FF30D941FF30D941FF30D941FF3D4
-:10E080000D941FF30D941FF30D941FF30D941FF3C4
-:10E090000D941FF30D941FF30D941FF30D941FF3B4
-:10E0A0000D941FF30D941FF30D941FF30D941FF3A4
-:10E0B0000D941FF30D941FF30D941FF30D941FF394
-:10E0C0000D941FF30D941FF30D941FF30D941FF384
-:10E0D0000D941FF30D941FF30D941FF30D941FF374
-:10E0E0000D941FF341546D65676132353630004140
-:10E0F000726475696E6F206578706C6F72657220DE
-:10E1000073746B3530305632206279204D4C530099
-:10E11000426F6F746C6F616465723E004875683F52
-:10E1200000436F6D70696C6564206F6E20203D2028
-:10E1300000435055205479706520202020203D2038
-:10E14000005F5F4156525F415243485F5F203D2070
-:10E1500000415652204C69624320566572203D2092
-:10E16000004743432056657273696F6E20203D203F
-:10E1700000435055207369676E61747572653D2068
-:10E18000004C6F77206675736520202020203D208D
-:10E1900000486967682066757365202020203D204F
-:10E1A00000457874206675736520202020203D206E
-:10E1B000004C6F636B2066757365202020203D2026
-:10E1C00000536570202039203230313000312E3636
-:10E1D0002E3700342E332E33005623202020414486
-:10E1E00044522020206F7020636F6465202020201F
-:10E1F00020696E737472756374696F6E20616464F4
-:10E2000072202020496E74657272757074006E6F92
-:10E2100020766563746F7200726A6D702020006AE8
-:10E220006D7020005768617420706F72743A0050EE
-:10E230006F7274206E6F7420737570706F72746576
-:10E2400064004D7573742062652061206C65747480
-:10E2500065720020005772697474696E67204545C5
-:10E260000052656164696E6720454500656570729E
-:10E270006F6D206572726F7220636F756E743D00F2
-:10E28000504F525400303D5A65726F206164647281
-:10E290006573732063747273003F3D435055207360
-:10E2A0007461747300403D454550524F4D20746574
-:10E2B000737400423D426C696E6B204C45440045CE
-:10E2C0003D44756D7020454550524F4D00463D44CC
-:10E2D000756D7020464C41534800483D48656C7050
-:10E2E000004C3D4C69737420492F4F20506F72745D
-:10E2F0007300513D517569742026206A756D702038
-:10E30000746F20757365722070676D00523D44759F
-:10E310006D702052414D00563D73686F7720696ED5
-:10E320007465727275707420566563746F727300D1
-:10E33000593D506F727420626C696E6B002A0052F6
-:10E340004553455400494E543000494E543100491C
-:10E350004E543200494E543300494E543400494E15
-:10E36000543500494E543600494E54370050434905
-:10E370004E5430005043494E5431005043494E549E
-:10E3800032005744540054494D45523020434F4DBC
-:10E3900050410054494D45523020434F4D504200AA
-:10E3A00054494D455230204F56460054494D455230
-:10E3B0003120434150540054494D45523120434F80
-:10E3C0004D50410054494D45523120434F4D50422C
-:10E3D0000054494D45523120434F4D50430054495C
-:10E3E0004D455231204F56460054494D455232203A
-:10E3F000434F4D50410054494D45523220434F4DFB
-:10E4000050420054494D455232204F56460054491F
-:10E410004D45523320434150540054494D455233E9
-:10E4200020434F4D50410054494D45523320434FF6
-:10E430004D50420054494D45523320434F4D5043B7
-:10E440000054494D455233204F56460054494D45DE
-:10E45000523420434150540054494D4552342043D6
-:10E460004F4D50410054494D45523420434F4D507B
-:10E47000420054494D45523420434F4D50430054BF
-:10E48000494D455234204F56460054494D4552356A
-:10E4900020434150540054494D45523520434F4D7F
-:10E4A00050410054494D45523520434F4D50420094
-:10E4B00054494D45523520434F4D50430054494D2A
-:10E4C000455235204F564600555341525430205244
-:10E4D000580055534152543020554452450055532D
-:10E4E0004152543020545800555341525431205217
-:10E4F000580055534152543120554452450055530C
-:10E5000041525431205458005553415254322052F4
-:10E5100058005553415254322055445245005553EA
-:10E5200041525432205458005553415254332052D2
-:10E5300058005553415254332055445245005553C9
-:10E5400041525433205458005350492053544300EF
-:10E5500041444300414E414C4F4720434F4D5000F2
-:10E560004545205245414459005457490053504DA8
-:10E57000205245414459002A003FE345E34AE34F16
-:10E58000E354E359E35EE363E368E36DE374E37B41
-:10E59000E382E3E9E3F6E303E4ABE3B7E3C4E3D107
-:10E5A000E3DEE386E393E3A0E348E5C8E4D2E4DEF8
-:10E5B000E454E550E560E50EE41AE427E434E44170
-:10E5C000E4E8E4F2E4FEE469E56DE54CE458E46572
-:10E5D000E472E47FE48AE496E4A3E4B0E4BDE408F2
-:10E5E000E512E51EE528E532E53EE50011241FBEF3
-:10E5F000CFEFD1E2DEBFCDBF01E00CBF12E0A0E063
-:10E60000B2E0EAEDFFEF03E00BBF02C007900D920E
-:10E61000A030B107D9F712E0A0E0B2E001C01D922E
-:10E62000AC30B107E1F70F94FBF40D94EBFF01E27E
-:10E630000EBF0FEF0DBF11241FBE0D94FBF40D9400
-:10E6400000F020E030E040ED57E005C0FA013197DE
-:10E65000F1F72F5F3F4F28173907C0F308959C014A
-:10E66000442737FD4095542FDA01C901860F911DCB
-:10E67000A11DB11DABBFFC018791882369F0809378
-:10E68000C6008091C00086FFFCCF8091C0008064EE
-:10E690008093C0006F5FE8CF08958DE08093C6003F
-:10E6A0008091C00086FFFCCF8091C0008064809381
-:10E6B000C0008AE08093C6008091C00086FFFCCF36
-:10E6C0008091C00080648093C00008950F942FF360
-:10E6D0000F944DF30895FC019081992359F0909384
-:10E6E000C6008091C00086FFFCCF8091C00080648E
-:10E6F0008093C0003196992379F70895282F982F99
-:10E7000092959F70892F805D8A3308F0895F80938E
-:10E71000C6008091C00086FFFCCF8091C00080645D
-:10E720008093C000822F8F70982F905D9A3308F0ED
-:10E73000995F9093C6008091C00086FFFCCF8091C6
-:10E74000C00080648093C00008959C01FB01853661
-:10E7500091051CF46330710594F0C90164E670E022
-:10E760000F948CFF605D7F4F6093C6008091C00066
-:10E7700086FFFCCF8091C00080648093C0002B3066
-:10E78000310514F43297B4F0C90164E670E00F94D7
-:10E790008CFF6AE070E00F948CFF605D7F4F6093A8
-:10E7A000C6008091C00086FFFCCF8091C0008064CD
-:10E7B0008093C000C9016AE070E00F948CFFC0969E
-:10E7C0008093C6008091C00086FFFCCF8091C0007E
-:10E7D00080648093C0000895282F277020642093C0
-:10E7E0007C0020917B0086958695869590E08170CF
-:10E7F000907033E0880F991F3A95E1F7277F282B17
-:10E8000020937B0080917A00806480937A008091CD
-:10E810007A0086FDFCCF2091780040917900942FFA
-:10E8200080E030E0282B392BC90108951F93182F61
-:10E8300080E892EE60E00F942FF31093C600809171
-:10E84000C00086FFFCCF8091C00080648093C00030
-:10E850000F944DF31F9108952F923F924F925F9224
-:10E860006F927F928F929F92AF92BF92CF92DF92E0
-:10E87000EF92FF920F931F93DF93CF93CDB7DEB745
-:10E8800062970FB6F894DEBF0FBECDBF382E622E52
-:10E89000CA01DB015C016D01772460E2262E2E01A6
-:10E8A0000894411C511C8BC081E0A81680E0B8067A
-:10E8B00081E0C80680E0D80628F0C601AA27BB2759
-:10E8C0000F947EF3BB27AD2D9C2D8B2D0F947EF3E3
-:10E8D0008A2D0F947EF32092C6008091C00086FF9F
-:10E8E000FCCF8091C00080648093C0009DE2909333
-:10E8F000C6008091C00086FFFCCF8091C00080647C
-:10E900008093C0002092C6008091C00086FFFCCF9B
-:10E910008091C00080648093C000198286017501D7
-:10E9200088249924A1E03A1651F03A1620F0B2E07A
-:10E930003B1661F409C00BBFF701779007C0C70110
-:10E940000F94D5FF782E02C0F7017080872D0F94A9
-:10E950007EF32092C6008091C00086FFFCCF80919C
-:10E96000C00080648093C000872D8052F401EF7056
-:10E97000F0708F3520F4E40DF51D708204C0E40DB5
-:10E98000F51D8EE280830894E11CF11C011D111D10
-:10E990000894811C911C90E18916910409F0C2CF62
-:10E9A00080E190E0A0E0B0E0A80EB91ECA1EDB1E18
-:10E9B000198AC2010F946BF30F944DF36A94662089
-:10E9C00009F072CF62960FB6F894DEBF0FBECDBFCE
-:10E9D000CF91DF911F910F91FF90EF90DF90CF903B
-:10E9E000BF90AF909F908F907F906F905F904F906F
-:10E9F0003F902F9008952F923F924F925F926F9287
-:10EA00007F928F929F92AF92BF92CF92DF92EF92BE
-:10EA1000FF920F931F93DF93CF93CDB7DEB7CD5304
-:10EA2000D1400FB6F894DEBF0FBECDBF279A2F9A04
-:10EA30008091C00082608093C00080E18093C40018
-:10EA400088E18093C1000000EE24FF248701B4E038
-:10EA5000AB2EB12CCC24DD2424C0C5010197F1F7E5
-:10EA60000894E11CF11C011D111D21E2E2162EE4A7
-:10EA7000F20620E0020720E0120718F0A1E0CA2EFB
-:10EA8000D12CC801B70128E53BE140E050E00F94EC
-:10EA90009FFF611571058105910519F485B18058B5
-:10EAA00085B98091C00087FD03C0C114D104A9F2CB
-:10EAB000A6014F5F5F4FC25EDE4F59834883CE5140
-:10EAC000D140C25EDE4F68817981CE51D140613044
-:10EAD000710511F00D946EFFC05DDE4F1982188232
-:10EAE000C053D14060E0C15DDE4F1882CF52D140AB
-:10EAF000AA24BB24C05EDE4F188219821A821B82B0
-:10EB0000C052D140CE5CDE4F188219821A821B821D
-:10EB1000C253D14080E090E0A0E0B0E0ABBFFC0188
-:10EB2000A791B691C45CDE4FB983A883CC53D14082
-:10EB30000D9469FFC25EDE4FE881F981CE51D1406C
-:10EB4000319709F52091C600C25EDE4F1982188206
-:10EB5000CE51D14022C02F5F3F4F4F4F5F4F2130EA
-:10EB6000F2E13F07FAE74F07F0E05F0780F0C45C8F
-:10EB7000DE4F08811981CC53D1400F5F1F4F19F030
-:10EB8000EE27FF27099420E030E040E050E080913C
-:10EB9000C00087FFE0CF2091C600213209F094C663
-:10EBA0000894A11CB11C33E0A316B10409F08EC671
-:10EBB00000E010E018C041E24093C6008091C00020
-:10EBC00086FFFCCF8091C00080648093C0002F5FDF
-:10EBD0003F4F2931310579F70F944DF30F5F1F4FE8
-:10EBE0000530110519F020E030E0E5CF1092080261
-:10EBF0001092090210920A0210920B021092040263
-:10EC00001092050210920602109207021092000262
-:10EC10001092010210920202109203028FEE90EE07
-:10EC200060E00F9466F380E191EE60E00F942FF3C3
-:10EC30008091C00087FFFCCF9091C600903608F00D
-:10EC40009F759032B8F09093C6008091C00086FF07
-:10EC5000FCCF8091C00080648093C00080E28093EC
-:10EC6000C6008091C00086FFFCCF8091C000806408
-:10EC70008093C000983409F4DBC19934B8F492341D
-:10EC800009F45DC1933458F4903319F1903308F4CA
-:10EC900018C69F33A1F1903409F013C6BDC0953456
-:10ECA00009F474C1963409F00CC69CC1923509F47C
-:10ECB0002FC2933538F49C3409F4F9C1913509F029
-:10ECC00000C61CC2963509F449C2993509F0F9C548
-:10ECD0009CC485E892EE62E00F9466F31092040201
-:10ECE000109205021092060210920702109208027A
-:10ECF0001092090210920A0210920B0217C189E9C0
-:10ED000092EE62E00F9466F38FEE90EE60E00F9467
-:10ED100066F381E291EE60E00F942FF381EC91EEC7
-:10ED200060E00F9466F381E391EE60E00F942FF3BF
-:10ED300084EE90EE60E00F9466F381E491EE60E083
-:10ED40000F942FF386E090E061E070E00F94A5F35C
-:10ED50000F944DF381E691EE60E00F942FF383ED75
-:10ED600091EE60E00F9466F381E591EE60E00F9420
-:10ED70002FF38DEC91EE60E00F9466F381E791EE56
-:10ED800060E00F942FF38EE10F947EF388E90F94E7
-:10ED90007EF381E00F947EF30F944DF381E891EEC2
-:10EDA00060E00F942FF319E0E0E0F0E010935700DB
-:10EDB000E4918E2F0F947EF30F944DF381E991EE41
-:10EDC00060E00F942FF3E3E0F0E010935700E4913C
-:10EDD0008E2F0F947EF30F944DF381EA91EE60E055
-:10EDE0000F942FF3E2E0F0E010935700E4918E2FA0
-:10EDF0000F947EF30F944DF381EB91EE60E00F944E
-:10EE00002FF3E1E0F0E0109357001491812F0F945D
-:10EE10007EF30F944DF307CF85EA92EE62E00F94F4
-:10EE200066F385E592EE60E00F9466F30F944DF380
-:10EE300000E010E019C0C8016F2D0F94DDFFFF2026
-:10EE400031F483E592EE60E00F942FF30BC0F09263
-:10EE5000C6008091C00086FFFCCF8091C000806416
-:10EE60008093C0000F5F1F4FC80181519F41AA27A7
-:10EE700097FDA095BA2FABBFFC01F7905AE2F516AB
-:10EE800021F062E000301607B1F60F944DF30F94B5
-:10EE90004DF381E692EE60E00F9466F30F944DF32C
-:10EEA000CC24DD2400E010E01EC0C8010F94D5FF83
-:10EEB000F82E882331F483E592EE60E00F942FF36F
-:10EEC0000BC08093C6008091C00086FFFCCF80916C
-:10EED000C00080648093C000FE1419F00894C11C27
-:10EEE000D11C0F5F1F4FC80181519F41AA2797FD79
-:10EEF000A095BA2FABBFFC01E7907AE2E71621F0AC
-:10EF000082E00030180789F60F944DF30F944DF30B
-:10EF10008CE692EE60E00F942FF3C60161E070E0A2
-:10EF20000F94A5F30F944DF30F944DF3109200023C
-:10EF300010920102109202021092030274CE83EB2F
-:10EF400092EE62E00F9466F3279A2F9A16C02F98DC
-:10EF500080E090E0E0EDF7E03197F1F7019684363C
-:10EF60009105C1F72F9A80E090E0E0EDF7E031974E
-:10EF7000F1F7019684369105C1F78091C00087FFB3
-:10EF8000E6CF8091C00087FFFCCF95C48FEB92EE57
-:10EF900062E00F9466F3409100025091010260918B
-:10EFA00002027091030281E020E10F942CF4809121
-:10EFB000000290910102A0910202B09103028050E0
-:10EFC0009F4FAF4FBF4F8093000290930102A093D9
-:10EFD0000202B093030280509041A040B04008F478
-:10EFE00022CEA4CF8DEC92EE62E00F9466F34091B6
-:10EFF000040250910502609106027091070280E0C0
-:10F0000020E10F942CF48091040290910502A091CC
-:10F010000602B091070280509F4FAF4FBF4F8093C1
-:10F02000040290930502A0930602B0930702FBCD61
-:10F030008AED92EE62E00F9466F385E892EE60E06E
-:10F040000F9466F389E992EE60E00F9466F385EA27
-:10F0500092EE60E00F9466F383EB92EE60E00F9423
-:10F0600066F38FEB92EE60E00F9466F38DEC92EE18
-:10F0700060E00F9466F38AED92EE60E00F9466F321
-:10F0800081EE92EE60E00F9466F382EF92EE60E024
-:10F090000F9466F38CE093EE60E00F9466F387E1E3
-:10F0A00093EE60E00F9466F380E393EEB9CD81EECA
-:10F0B00092EE62E00F9466F381E40F9416F482E41A
-:10F0C0000F9416F483E40F9416F484E40F9416F46A
-:10F0D00085E40F9416F486E40F9416F487E40F94F5
-:10F0E00016F488E40F9416F48AE40F9416F48BE473
-:10F0F0000F9416F48CE40F9416F495CD82EF92EEF3
-:10F1000062E00F9466F399249394AA24BB2445C427
-:10F110008CE093EE62E00F9466F340910802509108
-:10F12000090260910A0270910B0282E020E10F94C3
-:10F130002CF48091080290910902A0910A02B091EA
-:10F140000B0280509F4FAF4FBF4F809308029093A8
-:10F150000902A0930A02B0930B0265CD87E193EEFA
-:10F1600062E00F9466F384EE90EE60E00F9466F335
-:10F1700089ED91EE60E00F9466F309E715EECC5D42
-:10F18000DE4F19830883C452D1406624772443019B
-:10F19000CA5DDE4F19821882C652D140A401930184
-:10F1A0005695479537952795C85DDE4F2883398357
-:10F1B0004A835B83C852D140CA5DDE4F4881598182
-:10F1C000C652D1404F5F5F4FCA5DDE4F59834883BF
-:10F1D000C652D140CA0162E070E00F94A5F350E23C
-:10F1E0005093C6008091C00086FFFCCF8091C00084
-:10F1F00080648093C0006DE26093C6008091C0007F
-:10F2000086FFFCCF8091C00080648093C00070E2D4
-:10F210007093C6008091C00086FFFCCF8091C00033
-:10F2200080648093C000C85DDE4FE880F9800A8169
-:10F230001B81C852D140BB27A12F902F8F2D0F9437
-:10F240007EF3C85DDE4F8881C852D1400F947EF3B3
-:10F2500070E2F72EF092C6008091C00086FFFCCFCE
-:10F260008091C00080648093C0000DE30093C600CD
-:10F270008091C00086FFFCCF8091C00080648093A5
-:10F28000C00010E21093C6008091C00086FFFCCF42
-:10F290008091C00080648093C0008BBEF3012791F1
-:10F2A000C45DDE4F2883CC52D140A22EBB24CC2497
-:10F2B000DD240894611C711C811C911C8BBEF30120
-:10F2C0008791282E332444245524142D032DF22C09
-:10F2D000EE24EA0CFB1C0C1D1D1D0894611C711C06
-:10F2E000811C911C8BBEF3013791C35DDE4F3883C7
-:10F2F000CD52D1400894611C711C811C911C8BBEA5
-:10F30000F3014791C25DDE4F4883CE52D1402DEFCD
-:10F310003FEF4FEF5FEF620E731E841E951E0F943A
-:10F320007EF330E23093C6008091C00086FFFCCFB0
-:10F330008091C00080648093C000C45DDE4F8881EE
-:10F34000CC52D1400F947EF340E24093C6008091AE
-:10F35000C00086FFFCCF8091C00080648093C00015
-:10F36000C25DDE4F8881CE52D1400F947EF350E2D1
-:10F370005093C6008091C00086FFFCCF8091C000F2
-:10F3800080648093C000C35DDE4F8881CD52D14040
-:10F390000F947EF360E26093C6008091C00086FF08
-:10F3A000FCCF8091C00080648093C0007FEFE7169F
-:10F3B0007FEFF70670E0070770E0170731F48EE083
-:10F3C00092EE60E00F942FF3DFC0D801C701807088
-:10F3D000907CA070B0708050904CA040B040D1F5AF
-:10F3E0002FEF3FE340E050E0E222F3220423152315
-:10F3F000C85DDE4FA880B980CA80DB80C852D1408A
-:10F40000AE0CBF1CC01ED11EAA0CBB1CCC1CDD1C2C
-:10F4100088E192EE60E00F942FF3BB27A12F902F8D
-:10F420008F2D0F947EF38E2D0F947EF330E2309368
-:10F43000C6008091C00086FFFCCF8091C000806430
-:10F440008093C0004EE34093C6008091C00086FFC9
-:10F45000FCCF87C06EE07EEF80E090E0E622F722EE
-:10F46000082319237CE0E71674E9F70670E0070724
-:10F4700070E0170709F088C0C25DDE4F8881CE5268
-:10F48000D140E82EFF2400E010E0102F0F2DFE2CBD
-:10F49000EE24C35DDE4F9881CD52D140E90EF11CC0
-:10F4A000011D111DD601C50181709070A070B07052
-:10F4B000DC0199278827E80EF91E0A1F1B1F20EF81
-:10F4C00030E040E050E0A222B322C422D522F1E194
-:10F4D000AA0CBB1CCC1CDD1CFA95D1F7EA0CFB1C5A
-:10F4E0000C1D1D1D41E050E060E070E0242235223B
-:10F4F00046225722E5E1220C331C441C551CEA9598
-:10F50000D1F7E20CF31C041D151D57016801AA0C6C
-:10F51000BB1CCC1CDD1C8FE192EE60E00F942FF33E
-:10F52000C801AA27BB270F947EF3BB27A12F902FDA
-:10F530008F2D0F947EF38E2D0F947EF350E2509317
-:10F54000C6008091C00086FFFCCF8091C00080641F
-:10F550008093C0006EE36093C6008091C00086FF78
-:10F56000FCCF8091C00080648093C000C601AA27B0
-:10F57000BB270F947EF3BB27AD2D9C2D8B2D0F94B5
-:10F580007EF38A2D0F947EF370E27093C600809113
-:10F59000C00086FFFCCF8091C00080648093C000D3
-:10F5A000CC5DDE4FE881F981C452D140CF01AA275A
-:10F5B00097FDA095BA2FABBFFC018791969160E0B3
-:10F5C0000F942FF30F944DF3CC5DDE4F088119811A
-:10F5D000C452D1400E5F1F4FCC5DDE4F19830883AC
-:10F5E000C452D140CA5DDE4F28813981C652D14014
-:10F5F0002933310509F417CB44E050E060E070E0B6
-:10F60000640E751E861E971EC9CD80E393EE62E0E0
-:10F610000F9466F384E292EE60E00F942FF38091F2
-:10F62000C00087FFFCCF1091C6001F751093C60065
-:10F630008091C00086FFFCCF8091C00080648093E1
-:10F64000C0000F944DF3812F81548A3108F036C1E8
-:10F65000163409F495C0173490F4133409F44EC0ED
-:10F66000143430F41134F1F0123409F01DC130C0FB
-:10F67000143409F459C0153409F016C16BC01A349A
-:10F6800009F4C4C01B3438F4173409F48FC018349B
-:10F6900009F00AC1A1C01B3409F4D2C01C3409F01E
-:10F6A00003C1E8C08FEF81B90DC082B1809582B9E6
-:10F6B00080E090E0E0EDF7E03197F1F70196883CCB
-:10F6C0009105C1F78091C00087FFEFCF12B8EFC05E
-:10F6D0008FEF84B90DC085B1809585B980E090E049
-:10F6E000E0EDF7E03197F1F70196883C9105C1F71D
-:10F6F0008091C00087FFEFCF15B8D9C08FEF87B9D1
-:10F700000DC088B1809588B980E090E0E0EDF7E029
-:10F710003197F1F70196883C9105C1F78091C000BF
-:10F7200087FFEFCF18B8C3C08FEF8AB90DC08BB178
-:10F7300080958BB980E090E0E0EDF7E03197F1F74C
-:10F740000196883C9105C1F78091C00087FFEFCFFB
-:10F750001BB8ADC08FEF8DB90DC08EB180958EB93D
-:10F7600080E090E0E0EDF7E03197F1F70196883C1A
-:10F770009105C1F78091C00087FFEFCF1EB897C0F9
-:10F780008FEF80BB0DC081B3809581BB80E090E09E
-:10F79000E0EDF7E03197F1F70196883C9105C1F76C
-:10F7A0008091C00087FFEFCF11BA81C08FEF83BB7C
-:10F7B0000DC084B3809584BB80E090E0E0EDF7E07D
-:10F7C0003197F1F70196883C9105C1F78091C0000F
-:10F7D00087FFEFCF14BA6BC08FEF809301010FC08A
-:10F7E0008091020180958093020180E090E0E0ED3D
-:10F7F000F7E03197F1F70196883C9105C1F78091C8
-:10F80000C00087FFEDCF1092020151C08FEF8093AF
-:10F8100004010FC08091050180958093050180E06F
-:10F8200090E0E0EDF7E03197F1F70196883C910523
-:10F83000C1F78091C00087FFEDCF1092050137C05E
-:10F840008FEF809307010FC080910801809580930E
-:10F85000080180E090E0E0EDF7E03197F1F70196E4
-:10F86000883C9105C1F78091C00087FFEDCF1092D1
-:10F8700008011DC08FEF80930A010FC080910B011A
-:10F88000809580930B0180E090E0E0EDF7E0319708
-:10F89000F1F70196883C9105C1F78091C00087FF80
-:10F8A000EDCF10920B0103C08FE292EEB9C98091A7
-:10F8B000C00087FFFCCF8091C600B5C982E492EEFC
-:10F8C000AFC98CE191EEACC9AA24BB24933061F19D
-:10F8D000943028F4913089F0923008F508C09530C2
-:10F8E000B1F1953040F1963009F053C04EC02B3144
-:10F8F00009F020C991E06BE11DC9213041F0C15DE3
-:10F90000DE4F5881CF52D140251709F002C362273C
-:10F91000C15DDE4F2883CF52D14092E00BC9B22F98
-:10F92000A0E0622793E006C9822F90E0A82BB92BB4
-:10F93000622794E0FFC82E3009F0EBC2622795E001
-:10F94000C05DDE4F19821882C053D140F3C8E1E098
-:10F95000F0E0EC0FFD1FC05DDE4FE880F980C05382
-:10F96000D140EE0DFF1D208387010F5F1F4FC05D4B
-:10F97000DE4F19830883C053D14062270A171B0743
-:10F9800009F0D8C8D80196E0D5C8261709F0C1C239
-:10F9900003C0973009F0CEC899248981833109F4D6
-:10F9A000FCC08431C8F4863009F4C2C0873050F4FA
-:10F9B000823009F4F0C0833009F458C0813009F076
-:10F9C0000AC23EC0813109F462C0823108F0A6C08B
-:10F9D000803109F000C2DFC0883109F472C089317A
-:10F9E00050F4853109F4D9C0853108F477C18631E6
-:10F9F00009F0F1C173C18A3109F457C08A3108F4A2
-:10FA00007CC08B3109F446C08D3109F0E4C18D8191
-:10FA1000803311F090E00AC08F81882311F49EE1B9
-:10FA200005C0813011F091E001C098E91A821B8273
-:10FA30008D818C831D829E831F8227E030E0CFC1A1
-:10FA40001A8288E08B8381E48C8386E58D8382E54E
-:10FA50008E8389E48F8383E5888780E589878FE5B6
-:10FA60008A8782E38B872BE030E0B9C18A818139B4
-:10FA700041F0823941F0803911F48FE005C080E017
-:10FA800003C082E001C08AE01A828B8344C09924BB
-:10FA9000939481C08D81882311F48EE12CC0813034
-:10FAA00011F081E028C088E926C01A82E1E0F0E088
-:10FAB00089E08093570084918B831C8224E030E09E
-:10FAC0008EC18B81803589F48C81883039F4E2E0F5
-:10FAD000F0E089E08093570084910DC0E0E0F0E011
-:10FAE00089E080935700849106C0E3E0F0E089E06C
-:10FAF0008093570084911A82DFCF8D81836C99E0C7
-:10FB0000E1E0F0E0082E90935700E89507B600FC7E
-:10FB1000FDCF1A821B8223E030E061C11A82CE5CE5
-:10FB2000DE4F188219821A821B82C253D14055C1FE
-:10FB30008A8190E0A0E0B0E0582F442733272227A5
-:10FB40008B8190E0A0E0B0E0DC0199278827282B8A
-:10FB5000392B4A2B5B2B8D8190E0A0E0B0E0282B65
-:10FB6000392B4A2B5B2B8C8190E0A0E0B0E0BA2FC0
-:10FB7000A92F982F8827282B392B4A2B5B2B220F54
-:10FB8000331F441F551FC05EDE4F288339834A83CD
-:10FB90005B83C052D1401A8220C19A812B8183316C
-:10FBA00049F0C05EDE4F488159816A817B81C05235
-:10FBB000D1408AC0CE5CDE4F488159816A817B8109
-:10FBC000C253D140403080EC580783E0680780E0A2
-:10FBD0007807F0F483E0FA0160935B0080935700AC
-:10FBE000E89507B600FCFDCFCE5CDE4F4881598119
-:10FBF0006A817B81C253D14040505F4F6F4F7F4F2E
-:10FC0000CE5CDE4F488359836A837B83C253D140E5
-:10FC1000C95CDE4F9883C753D140CA5CDE4F18825F
-:10FC2000C653D140022F10E0CA5CDE4F6881798153
-:10FC3000C653D140062B172BC05EDE4F4881598139
-:10FC40006A817B81C052D140DE011B9631E08C91EC
-:10FC500011962C9111971296C75CDE4F2883C953D9
-:10FC6000D140C85CDE4F1882C853D14090E0C85CD8
-:10FC7000DE4FE881F981C853D1408E2B9F2B0C01B8
-:10FC8000FA0160935B0030935700E89511244E5FB2
-:10FC90005F4F6F4F7F4F02501040C9F685E0C05E46
-:10FCA000DE4FE880F9800A811B81C052D140F70104
-:10FCB00000935B0080935700E89507B600FCFDCFEA
-:10FCC00081E180935700E8951A82C05EDE4F488339
-:10FCD00059836A837B83C052D1407FC0FA80C55C60
-:10FCE000DE4FF882CB53D140C65CDE4F1882CA5338
-:10FCF000D1408B81C82EDD24C65CDE4F088119817E
-:10FD0000CA53D140C02AD12A1A828981BE016D5FAF
-:10FD10007F4F843121F59601C05EDE4FE880F98087
-:10FD20000A811B81C052D1400BBFF7018791969188
-:10FD3000DB018C9311969C936E5F7F4FD801C701B6
-:10FD40000296A11DB11DC05EDE4F88839983AA83F0
-:10FD5000BB83C052D14022503040F1F636C0C05E65
-:10FD6000DE4F288139814A815B81C052D14008949D
-:10FD7000C108D108760100E010E00894C11CD11C34
-:10FD80000894E11CF11C011D111DE20EF31E041F5D
-:10FD9000151F21BDBB27A52F942F832F82BD2F5F59
-:10FDA0003F4F4F4F5F4FF89A80B5DB018D93BD01F8
-:10FDB0002E153F054007510761F7C05EDE4F2883CF
-:10FDC00039834A835B83C052D14096012D5F3F4FF8
-:10FDD000FB01108204C080EC8A8322E030E08BE1DA
-:10FDE0008093C6008091C00086FFFCCF8091C00048
-:10FDF00080648093C000C15DDE4FF881CF52D14056
-:10FE0000F093C6008091C00086FFFCCF8091C000B7
-:10FE100080648093C000432F3093C6008091C0005F
-:10FE200086FFFCCF8091C00080648093C000922F39
-:10FE30002093C6008091C00086FFFCCF8091C00057
-:10FE400080648093C0008EE08093C6008091C000E3
-:10FE500086FFFCCF8091C00080648093C00065E184
-:10FE6000C15DDE4FE880CF52D1406E2569276427FF
-:10FE7000FE01319610C090819093C6008091C00021
-:10FE800086FFFCCF31968091C00080648093C000D3
-:10FE90006927215030402115310569F76093C6006C
-:10FEA0008091C00086FFFCCF8091C0008064809369
-:10FEB000C00085B1805885B9992081F4C15DDE4FBD
-:10FEC0000881CF52D1400F5FC15DDE4F0883CF5212
-:10FED000D14090E0A0E0B0E00D949AF527982F98DB
-:10FEE00080E090E020ED37E0F9013197F1F70196DD
-:10FEF00084369105C9F700008091C0008D7F809302
-:10FF0000C00081E180935700E895EE27FF27099410
-:10FF1000FFCF90E00D949AF597FB092E07260AD0A3
-:10FF200077FD04D02ED006D000201AF4709561958C
-:10FF30007F4F0895F6F7909581959F4F0895A1E220
-:10FF40001A2EAA1BBB1BFD010DC0AA1FBB1FEE1F53
-:10FF5000FF1FA217B307E407F50720F0A21BB30B9E
-:10FF6000E40BF50B661F771F881F991F1A9469F71A
-:10FF700060957095809590959B01AC01BD01CF0176
-:10FF80000895AA1BBB1B51E107C0AA1FBB1FA617E0
-:10FF9000B70710F0A61BB70B881F991F5A95A9F732
-:10FFA00080959095BC01CD010895F999FECF92BD41
-:10FFB00081BDF89A992780B50895262FF999FECF2B
-:10FFC0001FBA92BD81BD20BD0FB6F894FA9AF99A76
-:0AFFD0000FBE01960895F894FFCFCC
+:10E000000D9472F00D9493F00D9493F00D9493F0A1
+:10E010000D9493F00D9493F00D9493F00D9493F070
+:10E020000D9493F00D9493F00D9493F00D9493F060
+:10E030000D9493F00D9493F00D9493F00D9493F050
+:10E040000D9493F00D9493F00D9493F00D9493F040
+:10E050000D9493F00D9493F00D9493F00D9493F030
+:10E060000D9493F00D9493F00D9493F00D9493F020
+:10E070000D9493F00D9493F00D9493F00D9493F010
+:10E080000D9493F00D9493F00D9493F00D9493F000
+:10E090000D9493F00D9493F00D9493F00D9493F0F0
+:10E0A0000D9493F00D9493F00D9493F00D9493F0E0
+:10E0B0000D9493F00D9493F00D9493F00D9493F0D0
+:10E0C0000D9493F00D9493F00D9493F00D9493F0C0
+:10E0D0000D9493F00D9493F00D9493F00D9493F0B0
+:10E0E0000D9493F011241FBECFEFD1E2DEBFCDBF60
+:10E0F00001E00CBF12E0A0E0B2E0E0EAF8EE03E0DD
+:10E100000BBF02C007900D92A030B107D9F70F9452
+:10E11000A3F00D944EF401E20EBF0FEF0DBF1124DA
+:10E120001FBE0D94A3F00D9400F020E030E040ED10
+:10E1300057E005C0FA013197F1F72F5F3F4F2817DD
+:10E140003907C0F308952F923F924F925F926F92DA
+:10E150007F928F929F92AF92BF92CF92DF92EF9277
+:10E16000FF920F931F93DF93CF93CDB7DEB7C852C3
+:10E17000D1400FB6F894DEBF0FBECDBF279A2F9ABD
+:10E180008091C00082608093C00080E18093C400D1
+:10E1900088E18093C1000000EE24FF248701E4E0C1
+:10E1A000AE2EB12CCC24DD2424C0C5010197F1F79B
+:10E1B0000894E11CF11C011D111D21E2E2162EE460
+:10E1C000F20620E0020720E0120718F071E0C72EE7
+:10E1D000D12CC801B70128E53BE140E050E00F94A5
+:10E1E0002CF4611571058105910519F485B18058EC
+:10E1F00085B98091C00087FD03C0C114D104A9F284
+:10E20000A6014F5F5F4FC25EDE4F59834883CE51F8
+:10E21000D140C25EDE4F68817981CE51D1406130FC
+:10E22000710509F0FCC222243324A0E0C05EDE4F59
+:10E230001882C052D1408824992454014424552482
+:10E240003201ABBEF40187919691C95DDE4F99838F
+:10E250008883C752D140DFC2C25EDE4FE881F981B8
+:10E26000CE51D140319709F53091C600C25EDE4FE4
+:10E2700019821882CE51D14022C04F5F5F4F6F4F3D
+:10E280007F4F4130F2E15F07FAE76F07F0E07F0769
+:10E2900080F0C95DDE4F28813981C752D1402F5FA0
+:10E2A0003F4F19F0EE27FF27099440E050E060E06F
+:10E2B00070E08091C00087FFE0CF3091C6009330BE
+:10E2C00061F1943028F4913089F0923008F508C05B
+:10E2D000953091F1953040F1963009F043C03EC041
+:10E2E0003B3109F0B9CF91E0ABE1B6CF313041F02D
+:10E2F000C05EDE4F5881C052D140351709F0AAC226
+:10E30000A327C05EDE4F3883C052D14092E0A4CF35
+:10E31000132F00E0A32793E09FCF832F90E0082BDB
+:10E32000192BA32794E098CF3E3009F093C2A3277E
+:10E3300095E02224332490CFE1E0F0E0EC0FFD1FC4
+:10E34000E20DF31D30830894211C311CA3272016F5
+:10E35000310609F081CF810196E07ECF3A1709F0AE
+:10E3600079C203C0973009F077CF8981833109F4EE
+:10E37000F4C08431C0F4863009F4C2C0873048F458
+:10E38000823069F1833009F45BC0813009F0C4C187
+:10E3900041C0813109F465C0823108F0ACC08031E0
+:10E3A00009F0BAC11CC0883109F474C0893150F435
+:10E3B000853109F4D2C0853108F443C1863109F0B2
+:10E3C000ABC13FC18A3109F45CC08A3108F482C014
+:10E3D0008B3109F44BC08D3109F09EC102C090E031
+:10E3E00041C08D81803311F090E00AC08F81882375
+:10E3F00011F49EE105C0813011F091E001C098E96F
+:10E400001A821B828D818C831D829E831F8247E02E
+:10E4100050E086C11A8288E08B8381E48C8386E594
+:10E420008D8382E58E8389E48F8383E5888780E509
+:10E4300089878FE58A8782E38B874BE050E070C144
+:10E440008A81813941F0823941F0803911F48FE0BD
+:10E4500005C080E003C082E001C08AE01A828B839D
+:10E4600047C091E01A8242E050E05BC18D81882371
+:10E4700011F48EE129C0813011F081E025C088E9D6
+:10E4800023C01A82E1E0F0E069E060935700E49174
+:10E49000EB831CC08B81803589F48C81883039F402
+:10E4A00029E0E2E0F0E02093570084910DC029E0DC
+:10E4B000E0E0F0E020935700849106C0E3E0F0E054
+:10E4C00039E03093570084911A828B831C8244E098
+:10E4D00050E026C18D81836C49E0E1E0F0E0082E38
+:10E4E00040935700E89507B600FCFDCF1A821B82C7
+:10E4F00043E050E015C11A824424552432010EC174
+:10E500008A8190E0A0E0B0E0B82EAA249924882463
+:10E510008B8190E0A0E0B0E0DC0199278827882A71
+:10E52000992AAA2ABB2A8D8190E0A0E0B0E0882A2F
+:10E53000992AAA2ABB2A8C8190E0A0E0B0E0BA2FE9
+:10E54000A92F982F8827882A992AAA2ABB2A880CBB
+:10E55000991CAA1CBB1C1A82E1C09A813B818331A1
+:10E5600019F0B501A40169C050E0451650EC5506FC
+:10E5700053E0650650E0750690F463E0F2016092A6
+:10E580005B0060935700E89507B600FCFDCF40E0C4
+:10E5900051E060E070E0440E551E661E771ECE5DB1
+:10E5A000DE4F9883C252D140CF5DDE4F1882C152F8
+:10E5B000D140032F10E0CF5DDE4F68817981C152D9
+:10E5C000D140062B172BB501A401DE011B968C91BF
+:10E5D00011962C9111971296CC5DDE4F2883C45270
+:10E5E000D140CD5DDE4F1882C352D14090E0CD5D69
+:10E5F000DE4FE881F981C352D1408E2B9F2B21E061
+:10E600000C01FA0160935B0020935700E8951124F8
+:10E610004E5F5F4F6F4F7F4F02501040C1F635E0A5
+:10E62000F401A0925B0030935700E89507B600FC18
+:10E63000FDCF81E180935700E8951A824A015B0182
+:10E640006DC09A81CA5DDE4F9883C652D140CB5DC2
+:10E65000DE4F1882C552D1408B81C82EDD24CB5DA0
+:10E66000DE4FA881B981C552D140CA2ADB2A1A825D
+:10E6700089818431E9F4A60123E0E22EF12CEC0E2D
+:10E68000FD1EABBEF40187919691F70180839183C3
+:10E6900022E030E0E20EF31E62E070E080E090E005
+:10E6A000860E971EA81EB91E4250504051F72EC02C
+:10E6B000B501A40193E0E92EF12CEC0EFD1E0894A7
+:10E6C000C108D108860120E030E00894C11CD11CAB
+:10E6D0000F5F1F4F2F4F3F4F080D191D2A1D3B1D68
+:10E6E00041BDBB27A72F962F852F82BD4F5F5F4F60
+:10E6F0006F4F7F4FF89A80B5D7018D937D014017FA
+:10E7000051076207730761F74A015B01A6014D5F7C
+:10E710005F4FF701108204C0F0ECFA8342E050E052
+:10E7200090E02BE12093C6008091C00086FFFCCFD3
+:10E730008091C00080648093C000C05EDE4F38814D
+:10E74000C052D1403093C6008091C00086FFFCCFFC
+:10E750008091C00080648093C000652F5093C600F4
+:10E760008091C00086FFFCCF8091C00080648093C0
+:10E77000C000342F4093C6008091C00086FFFCCFBC
+:10E780008091C00080648093C0008EE08093C600BA
+:10E790008091C00086FFFCCF8091C0008064809390
+:10E7A000C000A5E1C05EDE4F7881C052D140A727EE
+:10E7B000A327A627FE01319610C030813093C600F2
+:10E7C0008091C00086FFFCCF31968091C0008064AC
+:10E7D0008093C000A327415050404115510569F76F
+:10E7E000A093C6008091C00086FFFCCF8091C0003E
+:10E7F00080648093C00085B1805885B9992379F4ED
+:10E80000C05EDE4F8881C052D1408F5FC05EDE4F58
+:10E810008883C052D14090E000E010E01DCD2798E1
+:10E820002F9880E090E020ED37E0F9013197F1F783
+:10E83000019684369105C9F700008091C0008D7F54
+:10E840008093C00081E180935700E895EE27FF2771
+:10E850000994FFCF90E000CDA1E21A2EAA1BBB1BAA
+:10E86000FD010DC0AA1FBB1FEE1FFF1FA217B3079C
+:10E87000E407F50720F0A21BB30BE40BF50B661FB2
+:10E88000771F881F991F1A9469F760957095809576
+:10E8900090959B01AC01BD01CF010895F894FFCF85
:040000033000E000E9
:00000001FF
diff --git a/cores/arduino/CDC.cpp b/cores/arduino/CDC.cpp
index 14a0eae..b8df09f 100644
--- a/cores/arduino/CDC.cpp
+++ b/cores/arduino/CDC.cpp
@@ -27,7 +27,7 @@ void Reboot()
{
USB.detach();
cli();
- asm volatile("jmp 0x7800"); // jump to bootloader - DiskLoader takes up last 2 kB
+ asm volatile("jmp 0x7000"); // jump to bootloader - DiskLoader lives in the last 4kB of Flash
}
typedef struct
diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h
index 176abe1..9dc67c4 100644
--- a/cores/arduino/HardwareSerial.h
+++ b/cores/arduino/HardwareSerial.h
@@ -32,7 +32,6 @@ class HardwareSerial : public Stream
{
private:
ring_buffer *_rx_buffer;
- ring_buffer *_tx_buffer;
volatile uint8_t *_ubrrh;
volatile uint8_t *_ubrrl;
volatile uint8_t *_ucsra;
@@ -41,29 +40,28 @@ class HardwareSerial : public Stream
uint8_t _rxen;
uint8_t _txen;
uint8_t _rxcie;
- uint8_t _udrie;
+ uint8_t _udre;
uint8_t _u2x;
public:
- HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer,
+ HardwareSerial(ring_buffer *rx_buffer,
volatile uint8_t *ubrrh, volatile uint8_t *ubrrl,
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
volatile uint8_t *udr,
- uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x);
+ uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udre, uint8_t u2x);
void begin(unsigned long);
void end();
virtual int available(void);
virtual int peek(void);
virtual int read(void);
virtual void flush(void);
- virtual size_t write(uint8_t);
+ virtual void write(uint8_t);
using Print::write; // pull in write(str) and write(buf, size) from Print
};
#if defined(UBRRH) || defined(UBRR0H)
extern HardwareSerial Serial;
#elif defined(USBCON)
- #include "USBAPI.h"
-// extern HardwareSerial Serial_;
+ #include "usb_api.h"
#endif
#if defined(UBRR1H)
extern HardwareSerial Serial1;
@@ -75,6 +73,4 @@ class HardwareSerial : public Stream
extern HardwareSerial Serial3;
#endif
-extern void serialEventRun(void) __attribute__((weak));
-
#endif
diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp
index ff9b154..fd68942 100755
--- a/cores/arduino/Print.cpp
+++ b/cores/arduino/Print.cpp
@@ -23,213 +23,173 @@
#include <stdio.h>
#include <string.h>
#include <math.h>
-#include "Arduino.h"
+#include "wiring.h"
#include "Print.h"
// Public Methods //////////////////////////////////////////////////////////////
/* default implementation: may be overridden */
-size_t Print::write(const uint8_t *buffer, size_t size)
+void Print::write(const char *str)
{
- size_t n = 0;
- while (size--) {
- n += write(*buffer++);
- }
- return n;
+ while (*str)
+ write(*str++);
}
-size_t Print::print(const __FlashStringHelper *ifsh)
+/* default implementation: may be overridden */
+void Print::write(const uint8_t *buffer, size_t size)
{
- const prog_char *p = (const prog_char *)ifsh;
- size_t n = 0;
- while (1) {
- unsigned char c = pgm_read_byte(p++);
- if (c == 0) break;
- n += write(c);
- }
- return n;
+ while (size--)
+ write(*buffer++);
}
-size_t Print::print(const String &s)
+void Print::print(const String &s)
{
- size_t n = 0;
- for (uint16_t i = 0; i < s.length(); i++) {
- n += write(s[i]);
+ for (unsigned int i = 0; i < s.length(); i++) {
+ write(s[i]);
}
- return n;
}
-size_t Print::print(const char str[])
+void Print::print(const char str[])
{
- return write(str);
+ write(str);
}
-size_t Print::print(char c)
+void Print::print(char c, int base)
{
- return write(c);
+ print((long) c, base);
}
-size_t Print::print(unsigned char b, int base)
+void Print::print(unsigned char b, int base)
{
- return print((unsigned long) b, base);
+ print((unsigned long) b, base);
}
-size_t Print::print(int n, int base)
+void Print::print(int n, int base)
{
- return print((long) n, base);
+ print((long) n, base);
}
-size_t Print::print(unsigned int n, int base)
+void Print::print(unsigned int n, int base)
{
- return print((unsigned long) n, base);
+ print((unsigned long) n, base);
}
-size_t Print::print(long n, int base)
+void Print::print(long n, int base)
{
if (base == 0) {
- return write(n);
+ write(n);
} else if (base == 10) {
if (n < 0) {
- int t = print('-');
+ print('-');
n = -n;
- return printNumber(n, 10) + t;
}
- return printNumber(n, 10);
+ printNumber(n, 10);
} else {
- return printNumber(n, base);
+ printNumber(n, base);
}
}
-size_t Print::print(unsigned long n, int base)
-{
- if (base == 0) return write(n);
- else return printNumber(n, base);
-}
-
-size_t Print::print(double n, int digits)
+void Print::print(unsigned long n, int base)
{
- return printFloat(n, digits);
+ if (base == 0) write(n);
+ else printNumber(n, base);
}
-size_t Print::println(const __FlashStringHelper *ifsh)
+void Print::print(double n, int digits)
{
- size_t n = print(ifsh);
- n += println();
- return n;
+ printFloat(n, digits);
}
-size_t Print::print(const Printable& x)
+void Print::println(void)
{
- return x.printTo(*this);
+ print('\r');
+ print('\n');
}
-size_t Print::println(void)
+void Print::println(const String &s)
{
- size_t n = print('\r');
- n += print('\n');
- return n;
+ print(s);
+ println();
}
-size_t Print::println(const String &s)
+void Print::println(const char c[])
{
- size_t n = print(s);
- n += println();
- return n;
+ print(c);
+ println();
}
-size_t Print::println(const char c[])
+void Print::println(char c, int base)
{
- size_t n = print(c);
- n += println();
- return n;
+ print(c, base);
+ println();
}
-size_t Print::println(char c)
+void Print::println(unsigned char b, int base)
{
- size_t n = print(c);
- n += println();
- return n;
+ print(b, base);
+ println();
}
-size_t Print::println(unsigned char b, int base)
+void Print::println(int n, int base)
{
- size_t n = print(b, base);
- n += println();
- return n;
+ print(n, base);
+ println();
}
-size_t Print::println(int num, int base)
+void Print::println(unsigned int n, int base)
{
- size_t n = print(num, base);
- n += println();
- return n;
+ print(n, base);
+ println();
}
-size_t Print::println(unsigned int num, int base)
+void Print::println(long n, int base)
{
- size_t n = print(num, base);
- n += println();
- return n;
+ print(n, base);
+ println();
}
-size_t Print::println(long num, int base)
+void Print::println(unsigned long n, int base)
{
- size_t n = print(num, base);
- n += println();
- return n;
+ print(n, base);
+ println();
}
-size_t Print::println(unsigned long num, int base)
+void Print::println(double n, int digits)
{
- size_t n = print(num, base);
- n += println();
- return n;
-}
-
-size_t Print::println(double num, int digits)
-{
- size_t n = print(num, digits);
- n += println();
- return n;
-}
-
-size_t Print::println(const Printable& x)
-{
- size_t n = print(x);
- n += println();
- return n;
+ print(n, digits);
+ println();
}
// Private Methods /////////////////////////////////////////////////////////////
-size_t Print::printNumber(unsigned long n, uint8_t base) {
- char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte.
- char *str = &buf[sizeof(buf) - 1];
-
- *str = '\0';
+void Print::printNumber(unsigned long n, uint8_t base)
+{
+ unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
+ unsigned long i = 0;
- // prevent crash if called with base == 1
- if (base < 2) base = 10;
+ if (n == 0) {
+ print('0');
+ return;
+ }
- do {
- unsigned long m = n;
+ while (n > 0) {
+ buf[i++] = n % base;
n /= base;
- char c = m - base * n;
- *--str = c < 10 ? c + '0' : c + 'A' - 10;
- } while(n);
+ }
- return write(str);
+ for (; i > 0; i--)
+ print((char) (buf[i - 1] < 10 ?
+ '0' + buf[i - 1] :
+ 'A' + buf[i - 1] - 10));
}
-size_t Print::printFloat(double number, uint8_t digits)
+void Print::printFloat(double number, uint8_t digits)
{
- size_t n = 0;
-
// Handle negative numbers
if (number < 0.0)
{
- n += print('-');
+ print('-');
number = -number;
}
@@ -243,21 +203,18 @@ size_t Print::printFloat(double number, uint8_t digits)
// Extract the integer part of the number and print it
unsigned long int_part = (unsigned long)number;
double remainder = number - (double)int_part;
- n += print(int_part);
+ print(int_part);
// Print the decimal point, but only if there are digits beyond
- if (digits > 0) {
- n += print(".");
- }
+ if (digits > 0)
+ print(".");
// Extract digits from the remainder one at a time
while (digits-- > 0)
{
remainder *= 10.0;
int toPrint = int(remainder);
- n += print(toPrint);
+ print(toPrint);
remainder -= toPrint;
}
-
- return n;
}
diff --git a/cores/arduino/WString.h b/cores/arduino/WString.h
index d76d2a3..56faf9a 100644
--- a/cores/arduino/WString.h
+++ b/cores/arduino/WString.h
@@ -1,8 +1,6 @@
/*
WString.h - String library for Wiring & Arduino
- ...mostly rewritten by Paul Stoffregen...
Copyright (c) 2009-10 Hernando Barragan. All right reserved.
- Copyright 2011, Paul Stoffregen, paul@pjrc.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -19,187 +17,96 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef String_class_h
-#define String_class_h
-#ifdef __cplusplus
+#ifndef String_h
+#define String_h
+//#include "WProgram.h"
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-#include <avr/pgmspace.h>
-// When compiling programs with this class, the following gcc parameters
-// dramatically increase performance and memory (RAM) efficiency, typically
-// with little or no increase in code size.
-// -felide-constructors
-// -std=c++0x
-
-class __FlashStringHelper;
-#define F(string_literal) (reinterpret_cast<__FlashStringHelper *>(PSTR(string_literal)))
-
-// An inherited class for holding the result of a concatenation. These
-// result objects are assumed to be writable by subsequent concatenations.
-class StringSumHelper;
-
-// The string class
class String
{
- // use a function pointer to allow for "if (s)" without the
- // complications of an operator bool(). for more information, see:
- // http://www.artima.com/cppsource/safebool.html
- typedef void (String::*StringIfHelperType)() const;
- void StringIfHelper() const {}
-
-public:
- // constructors
- // creates a copy of the initial value.
- // if the initial value is null or invalid, or if memory allocation
- // fails, the string will be marked as invalid (i.e. "if (s)" will
- // be false).
- String(const char *cstr = "");
- String(const String &str);
- #ifdef __GXX_EXPERIMENTAL_CXX0X__
- String(String &&rval);
- String(StringSumHelper &&rval);
- #endif
- explicit String(char c);
- explicit String(unsigned char, unsigned char base=10);
- explicit String(int, unsigned char base=10);
- explicit String(unsigned int, unsigned char base=10);
- explicit String(long, unsigned char base=10);
- explicit String(unsigned long, unsigned char base=10);
- ~String(void);
-
- // memory management
- // return true on success, false on failure (in which case, the string
- // is left unchanged). reserve(0), if successful, will validate an
- // invalid string (i.e., "if (s)" will be true afterwards)
- unsigned char reserve(unsigned int size);
- inline unsigned int length(void) const {return len;}
-
- // creates a copy of the assigned value. if the value is null or
- // invalid, or if the memory allocation fails, the string will be
- // marked as invalid ("if (s)" will be false).
- String & operator = (const String &rhs);
- String & operator = (const char *cstr);
- #ifdef __GXX_EXPERIMENTAL_CXX0X__
- String & operator = (String &&rval);
- String & operator = (StringSumHelper &&rval);
- #endif
-
- // concatenate (works w/ built-in types)
-
- // returns true on success, false on failure (in which case, the string
- // is left unchanged). if the argument is null or invalid, the
- // concatenation is considered unsucessful.
- unsigned char concat(const String &str);
- unsigned char concat(const char *cstr);
- unsigned char concat(char c);
- unsigned char concat(unsigned char c);
- unsigned char concat(int num);
- unsigned char concat(unsigned int num);
- unsigned char concat(long num);
- unsigned char concat(unsigned long num);
-
- // if there's not enough memory for the concatenated value, the string
- // will be left unchanged (but this isn't signalled in any way)
- String & operator += (const String &rhs) {concat(rhs); return (*this);}
- String & operator += (const char *cstr) {concat(cstr); return (*this);}
- String & operator += (char c) {concat(c); return (*this);}
- String & operator += (unsigned char num) {concat(num); return (*this);}
- String & operator += (int num) {concat(num); return (*this);}
- String & operator += (unsigned int num) {concat(num); return (*this);}
- String & operator += (long num) {concat(num); return (*this);}
- String & operator += (unsigned long num) {concat(num); return (*this);}
-
- friend StringSumHelper & operator + (const StringSumHelper &lhs, const String &rhs);
- friend StringSumHelper & operator + (const StringSumHelper &lhs, const char *cstr);
- friend StringSumHelper & operator + (const StringSumHelper &lhs, char c);
- friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned char num);
- friend StringSumHelper & operator + (const StringSumHelper &lhs, int num);
- friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned int num);
- friend StringSumHelper & operator + (const StringSumHelper &lhs, long num);
- friend StringSumHelper & operator + (const StringSumHelper &lhs, unsigned long num);
-
- // comparison (only works w/ Strings and "strings")
- operator StringIfHelperType() const { return buffer ? &String::StringIfHelper : 0; }
- int compareTo(const String &s) const;
- unsigned char equals(const String &s) const;
- unsigned char equals(const char *cstr) const;
- unsigned char operator == (const String &rhs) const {return equals(rhs);}
- unsigned char operator == (const char *cstr) const {return equals(cstr);}
- unsigned char operator != (const String &rhs) const {return !equals(rhs);}
- unsigned char operator != (const char *cstr) const {return !equals(cstr);}
- unsigned char operator < (const String &rhs) const;
- unsigned char operator > (const String &rhs) const;
- unsigned char operator <= (const String &rhs) const;
- unsigned char operator >= (const String &rhs) const;
- unsigned char equalsIgnoreCase(const String &s) const;
- unsigned char startsWith( const String &prefix) const;
- unsigned char startsWith(const String &prefix, unsigned int offset) const;
- unsigned char endsWith(const String &suffix) const;
+ public:
+ // constructors
+ String( const char *value = "" );
+ String( const String &value );
+ String( const char );
+ String( const unsigned char );
+ String( const int, const int base=10);
+ String( const unsigned int, const int base=10 );
+ String( const long, const int base=10 );
+ String( const unsigned long, const int base=10 );
+ ~String() { free(_buffer); _length = _capacity = 0;} //added _length = _capacity = 0;
+
+ // operators
+ const String & operator = ( const String &rhs );
+ const String & operator +=( const String &rhs );
+ //const String & operator +=( const char );
+ int operator ==( const String &rhs ) const;
+ int operator !=( const String &rhs ) const;
+ int operator < ( const String &rhs ) const;
+ int operator > ( const String &rhs ) const;
+ int operator <=( const String &rhs ) const;
+ int operator >=( const String &rhs ) const;
+ char operator []( unsigned int index ) const;
+ char& operator []( unsigned int index );
+ //operator const char *() const { return _buffer; }
+
+ // general methods
+ char charAt( unsigned int index ) const;
+ int compareTo( const String &anotherString ) const;
+ unsigned char endsWith( const String &suffix ) const;
+ unsigned char equals( const String &anObject ) const;
+ unsigned char equalsIgnoreCase( const String &anotherString ) const;
+ int indexOf( char ch ) const;
+ int indexOf( char ch, unsigned int fromIndex ) const;
+ int indexOf( const String &str ) const;
+ int indexOf( const String &str, unsigned int fromIndex ) const;
+ int lastIndexOf( char ch ) const;
+ int lastIndexOf( char ch, unsigned int fromIndex ) const;
+ int lastIndexOf( const String &str ) const;
+ int lastIndexOf( const String &str, unsigned int fromIndex ) const;
+ unsigned int length( ) const { return _length; }
+ void setCharAt(unsigned int index, const char ch);
+ unsigned char startsWith( const String &prefix ) const;
+ unsigned char startsWith( const String &prefix, unsigned int toffset ) const;
+ String substring( unsigned int beginIndex ) const;
+ String substring( unsigned int beginIndex, unsigned int endIndex ) const;
+ String toLowerCase( ) const;
+ String toUpperCase( ) const;
+ String trim( ) const;
+ void getBytes(unsigned char *buf, unsigned int bufsize);
+ void toCharArray(char *buf, unsigned int bufsize);
+ long toInt( );
+ const String& concat( const String &str );
+ String replace( char oldChar, char newChar );
+ String replace( const String& match, const String& replace );
+ friend String operator + ( String lhs, const String &rhs );
+
+ protected:
+ char *_buffer; // the actual char array
+ unsigned int _capacity; // the array length minus one (for the '\0')
+ unsigned int _length; // the String length (not counting the '\0')
+
+ void getBuffer(unsigned int maxStrLen);
+
+ private:
- // character acccess
- char charAt(unsigned int index) const;
- void setCharAt(unsigned int index, char c);
- char operator [] (unsigned int index) const;
- char& operator [] (unsigned int index);
- void getBytes(unsigned char *buf, unsigned int bufsize, unsigned int index=0) const;
- void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const
- {getBytes((unsigned char *)buf, bufsize, index);}
-
- // search
- int indexOf( char ch ) const;
- int indexOf( char ch, unsigned int fromIndex ) const;
- int indexOf( const String &str ) const;
- int indexOf( const String &str, unsigned int fromIndex ) const;
- int lastIndexOf( char ch ) const;
- int lastIndexOf( char ch, unsigned int fromIndex ) const;
- int lastIndexOf( const String &str ) const;
- int lastIndexOf( const String &str, unsigned int fromIndex ) const;
- String substring( unsigned int beginIndex ) const;
- String substring( unsigned int beginIndex, unsigned int endIndex ) const;
-
- // modification
- void replace(char find, char replace);
- void replace(const String& find, const String& replace);
- void toLowerCase(void);
- void toUpperCase(void);
- void trim(void);
-
- // parsing/conversion
- long toInt(void) const;
-
-protected:
- char *buffer; // the actual char array
- unsigned int capacity; // the array length minus one (for the '\0')
- unsigned int len; // the String length (not counting the '\0')
- unsigned char flags; // unused, for future features
-protected:
- void init(void);
- void invalidate(void);
- unsigned char changeBuffer(unsigned int maxStrLen);
- unsigned char concat(const char *cstr, unsigned int length);
-
- // copy and move
- String & copy(const char *cstr, unsigned int length);
- #ifdef __GXX_EXPERIMENTAL_CXX0X__
- void move(String &rhs);
- #endif
};
-class StringSumHelper : public String
+// allocate buffer space
+inline void String::getBuffer(unsigned int maxStrLen)
{
-public:
- StringSumHelper(const String &s) : String(s) {}
- StringSumHelper(const char *p) : String(p) {}
- StringSumHelper(char c) : String(c) {}
- StringSumHelper(unsigned char num) : String(num) {}
- StringSumHelper(int num) : String(num) {}
- StringSumHelper(unsigned int num) : String(num) {}
- StringSumHelper(long num) : String(num) {}
- StringSumHelper(unsigned long num) : String(num) {}
-};
+ _capacity = maxStrLen;
+ _buffer = (char *) malloc(_capacity + 1);
+ if (_buffer == NULL) _length = _capacity = 0;
+}
+
+inline String operator+( String lhs, const String &rhs )
+{
+ return lhs += rhs;
+}
+
-#endif // __cplusplus
-#endif // String_class_h
+#endif