+usbasp.2006-09-16
+-----------------
+- add usb reset on startup
+- included new AVRUSB driver version (Release 2006-07-18)
+- changed VID and PID to OBDEV's shared IDs to meet new licence conditions
+- removed avrdude patch from this package. USBasp is supported in latest avrdude CVS version
+
usbasp.2005-11-14
-----------------------
+-----------------
- fixed blocksize restriction (programming the Mega128 now works)
by Thomas Pfeifer (TP)
- update patch for avrdude-5.0
driver, choose "bin/win-driver". On Win2k and WinXP systems, Windows will
warn that the driver is is not 'digitally signed'. Ignore this message and
continue with the installation.
-Now you can run the precompiled version of avrdude: change in command line
-mode to "bin/win-avrdude" and start the program. Consult the documentation
-of avrdude for details. Examples:
+Now you can run avrdude. Examples:
1. Enter terminal mode with an AT90S2313 connected to the programmer:
avrdude -c usbasp -p at90s2313 -t
2. Write main.hex to the flash of an ATmega8:
and low byte = 0x9f.
Software (avrdude):
-An extension to avrdude (http://www.nongnu.org/avrdude/) was written.
-To compile the software:
+The latest avrdude CVS version supports USBasp.
1. install libusb: http://libusb.sourceforge.net/
-2. get avrdude-5.0.tar.gz and extract it:
- tar xvzf avrdude-5.0.tar.gz
-3. cp usbasp/software/usbasp.* avrdude-5.0/
-4. cd avrdude-5.0
-5. apply the patch:
- patch -p1 < ../usbasp/software/avrdude_usbasp.xxxx-xx-xx.patch
-6. configure to your environment:
+2. get avrdude CVS version:
+ cvs -z3 -d:pserver:anonymous@cvs.savannah.nongnu.org:/sources/avrdude co avrdude
+4. cd avrdude
+5. configure to your environment:
./bootstrap (I had to comment out the two if-blocks which verify the
installed versions of autoconf and automake)
./configure
-7. compile and install it:
+6. compile and install it:
make
make install
firmware ........................ Source code of the controller firmware
firmware/usbdrv ................. AVR USB driver by Objective Development
firmware/usbdrv/License.txt ..... Public license for AVR USB driver and USBasp
-software ........................ Source code of the host software
circuit ......................... Circuit diagram in PDF
bin ............................. Precompiled programs
bin/win-driver .................. Windows driver
-bin/win-avrdude ................. avrdude compiled for Windows
MORE INFORMATION
libusb-win32 .................... http://libusb-win32.sourceforge.net/
-2005-11-14 Thomas Fischl <tfischl@gmx.de>
+2006-09-16 Thomas Fischl <tfischl@gmx.de>
http://www.fischl.de
+++ /dev/null
-:100000003BC072C153C052C051C050C04FC04EC05F
-:100010004DC04CC04BC04AC049C048C047C046C094
-:1000200045C044C043C00E03550053004200610068
-:10003000730070001C037700770077002E006600C5
-:1000400069007300630068006C002E0064006500A6
-:1000500004030904090212000101008019090400C7
-:1000600000000000000012010101FF000008EB0386
-:10007000B4C700010102000111241FBECFE5D4E086
-:10008000DEBFCDBF10E0A0E6B0E0EEEEFCE002C0C7
-:1000900005900D92A436B107D9F710E0A4E6B0E0C0
-:1000A00001C01D92A33AB107E1F70CC6A9CF1F9377
-:1000B000CF93FC0180919C008D3269F080917A0091
-:1000C00087FD04C0CF0166D58F3F71F010926300A9
-:1000D00010927A0066C0C0E010E8683061F0C0930A
-:1000E000630010937A005DC08EE180938E0082E001
-:1000F0008093620056C080818076F9F427E930E071
-:10010000C093970081818823A1F08530E9F0863083
-:10011000F9F0883061F18A3071F130939E002093BC
-:100120009D0087818823D9F686818C17C0F6C82F59
-:10013000D6CFC0939800C2E0F0CFC681CF0104D4DF
-:100140008F3FA9F710E0CBCF828180937B00E5CF72
-:1001500010EC8381813089F0823099F08330E9F6A8
-:100160008281882391F4C4E020E530E0D6CFC1E05D
-:10017000C0939700D2CFC1E0D0CFC2E126E630E0F5
-:10018000CCCFC2E124E530E0C8CF813031F08230FD
-:1001900021F6CEE026E230E0C0CFCCE124E330E02F
-:1001A000BCCFCF911F910895CF9360919F0066239C
-:1001B00051F0635067FD05C080919A009927019620
-:1001C00076DF10929F008091620087FD1AC086B38F
-:1001D000837019F010927C0077C080917C00882396
-:1001E00009F072C094E686B3837009F06DC0915037
-:1001F000D1F781E080937C009093990090937B00ED
-:1002000063C0809163008F3F31F12BE490917A00BD
-:1002100090FD23EC9F5F90937A0020938E00682FCF
-:10022000893008F068E0861B80936300AFE8B0E097
-:1002300097FD30C0662349F560E070E0C62F693055
-:10024000A0F08EE180938E0092E08FEF80936300A8
-:1002500090936200BCCF80917B00882309F4B7CFD4
-:100260008093990010927B00B2CF8FE890E0C1D1CB
-:10027000EC2FFF27E257FF4F818392839C2F9C5FD7
-:10028000C83018F390936200A2CFCD0146D4682FF6
-:100290007727D4CFE0919D00F0919E0096FF0DC08E
-:1002A000962F03C084918D9331969150D8F7F09397
-:1002B0009E00E0939D007727C1CF962F02C08191C9
-:1002C0008D939150E0F7F3CFCF91089584E690E0BD
-:1002D00080939B000B9680939A0085B7836085BFBF
-:1002E0008BB780648BBF08950F930FB70F93B09BAC
-:1002F000FECFB09B06C0B09B04C0B09B02C0000004
-:1003000000C01F933F932F9331E012E006B31027F4
-:1003100010FD32E0102F3A95C9F700FDE4C006B396
-:10032000102717952FE72795DF9316B30127079519
-:100330002795CF93C0919B0006B31027179527955B
-:100340003BE0DD274F9316B30127079527954FEF25
-:10035000000055C0B09BFECFB09B06C0B09B04C050
-:10036000B09B02C0000000C0DF9100C0CDCF16B32B
-:10037000137079F1407C2C6F13C006B3037049F100
-:1003800041782C6F15C0037021F1102F2C6F06B32C
-:1003900019C006B30370E9F04E7F2C6F18C038F314
-:1003A00006B30370B1F0102717952795243028F372
-:1003B00016B3012707952795422749934FEF06B3B8
-:1003C000243008F3102717952795243010F316B31F
-:1003D0001370E1F10127079527952430F0F006B35B
-:1003E0000370A1F11027179527952430E0F016B37C
-:1003F0000127079527953A9541F12430D0F006B3AF
-:10040000037021F11027179527952430C0F016B3FB
-:100410000127079527952430C2CF16B31370B1F08A
-:100420004C7F2C6FDCCF06B3037081F0487F2C6FBC
-:10043000DECF16B3137051F0407F2C6FE0CF06B3C0
-:10044000037021F0407E2C6FE2CF3AC03C2FC09168
-:100450009B003C1B00E433300ABF90F108811981F6
-:10046000412F1F77209199000D3271F1013E61F10A
-:100470000936B9F0033C11F00B3411F51091A000CE
-:100480001123F1F000919F000030B1F530939F00EF
-:1004900010939C0000919A00C0939A0000939B00D7
-:1004A0002EC0121769F4309162003F3F29F10FEF1F
-:1004B00000936200CEE8D0E025C000270093A000A2
-:1004C0004F91CF91DF910FC01217B9F70093A000A1
-:1004D0000FEF00936300009362004F91CF910AB732
-:1004E00006FD38CFDF9100E40ABF2F913F911F91A5
-:1004F0000F910FBF0F911895C0E6D0E002C0C1E682
-:10050000D0E032E05F9308B30C7F016008BB53E09A
-:1005100017B3136017BB20E80FC0052710E008BB16
-:1005200010C0052710E0089408BB13C0052710E091
-:1005300015C0052710E019C020FF052708BB279527
-:1005400017951C3F50F720FF0527279508BB1795E7
-:100550001C3F38F720FF05272795179508BB1C3F40
-:1005600028F720FF0527279517951C3F08BB08F79C
-:1005700000C0499120FF052708BB279517951C3F10
-:1005800048F520FF0527279508BB17951C3F30F538
-:1005900020FF05272795179508BB1C3F20F520FF56
-:1005A0000527279517951C3F08BB00F5242F3A9582
-:1005B00019F60C7F5F9108BB34E03A95F1F70160C2
-:1005C00017B31C7F08BB0C7F4F91CF9117BB08BBA3
-:1005D000DF9189CF052710E008BBD1CF052710E0B8
-:1005E000089408BBD4CF052710E0D6CF052710E02C
-:1005F000DACFA82FB92F8FEF9FEF41E050EA61507B
-:1006000070F02D9138E0722F782796958795269572
-:1006100070FF02C0842795273A95A9F7F0CF8095FF
-:100620009095089582E58DB981E08EB9089588236B
-:1006300039F488E493E09093A2008093A100089598
-:1006400085E693E09093A2008093A100089592B76D
-:1006500082B7891B8C30E0F3089587B38C6287BB27
-:10066000C298C598F4DFC29AF2DFC2988091A100C7
-:100670009091A2008556934009F00895D3DF089524
-:1006800087B3837D87BB88B3837D88BB1DB80895FE
-:100690000F931F93CF93C82F00E017E00CC0C398AF
-:1006A000CC0F000FB4990F5FC59AD1DFC598CFDF8B
-:1006B000115017FD04C0C7FFF2CFC39AF1CF802FAE
-:1006C0009927CF911F910F9108958FB9779BFECFF6
-:1006D0008FB1992708951F93CF93CFE103C0C150E5
-:1006E000CF3F51F1E091A100F091A2008CEA099571
-:1006F000E091A100F091A20083E50995E091A100AD
-:10070000F091A20080E00995182FE091A100F091EE
-:10071000A20080E00995133591F01DB8C59A97DFC6
-:10072000C59895DF8091A1009091A20085569340D5
-:10073000B1F678DFC150B0F681E090E002C080E011
-:1007400090E0CF911F9108950F931F938C018170BA
-:10075000880F880F880FE091A100F091A2008062BD
-:100760000995C801892F99278695E091A100F091FC
-:10077000A200099516950795E091A100F091A200BD
-:10078000802F0995E091A100F091A20080E00995E9
-:1007900099271F910F9108950F931F93CF93DF9384
-:1007A000EC01062F142F8170880F880F880FE091BD
-:1007B000A100F091A20080640995CE01892F9927AC
-:1007C0008695E091A100F091A2000995CE01969541
-:1007D0008795E091A100F091A2000995E091A10018
-:1007E000F091A200802F09951123A9F00F3789F00D
-:1007F0001EE102B7CE01A8DF8F3769F482B7801BF4
-:100800008D3310F002B711501123A1F781E090E071
-:1008100004C08FE08CD080E090E0DF91CF911F91F9
-:100820000F9108950F931F93CF93DF93EC01162F31
-:10083000E091A100F091A2008CE40995CE01892FEE
-:1008400099278695E091A100F091A2000995CE012B
-:1008500096958795E091A100F091A2000995E0910D
-:10086000A100F091A20080E009951F3F89F01EE1F0
-:1008700002B7CE0169DF8F3F69F482B7801B8D33E9
-:1008800010F002B711501123A1F781E090E004C0ED
-:100890008FE04DD080E090E0DF91CF911F910F91DC
-:1008A00008950F931F938C01E091A100F091A20095
-:1008B00080EA0995812F9927E091A100F091A2008B
-:1008C0000995E091A100F091A200802F0995E09197
-:1008D000A100F091A20080E0099599271F910F9146
-:1008E0000895FF920F931F938C01F62EE091A100C3
-:1008F000F091A20080EC0995812F9927E091A10049
-:10090000F091A2000995E091A100F091A200802F42
-:100910000995E091A100F091A2008F2D09958EE13B
-:1009200006D080E090E01F910F91FF900895382F3E
-:1009300020E0231740F492B782B7891B8C33E0F391
-:100940002F5F2317C0F308951F93CF93DF93EC011C
-:1009500010E089818130A1F0823009F489C08330B0
-:1009600009F489C0843091F0873009F467C085307C
-:1009700009F4C3C0863039F1883009F0C2C09DC087
-:100980009A9B812F54DE69DEA998BBC08B81992781
-:10099000982F88272A813327822B932B90938900C5
-:1009A000809388008F819927982F88272E8133275D
-:1009B000822B932B90937E0080937D0082E0809326
-:1009C0007F001FEF9EC08B819927982F88272A814F
-:1009D0003327822B932B90938900809388008C81FE
-:1009E000482F552750938B0040938A002D812F70FC
-:1009F00020938C008D819927807F907082959295AD
-:100A0000907F9827807F9827840F951F90938B0065
-:100A100080938A0020FF04C080918A0080938D001B
-:100A20008F819927982F88272E813327822B932B0C
-:100A300090937E0080937D0081E0C1CF8B819927C8
-:100A4000982F88272A813327822B932B9093890014
-:100A5000809388008F819927982F88272E813327AC
-:100A6000822B932B90937E0080937D0083E0A7CF11
-:100A700007DEA99A46C0E091A100F091A2008A8108
-:100A8000099580938000E091A100F091A2008B81F4
-:100A9000099580938100E091A100F091A2008C81E2
-:100AA000099580938200E091A100F091A2008D81D0
-:100AB00009958093830014E024C08B819927982F97
-:100AC00088272A813327822B932B90938900809348
-:100AD000880010928B0010928A0010938C008F81F6
-:100AE0009927982F88272E813327822B932B909339
-:100AF0007E0080937D0084E062CFEDDD80938000F6
-:100B000011E080E890E090939E0080939D00812FFB
-:100B10009927DF91CF911F910895EF92FF921F9334
-:100B2000CF937C01162F90917F00892F82508230C5
-:100B300050F5C0E0C617C0F01FC0809188009091AA
-:100B40008900AFDEF701EC0FF11D808380918800F2
-:100B50009091890001969093890080938800CF5FDF
-:100B6000C11750F490917F00923039F7809188003E
-:100B700090918900E9DDE6CF183010F410927F00E3
-:100B8000812F992702C08FEF90E0CF911F91FF90A6
-:100B9000EF900895CF92DF92EF92FF920F931F9301
-:100BA000CF93DF936C01062F40917F00413019F005
-:100BB000443009F07CC010E0101708F445C074C040
-:100BC00080918A0090918B00892B09F04CC0C12F35
-:100BD000DD27FE01EC0DFD1D608180918800909164
-:100BE0008900DADD80917D0090917E0001979093DD
-:100BF0007E0080937D00892BC9F410927F00809144
-:100C00008C0081FF13C080918D00282F33278091A5
-:100C10008A0090918B002817390741F0CC0DDD1D1B
-:100C200068818091880090918900FCDD8091880026
-:100C300090918900019690938900809388001F5FAE
-:100C4000101790F540917F00413009F4B9CFC12FC2
-:100C5000DD27FE01EC0DFD1D6081809188009091E3
-:100C600089003FDEBFCFC12FDD277E01EC0CFD1CCC
-:100C700040E0F701608180918800909189008CDDCF
-:100C800080918D00815080938D00882309F0AACF38
-:100C9000F70160818091880090918900C3DD809187
-:100CA0008A0080938D009ECF80E090E002C08FEF9D
-:100CB00090E0DF91CF911F910F91FF90EF90DF9027
-:100CC000CF900895CFE5D4E0DEBFCDBF12BA18BAF9
-:100CD0008BEF81BB17BA93E094BB8EEF85BB93BFBC
-:0E0CE00081E0A5DCF3DA78945FDA5EDAFDCF0E
-:040CEE005AD2FFFFD8
-:00000001FF
--- /dev/null
+:100000003BC07CC153C052C051C050C04FC04EC055
+:100010004DC04CC04BC04AC049C048C047C046C094
+:1000200045C044C043C00902120001010080190903
+:10003000040000000000000012010101FF000008A0
+:10004000C016DC050101010200010E03550053003A
+:1000500042006100730070001C0377007700770096
+:100060002E00660069007300630068006C002E00BB
+:10007000640065000403090411241FBECFE5D4E029
+:10008000DEBFCDBF10E0A0E6B0E0E2E2FDE002C0DE
+:1000900005900D92A236B107D9F710E0A2E6B0E0C4
+:1000A00001C01D92A23AB107E1F71FC6A9CF1F9365
+:1000B000CF93DF9360919C00662359F1635067FDF5
+:1000C0006CC0C2E6D0E0C0919600CF5F20E010E89F
+:1000D000809199008D3209F465C08091780087FD88
+:1000E00009C0CE016AD52FEF821709F49FC0811194
+:1000F00020E010E010937800922F2093610010927E
+:100100009C009F3F51F486B3837089F1109279006F
+:10011000E3C0909161009F3FB1F38091600084FF44
+:10012000F2CF692F9930B8F5961B909361001BE4CC
+:100130008091780080FD13EC8F5F80937800ACE8AD
+:10014000B0E087FD60C0662309F058C060E070E051
+:10015000C62F693008F446C02EE18FEF809361000E
+:1001600010938B002093600086B3837079F68091A2
+:100170007900882309F0B0C094E686B3837009F053
+:10018000ABC09150D1F781E08093790090939D00AE
+:1001900090939800A1C068E0C7CF90916100109241
+:1001A0009C00AFCF683009F0A5CF8881807609F038
+:1001B00056C044E950E0209394008981882309F0D7
+:1001C00041C02093950022E050939B0040939A00F9
+:1001D0008F81882309F08ECF8E81821708F08ACF15
+:1001E000282F88CF8CE890E02CD22C2F2C5FC830A1
+:1001F00008F0B6CF9FEF90936100B2CFCD01A0D4AD
+:10020000682F7727A5CFE0919A00F0919B0086FF99
+:1002100012C0962F03C084918D9331969150D8F7D8
+:10022000F0939B00E0939A00772792CF8EE1809322
+:10023000600010E05FCF962F02C081918D939150A6
+:10024000E0F7EECF8530B9F08630C9F0883039F16B
+:10025000893049F18A3009F0BBCF21E0B5CFCE011A
+:1002600086D3282F8F3F09F0B3CF888187FF41CFF6
+:100270002E8110E03FCF8A8180939D00A9CF10ECA2
+:100280008B818130A1F08230B1F0833009F0A0CFB2
+:100290008A818823A1F444E750E024E095CF4FE918
+:1002A00050E021E091CF8A8180939F0091CF48E375
+:1002B00050E022E189CF46E250E022E185CF813053
+:1002C00039F0823009F084CF4AE450E02EE07CCF50
+:1002D00048E550E02CE178CFDF91CF911F91089550
+:1002E00082E690E0809397000B968093960085B706
+:1002F000836085BF8BB780648BBF08950F930FB762
+:100300000F93B09BFECFB09B06C0B09B04C0B09BC8
+:1003100002C0000000C01F933F932F9331E012E012
+:1003200006B3102710FD32E0102F3A95C9F700FDF3
+:10033000E3C006B3102720E010FB20F9DF9316B3CB
+:10034000012700FB21F9CF93C091970006B3102736
+:1003500010FB22F93BE0D0E04F9316B3012700FBDE
+:1003600023F94FEF000055C0B09BFECFB09B06C0F5
+:10037000B09B04C0B09B02C0000000C0DF9100C071
+:10038000CDCF16B3137079F14F7D206213C006B341
+:10039000037049F14F7B206415C0037021F1102FC9
+:1003A000206806B319C006B30370E9F04E7F2160E0
+:1003B00018C039F306B30370B1F0102710FB26F90B
+:1003C000223028F316B3012700FB27F9422749936F
+:1003D0004FEF06B3243008F3102710FB20F9297FD4
+:1003E00011F316B31370E1F1012700FB21F9237F0C
+:1003F000F1F006B30370A1F1102710FB22F9277E5C
+:10040000E1F016B3012700FB23F93A9541F12F7C67
+:10041000D1F006B3037021F1102710FB24F92F79D6
+:10042000C1F016B3012700FB25F92F73C2CF16B315
+:100430001370B1F04D7F2260DCCF06B3037081F002
+:100440004B7F2460DECF16B3137051F0477F2860D6
+:10045000E0CF06B3037021F04F7E2061E2CF3BC0B6
+:100460003C2FC09197003C1B00E433300ABF98F149
+:1004700008811981412F1F77209198000D3279F161
+:10048000013E69F10936C1F00777033421F5109177
+:100490009E00112301F100919C000030C1F5343021
+:1004A000C2F130939C001093990000919600C09384
+:1004B0009600009397002DC0121769F430916000E8
+:1004C00034FD23C00AE500936000CBE8D0E025C0EE
+:1004D000002700939E004F91CF91DF910DC012171E
+:1004E000B9F700939E000AE5009360004F91CF9109
+:1004F0000AB706FD39CFDF9100E40ABF2F913F9183
+:100500001F910F910FBF0F911895432F03C04AE51C
+:1005100001C042EDC4E1D0E032E05F9353E0C09A05
+:1005200008B3B89AB99A20E80FC0052710E008BBB5
+:1005300010C0052710E0089408BB13C0052710E081
+:1005400015C0052710E019C020FF052708BB279517
+:1005500017951C3F50F720FF0527279508BB1795D7
+:100560001C3F38F720FF05272795179508BB1C3F30
+:1005700028F720FF0527279517951C3F08BB08F78C
+:1005800000C0499120FF052708BB279517951C3F00
+:1005900080F520FF0527279508BB17951C3F68F5B8
+:1005A00020FF05272795179508BB1C3F58F520FF0E
+:1005B0000527279517951C3F08BB38F5242F3A953A
+:1005C00019F60C7F5F9108BB32E03A95F1F7109174
+:1005D0009D00C651D04011F010939800016017B3F0
+:1005E0001C7F08BB0C7F4F91CF9117BB08BBDF91DD
+:1005F00083CF052710E008BBCACF052710E0089479
+:1006000008BBCDCF052710E0CFCF052710E0D3CF13
+:10061000A82FB92F8FEF9FEF41E050EA615070F0A3
+:100620002D9138E0722F782796958795269570FF43
+:1006300002C0842795273A95A9F7F0CF8095909529
+:100640000895E6DF8D939D93089582E58DB981E04D
+:100650008EB90895882339F48BE593E09093A10037
+:100660008093A000089588E793E09093A100809381
+:10067000A000089592B782B7891B8C30E0F30895EB
+:1006800087B38C6287BBC298C598F4DFC29AF2DF49
+:10069000C2988091A0009091A1008857934009F0E2
+:1006A0000895D3DF089587B3837D87BB88B3837DA7
+:1006B00088BB1DB808950F931F93CF93C82F00E0F8
+:1006C00017E00CC0C398CC0F000FB4990F5FC59A08
+:1006D000D1DFC598CFDF115017FD04C0C7FFF2CF9F
+:1006E000C39AF1CF802F9927CF911F910F91089531
+:1006F0008FB9779BFECF8FB1992708951F93CF9322
+:10070000CFE103C0C150CF3F51F1E091A000F09183
+:10071000A1008CEA0995E091A000F091A10083E589
+:100720000995E091A000F091A10080E00995182FB3
+:10073000E091A000F091A10080E00995133591F0BF
+:100740001DB8C59A97DFC59895DF8091A00090915C
+:10075000A10088579340B1F678DFC150B0F681E030
+:1007600090E002C080E090E0CF911F9108950F9338
+:100770001F938C018170880F880F880FE091A00073
+:10078000F091A10080620995C801892F992786956B
+:10079000E091A000F091A100099516950795E091D0
+:1007A000A000F091A100802F0995E091A000F091A8
+:1007B000A10080E0099599271F910F9108950F934B
+:1007C0001F93CF93DF93EC01062F142F8170880FB6
+:1007D000880F880FE091A000F091A1008064099536
+:1007E000CE01892F99278695E091A000F091A10074
+:1007F0000995CE0196958795E091A000F091A10012
+:100800000995E091A000F091A100802F0995112396
+:10081000A9F00F3789F01EE102B7CE01A8DF8F37AC
+:1008200069F482B7801B8D3310F002B71150112389
+:10083000A1F781E090E004C08FE08CD080E090E0F0
+:10084000DF91CF911F910F9108950F931F93CF9335
+:10085000DF93EC01162FE091A000F091A1008CE451
+:100860000995CE01892F99278695E091A000F091F6
+:10087000A1000995CE0196958795E091A000F09191
+:10088000A1000995E091A000F091A10080E00995F8
+:100890001F3F89F01EE102B7CE0169DF8F3F69F487
+:1008A00082B7801B8D3310F002B711501123A1F7CE
+:1008B00081E090E004C08FE04DD080E090E0DF91D7
+:1008C000CF911F910F9108950F931F938C01E09189
+:1008D000A000F091A10080EA0995812F9927E0916D
+:1008E000A000F091A1000995E091A000F091A10075
+:1008F000802F0995E091A000F091A10080E009957A
+:1009000099271F910F910895FF920F931F938C01C8
+:10091000F62EE091A000F091A10080EC0995812FC6
+:100920009927E091A000F091A1000995E091A00025
+:10093000F091A100802F0995E091A000F091A10015
+:100940008F2D09958EE106D080E090E01F910F91E8
+:10095000FF900895382F20E0231740F492B782B714
+:10096000891B8C33E0F32F5F2317C0F308951F9387
+:10097000CF93DF93EC0110E089818130A1F08230C8
+:1009800009F489C0833009F489C0843091F087303C
+:1009900009F467C0853009F4C3C0863039F1883066
+:1009A00009F0C2C09DC09A9B812F54DE69DEA998D0
+:1009B000BBC08B819927982F88272A813327822BC8
+:1009C000932B90938600809385008F819927982F91
+:1009D00088272E813327822B932B90937B00809343
+:1009E0007A0082E080937C001FEF9EC08B81992764
+:1009F000982F88272A813327822B932B9093860068
+:100A0000809385008C81482F552750938800409310
+:100A100087002D812F70209389008D819927807FF9
+:100A2000907082959295907F9827807F9827840F69
+:100A3000951F909388008093870020FF04C08091C9
+:100A4000870080938A008F819927982F88272E818D
+:100A50003327822B932B90937B0080937A0081E045
+:100A6000C1CF8B819927982F88272A813327822B02
+:100A7000932B90938600809385008F819927982FE0
+:100A800088272E813327822B932B90937B00809392
+:100A90007A0083E0A7CF07DEA99A46C0E091A000C4
+:100AA000F091A1008A81099580937D00E091A000DA
+:100AB000F091A1008B81099580937E00E091A000C8
+:100AC000F091A1008C81099580937F00E091A000B6
+:100AD000F091A1008D8109958093800014E024C0DD
+:100AE0008B819927982F88272A813327822B932B54
+:100AF0009093860080938500109288001092870062
+:100B0000109389008F819927982F88272E8133276A
+:100B1000822B932B90937B0080937A0084E062CFAA
+:100B2000EDDD80937D0011E08DE790E090939B00D8
+:100B300080939A00812F9927DF91CF911F9108957B
+:100B4000EF92FF921F93CF937C01162F90917C0020
+:100B5000892F8250823050F5C0E0C617C0F01FC008
+:100B60008091850090918600AFDEF701EC0FF11DBA
+:100B700080838091850090918600019690938600F5
+:100B800080938500CF5FC11750F490917C00923024
+:100B900039F78091850090918600E9DDE6CF183025
+:100BA00010F410927C00812F992702C08FEF90E003
+:100BB000CF911F91FF90EF900895CF92DF92EF9227
+:100BC000FF920F931F93CF93DF936C01062F4091F9
+:100BD0007C00413019F0443009F07CC010E010175F
+:100BE00008F445C074C08091870090918800892BDB
+:100BF00009F04CC0C12FDD27FE01EC0DFD1D608109
+:100C00008091850090918600DADD80917A00909144
+:100C10007B00019790937B0080937A00892BC9F425
+:100C200010927C008091890081FF13C080918A001E
+:100C3000282F332780918700909188002817390743
+:100C400041F0CC0DDD1D688180918500909186007A
+:100C5000FCDD80918500909186000196909386003E
+:100C6000809385001F5F101790F540917C00413004
+:100C700009F4B9CFC12FDD27FE01EC0DFD1D608108
+:100C800080918500909186003FDEBFCFC12FDD2788
+:100C90007E01EC0CFD1C40E0F70160818091850035
+:100CA000909186008CDD80918A00815080938A002B
+:100CB000882309F0AACFF701608180918500909187
+:100CC0008600C3DD8091870080938A009ECF80E0FC
+:100CD00090E002C08FEF90E0DF91CF911F910F91D4
+:100CE000FF90EF90DF90CF900895CFE5D4E0DEBF86
+:100CF000CDBF12BA18BA8BEF81BB8FEF87BB90E0E4
+:100D00009150F1F78150D9F787BB93E094BB8EEFF8
+:100D100085BB93BF81E09EDCE3DA7894C8D9C7D95C
+:020D2000FDCF05
+:020D22005AFF76
+:00000001FF
+++ /dev/null
-# $Id: avrdude.conf.in,v 1.58 2005/09/18 00:44:20 bdean Exp $
-#
-# AVRDUDE Configuration File
-#
-# This file contains configuration data used by AVRDUDE which describes
-# the programming hardware pinouts and also provides part definitions.
-# AVRDUDE's "-C" command line option specifies the location of the
-# configuration file. The "-c" option names the programmer configuration
-# which must match one of the entry's "id" parameter. The "-p" option
-# identifies which part AVRDUDE is going to be programming and must match
-# one of the parts' "id" parameter.
-#
-# Possible entry formats are:
-#
-# programmer
-# id = <id1> [, <id2> [, <id3>] ...] ; # <idN> are quoted strings
-# desc = <description> ; # quoted string
-# type = par | stk500 | stk500v2 | avr910 | jtagmkii; # programmer type
-# baudrate = <num> ; # baudrate for avr910-programmer
-# vcc = <num1> [, <num2> ... ] ; # pin number(s)
-# reset = <num> ; # pin number
-# sck = <num> ; # pin number
-# mosi = <num> ; # pin number
-# miso = <num> ; # pin number
-# errled = <num> ; # pin number
-# rdyled = <num> ; # pin number
-# pgmled = <num> ; # pin number
-# vfyled = <num> ; # pin number
-# ;
-#
-# part
-# id = <id> ; # quoted string
-# desc = <description> ; # quoted string
-# has_jtag = <yes/no> ; # part has JTAG i/f
-# devicecode = <num> ; # deprecated, use stk500_devcode
-# stk500_devcode = <num> ; # numeric
-# avr910_devcode = <num> ; # numeric
-# chip_erase_delay = <num> ; # micro-seconds
-# reset = dedicated | io;
-# retry_pulse = reset | sck;
-# pgm_enable = <instruction format> ;
-# chip_erase = <instruction format> ;
-# chip_erase_delay = <num> ; # chip erase delay (us)
-# # STK500 parameters (parallel programming IO lines)
-# pagel = <num> ; # pin name in hex, i.e., 0xD7
-# bs2 = <num> ; # pin name in hex, i.e., 0xA0
-# serial = <yes/no> ; # can use serial downloading
-# parallel = <yes/no/pseudo>; # can use par. programming
-# # STK500v2 parameters, to be taken from Atmel's XML files
-# timeout = <num> ;
-# stabdelay = <num> ;
-# cmdexdelay = <num> ;
-# synchloops = <num> ;
-# bytedelay = <num> ;
-# pollvalue = <num> ;
-# pollindex = <num> ;
-# predelay = <num> ;
-# postdelay = <num> ;
-# pollmethod = <num> ;
-# mode = <num> ;
-# delay = <num> ;
-# blocksize = <num> ;
-# readsize = <num> ;
-# # JTAG ICE mkII parameters, also from XML files
-# allowfullpagebitstream = <yes/no> ;
-# enablepageprogramming = <yes/no> ;
-# idr = <num> ; # IO addr of IDR (OCD) reg.
-# rampz = <num> ; # IO addr of RAMPZ reg.
-# spmcr = <num> ; # mem addr of SPMC[S]R reg.
-# eecr = <num> ; # mem addr of EECR reg.
-# # (only when != 0x3c)
-#
-# memory <memtype>
-# paged = <yes/no> ; # yes / no
-# size = <num> ; # bytes
-# page_size = <num> ; # bytes
-# num_pages = <num> ; # numeric
-# min_write_delay = <num> ; # micro-seconds
-# max_write_delay = <num> ; # micro-seconds
-# readback_p1 = <num> ; # byte value
-# readback_p2 = <num> ; # byte value
-# pwroff_after_write = <yes/no> ; # yes / no
-# read = <instruction format> ;
-# write = <instruction format> ;
-# read_lo = <instruction format> ;
-# read_hi = <instruction format> ;
-# write_lo = <instruction format> ;
-# write_hi = <instruction format> ;
-# loadpage_lo = <instruction format> ;
-# loadpage_hi = <instruction format> ;
-# writepage = <instruction format> ;
-# ;
-# ;
-#
-# If any of the above parameters are not specified, the default value
-# of 0 is used for numerics or the empty string ("") for string
-# values. If a required parameter is left empty, AVRDUDE will
-# complain.
-#
-# NOTES:
-# * 'devicecode' is the device code used by the STK500 (see codes
-# listed below)
-# * Not all memory types will implement all instructions.
-# * AVR Fuse bits and Lock bits are implemented as a type of memory.
-# * Example memory types are:
-# "flash", "eeprom", "fuse", "lfuse" (low fuse), "hfuse" (high
-# fuse), "signature", "calibration", "lock"
-# * The memory type specified on the avrdude command line must match
-# one of the memory types defined for the specified chip.
-# * The pwroff_after_write flag causes avrdude to attempt to
-# power the device off and back on after an unsuccessful write to
-# the affected memory area if VCC programmer pins are defined. If
-# VCC pins are not defined for the programmer, a message
-# indicating that the device needs a power-cycle is printed out.
-# This flag was added to work around a problem with the
-# at90s4433/2333's; see the at90s4433 errata at:
-#
-# http://www.atmel.com/atmel/acrobat/doc1280.pdf
-#
-# INSTRUCTION FORMATS
-#
-# Instruction formats are specified as a comma seperated list of
-# string values containing information (bit specifiers) about each
-# of the 32 bits of the instruction. Bit specifiers may be one of
-# the following formats:
-#
-# '1' = the bit is always set on input as well as output
-#
-# '0' = the bit is always clear on input as well as output
-#
-# 'x' = the bit is ignored on input and output
-#
-# 'a' = the bit is an address bit, the bit-number matches this bit
-# specifier's position within the current instruction byte
-#
-# 'aN' = the bit is the Nth address bit, bit-number = N, i.e., a12
-# is address bit 12 on input, a0 is address bit 0.
-#
-# 'i' = the bit is an input data bit
-#
-# 'o' = the bit is an output data bit
-#
-# Each instruction must be composed of 32 bit specifiers. The
-# instruction specification closely follows the instruction data
-# provided in Atmel's data sheets for their parts.
-#
-# See below for some examples.
-#
-#
-# The following are STK500 part device codes to use for the
-# "devicecode" field of the part. These came from Atmel's software
-# section avr061.zip which accompanies the application note
-# AVR061 available from:
-#
-# http://www.atmel.com/atmel/acrobat/doc2525.pdf
-#
-
-#define ATTINY10 0x10
-#define ATTINY11 0x11
-#define ATTINY12 0x12
-#define ATTINY15 0x13
-#define ATTINY13 0x14
-
-#define ATTINY22 0x20
-#define ATTINY26 0x21
-#define ATTINY28 0x22
-#define ATTINY2313 0x23
-
-#define AT90S1200 0x33
-
-#define AT90S2313 0x40
-#define AT90S2323 0x41
-#define AT90S2333 0x42
-#define AT90S2343 0x43
-
-#define AT90S4414 0x50
-#define AT90S4433 0x51
-#define AT90S4434 0x52
-#define ATMEGA48 0x59
-
-#define AT90S8515 0x60
-#define AT90S8535 0x61
-#define AT90C8534 0x62
-#define ATMEGA8515 0x63
-#define ATMEGA8535 0x64
-
-#define ATMEGA8 0x70
-#define ATMEGA88 0x73
-
-#define ATMEGA161 0x80
-#define ATMEGA163 0x81
-#define ATMEGA16 0x82
-#define ATMEGA162 0x83
-#define ATMEGA169 0x84
-
-#define ATMEGA323 0x90
-#define ATMEGA32 0x91
-
-#define ATMEGA64 0xA0
-
-#define ATMEGA103 0xB1
-#define ATMEGA128 0xB2
-#define AT90CAN128 0xB3
-
-#define AT86RF401 0xD0
-
-#define AT89START 0xE0
-#define AT89S51 0xE0
-#define AT89S52 0xE1
-
-
-#
-# Overall avrdude defaults
-#
-default_parallel = "lpt1";
-default_serial = "com1";
-
-
-#
-# PROGRAMMER DEFINITIONS
-#
-
-programmer
- id = "bsd";
- desc = "Brian Dean's Programmer, http://www.bsdhome.com/avrdude/";
- type = par;
- vcc = 2, 3, 4, 5;
- reset = 7;
- sck = 8;
- mosi = 9;
- miso = 10;
-;
-
-programmer
- id = "avrisp";
- desc = "Atmel AVR ISP";
- type = stk500;
-;
-
-programmer
- id = "avrispv2";
- desc = "Atmel AVR ISP V2";
- type = stk500v2;
-;
-
-programmer
- id = "stk500";
- desc = "Atmel STK500";
- type = stk500;
-;
-
-programmer
- id = "stk500v2";
- desc = "Atmel STK500 V2";
- type = stk500v2;
-;
-
-programmer
- id = "avr910";
- desc = "Atmel Low Cost Serial Programmer";
- type = avr910;
-;
-
-programmer
- id = "usbasp";
- desc = "usbasp";
- type = usbasp;
-;
-
-programmer
- id = "butterfly";
- desc = "Atmel Butterfly Development Board";
- type = butterfly;
-;
-
-programmer
- id = "avr109";
- desc = "Atmel AppNote AVR109 Boot Loader";
- type = butterfly;
-;
-
-programmer
- id = "avr911";
- desc = "Atmel AppNote AVR911 AVROSP";
- type = butterfly;
-;
-
-programmer
- id = "jtagmkII";
- desc = "Atmel JTAG ICE mkII";
- baudrate = 19200; # default is 19200
- type = jtagmkii;
-;
-
-# easier to type
-programmer
- id = "jtag2slow";
- desc = "Atmel JTAG ICE mkII";
- baudrate = 19200; # default is 19200
- type = jtagmkii;
-;
-
-# JTAG ICE mkII @ 115200 Bd
-programmer
- id = "jtag2fast";
- desc = "Atmel JTAG ICE mkII";
- baudrate = 115200;
- type = jtagmkii;
-;
-
-# make the fast one the default, people will love that
-programmer
- id = "jtag2";
- desc = "Atmel JTAG ICE mkII";
- baudrate = 115200;
- type = jtagmkii;
-;
-
-programmer
- id = "pavr";
- desc = "Jason Kyle's pAVR Serial Programmer";
- type = avr910;
-;
-
-programmer
- id = "stk200";
- desc = "STK200";
- type = par;
- buff = 4, 5;
- sck = 6;
- mosi = 7;
- reset = 9;
- miso = 10;
-;
-
-# The programming dongle used by the popular Ponyprog
-# utility. It is almost similar to the STK200 one,
-# except that there is a LED indicating that the
-# programming is currently in progress.
-
-programmer
- id = "pony-stk200";
- desc = "Pony Prog STK200";
- type = par;
- buff = 4, 5;
- sck = 6;
- mosi = 7;
- reset = 9;
- miso = 10;
- pgmled = 8;
-;
-
-programmer
- id = "dt006";
- desc = "Dontronics DT006";
- type = par;
- reset = 4;
- sck = 5;
- mosi = 2;
- miso = 11;
-;
-
-programmer
- id = "bascom";
- desc = "Bascom SAMPLE programming cable";
- type = par;
- reset = 4;
- sck = 5;
- mosi = 2;
- miso = 11;
-;
-
-programmer
- id = "alf";
- desc = "Nightshade ALF-PgmAVR, http://nightshade.homeip.net/";
- type = par;
- vcc = 2, 3, 4, 5;
- buff = 6;
- reset = 7;
- sck = 8;
- mosi = 9;
- miso = 10;
- errled = 1;
- rdyled = 14;
- pgmled = 16;
- vfyled = 17;
-;
-
-programmer
- id = "sp12";
- desc = "Steve Bolt's Programmer";
- type = par;
- vcc = 4,5,6,7,8;
- reset = 3;
- sck = 2;
- mosi = 9;
- miso = 11;
-;
-
-programmer
- id = "picoweb";
- desc = "Picoweb Programming Cable, http://www.picoweb.net/";
- type = par;
- reset = 2;
- sck = 3;
- mosi = 4;
- miso = 13;
-;
-
-programmer
- id = "abcmini";
- desc = "ABCmini Board, aka Dick Smith HOTCHIP";
- type = par;
- reset = 4;
- sck = 3;
- mosi = 2;
- miso = 10;
-;
-
-programmer
- id = "futurlec";
- desc = "Futurlec.com programming cable.";
- type = par;
- reset = 3;
- sck = 2;
- mosi = 1;
- miso = 10;
-;
-
-
-# From the contributor of the "xil" jtag cable:
-# The "vcc" definition isn't really vcc (the cable gets its power from
-# the programming circuit) but is necessary to switch one of the
-# buffer lines (trying to add it to the "buff" lines doesn't work).
-# With this, TMS connects to RESET, TDI to MOSI, TDO to MISO and TCK
-# to SCK (plus vcc/gnd of course)
-programmer
- id = "xil";
- desc = "Xilinx JTAG cable";
- type = par;
- mosi = 2;
- sck = 3;
- reset = 4;
- buff = 5;
- miso = 13;
- vcc = 6;
-;
-
-
-programmer
- id = "dapa";
- desc = "Direct AVR Parallel Access cable";
- type = par;
- vcc = 3;
- reset = 16;
- sck = 1;
- mosi = 2;
- miso = 11;
-;
-
-
-#
-# some ultra cheap programmers use bitbanging on the
-# serialport.
-#
-
-# serial ponyprog design (dasa2 in uisp)
-# reset=!txd sck=rts mosi=dtr miso=cts
-
-programmer
- id = "ponyser";
- desc = "serial port banging, design ponyprog serial";
- type = serbb;
- reset = ~3;
- sck = 6;
- mosi = 4;
- miso = 7;
-;
-
-# unknown (dasa in uisp)
-# reset=rts sck=dtr mosi=txd miso=cts
-
-programmer
- id = "dasa";
- desc = "serial port banging, reset=rts sck=dtr mosi=txd miso=cts";
- type = serbb;
- reset = 6;
- sck = 4;
- mosi = 3;
- miso = 7;
-;
-
-# unknown (dasa3 in uisp)
-# reset=!dtr sck=rts mosi=txd miso=cts
-
-programmer
- id = "dasa3";
- desc = "serial port banging, reset=!dtr sck=rts mosi=txd miso=cts";
- type = serbb;
- reset = ~4;
- sck = 6;
- mosi = 3;
- miso = 7;
-;
-
-#
-# PART DEFINITIONS
-#
-
-#------------------------------------------------------------
-# ATtiny12
-#------------------------------------------------------------
-
-part
- id = "t12";
- desc = "ATtiny12";
- stk500_devcode = 0x12;
- avr910_devcode = 0x55;
- chip_erase_delay = 20000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- size = 64;
- min_write_delay = 9000;
- max_write_delay = 20000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = "1 0 1 0 0 0 0 0 x x x x x x x x",
- "x x a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = "1 1 0 0 0 0 0 0 x x x x x x x x",
- "x x a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x04;
- delay = 8;
- blocksize = 64;
- readsize = 256;
- ;
-
- memory "flash"
- size = 1024;
- min_write_delay = 4500;
- max_write_delay = 20000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- write_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 5;
- blocksize = 128;
- readsize = 256;
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "0 0 0 0 0 0 a1 a0 o o o o o o o o";
- ;
-
- memory "lock"
- size = 1;
- read = "0 1 0 1 1 0 0 0 x x x x x x x x",
- "x x x x x x x x x x x x x o o x";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1",
- "x x x x x x x x x x x x x x x x";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 x x x x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
-
- memory "fuse"
- size = 1;
- read = "0 1 0 1 0 0 0 0 x x x x x x x x",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x",
- "x x x x x x x x i i i i i i i i";
- ;
-;
-
-#------------------------------------------------------------
-# ATtiny13
-#------------------------------------------------------------
-
-part
- id = "t13";
- desc = "ATtiny13";
- stk500_devcode = 0x14;
- chip_erase_delay = 4000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 1;
-
- memory "eeprom"
- size = 64;
- min_write_delay = 4000;
- max_write_delay = 4000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x",
- "x x a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x",
- "x x a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x41;
- delay = 5;
- blocksize = 4;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 1024;
- page_size = 32;
- num_pages = 32;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 0 0 0 0 0 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 0 0 0 0 0 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 0 x x x x x",
- " x x x x a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 0 x x x x x",
- " x x x x a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 0 0 0 0 0 a8",
- " a7 a6 a5 a4 x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 32;
- readsize = 256;
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
-
- memory "lock"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
-
- memory "lfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "hfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
-;
-
-
-#------------------------------------------------------------
-# ATtiny15
-#------------------------------------------------------------
-
-part
- id = "t15";
- desc = "ATtiny15";
- stk500_devcode = 0x13;
- avr910_devcode = 0x56;
- chip_erase_delay = 8200;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- size = 64;
- min_write_delay = 8200;
- max_write_delay = 8200;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = "1 0 1 0 0 0 0 0 x x x x x x x x",
- "x x a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = "1 1 0 0 0 0 0 0 x x x x x x x x",
- "x x a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x04;
- delay = 10;
- blocksize = 64;
- readsize = 256;
- ;
-
- memory "flash"
- size = 1024;
- min_write_delay = 4100;
- max_write_delay = 4100;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- write_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 5;
- blocksize = 128;
- readsize = 256;
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "0 0 0 0 0 0 a1 a0 o o o o o o o o";
- ;
-
- memory "lock"
- size = 1;
- read = "0 1 0 1 1 0 0 0 x x x x x x x x",
- "x x x x x x x x x x x x x o o x";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1",
- "x x x x x x x x x x x x x x x x";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 x x x x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
-
- memory "fuse"
- size = 1;
- read = "0 1 0 1 0 0 0 0 x x x x x x x x",
- "x x x x x x x x o o o o x x o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x",
- "x x x x x x x x i i i i 1 1 i i";
- ;
-;
-
-#------------------------------------------------------------
-# AT90s1200
-#------------------------------------------------------------
-
-part
- id = "1200";
- desc = "AT90S1200";
- stk500_devcode = 0x33;
- avr910_devcode = 0x13;
- pagel = 0xd7;
- bs2 = 0xa0;
- chip_erase_delay = 20000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 1;
- bytedelay = 0;
- pollindex = 0;
- pollvalue = 0xFF;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- size = 64;
- min_write_delay = 4000;
- max_write_delay = 9000;
- readback_p1 = 0x00;
- readback_p2 = 0xff;
- read = "1 0 1 0 0 0 0 0 x x x x x x x x",
- "x x a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = "1 1 0 0 0 0 0 0 x x x x x x x x",
- "x x a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x04;
- delay = 20;
- blocksize = 32;
- readsize = 256;
- ;
- memory "flash"
- size = 1024;
- min_write_delay = 4000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- write_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x02;
- delay = 15;
- blocksize = 128;
- readsize = 256;
- ;
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- memory "fuse"
- size = 1;
- min_write_delay = 9000;
- max_write_delay = 20000;
- read = "0 1 0 1 0 0 0 0 x x x x x x x x",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i",
- "x x x x x x x x x x x x x x x x";
- ;
- memory "lock"
- size = 1;
- min_write_delay = 9000;
- max_write_delay = 20000;
- read = "0 1 0 1 1 0 0 0 x x x x x x x x",
- "x x x x x x x x x x x x x o o x";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1",
- "x x x x x x x x x x x x x x x x";
- ;
- ;
-
-#------------------------------------------------------------
-# AT90s4414
-#------------------------------------------------------------
-
-part
- id = "4414";
- desc = "AT90S4414";
- stk500_devcode = 0x50;
- avr910_devcode = 0x28;
- chip_erase_delay = 20000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- size = 256;
- min_write_delay = 9000;
- max_write_delay = 20000;
- readback_p1 = 0x80;
- readback_p2 = 0x7f;
- read = " 1 0 1 0 0 0 0 0 x x x x x x x a8",
- "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0 x x x x x x x a8",
- "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x04;
- delay = 12;
- blocksize = 64;
- readsize = 256;
- ;
- memory "flash"
- size = 4096;
- min_write_delay = 9000;
- max_write_delay = 20000;
- readback_p1 = 0x7f;
- readback_p2 = 0x7f;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write_lo = " 0 1 0 0 0 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- write_hi = " 0 1 0 0 1 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 12;
- blocksize = 64;
- readsize = 256;
- ;
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- ;
-
-#------------------------------------------------------------
-# AT90s2313
-#------------------------------------------------------------
-
-part
- id = "2313";
- desc = "AT90S2313";
- stk500_devcode = 0x40;
- avr910_devcode = 0x20;
- chip_erase_delay = 20000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- size = 128;
- min_write_delay = 4000;
- max_write_delay = 9000;
- readback_p1 = 0x80;
- readback_p2 = 0x7f;
- read = "1 0 1 0 0 0 0 0 x x x x x x x x",
- "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = "1 1 0 0 0 0 0 0 x x x x x x x x",
- "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x04;
- delay = 12;
- blocksize = 64;
- readsize = 256;
- ;
- memory "flash"
- size = 2048;
- min_write_delay = 4000;
- max_write_delay = 9000;
- readback_p1 = 0x7f;
- readback_p2 = 0x7f;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- write_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 12;
- blocksize = 128;
- readsize = 256;
- ;
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- memory "lock"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 1 1 x x i i x",
- "x x x x x x x x x x x x x x x x";
- ;
- ;
-
-#------------------------------------------------------------
-# AT90s2333
-#------------------------------------------------------------
-
-part
- id = "2333";
-##### WARNING: No XML file for device 'AT90S2333'! #####
- desc = "AT90S2333";
- stk500_devcode = 0x42;
- avr910_devcode = 0x34;
- chip_erase_delay = 20000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
-
- memory "eeprom"
- size = 128;
- min_write_delay = 9000;
- max_write_delay = 20000;
- readback_p1 = 0x00;
- readback_p2 = 0xff;
- read = "1 0 1 0 0 0 0 0 x x x x x x x x",
- "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = "1 1 0 0 0 0 0 0 x x x x x x x x",
- "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
- ;
- memory "flash"
- size = 2048;
- min_write_delay = 9000;
- max_write_delay = 20000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- write_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
- ;
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- memory "fuse"
- size = 1;
- min_write_delay = 9000;
- max_write_delay = 20000;
- pwroff_after_write = yes;
- read = "0 1 0 1 0 0 0 0 x x x x x x x x",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i",
- "x x x x x x x x x x x x x x x x";
- ;
- memory "lock"
- size = 1;
- min_write_delay = 9000;
- max_write_delay = 20000;
- read = "0 1 0 1 1 0 0 0 x x x x x x x x",
- "x x x x x x x x x x x x x o o x";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1",
- "x x x x x x x x x x x x x x x x";
- ;
- ;
-
-
-#------------------------------------------------------------
-# AT90s2343 (also AT90s2323 and ATtiny22)
-#------------------------------------------------------------
-
-part
- id = "2343";
- desc = "AT90S2343";
- stk500_devcode = 0x43;
- avr910_devcode = 0x4c;
- chip_erase_delay = 18000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- size = 128;
- min_write_delay = 9000;
- max_write_delay = 20000;
- readback_p1 = 0x00;
- readback_p2 = 0xff;
- read = "1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0",
- "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = "1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0",
- "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x04;
- delay = 12;
- blocksize = 64;
- readsize = 256;
- ;
- memory "flash"
- size = 2048;
- min_write_delay = 9000;
- max_write_delay = 20000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- write_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 12;
- blocksize = 128;
- readsize = 128;
- ;
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- memory "fuse"
- size = 1;
- min_write_delay = 9000;
- max_write_delay = 20000;
- read = "0 1 0 1 1 0 0 0 x x x x x x x x",
- "x x x x x x x x o o o x x x x o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 i",
- "x x x x x x x x x x x x x x x x";
- ;
- memory "lock"
- size = 1;
- min_write_delay = 9000;
- max_write_delay = 20000;
- read = "0 1 0 1 1 0 0 0 x x x x x x x x",
- "x x x x x x x x o o o x x x x o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1",
- "x x x x x x x x x x x x x x x x";
- ;
- ;
-
-
-#------------------------------------------------------------
-# AT90s4433
-#------------------------------------------------------------
-
-part
- id = "4433";
- desc = "AT90S4433";
- stk500_devcode = 0x51;
- avr910_devcode = 0x30;
- chip_erase_delay = 20000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- size = 256;
- min_write_delay = 9000;
- max_write_delay = 20000;
- readback_p1 = 0x00;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0 x x x x x x x x",
- "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0 x x x x x x x x",
- "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x04;
- delay = 12;
- blocksize = 128;
- readsize = 256;
- ;
- memory "flash"
- size = 4096;
- min_write_delay = 9000;
- max_write_delay = 20000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x x x x x a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x x x x x a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- write_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 12;
- blocksize = 128;
- readsize = 256;
- ;
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- memory "fuse"
- size = 1;
- min_write_delay = 9000;
- max_write_delay = 20000;
- pwroff_after_write = yes;
- read = "0 1 0 1 0 0 0 0 x x x x x x x x",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i",
- "x x x x x x x x x x x x x x x x";
- ;
- memory "lock"
- size = 1;
- min_write_delay = 9000;
- max_write_delay = 20000;
- read = "0 1 0 1 1 0 0 0 x x x x x x x x",
- "x x x x x x x x x x x x x o o x";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1",
- "x x x x x x x x x x x x x x x x";
- ;
- ;
-
-#------------------------------------------------------------
-# AT90s4434
-#------------------------------------------------------------
-
-part
- id = "4434";
-##### WARNING: No XML file for device 'AT90S4434'! #####
- desc = "AT90S4434";
- stk500_devcode = 0x52;
- avr910_devcode = 0x6c;
- chip_erase_delay = 20000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
-
- memory "eeprom"
- size = 256;
- min_write_delay = 9000;
- max_write_delay = 20000;
- readback_p1 = 0x00;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0 x x x x x x x x",
- "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0 x x x x x x x x",
- "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
- ;
- memory "flash"
- size = 4096;
- min_write_delay = 9000;
- max_write_delay = 20000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x x x x x a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x x x x x a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- write_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
- ;
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- memory "fuse"
- size = 1;
- min_write_delay = 9000;
- max_write_delay = 20000;
- read = "0 1 0 1 0 0 0 0 x x x x x x x x",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 i i i i i",
- "x x x x x x x x x x x x x x x x";
- ;
- memory "lock"
- size = 1;
- min_write_delay = 9000;
- max_write_delay = 20000;
- read = "0 1 0 1 1 0 0 0 x x x x x x x x",
- "x x x x x x x x x x x x x o o x";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1",
- "x x x x x x x x x x x x x x x x";
- ;
- ;
-
-#------------------------------------------------------------
-# AT90s8515
-#------------------------------------------------------------
-
-part
- id = "8515";
- desc = "AT90S8515";
- stk500_devcode = 0x60;
- avr910_devcode = 0x38;
- chip_erase_delay = 20000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- size = 512;
- min_write_delay = 4000;
- max_write_delay = 9000;
- readback_p1 = 0x80;
- readback_p2 = 0x7f;
- read = " 1 0 1 0 0 0 0 0 x x x x x x x a8",
- "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0 x x x x x x x a8",
- "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x04;
- delay = 12;
- blocksize = 128;
- readsize = 256;
- ;
- memory "flash"
- size = 8192;
- min_write_delay = 4000;
- max_write_delay = 9000;
- readback_p1 = 0x7f;
- readback_p2 = 0x7f;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write_lo = " 0 1 0 0 0 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- write_hi = " 0 1 0 0 1 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 12;
- blocksize = 128;
- readsize = 256;
- ;
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- memory "fuse"
- size = 1;
- read = "0 1 0 1 1 0 0 0 x x x x x x x x",
- "x x x x x x x x x x x x x x x o";
- write = "1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 i",
- "x x x x x x x x x x x x x x x x";
- ;
- memory "lock"
- size = 1;
- read = "0 1 0 1 1 0 0 0 x x x x x x x x",
- "x x x x x x x x o o x x x x x x";
- write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1",
- "x x x x x x x x x x x x x x x x";
- ;
- ;
-
-#------------------------------------------------------------
-# AT90s8535
-#------------------------------------------------------------
-
-part
- id = "8535";
- desc = "AT90S8535";
- stk500_devcode = 0x61;
- avr910_devcode = 0x68;
- chip_erase_delay = 20000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- size = 512;
- min_write_delay = 9000;
- max_write_delay = 20000;
- readback_p1 = 0x00;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0 x x x x x x x a8",
- "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0 x x x x x x x a8",
- "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x04;
- delay = 12;
- blocksize = 128;
- readsize = 256;
- ;
- memory "flash"
- size = 8192;
- min_write_delay = 9000;
- max_write_delay = 20000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write_lo = " 0 1 0 0 0 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- write_hi = " 0 1 0 0 1 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 12;
- blocksize = 128;
- readsize = 256;
- ;
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- memory "fuse"
- size = 1;
- read = "0 1 0 1 1 0 0 0 x x x x x x x x",
- "x x x x x x x x x x x x x x x o";
- write = "1 0 1 0 1 1 0 0 1 0 1 1 1 1 1 i",
- "x x x x x x x x x x x x x x x x";
- ;
- memory "lock"
- size = 1;
- read = "0 1 0 1 1 0 0 0 x x x x x x x x",
- "x x x x x x x x o o x x x x x x";
- write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1",
- "x x x x x x x x x x x x x x x x";
- ;
- ;
-
-#------------------------------------------------------------
-# ATmega103
-#------------------------------------------------------------
-
-part
- id = "m103";
- desc = "ATMEGA103";
- stk500_devcode = 0xB1;
- avr910_devcode = 0x41;
- chip_erase_delay = 112000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- size = 4096;
- min_write_delay = 4000;
- max_write_delay = 9000;
- readback_p1 = 0x80;
- readback_p2 = 0x7f;
- read = " 1 0 1 0 0 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 12;
- blocksize = 64;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 131072;
- page_size = 256;
- num_pages = 512;
- min_write_delay = 22000;
- max_write_delay = 56000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 x x x x x x x",
- " x x x x x x x x";
-
- mode = 0x11;
- delay = 70;
- blocksize = 256;
- readsize = 256;
- ;
-
- memory "fuse"
- size = 1;
- read = "0 1 0 1 0 0 0 0 x x x x x x x x",
- "x x x x x x x x x x o x o 1 o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 1 i 1 i i",
- "x x x x x x x x x x x x x x x x";
- ;
-
- memory "lock"
- size = 1;
- read = "0 1 0 1 1 0 0 0 x x x x x x x x",
- "x x x x x x x x x x x x x o o x";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 1 1 i i 1",
- "x x x x x x x x x x x x x x x x";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- ;
-
-
-#------------------------------------------------------------
-# ATmega64
-#------------------------------------------------------------
-
-part
- id = "m64";
- desc = "ATMEGA64";
- has_jtag = yes;
- stk500_devcode = 0xA0;
- chip_erase_delay = 9000;
- pagel = 0xD7;
- bs2 = 0xA0;
- reset = dedicated;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- idr = 0x22;
- spmcr = 0x68;
- allowfullpagebitstream = yes;
-
- memory "eeprom"
- paged = no; /* leave this "no" */
- page_size = 8; /* for parallel programming */
- size = 2048;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 20;
- blocksize = 64;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 65536;
- page_size = 256;
- num_pages = 256;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " x a14 a13 a12 a11 a10 a9 a8",
- " a7 x x x x x x x",
- " x x x x x x x x";
-
- mode = 0x21;
- delay = 6;
- blocksize = 128;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "hfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "efuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x x x x x x x i i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "lock"
- size = 1;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 x x x x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- ;
-
-
-
-
-#------------------------------------------------------------
-# ATmega128
-#------------------------------------------------------------
-
-part
- id = "m128";
- desc = "ATMEGA128";
- has_jtag = yes;
- stk500_devcode = 0xB2;
- avr910_devcode = 0x43;
- chip_erase_delay = 9000;
- pagel = 0xD7;
- bs2 = 0xA0;
- reset = dedicated;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- idr = 0x22;
- spmcr = 0x68;
- rampz = 0x3b;
- allowfullpagebitstream = yes;
-
- memory "eeprom"
- paged = no; /* leave this "no" */
- page_size = 8; /* for parallel programming */
- size = 4096;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " x x x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 12;
- blocksize = 64;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 131072;
- page_size = 256;
- num_pages = 512;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 x x x x x x x",
- " x x x x x x x x";
-
- mode = 0x21;
- delay = 6;
- blocksize = 128;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "hfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "efuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x x x x x x x i i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "lock"
- size = 1;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "calibration"
- size = 4;
- read = "0 0 1 1 1 0 0 0 x x x x x x x x",
- "0 0 0 0 0 0 a1 a0 o o o o o o o o";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- ;
-
-#------------------------------------------------------------
-# AT90CAN128
-#------------------------------------------------------------
-
-part
- id = "c128";
- desc = "AT90CAN128";
- has_jtag = yes;
- stk500_devcode = 0xB3;
-# avr910_devcode = 0x43;
- chip_erase_delay = 9000;
- pagel = 0xD7;
- bs2 = 0xA0;
- reset = dedicated;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 1;
-
- idr = 0x31;
- spmcr = 0x57;
- rampz = 0x3b;
- eecr = 0x3f;
- allowfullpagebitstream = no;
-
- memory "eeprom"
- paged = no; /* leave this "no" */
- page_size = 8; /* for parallel programming */
- size = 4096;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " 0 0 0 x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " 0 0 0 x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x41;
- delay = 20;
- blocksize = 8;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 131072;
- page_size = 256;
- num_pages = 512;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 0 x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 0 x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 x x x x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 256;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "hfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "efuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x x x x x i i i i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "lock"
- size = 1;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- ;
-
-
-#------------------------------------------------------------
-# ATmega16
-#------------------------------------------------------------
-
-part
- id = "m16";
- desc = "ATMEGA16";
- has_jtag = yes;
- stk500_devcode = 0x82;
- avr910_devcode = 0x74;
- pagel = 0xd7;
- bs2 = 0xa0;
- chip_erase_delay = 9000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- idr = 0x31;
- spmcr = 0x57;
- allowfullpagebitstream = yes;
-
- memory "eeprom"
- paged = no; /* leave this "no" */
- page_size = 4; /* for parallel programming */
- size = 512;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " 0 0 x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " 0 0 x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 10;
- blocksize = 128;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 16384;
- page_size = 128;
- num_pages = 128;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 a13 a12 a11 a10 a9 a8",
- " a7 a6 x x x x x x",
- " x x x x x x x x";
-
- mode = 0x21;
- delay = 6;
- blocksize = 128;
- readsize = 256;
- ;
-
- memory "lock"
- size = 1;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "lfuse"
- size = 1;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- ;
-
-
-#------------------------------------------------------------
-# ATmega164
-#------------------------------------------------------------
-
-# close to ATmega16
-
-part
- id = "m164";
- desc = "ATMEGA164";
- has_jtag = yes;
-# stk500_devcode = 0x82; # no STK500v1 support
-# avr910_devcode = 0x?; # try the ATmega16 one:^
- avr910_devcode = 0x74;
- pagel = 0xd7;
- bs2 = 0xa0;
- chip_erase_delay = 9000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- idr = 0x31;
- spmcr = 0x57;
- allowfullpagebitstream = no;
-
- memory "eeprom"
- paged = no; /* leave this "no" */
- page_size = 4; /* for parallel programming */
- size = 512;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " 0 0 x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " 0 0 x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 10;
- blocksize = 128;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 16384;
- page_size = 128;
- num_pages = 128;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 a13 a12 a11 a10 a9 a8",
- " a7 a6 x x x x x x",
- " x x x x x x x x";
-
- mode = 0x21;
- delay = 6;
- blocksize = 128;
- readsize = 256;
- ;
-
- memory "lock"
- size = 1;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "lfuse"
- size = 1;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "efuse"
- size = 1;
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x 1 1 1 1 1 i i i";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
-
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
- ;
-
-
-#------------------------------------------------------------
-# ATmega324
-#------------------------------------------------------------
-
-# similar to ATmega164
-
-part
- id = "m324";
- desc = "ATMEGA324";
- has_jtag = yes;
-# stk500_devcode = 0x82; # no STK500v1 support
-# avr910_devcode = 0x?; # try the ATmega16 one:^
- avr910_devcode = 0x74;
- pagel = 0xd7;
- bs2 = 0xa0;
- chip_erase_delay = 9000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- idr = 0x31;
- spmcr = 0x57;
- allowfullpagebitstream = no;
-
- memory "eeprom"
- paged = no; /* leave this "no" */
- page_size = 4; /* for parallel programming */
- size = 1024;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " 0 0 x x x a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " 0 0 x x x a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 10;
- blocksize = 128;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 32768;
- page_size = 256;
- num_pages = 128;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 x x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 x x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 a14 a13 a12 a11 a10 a9 a8",
- " a7 x x x x x x x",
- " x x x x x x x x";
-
- mode = 0x21;
- delay = 6;
- blocksize = 256;
- readsize = 256;
- ;
-
- memory "lock"
- size = 1;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "lfuse"
- size = 1;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "efuse"
- size = 1;
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x 1 1 1 1 1 i i i";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
-
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
- ;
-
-
-#------------------------------------------------------------
-# ATmega644
-#------------------------------------------------------------
-
-# similar to ATmega164
-
-part
- id = "m644";
- desc = "ATMEGA644";
- has_jtag = yes;
-# stk500_devcode = 0x82; # no STK500v1 support
-# avr910_devcode = 0x?; # try the ATmega16 one:^
- avr910_devcode = 0x74;
- pagel = 0xd7;
- bs2 = 0xa0;
- chip_erase_delay = 9000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- idr = 0x31;
- spmcr = 0x57;
- allowfullpagebitstream = no;
-
- memory "eeprom"
- paged = no; /* leave this "no" */
- page_size = 8; /* for parallel programming */
- size = 2048;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " 0 0 x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " 0 0 x x a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 10;
- blocksize = 128;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 65536;
- page_size = 256;
- num_pages = 256;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 x x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 x x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 x x x x x x x",
- " x x x x x x x x";
-
- mode = 0x21;
- delay = 6;
- blocksize = 256;
- readsize = 256;
- ;
-
- memory "lock"
- size = 1;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "lfuse"
- size = 1;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "efuse"
- size = 1;
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x 1 1 1 1 1 i i i";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
-
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
- ;
-
-
-#------------------------------------------------------------
-# ATmega162
-#------------------------------------------------------------
-
-part
- id = "m162";
- desc = "ATMEGA162";
- has_jtag = yes;
- stk500_devcode = 0x83;
- chip_erase_delay = 9000;
-
- idr = 0x04;
- spmcr = 0x57;
- allowfullpagebitstream = yes;
-
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- memory "flash"
- paged = yes;
- size = 16384;
- page_size = 128;
- num_pages = 128;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
-
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 a13 a12 a11 a10 a9 a8",
- " a7 a6 x x x x x x",
- " x x x x x x x x";
- ;
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- paged = no; /* leave this "no" */
- page_size = 4; /* for parallel programming */
- size = 512;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
-
- read = " 1 0 1 0 0 0 0 0",
- " 0 0 x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " 0 0 x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x41;
- delay = 20;
- blocksize = 4;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- min_write_delay = 16000;
- max_write_delay = 16000;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- min_write_delay = 16000;
- max_write_delay = 16000;
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "efuse"
- size = 1;
- min_write_delay = 16000;
- max_write_delay = 16000;
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x 1 1 1 1 1 i i i";
- ;
-
- memory "lock"
- size = 1;
- min_write_delay = 16000;
- max_write_delay = 16000;
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "signature"
- size = 3;
-
- read = "0 0 1 1 0 0 0 0 0 0 x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
-
- read = "0 0 1 1 1 0 0 0 0 0 x x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
-;
-
-
-
-#------------------------------------------------------------
-# ATmega163
-#------------------------------------------------------------
-
-part
- id = "m163";
- desc = "ATMEGA163";
- stk500_devcode = 0x81;
- avr910_devcode = 0x64;
- chip_erase_delay = 32000;
- pagel = 0xd7;
- bs2 = 0xa0;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
- memory "eeprom"
- size = 512;
- min_write_delay = 4000;
- max_write_delay = 4000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
- ;
-
- memory "flash"
- paged = yes;
- size = 16384;
- page_size = 128;
- num_pages = 128;
- min_write_delay = 16000;
- max_write_delay = 16000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x x x a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x x x a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " x x x a12 a11 a10 a9 a8",
- " a7 a6 x x x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 128;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o x x o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i 1 1 i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x x x x x 1 o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x 1 1 1 1 1 i i i";
- ;
-
- memory "lock"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x 0 x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 x x x x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
- ;
-
-#------------------------------------------------------------
-# ATmega169
-#------------------------------------------------------------
-
-part
- id = "m169";
- desc = "ATMEGA169";
- has_jtag = yes;
- stk500_devcode = 0x85;
- avr910_devcode = 0x75;
- chip_erase_delay = 9000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 1;
-
- idr = 0x31;
- spmcr = 0x57;
-
- memory "eeprom"
- paged = no; /* leave this "no" */
- page_size = 4; /* for parallel programming */
- size = 512;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x41;
- delay = 20;
- blocksize = 4;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 16384;
- page_size = 128;
- num_pages = 128;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x x x a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x x x a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " x x x a12 a11 a10 a9 a8",
- " a7 a6 x x x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 128;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "efuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x x x x x i i i i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "lock"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
- ;
-
-#------------------------------------------------------------
-# ATmega329
-#------------------------------------------------------------
-
-part
- id = "m329";
- desc = "ATMEGA329";
- has_jtag = yes;
-# stk500_devcode = 0x85; # no STK500 support, only STK500v2
-# avr910_devcode = 0x?; # try the ATmega169 one:
- avr910_devcode = 0x75;
- chip_erase_delay = 9000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 1;
-
- idr = 0x31;
- spmcr = 0x57;
-
- memory "eeprom"
- paged = no; /* leave this "no" */
- page_size = 4; /* for parallel programming */
- size = 1024;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x41;
- delay = 20;
- blocksize = 8;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 32768;
- page_size = 128;
- num_pages = 256;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " x x x a12 a11 a10 a9 a8",
- " a7 a6 x x x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 256;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "efuse"
- size = 1;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x x x x x i i i x";
- ;
-
- memory "lock"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
- ;
-
-#------------------------------------------------------------
-# ATmega3290
-#------------------------------------------------------------
-
-# identical to ATmega329
-
-part
- id = "m3290";
- desc = "ATMEGA3290";
- has_jtag = yes;
-# stk500_devcode = 0x85; # no STK500 support, only STK500v2
-# avr910_devcode = 0x?; # try the ATmega169 one:
- avr910_devcode = 0x75;
- chip_erase_delay = 9000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 1;
-
- idr = 0x31;
- spmcr = 0x57;
-
- memory "eeprom"
- paged = no; /* leave this "no" */
- page_size = 4; /* for parallel programming */
- size = 1024;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x41;
- delay = 20;
- blocksize = 8;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 32768;
- page_size = 128;
- num_pages = 256;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " x x x a12 a11 a10 a9 a8",
- " a7 a6 x x x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 256;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "efuse"
- size = 1;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x x x x x i i i x";
- ;
-
- memory "lock"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
- ;
-
-#------------------------------------------------------------
-# ATmega649
-#------------------------------------------------------------
-
-part
- id = "m649";
- desc = "ATMEGA649";
- has_jtag = yes;
-# stk500_devcode = 0x85; # no STK500 support, only STK500v2
-# avr910_devcode = 0x?; # try the ATmega169 one:
- avr910_devcode = 0x75;
- chip_erase_delay = 9000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 1;
-
- idr = 0x31;
- spmcr = 0x57;
-
- memory "eeprom"
- paged = no; /* leave this "no" */
- page_size = 8; /* for parallel programming */
- size = 2048;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " x x x x x a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " x x x x x a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x41;
- delay = 20;
- blocksize = 8;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 65536;
- page_size = 256;
- num_pages = 256;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " x x x a12 a11 a10 a9 a8",
- " a7 x x x x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 256;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "efuse"
- size = 1;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x x x x x i i i x";
- ;
-
- memory "lock"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
- ;
-
-#------------------------------------------------------------
-# ATmega6490
-#------------------------------------------------------------
-
-# identical to ATmega649
-
-part
- id = "m6490";
- desc = "ATMEGA6490";
- has_jtag = yes;
-# stk500_devcode = 0x85; # no STK500 support, only STK500v2
-# avr910_devcode = 0x?; # try the ATmega169 one:
- avr910_devcode = 0x75;
- chip_erase_delay = 9000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 1;
-
- idr = 0x31;
- spmcr = 0x57;
-
- memory "eeprom"
- paged = no; /* leave this "no" */
- page_size = 8; /* for parallel programming */
- size = 2048;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " x x x x x a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " x x x x x a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x41;
- delay = 20;
- blocksize = 8;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 65536;
- page_size = 256;
- num_pages = 256;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- "a15 a14 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x x x",
- " x a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " x x x a12 a11 a10 a9 a8",
- " a7 x x x x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 256;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "efuse"
- size = 1;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x x x x x i i i x";
- ;
-
- memory "lock"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
- ;
-
-#------------------------------------------------------------
-# ATmega32
-#------------------------------------------------------------
-
-part
- id = "m32";
- desc = "ATMEGA32";
- has_jtag = yes;
- stk500_devcode = 0x91;
- avr910_devcode = 0x72;
- chip_erase_delay = 9000;
- pagel = 0xd7;
- bs2 = 0xa0;
- reset = dedicated;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- idr = 0x31;
- spmcr = 0x57;
- allowfullpagebitstream = yes;
-
- memory "eeprom"
- paged = no; /* leave this "no" */
- page_size = 4; /* for parallel programming */
- size = 1024;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " 0 0 x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " 0 0 x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 10;
- blocksize = 64;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 32768;
- page_size = 128;
- num_pages = 256;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 a13 a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 a13 a12 a11 a10 a9 a8",
- " a7 a6 x x x x x x",
- " x x x x x x x x";
-
- mode = 0x21;
- delay = 6;
- blocksize = 64;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "lock"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 x x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
- ;
-
-#------------------------------------------------------------
-# ATmega161
-#------------------------------------------------------------
-
-part
- id = "m161";
- desc = "ATMEGA161";
- stk500_devcode = 0x80;
- avr910_devcode = 0x60;
- chip_erase_delay = 28000;
- pagel = 0xd7;
- bs2 = 0xa0;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
- "x x x x x x x x x x x x x x x x";
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- size = 512;
- min_write_delay = 3400;
- max_write_delay = 3400;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " x x x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 5;
- blocksize = 128;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 16384;
- page_size = 128;
- num_pages = 128;
- min_write_delay = 14000;
- max_write_delay = 14000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x x x a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x x x a12 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " x x x a12 a11 a10 a9 a8",
- " a7 a6 x x x x x x",
- " x x x x x x x x";
-
- mode = 0x21;
- delay = 16;
- blocksize = 128;
- readsize = 256;
- ;
-
- memory "fuse"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 0 0 0 0 x x x x x x x x",
- "x x x x x x x x x o x o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 x x x x x",
- "x x x x x x x x 1 i 1 i i i i i";
- ;
-
- memory "lock"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- ;
-
-
-#------------------------------------------------------------
-# ATmega8
-#------------------------------------------------------------
-
-part
- id = "m8";
- desc = "ATMEGA8";
- stk500_devcode = 0x70;
- avr910_devcode = 0x76;
- pagel = 0xd7;
- bs2 = 0xc2;
- chip_erase_delay = 10000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- size = 512;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " 0 0 x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " 0 0 x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 10;
- blocksize = 128;
- readsize = 256;
- ;
- memory "flash"
- paged = yes;
- size = 8192;
- page_size = 64;
- num_pages = 128;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0x00;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 0 0 x x x x",
- " x x x a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 0 0 x x x x",
- " x x x a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 x x x x x",
- " x x x x x x x x";
-
- mode = 0x21;
- delay = 6;
- blocksize = 64;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "lock"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "calibration"
- size = 4;
- read = "0 0 1 1 1 0 0 0 0 0 x x x x x x",
- "0 0 0 0 0 0 a1 a0 o o o o o o o o";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- ;
-
-
-
-#------------------------------------------------------------
-# ATmega8515
-#------------------------------------------------------------
-
-part
- id = "m8515";
- desc = "ATMEGA8515";
- stk500_devcode = 0x63;
- avr910_devcode = 0x3A;
- chip_erase_delay = 9000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- size = 512;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " 0 0 x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " 0 0 x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 10;
- blocksize = 128;
- readsize = 256;
- ;
- memory "flash"
- paged = yes;
- size = 8192;
- page_size = 64;
- num_pages = 128;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 0 0 x x x x",
- " x x x a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 0 0 x x x x",
- " x x x a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 x x x x x",
- " x x x x x x x x";
-
- mode = 0x21;
- delay = 6;
- blocksize = 64;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "lock"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 x x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- ;
-
-
-
-
-#------------------------------------------------------------
-# ATmega8535
-#------------------------------------------------------------
-
-part
- id = "m8535";
- desc = "ATMEGA8535";
- stk500_devcode = 0x64;
- pagel = 0xd7;
- bs2 = 0xa0;
- chip_erase_delay = 9000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- size = 512;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " 0 0 x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " 0 0 x x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x04;
- delay = 10;
- blocksize = 128;
- readsize = 256;
- ;
- memory "flash"
- paged = yes;
- size = 8192;
- page_size = 64;
- num_pages = 128;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 0 0 x x x x",
- " x x x a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 0 0 x x x x",
- " x x x a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 x x x x x",
- " x x x x x x x x";
-
- mode = 0x21;
- delay = 6;
- blocksize = 64;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "lock"
- size = 1;
- min_write_delay = 2000;
- max_write_delay = 2000;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 x x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- ;
-
-
-#------------------------------------------------------------
-# ATtiny26
-#------------------------------------------------------------
-
-part
- id = "t26";
- desc = "ATTINY26";
- stk500_devcode = 0x21;
- avr910_devcode = 0x5e;
- pagel = 0xb3;
- bs2 = 0xb2;
- chip_erase_delay = 9000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 0;
-
- memory "eeprom"
- size = 128;
- min_write_delay = 9000;
- max_write_delay = 9000;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = "1 0 1 0 0 0 0 0 x x x x x x x x",
- "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = "1 1 0 0 0 0 0 0 x x x x x x x x",
- "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x04;
- delay = 10;
- blocksize = 64;
- readsize = 256;
- ;
-
- memory "flash"
- paged = yes;
- size = 2048;
- page_size = 32;
- num_pages = 64;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " x x x x x x x x",
- " x x x x a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " x x x x x x x x",
- " x x x x a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " x x x x x x a9 a8",
- " a7 a6 a5 a4 x x x x",
- " x x x x x x x x";
-
- mode = 0x21;
- delay = 6;
- blocksize = 16;
- readsize = 256;
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 x x x x x x x x",
- "0 0 0 0 0 0 a1 a0 o o o o o o o o";
- ;
-
- memory "lock"
- size = 1;
- read = "0 1 0 1 1 0 0 0 x x x x x x x x",
- "x x x x x x x x x x x x x x o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 1 1 1 i i",
- "x x x x x x x x x x x x x x x x";
- ;
-
- memory "lfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "hfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x x x x i i i i i";
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x x x x o o o o o";
- ;
-
- memory "calibration"
- size = 4;
- read = "0 0 1 1 1 0 0 0 x x x x x x x x",
- "0 0 0 0 0 0 a1 a0 o o o o o o o o";
- ;
-
-;
-
-
-#------------------------------------------------------------
-# ATmega48
-#------------------------------------------------------------
-
-part
- id = "m48";
- desc = "ATMEGA48";
- stk500_devcode = 0x59;
-# avr910_devcode = 0x;
- pagel = 0xd7;
- bs2 = 0xc2;
- chip_erase_delay = 45000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 1;
-
- memory "eeprom"
- size = 256;
- min_write_delay = 3600;
- max_write_delay = 3600;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " 0 0 0 x x x x x",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " 0 0 0 x x x x x",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x41;
- delay = 5;
- blocksize = 4;
- readsize = 256;
- ;
- memory "flash"
- paged = yes;
- size = 4096;
- page_size = 64;
- num_pages = 64;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0x00;
- readback_p2 = 0x00;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 0 0 0 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 0 0 0 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 0 x x x x x",
- " x x x a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 0 x x x x x",
- " x x x a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 0 0 0 a10 a9 a8",
- " a7 a6 a5 x x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 64;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "efuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- ;
-
-
-#------------------------------------------------------------
-# ATmega88
-#------------------------------------------------------------
-
-part
- id = "m88";
- desc = "ATMEGA88";
- stk500_devcode = 0x73;
-# avr910_devcode = 0x;
- pagel = 0xd7;
- bs2 = 0xc2;
- chip_erase_delay = 9000;
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 1;
-
- memory "eeprom"
- size = 512;
- min_write_delay = 3600;
- max_write_delay = 3600;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = " 1 0 1 0 0 0 0 0",
- " 0 0 0 x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- write = " 1 1 0 0 0 0 0 0",
- " 0 0 0 x x x x a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- mode = 0x41;
- delay = 5;
- blocksize = 4;
- readsize = 256;
- ;
- memory "flash"
- paged = yes;
- size = 8192;
- page_size = 64;
- num_pages = 128;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 0 x x x x x",
- " x x x a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 0 x x x x x",
- " x x x a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 x x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 64;
- readsize = 256;
- ;
-
- memory "lfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "hfuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "efuse"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x i i i i i i i i";
- ;
-
- memory "lock"
- size = 1;
- min_write_delay = 4500;
- max_write_delay = 4500;
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
-
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
-
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- ;
-
-
-#------------------------------------------------------------
-# ATtiny2313
-#------------------------------------------------------------
-
-part
- id = "t2313";
- desc = "ATtiny2313";
- stk500_devcode = 0x23;
-## avr910_devcode = ?;
-## Try the AT90S2313 devcode:
- avr910_devcode = 0x20;
- pagel = 0xD4;
- bs2 = 0xD6;
- reset = io;
- chip_erase_delay = 9000;
-
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 1;
-
- memory "eeprom"
- size = 128;
- min_write_delay = 4000;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x",
- "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x",
- "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x41;
- delay = 6;
- blocksize = 4;
- readsize = 256;
- ;
- memory "flash"
- paged = yes;
- size = 2048;
- page_size = 32;
- num_pages = 64;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 0 0 0 0 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 0 0 0 0 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
-# The information in the data sheet of April/2004 is wrong, this works:
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 0 x x x x x",
- " x x x x a3 a2 a1 a0",
- " i i i i i i i i";
-
-# The information in the data sheet of April/2004 is wrong, this works:
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 0 x x x x x",
- " x x x x a3 a2 a1 a0",
- " i i i i i i i i";
-
-# The information in the data sheet of April/2004 is wrong, this works:
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 0 0 0 0 a9 a8",
- " a7 a6 a5 a4 x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 32;
- readsize = 256;
- ;
-# ATtiny2313 has Signature Bytes: 0x1E 0x91 0x0A.
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- memory "lock"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "lfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "hfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "efuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x x x x x x x x i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-# The Tiny2313 has calibration data for both 4 MHz and 8 MHz.
-# The information in the data sheet of April/2004 is wrong, this works:
-
- memory "calibration"
- size = 2;
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 a0 o o o o o o o o";
- ;
- ;
-
-#------------------------------------------------------------
-# AT90PWM2
-#------------------------------------------------------------
-
-part
- id = "pwm2";
- desc = "AT90PWM2";
- stk500_devcode = 0x65;
-## avr910_devcode = ?;
- pagel = 0xD8;
- bs2 = 0xE2;
- reset = io;
- chip_erase_delay = 9000;
-
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 1;
-
- memory "eeprom"
- size = 512;
- min_write_delay = 4000;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8",
- "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8",
- "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x41;
- delay = 6;
- blocksize = 4;
- readsize = 256;
- ;
- memory "flash"
- paged = yes;
- size = 8192;
- page_size = 64;
- num_pages = 128;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 0 x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 0 x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 x x x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 64;
- readsize = 256;
- ;
-# AT90PWM2 has Signature Bytes: 0x1E 0x93 0x81.
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 0 0 x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- memory "lock"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
- ;
-
- memory "lfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "hfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "efuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x x x x x x x x i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
- ;
-
-#------------------------------------------------------------
-# AT90PWM3
-#------------------------------------------------------------
-
-# Completely identical to AT90PWM2 (including the signature!)
-
-part
- id = "pwm3";
- desc = "AT90PWM3";
- stk500_devcode = 0x65;
-## avr910_devcode = ?;
- pagel = 0xD8;
- bs2 = 0xE2;
- reset = io;
- chip_erase_delay = 9000;
-
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 1;
-
- memory "eeprom"
- size = 512;
- min_write_delay = 4000;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8",
- "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8",
- "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x41;
- delay = 6;
- blocksize = 4;
- readsize = 256;
- ;
- memory "flash"
- paged = yes;
- size = 8192;
- page_size = 64;
- num_pages = 128;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 0 x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 0 x x x x x",
- " x x a5 a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 x x x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 64;
- readsize = 256;
- ;
-# AT90PWM2 has Signature Bytes: 0x1E 0x93 0x81.
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 0 0 x x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- memory "lock"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x x x o o o o o o";
- ;
-
- memory "lfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "hfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "efuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x x x x x x x x i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 0 o o o o o o o o";
- ;
- ;
-
-#------------------------------------------------------------
-# ATtiny25
-#------------------------------------------------------------
-
-part
- id = "t25";
- desc = "ATtiny25";
-## no STK500 devcode in XML file, use the ATtiny45 one
- stk500_devcode = 0x14;
-## avr910_devcode = ?;
-## Try the AT90S2313 devcode:
- avr910_devcode = 0x20;
- reset = io;
- chip_erase_delay = 4500;
-
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 1;
-
- memory "eeprom"
- size = 128;
- min_write_delay = 4000;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x",
- "x a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x",
- "x a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x41;
- delay = 6;
- blocksize = 4;
- readsize = 256;
- ;
- memory "flash"
- paged = yes;
- size = 2048;
- page_size = 32;
- num_pages = 64;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 0 0 0 0 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 0 0 0 0 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 0 x x x x x",
- " x x x x a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 0 x x x x x",
- " x x x x a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 0 0 0 0 a9 a8",
- " a7 a6 a5 a4 x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 32;
- readsize = 256;
- ;
-# ATtiny25 has Signature Bytes: 0x1E 0x91 0x08.
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- memory "lock"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "lfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "hfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "efuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x x x x x x x x i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 a0 o o o o o o o o";
- ;
- ;
-
-#------------------------------------------------------------
-# ATtiny45
-#------------------------------------------------------------
-
-part
- id = "t45";
- desc = "ATtiny45";
- stk500_devcode = 0x14;
-## avr910_devcode = ?;
-## Try the AT90S2313 devcode:
- avr910_devcode = 0x20;
- reset = io;
- chip_erase_delay = 4500;
-
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 1;
-
- memory "eeprom"
- size = 256;
- min_write_delay = 4000;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x",
- "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x",
- "a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x41;
- delay = 6;
- blocksize = 4;
- readsize = 256;
- ;
- memory "flash"
- paged = yes;
- size = 4096;
- page_size = 64;
- num_pages = 64;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 0 0 0 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 0 0 0 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 0 x x x x x",
- " x x x a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 0 x x x x x",
- " x x x a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 0 0 0 a10 a9 a8",
- " a7 a6 a5 x x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 32;
- readsize = 256;
- ;
-# ATtiny45 has Signature Bytes: 0x1E 0x92 0x08.
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- memory "lock"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "lfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "hfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "efuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x x x x x x x x i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 a0 o o o o o o o o";
- ;
- ;
-
-#------------------------------------------------------------
-# ATtiny85
-#------------------------------------------------------------
-
-part
- id = "t85";
- desc = "ATtiny85";
-## no STK500 devcode in XML file, use the ATtiny45 one
- stk500_devcode = 0x14;
-## avr910_devcode = ?;
-## Try the AT90S2313 devcode:
- avr910_devcode = 0x20;
- reset = io;
- chip_erase_delay = 4500;
-
- pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
- "x x x x x x x x x x x x x x x x";
-
- chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
- "x x x x x x x x x x x x x x x x";
-
- timeout = 200;
- stabdelay = 100;
- cmdexedelay = 25;
- synchloops = 32;
- bytedelay = 0;
- pollindex = 3;
- pollvalue = 0x53;
- predelay = 1;
- postdelay = 1;
- pollmethod = 1;
-
- memory "eeprom"
- size = 512;
- min_write_delay = 4000;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read = "1 0 1 0 0 0 0 0 0 0 0 x x x x a8",
- "a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
-
- write = "1 1 0 0 0 0 0 0 0 0 0 x x x x a8",
- "a8 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
-
- mode = 0x41;
- delay = 6;
- blocksize = 4;
- readsize = 256;
- ;
- memory "flash"
- paged = yes;
- size = 8192;
- page_size = 64;
- num_pages = 128;
- min_write_delay = 4500;
- max_write_delay = 4500;
- readback_p1 = 0xff;
- readback_p2 = 0xff;
- read_lo = " 0 0 1 0 0 0 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- read_hi = " 0 0 1 0 1 0 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 a4 a3 a2 a1 a0",
- " o o o o o o o o";
-
- loadpage_lo = " 0 1 0 0 0 0 0 0",
- " 0 0 0 x x x x x",
- " x x x a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- loadpage_hi = " 0 1 0 0 1 0 0 0",
- " 0 0 0 x x x x x",
- " x x x a4 a3 a2 a1 a0",
- " i i i i i i i i";
-
- writepage = " 0 1 0 0 1 1 0 0",
- " 0 0 0 0 a11 a10 a9 a8",
- " a7 a6 a5 x x x x x",
- " x x x x x x x x";
-
- mode = 0x41;
- delay = 6;
- blocksize = 32;
- readsize = 256;
- ;
-# ATtiny85 has Signature Bytes: 0x1E 0x93 0x08.
- memory "signature"
- size = 3;
- read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
- "x x x x x x a1 a0 o o o o o o o o";
- ;
- memory "lock"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
- "x x x x x x x x 1 1 i i i i i i";
- ;
-
- memory "lfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "hfuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
- "x x x x x x x x i i i i i i i i";
-
- read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "efuse"
- size = 1;
- write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
- "x x x x x x x x x x x x x x x i";
-
- read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
- "x x x x x x x x o o o o o o o o";
- ;
-
- memory "calibration"
- size = 1;
- read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
- "0 0 0 0 0 0 0 a0 o o o o o o o o";
- ;
- ;
;--------------------------------------------------------------------------
[Devices]
-"USBasp"=LIBUSB_DEV, USB\VID_03eb&PID_c7b4
+"USBasp"=LIBUSB_DEV, USB\VID_16c0&PID_05dc
[Strings]
manufacturer = "www.fischl.de"
$(COMPILE) -E main.c
avrdude:
- avrdude -c butterfly -p $(TARGET) -U flash:w:main.hex
+ avrdude -c avr910 -p $(TARGET) -U flash:w:main.hex
fuses:
avrdude -c avr910 -p m8 -u -U hfuse:w:0xc9:m -U lfuse:w:0x9f:m
int main(void)
{
+ uchar i, j;
+
PORTD = 0;
PORTB = 0; /* no pullups on USB and ISP pins */
DDRD = ~(1 << 2); /* all outputs except PD2 = INT0 */
+
+ DDRB = ~0; /* output SE0 for USB reset */
+ j = 0;
+ while(--j){ /* USB Reset by device only required on Watchdog Reset */
+ i = 0;
+ while(--i); /* delay >10ms for USB reset */
+ }
DDRB = 0; /* all USB and ISP pins inputs */
DDRC = 0x03; /* all inputs except PC0, PC1 */
*/
#ifndef __usbconfig_h_included__
-#define __usbconfig_h_included__
+#define __usbconfig_h_included__
/*
General Description:
This file contains parts of the USB driver which can be configured and can or
must be adapted to your hardware.
+
+Please note that the usbdrv contains a usbconfig-prototype.h file now. We
+recommend that you use that file as a template because it will always list
+the newest features and options.
*/
/* ---------------------------- Hardware Config ---------------------------- */
-#define USB_CFG_IOPORT PORTB
+#define USB_CFG_IOPORTNAME B
/* This is the port where the USB bus is connected. When you configure it to
- * "PORTB", the registers PORTB, PINB (=PORTB+2) and DDRB (=PORTB+1) will be
+ * "PORTB", the registers PORTB, PINB (=PORTB-2) and DDRB (=PORTB-1) will be
* used.
*/
-#define USB_CFG_DMINUS_BIT 0
+#define USB_CFG_DMINUS_BIT 0
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
- * This MUST be bit 0. All other values will result in a compile error!
+ * This MUST be bit 0 or 7. All other values will result in a compile error!
*/
-#define USB_CFG_DPLUS_BIT 1
+#define USB_CFG_DPLUS_BIT 1
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
* This may be any bit in the port. Please note that D+ must also be connected
* to interrupt pin INT0!
*/
+/* #define USB_CFG_PULLUP_IOPORTNAME B */
+/* This is the port where the USB D- pullup resistor is connected. When you
+ * configure it to "PORTB", the registers PORTB and DDRB (=PORTB-1) will be
+ * used. If this constant is defined, the macros usbDeviceConnect() and
+ * usbDeviceDisconnect will be available.
+ */
+/* #define USB_CFG_PULLUP_BIT 2 */
+/* This is the bit number in USB_CFG_PULLUP_IOPORT where the USB D- 1.5 kOhm
+ * pullup resistor is connected instead of VBUS. This may be any bit in
+ * the port.
+ */
+
/* --------------------------- Functional Range ---------------------------- */
-#define USB_CFG_HAVE_INTRIN_ENDPOINT 0
+#define USB_CFG_HAVE_INTRIN_ENDPOINT 0
/* Define this to 1 if you want to compile a version with two endpoints: The
* default control endpoint 0 and an interrupt-in endpoint 1.
*/
-#define USB_CFG_INTR_POLL_INTERVAL 10
+#define USB_CFG_IMPLEMENT_HALT 0
+/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature
+ * for endpoint 1 (interrupt endpoint). Although you may not need this feature,
+ * it is required by the standard. We have made it a config option because it
+ * bloats the code considerably.
+ */
+#define USB_CFG_INTR_POLL_INTERVAL 10
/* If you compile a version with endpoint 1 (interrupt-in), this is the poll
* interval. The value is in milliseconds and must not be less than 10 ms for
* low speed devices.
*/
-#define USB_CFG_IS_SELF_POWERED 0
+#define USB_CFG_IS_SELF_POWERED 0
/* Define this to 1 if the device has its own power supply. Set it to 0 if the
* device is powered from the USB bus.
*/
-#define USB_CFG_MAX_BUS_POWER 50
+#define USB_CFG_MAX_BUS_POWER 50
/* Set this variable to the maximum USB bus power consumption of your device.
* The value is in milliamperes. [It will be divided by two since USB
* communicates power requirements in units of 2 mA.]
*/
-#define USB_CFG_SAMPLE_EXACT 1
+#define USB_CFG_SAMPLE_EXACT 1
/* This variable affects Sampling Jitter for USB receiving. When it is 0, the
* driver guarantees a sampling window of 1/2 bit. The USB spec requires
* that the receiver has at most 1/4 bit sampling window. The 1/2 bit window
* results in bigger code size.
* If you have problems with long cables, try setting this value to 1.
*/
-#define USB_CFG_IMPLEMENT_FN_WRITE 1
+#define USB_CFG_IMPLEMENT_FN_WRITE 1
/* Set this to 1 if you want usbFunctionWrite() to be called for control-out
* transfers. Set it to 0 if you don't need it and want to save a couple of
* bytes.
*/
-#define USB_CFG_IMPLEMENT_FN_READ 1
+#define USB_CFG_IMPLEMENT_FN_READ 1
/* Set this to 1 if you need to send control replies which are generated
* "on the fly" when usbFunctionRead() is called. If you only want to send
* data from a static buffer, set it to 0 and return the data from
/* -------------------------- Device Description --------------------------- */
-#define USB_CFG_VENDOR_ID 0xeb, 0x03
-/* USB vendor ID for the device, low byte first. 0xeb, 0x03 is Atmel's vendor
- * ID. Don't use it for hardware you sell or publish!
- */
-#define USB_CFG_DEVICE_ID 0xb4, 0xc7
-/* This is the ID of the device, low byte first. It is interpreted in the
- * scope of the vendor ID. The only requirement is that no two devices may
- * share the same product and vendor IDs. Not even if the devices are never
- * on the same bus together!
- */
-#define USB_CFG_DEVICE_VERSION 0x00, 0x01
+#define USB_CFG_VENDOR_ID 0xc0, 0x16 /* 5824 in dec, stands for VOTI */
+/* USB vendor ID for the device, low byte first. If you have registered your
+ * own Vendor ID, define it here. Otherwise you use obdev's free shared
+ * VID/PID pair. Be sure to read USBID-License.txt for rules!
+ */
+#define USB_CFG_DEVICE_ID 0xdc, 0x05 /* 1500 in dec, obdev's free PID */
+/* This is the ID of the product, low byte first. It is interpreted in the
+ * scope of the vendor ID. If you have registered your own VID with usb.org
+ * or if you have licensed a PID from somebody else, define it here. Otherwise
+ * you use obdev's free shared VID/PID pair. Be sure to read the rules in
+ * USBID-License.txt!
+ */
+#define USB_CFG_DEVICE_VERSION 0x01, 0x01
/* Version number of the device: Minor number first, then major number.
*/
-#define USB_CFG_VENDOR_NAME 'w', 'w', 'w', '.', 'f', 'i', 's', 'c', 'h', 'l', '.', 'd', 'e'
-#define USB_CFG_VENDOR_NAME_LEN 13
+#define USB_CFG_VENDOR_NAME 'w', 'w', 'w', '.', 'f', 'i', 's', 'c', 'h', 'l', '.', 'd', 'e'
+#define USB_CFG_VENDOR_NAME_LEN 13
/* These two values define the vendor name returned by the USB device. The name
* must be given as a list of characters under single quotes. The characters
* are interpreted as Unicode (UTF-16) entities.
* If you don't want a vendor name string, undefine these macros.
+ * ALWAYS define a vendor name containing your Internet domain name if you use
+ * obdev's free shared VID/PID pair. See the file USBID-License.txt for
+ * details.
*/
#define USB_CFG_DEVICE_NAME 'U', 'S', 'B', 'a', 's', 'p'
#define USB_CFG_DEVICE_NAME_LEN 6
/* Same as above for the device name. If you don't want a device name, undefine
- * the macros.
- */
-#define USB_CFG_DEVICE_CLASS 0xff
-#define USB_CFG_DEVICE_SUBCLASS 0
+ * the macros. See the file USBID-License.txt before you assign a name.
+ */
+#define USB_CFG_SERIAL_NUMBER_LENGTH 0
+/* Set this define to the number of charcters in the serial number if your
+ * device should have a serial number to uniquely identify each hardware
+ * instance. You must supply the serial number in a string descriptor with the
+ * name "usbCfgSerialNumberStringDescriptor", e.g.:
+ * #define USB_CFG_SERIAL_NUMBER_LENGTH 5
+ * int usbCfgSerialNumberStringDescriptor[] PROGMEM = {
+ * USB_STRING_DESCRIPTOR_HEADER(USB_CFG_SERIAL_NUMBER_LENGTH),
+ * '1', '2', '3', '4', '5'
+ * };
+ * See usbdrv.h for more information about the USB_STRING_DESCRIPTOR_HEADER()
+ * macro or usbdrv.c for example string descriptors.
+ * You may want to put "usbCfgSerialNumberStringDescriptor" at a constant
+ * flash memory address (with magic linker commands) so that you don't need
+ * to recompile if you change it.
+ */
+#define USB_CFG_DEVICE_CLASS 0xff
+#define USB_CFG_DEVICE_SUBCLASS 0
/* See USB specification if you want to conform to an existing device class.
*/
-#define USB_CFG_INTERFACE_CLASS 0
-#define USB_CFG_INTERFACE_SUBCLASS 0
-#define USB_CFG_INTERFACE_PROTOCOL 0
+#define USB_CFG_INTERFACE_CLASS 0
+#define USB_CFG_INTERFACE_SUBCLASS 0
+#define USB_CFG_INTERFACE_PROTOCOL 0
/* See USB specification if you want to conform to an existing device class or
* protocol.
*/
-
+#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 0 /* total length of report descriptor */
+/* Define this to the length of the HID report descriptor, if you implement
+ * an HID device. Otherwise don't define it or define it to 0.
+ */
#endif /* __usbconfig_h_included__ */
-This file documents changes in the software, firmware and hardware of the
-"Remote Sensor" device. New entries are always appended to the end of the file.
+This file documents changes in the firmware-only USB driver for atmel's AVR
+microcontrollers. New entries are always appended to the end of the file.
Scroll down to the bottom to see the most recent changes.
2005-04-01:
of these functions to compile in.
- Assembler module delivers receive data non-inverted now.
- Made register and bit names compatible with more AVR devices.
+
+2005-05-03:
+ - Allow address of usbRxBuf on any memory page as long as the buffer does
+ not cross 256 byte page boundaries.
+ - Better device compatibility: works with Mega88 now.
+ - Code optimization in debugging module.
+ - Documentation updates.
+
+2006-01-02:
+ - Added (free) default Vendor- and Product-IDs bought from voti.nl.
+ - Added USBID-License.txt file which defines the rules for using the free
+ shared VID/PID pair.
+ - Added Readme.txt to the usbdrv directory which clarifies administrative
+ issues.
+
+2006-01-25:
+ - Added "configured state" to become more standards compliant.
+ - Added "HALT" state for interrupt endpoint.
+ - Driver passes the "USB Command Verifier" test from usb.org now.
+ - Made "serial number" a configuration option.
+ - Minor optimizations, we now recommend compiler option "-Os" for best
+ results.
+ - Added a version number to usbdrv.h
+
+2006-02-03:
+ - New configuration variable USB_BUFFER_SECTION for the memory section where
+ the USB rx buffer will go. This defaults to ".bss" if not defined. Since
+ this buffer MUST NOT cross 256 byte pages (not even touch a page at the
+ end), the user may want to pass a linker option similar to
+ "-Wl,--section-start=.mybuffer=0x800060".
+ - Provide structure for usbRequest_t.
+ - New defines for USB constants.
+ - Prepared for HID implementations.
+ - Increased data size limit for interrupt transfers to 8 bytes.
+ - New macro usbInterruptIsReady() to query interrupt buffer state.
+
+2006-02-18:
+ - Ensure that the data token which is sent as an ack to an OUT transfer is
+ always zero sized. This fixes a bug where the host reports an error after
+ sending an out transfer to the device, although all data arrived at the
+ device.
+ - Updated docs in usbdrv.h to reflect changed API in usbFunctionWrite().
+
+* Release 2006-02-20
+
+ - Give a compiler warning when compiling with debugging turned on.
+ - Added Oleg Semyonov's changes for IAR-cc compatibility.
+ - Added new (optional) functions usbDeviceConnect() and usbDeviceDisconnect()
+ (also thanks to Oleg!).
+ - Rearranged tests in usbPoll() to save a couple of instructions in the most
+ likely case that no actions are pending.
+ - We need a delay between the SET ADDRESS request until the new address
+ becomes active. This delay was handled in usbPoll() until now. Since the
+ spec says that the delay must not exceed 2ms, previous versions required
+ aggressive polling during the enumeration phase. We have now moved the
+ handling of the delay into the interrupt routine.
+ - We must not reply with NAK to a SETUP transaction. We can only achieve this
+ by making sure that the rx buffer is empty when SETUP tokens are expected.
+ We therefore don't pass zero sized data packets from the status phase of
+ a transfer to usbPoll(). This change MAY cause troubles if you rely on
+ receiving a less than 8 bytes long packet in usbFunctionWrite() to
+ identify the end of a transfer. usbFunctionWrite() will NEVER be called
+ with a zero length.
+
+* Release 2006-03-14
+
+ - Improved IAR C support: tiny memory model, more devices
+ - Added template usbconfig.h file under the name usbconfig-prototype.h
+
+* Release 2006-03-26
+
+ - Added provision for one more interrupt-in endpoint (endpoint 3).
+ - Added provision for one interrupt-out endpoint (endpoint 1).
+ - Added flowcontrol macros for USB.
+ - Added provision for custom configuration descriptor.
+ - Allow ANY two port bits for D+ and D-.
+ - Merged (optional) receive endpoint number into global usbRxToken variable.
+ - Use USB_CFG_IOPORTNAME instead of USB_CFG_IOPORT. We now construct the
+ variable name from the single port letter instead of computing the address
+ of related ports from the output-port address.
+
+* Release 2006-06-26
+
+ - Updated documentation in usbdrv.h and usbconfig-prototype.h to reflect the
+ new features.
+ - Removed "#warning" directives because IAR does not understand them. Use
+ unused static variables instead to generate a warning.
+ - Do not include <avr/io.h> when compiling with IAR.
+ - Introduced USB_CFG_DESCR_PROPS_* in usbconfig.h to configure how each
+ USB descriptor should be handled. It is now possible to provide descriptor
+ data in Flash, RAM or dynamically at runtime.
+ - STALL is now a status in usbTxLen* instead of a message. We can now conform
+ to the spec and leave the stall status pending until it is cleared.
+ - Made usbTxPacketCnt1 and usbTxPacketCnt3 public. This allows the
+ application code to reset data toggling on interrupt pipes.
+
+* Release 2006-07-18
file formats etc).
(3) As the author of the software, we can distribute it under more than one
license. For people who don't want to meet the obligations of the GNU GPL,
- we want to offer pay-by-unit business licenses. To avoid a split in
- revisions of the driver, we need special privileges to distribute
- contributed modifications under other licenses.
+ we want to offer commercial licenses. To avoid a split in revisions of
+ the driver, we need special privileges to distribute contributed
+ modifications under proprietary licenses.
We can not simply modify the GNU GPL and incorporate our changes because the
Free Software Foundation (FSF) who holds the copyright for the text of the
LICENSE FOR PROJECTS BUILT WITH "OBJECTIVE DEVELOPMENT'S
FIRMWARE-ONLY USB-DRIVER FOR ATMEL'S AVR MICROCONTROLLERS"
-Version 2005-02
+Version 2006-01
I. Definitions
sufficient.
(d) Optionally a text file with a description of the circuit diagram, an
explanation of special (software) techniques used etc.
-(e) A copy of this license in a file with the name "License.txt".
+(e) A copy of this license in a file with the name "License.txt". This copy
+ can be in the "usbdrv" subdirectory which contains the driver.
IV. Requirement for Publication
APPENDIX A
- GNU GENERAL PUBLIC LICENSE
- Version 2, June 1991
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
- Preamble
+ Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
The precise terms and conditions for copying, distribution and
modification follow.
- GNU GENERAL PUBLIC LICENSE
+ GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
- NO WARRANTY
+ NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
- END OF TERMS AND CONDITIONS
+ END OF TERMS AND CONDITIONS
- How to Apply These Terms to Your New Programs
+ How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
--- /dev/null
+This is the Readme file to Objective Development's firmware-only USB driver
+for Atmel AVR microcontrollers. For more information please visit
+http://www.obdev.at/avrusb/
+
+This directory contains the USB firmware only. Copy it as-is to your own
+project and add your own version of "usbconfig.h". A template for your own
+"usbconfig.h" can be found in "usbconfig-prototype.h" in this directory.
+
+
+TECHNICAL DOCUMENTATION
+=======================
+The technical documentation for the firmware driver is contained in the file
+"usbdrv.h". Please read all of it carefully!
+
+
+USB IDENTIFIERS
+===============
+Every USB device needs a vendor- and a product-identifier (VID and PID). VIDs
+are obtained from usb.org for a price of 1,500 USD. Once you have a VID, you
+can assign PIDs at will.
+
+Since an entry level cost of 1,500 USD is too high for most small companies
+and hobbyists, we provide a single VID/PID pair for free. If you want to use
+your own VID and PID instead of our's, define the macros "USB_CFG_VENDOR_ID"
+and "USB_CFG_DEVICE_ID" accordingly in "usbconfig.h".
+
+To use our predefined VID/PID pair, you MUST conform to a couple of
+requirements. See the file "USBID-License.txt" for details.
+
+
+HOST DRIVER
+===========
+You have received this driver together with an example device implementation
+and an example host driver. The host driver is based on libusb and compiles
+on various Unix flavors (Linux, BSD, Mac OS X). It also compiles natively on
+Windows using MinGW (see www.mingw.org) and libusb-win32 (see
+libusb-win32.sourceforge.net). The "Automator" project contains a native
+Windows host driver (not based on libusb) for Human Interface Devices.
+
+
+DEVELOPMENT SYSTEM
+==================
+This driver has been developed and optimized for the GNU compiler version 3
+(gcc 3). It does work well with gcc 4 and future versions will probably be
+optimized for gcc 4. We recommend that you use the GNU compiler suite because
+it is freely available. AVR-USB has also been ported to the IAR compiler and
+assembler. It has been tested with IAR 4.10B/W32 and 4.12A/W32 on an ATmega8
+with the "small" and "tiny" memory model. Please note that gcc is more
+efficient for usbdrv.c because this module has been deliberately optimized
+for gcc.
+
+
+USING AVR-USB FOR FREE
+======================
+The AVR firmware driver is published under an Open Source compliant license.
+See the file "License.txt" for details. Since it is not obvious for many
+people how this license applies to their own projects, here's a short guide:
+
+(1) The USB driver and all your modifications to the driver itself are owned
+by Objective Development. You must give us a worldwide, perpetual,
+irrevocable royalty free license for your modifications.
+
+(2) Since you own the code you have written (except where you modify our
+driver), you can (at least in principle) determine the license for it freely.
+However, to "pay" for the USB driver code you link against, we demand that
+you choose an Open Source compliant license (compatible with our license) for
+your source code and the hardware circuit diagrams. Simply attach your
+license of choice to your parts of the project and leave our "License.txt" in
+the "usbdrv" subdirectory.
+
+(3) We also demand that you publish your work on the Internet and drop us a
+note with the URL. The publication must meet certain formal criteria (files
+distributed, file formats etc.). See the file "License.txt" for details.
+
+Other than that, you are allowed to manufacture any number of units and sell
+them for any price. If you like our driver, we also encourage you to make a
+donation on our web site.
+
+
+COMMERCIAL LICENSES FOR AVR-USB
+===============================
+If you don't want to publish your source code and the circuit diagrams under
+an Open Source license, you can simply pay money for AVR-USB. As an
+additional benefit you get USB PIDs for free, licensed exclusively to you.
+See http://www.obdev.at/products/avrusb/license.html for details.
--- /dev/null
+Royalty-Free Non-Exclusive License USB Product-ID
+=================================================
+
+Version 2006-06-19
+
+OBJECTIVE DEVELOPMENT Software GmbH hereby grants you the non-exclusive
+right to use three USB.org vendor-ID (VID) / product-ID (PID) pairs with
+products based on Objective Development's firmware-only USB driver for
+Atmel AVR microcontrollers:
+
+ * VID = 5824 (=0x16c0) / PID = 1500 (=0x5dc) for devices implementing no
+ USB device class (vendor-class devices with USB class = 0xff). Devices
+ using this pair will be referred to as "VENDOR CLASS" devices.
+
+ * VID = 5824 (=0x16c0) / PID = 1503 (=0x5df) for HID class devices
+ (excluding mice and keyboards). Devices using this pair will be referred
+ to as "HID CLASS" devices.
+
+ * VID = 5824 (=0x16c0) / PID = 1505 (=0x5e1) for CDC class modem devices
+ Devices using this pair will be referred to as "CDC-ACM CLASS" devices.
+
+Since the granted right is non-exclusive, the same VID/PID pairs may be
+used by many companies and individuals for different products. To avoid
+conflicts, your device and host driver software MUST adhere to the rules
+outlined below.
+
+OBJECTIVE DEVELOPMENT Software GmbH has licensed these VID/PID pairs from
+Wouter van Ooijen (see www.voti.nl), who has licensed the VID from the USB
+Implementers Forum, Inc. (see www.usb.org). The VID is registered for the
+company name "Van Ooijen Technische Informatica".
+
+
+RULES AND RESTRICTIONS
+======================
+
+(1) The USB device MUST provide a textual representation of the
+manufacturer and product identification. The manufacturer identification
+MUST be available at least in USB language 0x0409 (English/US).
+
+(2) The textual manufacturer identification MUST contain either an Internet
+domain name (e.g. "mycompany.com") registered and owned by you, or an
+e-mail address under your control (e.g. "myname@gmx.net"). You can embed
+the domain name or e-mail address in any string you like, e.g. "Objective
+Development http://www.obdev.at/avrusb/".
+
+(3) You are responsible for retaining ownership of the domain or e-mail
+address for as long as any of your products are in use.
+
+(4) You may choose any string for the textual product identification, as
+long as this string is unique within the scope of your textual manufacturer
+identification.
+
+(5) Matching of device-specific drivers MUST be based on the textual
+manufacturer and product identification in addition to the usual VID/PID
+matching. This means that operating system features which are based on
+VID/PID matching only (e.g. Windows kernel level drivers, automatic actions
+when the device is plugged in etc) MUST NOT be used. The driver matching
+MUST be a comparison of the entire strings, NOT a sub-string match. For
+CDC-ACM CLASS devices, a generic class driver should be used and the
+matching is based on the USB device class.
+
+(6) The extent to which VID/PID matching is allowed for non device-specific
+drivers or features depends on the operating system and particular VID/PID
+pair used:
+
+ * Mac OS X, Linux, FreeBSD and other Unixes: No VID/PID matching is
+ required and hence no VID/PID-only matching is allowed at all.
+
+ * Windows: The operating system performs VID/PID matching for the kernel
+ level driver. You are REQUIRED to use libusb-win32 (see
+ http://libusb-win32.sourceforge.net/) as the kernel level driver for
+ VENDOR CLASS devices. HID CLASS devices all use the generic HID class
+ driver shipped with Windows, except mice and keyboards. You therefore
+ MUST NOT use any of the shared VID/PID pairs for mice or keyboards.
+ CDC-ACM CLASS devices require a ".inf" file which matches on the VID/PID
+ pair. This ".inf" file MUST load the "usbser" driver to configure the
+ device as modem (COM-port).
+
+(7) OBJECTIVE DEVELOPMENT Software GmbH disclaims all liability for any
+problems which are caused by the shared use of these VID/PID pairs. You
+have been warned that the sharing of VID/PID pairs may cause problems. If
+you want to avoid them, get your own VID/PID pair for exclusive use.
+
+
+HOW TO IMPLEMENT THESE RULES
+============================
+
+The following rules are for VENDOR CLASS and HID CLASS devices. CDC-ACM
+CLASS devices use the operating system's class driver and don't need a
+custom driver.
+
+The host driver MUST iterate over all devices with the given VID/PID
+numbers in their device descriptors and query the string representation for
+the manufacturer name in USB language 0x0409 (English/US). It MUST compare
+the ENTIRE string with your textual manufacturer identification chosen in
+(2) above. A substring search for your domain or e-mail address is NOT
+acceptable. The driver MUST NOT touch the device (other than querying the
+descriptors) unless the strings match.
+
+For all USB devices with matching VID/PID and textual manufacturer
+identification, the host driver must query the textual product
+identification and string-compare it with the name of the product it can
+control. It may only initialize the device if the product matches exactly.
+
+Objective Development provides examples for these matching rules with the
+"PowerSwitch" project (using libusb) and with the "Automator" project
+(using Windows calls on Windows and libusb on Unix).
+
+
+Technical Notes:
+================
+
+Sharing the same VID/PID pair among devices is possible as long as ALL
+drivers which match the VID/PID also perform matching on the textual
+identification strings. This is easy on all operating systems except
+Windows, since Windows establishes a static connection between the VID/PID
+pair and a kernel level driver. All devices with the same VID/PID pair must
+therefore use THE SAME kernel level driver.
+
+We therefore demand that you use libusb-win32 for VENDOR CLASS devices.
+This is a generic kernel level driver which allows all types of USB access
+for user space applications. This is only a partial solution of the
+problem, though, because different device drivers may come with different
+versions of libusb-win32 and they may not work with the libusb version of
+the respective other driver. You are therefore encouraged to test your
+driver against a broad range of libusb-win32 versions. Do not use new
+features in new versions, or check for their existence before you use them.
+When a new libusb-win32 becomes available, make sure that your driver is
+compatible with it.
+
+For HID CLASS devices it is necessary that all those devices bind to the
+same kernel driver: Microsoft's generic USB HID driver. This is true for
+all HID devices except those with a specialized driver. Currently, the only
+HIDs with specialized drivers are mice and keyboards. You therefore MUST
+NOT use a shared VID/PID with mouse and keyboard devices.
+
+Sharing the same VID/PID among different products is unusual and probably
+violates the USB specification. If you do it, you do it at your own risk.
+
+To avoid possible incompatibilities, we highly recommend that you get your
+own VID/PID pair if you intend to sell your product. Objective
+Development's commercial licenses for AVR-USB include a PID for
+unrestricted exclusive use.
--- /dev/null
+/* Name: iarcompat.h
+ * Project: AVR USB driver
+ * Author: Christian Starkjohann
+ * Creation Date: 2006-03-01
+ * Tabsize: 4
+ * Copyright: (c) 2006 by OBJECTIVE DEVELOPMENT Software GmbH
+ * License: Proprietary, free under certain conditions. See Documentation.
+ * This Revision: $Id: iarcompat.h 174 2006-03-23 10:09:01Z cs $
+ */
+
+/*
+General Description:
+This header is included when we compile with the IAR C-compiler and assembler.
+It defines macros for cross compatibility between gcc and IAR-cc.
+
+Thanks to Oleg Semyonov for his help with the IAR tools port!
+*/
+
+#ifndef __iarcompat_h_INCLUDED__
+#define __iarcompat_h_INCLUDED__
+
+#if defined __IAR_SYSTEMS_ICC__ || defined __IAR_SYSTEMS_ASM__
+
+/* Enable bit definitions */
+#ifndef ENABLE_BIT_DEFINITIONS
+# define ENABLE_BIT_DEFINITIONS 1
+#endif
+
+/* Include IAR headers */
+#include <ioavr.h>
+#ifndef __IAR_SYSTEMS_ASM__
+# include <inavr.h>
+#endif
+
+#define __attribute__(arg)
+#define IAR_SECTION(section) @ section
+
+#ifndef USB_BUFFER_SECTION
+# define USB_BUFFER_SECTION "TINY_Z" /* if user has not selected a named section */
+#endif
+
+#ifdef __IAR_SYSTEMS_ASM__
+# define __ASSEMBLER__
+#endif
+
+#ifdef __HAS_ELPM__
+# define PROGMEM __farflash
+#else
+# define PROGMEM __flash
+#endif
+
+#define PRG_RDB(addr) (*(PROGMEM char *)(addr))
+
+/* The following definitions are not needed by the driver, but may be of some
+ * help if you port a gcc based project to IAR.
+ */
+#define cli() __disable_interrupt()
+#define sei() __enable_interrupt()
+#define wdt_reset() __watchdog_reset()
+
+/* Depending on the device you use, you may get problems with the way usbdrv.h
+ * handles the differences between devices. Since IAR does not use #defines
+ * for MCU registers, we can't check for the existence of a particular
+ * register with an #ifdef. If the autodetection mechanism fails, include
+ * definitions for the required USB_INTR_* macros in your usbconfig.h. See
+ * usbconfig-prototype.h and usbdrv.h for details.
+ */
+
+#endif /* defined __IAR_SYSTEMS_ICC__ || defined __IAR_SYSTEMS_ASM__ */
+#endif /* __iarcompat_h_INCLUDED__ */
* Tabsize: 4
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
* License: Proprietary, free under certain conditions. See Documentation.
- * This Revision: $Id: oddebug.c 52 2005-04-12 16:57:29Z cs $
+ * This Revision: $Id: oddebug.c 215 2006-07-10 21:54:51Z cs $
*/
-#include <avr/io.h>
#include "oddebug.h"
-#if DEBUG_LEVEL > 0
+#if DEBUG_LEVEL > 0
-static void uartPutc(char c)
+static uchar Warning__Never_compile_production_devices_with_debugging;
+/* The "#warning" preprocessor directive is non-standard. The unused static
+ * variable above should give a compiler warning on all compilers.
+ */
+
+static void uartPutc(char c)
{
- while(!(ODDBG_USR & (1 << UDRE))); /* wait for data register empty */
- ODDBG_UDR = c;
+ while(!(ODDBG_USR & (1 << ODDBG_UDRE))); /* wait for data register empty */
+ ODDBG_UDR = c;
}
-static uchar hexAscii(uchar h)
+static uchar hexAscii(uchar h)
{
- h &= 0xf;
- if(h < 10){
- h += '0';
- }else{
- h += 'a' - (uchar)10;
- }
- return h;
+ h &= 0xf;
+ if(h >= 10)
+ h += 'a' - (uchar)10 - '0';
+ h += '0';
+ return h;
}
-static void printHex(uchar c)
+static void printHex(uchar c)
{
- uartPutc(hexAscii(c >> 4));
- uartPutc(hexAscii(c));
+ uartPutc(hexAscii(c >> 4));
+ uartPutc(hexAscii(c));
}
-void odDebug(uchar prefix, uchar *data, uchar len)
+void odDebug(uchar prefix, uchar *data, uchar len)
{
- printHex(prefix);
- uartPutc(':');
- while(len--){
- uartPutc(' ');
- printHex(*data++);
- }
- uartPutc('\r');
- uartPutc('\n');
+ printHex(prefix);
+ uartPutc(':');
+ while(len--){
+ uartPutc(' ');
+ printHex(*data++);
+ }
+ uartPutc('\r');
+ uartPutc('\n');
}
#endif
* Tabsize: 4
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
* License: Proprietary, free under certain conditions. See Documentation.
- * This Revision: $Id: oddebug.h 52 2005-04-12 16:57:29Z cs $
+ * This Revision: $Id: oddebug.h 215 2006-07-10 21:54:51Z cs $
*/
#ifndef __oddebug_h_included__
#define __oddebug_h_included__
-#include <avr/io.h>
-
/*
General Description:
This module implements a function for debug logs on the serial line of the
#ifndef F_CPU
-# define F_CPU 12000000 /* 12 MHz */
+# define F_CPU 12000000 /* 12 MHz */
+#endif
+
+/* make sure we have the UART defines: */
+#include "iarcompat.h"
+#ifndef __IAR_SYSTEMS_ICC__
+# include <avr/io.h>
#endif
#ifndef uchar
-# define uchar unsigned char
+# define uchar unsigned char
#endif
-#if DEBUG_LEVEL > 0 && !defined TXEN /* no UART in device */
-# warning "Debugging disabled because device has no UART"
-# undef DEBUG_LEVEL
+#if DEBUG_LEVEL > 0 && !(defined TXEN || defined TXEN0) /* no UART in device */
+# warning "Debugging disabled because device has no UART"
+# undef DEBUG_LEVEL
#endif
#ifndef DEBUG_LEVEL
-# define DEBUG_LEVEL 0
+# define DEBUG_LEVEL 0
#endif
/* ------------------------------------------------------------------------- */
#if DEBUG_LEVEL > 0
-# define DBG1(prefix, data, len) odDebug(prefix, data, len)
+# define DBG1(prefix, data, len) odDebug(prefix, data, len)
#else
-# define DBG1(prefix, data, len)
+# define DBG1(prefix, data, len)
#endif
#if DEBUG_LEVEL > 1
-# define DBG2(prefix, data, len) odDebug(prefix, data, len)
+# define DBG2(prefix, data, len) odDebug(prefix, data, len)
#else
-# define DBG2(prefix, data, len)
+# define DBG2(prefix, data, len)
#endif
/* ------------------------------------------------------------------------- */
-#if DEBUG_LEVEL > 0
-extern void odDebug(uchar prefix, uchar *data, uchar len);
+#if DEBUG_LEVEL > 0
+extern void odDebug(uchar prefix, uchar *data, uchar len);
/* Try to find our control registers; ATMEL likes to rename these */
#if defined UBRR
-# define ODDBG_UBRR UBRR
+# define ODDBG_UBRR UBRR
#elif defined UBRRL
-# define ODDBG_UBRR UBRRL
-#elif defined UBRR1
-# define ODDBG_UBRR UBRR1
-#elif defined UBRR1L
-# define ODDBG_UBRR UBRR1L
+# define ODDBG_UBRR UBRRL
+#elif defined UBRR0
+# define ODDBG_UBRR UBRR0
+#elif defined UBRR0L
+# define ODDBG_UBRR UBRR0L
#endif
#if defined UCR
-# define ODDBG_UCR UCR
+# define ODDBG_UCR UCR
#elif defined UCSRB
-# define ODDBG_UCR UCSRB
-#elif defined UCSR1B
-# define ODDBG_UCR UCSR1B
+# define ODDBG_UCR UCSRB
+#elif defined UCSR0B
+# define ODDBG_UCR UCSR0B
+#endif
+
+#if defined TXEN
+# define ODDBG_TXEN TXEN
+#else
+# define ODDBG_TXEN TXEN0
#endif
-#if defined USR
-# define ODDBG_USR USR
+#if defined USR
+# define ODDBG_USR USR
#elif defined UCSRA
-# define ODDBG_USR UCSRA
-#elif defined UCSR1A
-# define ODDBG_USR UCSR1A
+# define ODDBG_USR UCSRA
+#elif defined UCSR0A
+# define ODDBG_USR UCSR0A
+#endif
+
+#if defined UDRE
+# define ODDBG_UDRE UDRE
+#else
+# define ODDBG_UDRE UDRE0
#endif
#if defined UDR
-# define ODDBG_UDR UDR
-#elif defined UDR1
-# define ODDBG_UDR UDR1
+# define ODDBG_UDR UDR
+#elif defined UDR0
+# define ODDBG_UDR UDR0
#endif
-static inline void odDebugInit(void)
+static inline void odDebugInit(void)
{
- ODDBG_UCR |= (1<<TXEN);
- ODDBG_UBRR = F_CPU / (19200 * 16L) - 1;
+ ODDBG_UCR |= (1<<ODDBG_TXEN);
+ ODDBG_UBRR = F_CPU / (19200 * 16L) - 1;
}
#else
-# define odDebugInit()
+# define odDebugInit()
#endif
/* ------------------------------------------------------------------------- */
--- /dev/null
+/* Name: usbconfig.h
+ * Project: AVR USB driver
+ * Author: Christian Starkjohann
+ * Creation Date: 2005-04-01
+ * Tabsize: 4
+ * Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
+ * License: Proprietary, free under certain conditions. See Documentation.
+ * This Revision: $Id: usbconfig-prototype.h 216 2006-07-14 21:51:00Z cs $
+ */
+
+#ifndef __usbconfig_h_included__
+#define __usbconfig_h_included__
+
+/*
+General Description:
+This file is an example configuration (with inline documentation) for the USB
+driver. It configures AVR-USB for an ATMega8 with USB D+ connected to Port D
+bit 2 (which is also hardware interrupt 0) and USB D- to Port D bit 0. You may
+wire the lines to any other port, as long as D- is on bit 0 and D+ is also
+wired to INT0.
+To create your own usbconfig.h file, copy this file to the directory
+containing "usbdrv" (that is your project firmware source directory) and
+rename it to "usbconfig.h". Then edit it accordingly.
+*/
+
+/* ---------------------------- Hardware Config ---------------------------- */
+
+#define USB_CFG_IOPORTNAME D
+/* This is the port where the USB bus is connected. When you configure it to
+ * "B", the registers PORTB, PINB and DDRB will be used.
+ */
+#define USB_CFG_DMINUS_BIT 0
+/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
+ * This may be any bit in the port.
+ */
+#define USB_CFG_DPLUS_BIT 2
+/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
+ * This may be any bit in the port. Please note that D+ must also be connected
+ * to interrupt pin INT0!
+ */
+
+/* ----------------------- Optional Hardware Config ------------------------ */
+
+/* #define USB_CFG_PULLUP_IOPORTNAME D */
+/* If you connect the 1.5k pullup resistor from D- to a port pin instead of
+ * V+, you can connect and disconnect the device from firmware by calling
+ * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
+ * This constant defines the port on which the pullup resistor is connected.
+ */
+/* #define USB_CFG_PULLUP_BIT 4 */
+/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
+ * above) where the 1.5k pullup resistor is connected. See description
+ * above for details.
+ */
+/* #define USB_BUFFER_SECTION ".bss" */
+/* The USB receive buffer (variable "usbRxBuf") with a length of 22 bytes
+ * MUST NOT cross a 256 byte boundary. We have introduced this configuration
+ * option to allow you to change the data segment where this buffer is
+ * allocated. If you have problems with the default segment (start of .bss),
+ * you may change this setting. See the comment in usbdrv.h for details.
+ * On IAR C, the default is the TINY_Z segment (first 256 bytes). You must
+ * change this default for devices which don't have RAM below 0x100.
+ */
+
+/* --------------------------- Functional Range ---------------------------- */
+
+#define USB_CFG_HAVE_INTRIN_ENDPOINT 1
+/* Define this to 1 if you want to compile a version with two endpoints: The
+ * default control endpoint 0 and an interrupt-in endpoint 1.
+ */
+#define USB_CFG_HAVE_INTRIN_ENDPOINT3 0
+/* Define this to 1 if you want to compile a version with three endpoints: The
+ * default control endpoint 0, an interrupt-in endpoint 1 and an interrupt-in
+ * endpoint 3. You must also enable endpoint 1 above.
+ */
+#define USB_CFG_IMPLEMENT_HALT 0
+/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature
+ * for endpoint 1 (interrupt endpoint). Although you may not need this feature,
+ * it is required by the standard. We have made it a config option because it
+ * bloats the code considerably.
+ */
+#define USB_CFG_INTR_POLL_INTERVAL 20
+/* If you compile a version with endpoint 1 (interrupt-in), this is the poll
+ * interval. The value is in milliseconds and must not be less than 10 ms for
+ * low speed devices.
+ */
+#define USB_CFG_IS_SELF_POWERED 0
+/* Define this to 1 if the device has its own power supply. Set it to 0 if the
+ * device is powered from the USB bus.
+ */
+#define USB_CFG_MAX_BUS_POWER 100
+/* Set this variable to the maximum USB bus power consumption of your device.
+ * The value is in milliamperes. [It will be divided by two since USB
+ * communicates power requirements in units of 2 mA.]
+ */
+#define USB_CFG_SAMPLE_EXACT 1
+/* This variable affects Sampling Jitter for USB receiving. When it is 0, the
+ * driver guarantees a sampling window of 1/2 bit. The USB spec requires
+ * that the receiver has at most 1/4 bit sampling window. The 1/2 bit window
+ * should still work reliably enough because we work at low speed. If you want
+ * to meet the spec, set this value to 1. This will unroll a loop which
+ * results in bigger code size.
+ * If you have problems with long cables, try setting this value to 1.
+ */
+#define USB_CFG_IMPLEMENT_FN_WRITE 0
+/* Set this to 1 if you want usbFunctionWrite() to be called for control-out
+ * transfers. Set it to 0 if you don't need it and want to save a couple of
+ * bytes.
+ */
+#define USB_CFG_IMPLEMENT_FN_READ 0
+/* Set this to 1 if you need to send control replies which are generated
+ * "on the fly" when usbFunctionRead() is called. If you only want to send
+ * data from a static buffer, set it to 0 and return the data from
+ * usbFunctionSetup(). This saves a couple of bytes.
+ */
+#define USB_CFG_IMPLEMENT_FN_WRITEOUT 0
+/* Define this to 1 if you want to use interrupt-out (or bulk out) endpoint 1.
+ * You must implement the function usbFunctionWriteOut() which receives all
+ * interrupt/bulk data sent to endpoint 1.
+ */
+#define USB_CFG_HAVE_FLOWCONTROL 0
+/* Define this to 1 if you want flowcontrol over USB data. See the definition
+ * of the macros usbDisableAllRequests() and usbEnableAllRequests() in
+ * usbdrv.h.
+ */
+
+/* -------------------------- Device Description --------------------------- */
+
+#define USB_CFG_VENDOR_ID 0xc0, 0x16
+/* USB vendor ID for the device, low byte first. If you have registered your
+ * own Vendor ID, define it here. Otherwise you use obdev's free shared
+ * VID/PID pair. Be sure to read USBID-License.txt for rules!
+ * This template uses obdev's shared VID/PID pair for HIDs: 0x16c0/0x5df.
+ * Use this VID/PID pair ONLY if you understand the implications!
+ */
+#define USB_CFG_DEVICE_ID 0xdf, 0x05
+/* This is the ID of the product, low byte first. It is interpreted in the
+ * scope of the vendor ID. If you have registered your own VID with usb.org
+ * or if you have licensed a PID from somebody else, define it here. Otherwise
+ * you use obdev's free shared VID/PID pair. Be sure to read the rules in
+ * USBID-License.txt!
+ * This template uses obdev's shared VID/PID pair for HIDs: 0x16c0/0x5df.
+ * Use this VID/PID pair ONLY if you understand the implications!
+ */
+#define USB_CFG_DEVICE_VERSION 0x00, 0x01
+/* Version number of the device: Minor number first, then major number.
+ */
+#define USB_CFG_VENDOR_NAME 'w', 'w', 'w', '.', 'o', 'b', 'd', 'e', 'v', '.', 'a', 't'
+#define USB_CFG_VENDOR_NAME_LEN 12
+/* These two values define the vendor name returned by the USB device. The name
+ * must be given as a list of characters under single quotes. The characters
+ * are interpreted as Unicode (UTF-16) entities.
+ * If you don't want a vendor name string, undefine these macros.
+ * ALWAYS define a vendor name containing your Internet domain name if you use
+ * obdev's free shared VID/PID pair. See the file USBID-License.txt for
+ * details.
+ */
+#define USB_CFG_DEVICE_NAME 'T', 'e', 'm', 'p', 'l', 'a', 't', 'e'
+#define USB_CFG_DEVICE_NAME_LEN 8
+/* Same as above for the device name. If you don't want a device name, undefine
+ * the macros. See the file USBID-License.txt before you assign a name if you
+ * use a shared VID/PID.
+ */
+/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */
+/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */
+/* Same as above for the serial number. If you don't want a serial number,
+ * undefine the macros.
+ * It may be useful to provide the serial number through other means than at
+ * compile time. See the section about descriptor properties below for how
+ * to fine tune control over USB descriptors such as the string descriptor
+ * for the serial number.
+ */
+#define USB_CFG_DEVICE_CLASS 0
+#define USB_CFG_DEVICE_SUBCLASS 0
+/* See USB specification if you want to conform to an existing device class.
+ */
+#define USB_CFG_INTERFACE_CLASS 3 /* HID */
+#define USB_CFG_INTERFACE_SUBCLASS 0
+#define USB_CFG_INTERFACE_PROTOCOL 0
+/* See USB specification if you want to conform to an existing device class or
+ * protocol.
+ * This template defines a HID class device. If you implement a vendor class
+ * device, set USB_CFG_INTERFACE_CLASS to 0 and USB_CFG_DEVICE_CLASS to 0xff.
+ */
+#define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 42 /* total length of report descriptor */
+/* Define this to the length of the HID report descriptor, if you implement
+ * an HID device. Otherwise don't define it or define it to 0.
+ * Since this template defines a HID device, it must also specify a HID
+ * report descriptor length. You must add a PROGMEM character array named
+ * "usbHidReportDescriptor" to your code which contains the report descriptor.
+ * Don't forget to keep the array and this define in sync!
+ */
+
+/* ------------------- Fine Control over USB Descriptors ------------------- */
+/* If you don't want to use the driver's default USB descriptors, you can
+ * provide our own. These can be provided as (1) fixed length static data in
+ * flash memory, (2) fixed length static data in RAM or (3) dynamically at
+ * runtime in the function usbFunctionDescriptor(). See usbdrv.h for more
+ * information about this function.
+ * Descriptor handling is configured through the descriptor's properties. If
+ * no properties are defined or if they are 0, the default descriptor is used.
+ * Possible properties are:
+ * + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched
+ * at runtime via usbFunctionDescriptor().
+ * + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found
+ * in static memory is in RAM, not in flash memory.
+ * + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash),
+ * the driver must know the descriptor's length. The descriptor itself is
+ * found at the address of a well known identifier (see below).
+ * List of static descriptor names (must be declared PROGMEM if in flash):
+ * char usbDescriptorDevice[];
+ * char usbDescriptorConfiguration[];
+ * char usbDescriptorHidReport[];
+ * char usbDescriptorString0[];
+ * int usbDescriptorStringVendor[];
+ * int usbDescriptorStringDevice[];
+ * int usbDescriptorStringSerialNumber[];
+ * Other descriptors can't be provided statically, they must be provided
+ * dynamically at runtime.
+ *
+ * Descriptor properties are or-ed or added together, e.g.:
+ * #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18))
+ *
+ * The following descriptors are defined:
+ * USB_CFG_DESCR_PROPS_DEVICE
+ * USB_CFG_DESCR_PROPS_CONFIGURATION
+ * USB_CFG_DESCR_PROPS_STRINGS
+ * USB_CFG_DESCR_PROPS_STRING_0
+ * USB_CFG_DESCR_PROPS_STRING_VENDOR
+ * USB_CFG_DESCR_PROPS_STRING_PRODUCT
+ * USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER
+ * USB_CFG_DESCR_PROPS_HID
+ * USB_CFG_DESCR_PROPS_HID_REPORT
+ * USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver)
+ *
+ */
+
+#define USB_CFG_DESCR_PROPS_DEVICE 0
+#define USB_CFG_DESCR_PROPS_CONFIGURATION 0
+#define USB_CFG_DESCR_PROPS_STRINGS 0
+#define USB_CFG_DESCR_PROPS_STRING_0 0
+#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0
+#define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0
+#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0
+#define USB_CFG_DESCR_PROPS_HID 0
+#define USB_CFG_DESCR_PROPS_HID_REPORT 0
+#define USB_CFG_DESCR_PROPS_UNKNOWN 0
+
+/* ----------------------- Optional MCU Description ------------------------ */
+
+/* The following configurations have working defaults in usbdrv.h. You
+ * usually don't need to set them explicitly. Only if you want to run
+ * the driver on a device which is not yet supported or with a compiler
+ * which is not fully supported (such as IAR C) or if you use a differnt
+ * interrupt than INT0, you may have to define some of these.
+ */
+/* #define USB_INTR_CFG MCUCR */
+/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */
+/* #define USB_INTR_CFG_CLR 0 */
+/* #define USB_INTR_ENABLE GIMSK */
+/* #define USB_INTR_ENABLE_BIT INT0 */
+/* #define USB_INTR_PENDING GIFR */
+/* #define USB_INTR_PENDING_BIT INTF0 */
+
+#endif /* __usbconfig_h_included__ */
* Tabsize: 4
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
* License: Proprietary, free under certain conditions. See Documentation.
- * This Revision: $Id: usbdrv.c 53 2005-04-12 17:11:29Z cs $
+ * This Revision: $Id: usbdrv.c 222 2006-07-17 15:07:34Z cs $
*/
-#include <avr/io.h>
-#include <avr/pgmspace.h>
+#include "iarcompat.h"
+#ifndef __IAR_SYSTEMS_ICC__
+# include <avr/io.h>
+# include <avr/pgmspace.h>
+#endif
#include "usbdrv.h"
#include "oddebug.h"
documentation of the entire driver.
*/
+#ifndef IAR_SECTION
+#define IAR_SECTION(arg)
+#define __no_init
+#endif
+/* The macro IAR_SECTION is a hack to allow IAR-cc compatibility. On gcc, it
+ * is defined to nothing. __no_init is required on IAR.
+ */
+
/* ------------------------------------------------------------------------- */
/* raw USB registers / interface to assembler code: */
/* usbRxBuf MUST be in 1 byte addressable range (because usbInputBuf is only 1 byte) */
-static char usbRxBuf[2][USB_BUFSIZE];/* raw RX buffer: PID, 8 bytes data, 2 bytes CRC */
-uchar usbDeviceId; /* assigned during enumeration, defaults to 0 */
-uchar usbInputBuf; /* ptr to raw buffer used for receiving */
-uchar usbAppBuf; /* ptr to raw buffer passed to app for processing */
-volatile char usbRxLen; /* = 0; number of bytes in usbAppBuf; 0 means free */
-uchar usbCurrentTok; /* last token received */
-uchar usbRxToken; /* token for data we received */
-uchar usbMsgLen = 0xff; /* remaining number of bytes, no msg to send if -1 (see usbMsgPtr) */
-volatile char usbTxLen = -1; /* number of bytes to transmit with next IN token */
-uchar usbTxBuf[USB_BUFSIZE];/* data to transmit with next IN, free if usbTxLen == -1 */
+__no_init uchar usbRxBuf[2][USB_BUFSIZE] __attribute__ ((section (USB_BUFFER_SECTION))) IAR_SECTION(USB_BUFFER_SECTION);/* raw RX buffer: PID, 8 bytes data, 2 bytes CRC */
+uchar usbDeviceAddr; /* assigned during enumeration, defaults to 0 */
+uchar usbNewDeviceAddr; /* device ID which should be set after status phase */
+uchar usbConfiguration; /* currently selected configuration. Administered by driver, but not used */
+uchar usbInputBuf; /* ptr to raw buffer used for receiving */
+uchar usbAppBuf; /* ptr to raw buffer passed to app for processing */
+volatile schar usbRxLen; /* = 0; number of bytes in usbAppBuf; 0 means free */
+uchar usbCurrentTok; /* last token received, if more than 1 rx endpoint: MSb=endpoint */
+uchar usbRxToken; /* token for data we received; if more than 1 rx endpoint: MSb=endpoint */
+uchar usbMsgLen = 0xff; /* remaining number of bytes, no msg to send if -1 (see usbMsgPtr) */
+volatile uchar usbTxLen = USBPID_NAK; /* number of bytes to transmit with next IN token or handshake token */
+uchar usbTxBuf[USB_BUFSIZE];/* data to transmit with next IN, free if usbTxLen contains handshake token */
#if USB_CFG_HAVE_INTRIN_ENDPOINT
-/* uchar usbRxEndp; endpoint which was addressed (1 bit in MSB) [not impl] */
-volatile char usbTxLen1 = -1; /* TX count for endpoint 1 */
-uchar usbTxBuf1[USB_BUFSIZE];/* TX data for endpoint 1 */
+volatile uchar usbTxLen1 = USBPID_NAK; /* TX count for endpoint 1 */
+uchar usbTxBuf1[USB_BUFSIZE]; /* TX data for endpoint 1 */
+#if USB_CFG_HAVE_INTRIN_ENDPOINT3
+volatile uchar usbTxLen3 = USBPID_NAK; /* TX count for endpoint 1 */
+uchar usbTxBuf3[USB_BUFSIZE]; /* TX data for endpoint 1 */
+#endif
#endif
-uchar usbAckBuf[1] = {USBPID_ACK}; /* transmit buffer for ack tokens */
-uchar usbNakBuf[1] = {USBPID_NAK}; /* transmit buffer for nak tokens */
/* USB status registers / not shared with asm code */
-uchar *usbMsgPtr; /* data to transmit next -- ROM or RAM address */
-static uchar usbMsgFlags; /* flag values see below */
-static uchar usbNewDeviceId; /* = 0; device ID which should be set after status phase */
-static uchar usbIsReset; /* = 0; USB bus is in reset phase */
+uchar *usbMsgPtr; /* data to transmit next -- ROM or RAM address */
+static uchar usbMsgFlags; /* flag values see below */
+static uchar usbIsReset; /* = 0; USB bus is in reset phase */
-#define USB_FLG_TX_PACKET (1<<0)
+#define USB_FLG_TX_PACKET (1<<0)
/* Leave free 6 bits after TX_PACKET. This way we can increment usbMsgFlags to toggle TX_PACKET */
-#define USB_FLG_MSGPTR_IS_ROM (1<<6)
-#define USB_FLG_USE_DEFAULT_RW (1<<7)
+#define USB_FLG_MSGPTR_IS_ROM (1<<6)
+#define USB_FLG_USE_DEFAULT_RW (1<<7)
/*
optimizing hints:
/* ------------------------------------------------------------------------- */
-static char usbDescrDevice[] PROGMEM = { /* USB device descriptor */
- 18, /* sizeof(usbDescrDevice): length of descriptor in bytes */
- 1, /* descriptor type */
- 0x01, 0x01, /* USB version supported */
- USB_CFG_DEVICE_CLASS,
- USB_CFG_DEVICE_SUBCLASS,
- 0, /* protocol */
- 8, /* max packet size */
- USB_CFG_VENDOR_ID, /* 2 bytes */
- USB_CFG_DEVICE_ID, /* 2 bytes */
- USB_CFG_DEVICE_VERSION, /* 2 bytes */
-#if USB_CFG_VENDOR_NAME_LEN
- 1, /* manufacturer string index */
-#else
- 0, /* manufacturer string index */
+#if USB_CFG_DESCR_PROPS_STRINGS == 0
+
+#if USB_CFG_DESCR_PROPS_STRING_0 == 0
+#undef USB_CFG_DESCR_PROPS_STRING_0
+#define USB_CFG_DESCR_PROPS_STRING_0 sizeof(usbDescriptorString0)
+PROGMEM char usbDescriptorString0[] = { /* language descriptor */
+ 4, /* sizeof(usbDescriptorString0): length of descriptor in bytes */
+ 3, /* descriptor type */
+ 0x09, 0x04, /* language index (0x0409 = US-English) */
+};
#endif
-#if USB_CFG_DEVICE_NAME_LEN
- 2, /* product string index */
-#else
- 0, /* product string index */
+
+#if USB_CFG_DESCR_PROPS_STRING_VENDOR == 0 && USB_CFG_VENDOR_NAME_LEN
+#undef USB_CFG_DESCR_PROPS_STRING_VENDOR
+#define USB_CFG_DESCR_PROPS_STRING_VENDOR sizeof(usbDescriptorStringVendor)
+PROGMEM int usbDescriptorStringVendor[] = {
+ USB_STRING_DESCRIPTOR_HEADER(USB_CFG_VENDOR_NAME_LEN),
+ USB_CFG_VENDOR_NAME
+};
+#endif
+
+#if USB_CFG_DESCR_PROPS_STRING_DEVICE == 0 && USB_CFG_DEVICE_NAME_LEN
+#undef USB_CFG_DESCR_PROPS_STRING_DEVICE
+#define USB_CFG_DESCR_PROPS_STRING_DEVICE sizeof(usbDescriptorStringDevice)
+PROGMEM int usbDescriptorStringDevice[] = {
+ USB_STRING_DESCRIPTOR_HEADER(USB_CFG_DEVICE_NAME_LEN),
+ USB_CFG_DEVICE_NAME
+};
#endif
- 0, /* serial number string index */
- 1, /* number of configurations */
+
+#if USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER == 0 && USB_CFG_SERIAL_NUMBER_LEN
+#undef USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER
+#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER sizeof(usbDescriptorStringSerialNumber)
+PROGMEM int usbDescriptorStringSerialNumber[] = {
+ USB_STRING_DESCRIPTOR_HEADER(USB_CFG_SERIAL_NUMBER_LEN),
+ USB_CFG_SERIAL_NUMBER
};
+#endif
+
+#endif /* USB_CFG_DESCR_PROPS_STRINGS == 0 */
+
+#if USB_CFG_DESCR_PROPS_DEVICE == 0
+#undef USB_CFG_DESCR_PROPS_DEVICE
+#define USB_CFG_DESCR_PROPS_DEVICE sizeof(usbDescriptorDevice)
+PROGMEM char usbDescriptorDevice[] = { /* USB device descriptor */
+ 18, /* sizeof(usbDescriptorDevice): length of descriptor in bytes */
+ USBDESCR_DEVICE, /* descriptor type */
+ 0x01, 0x01, /* USB version supported */
+ USB_CFG_DEVICE_CLASS,
+ USB_CFG_DEVICE_SUBCLASS,
+ 0, /* protocol */
+ 8, /* max packet size */
+ USB_CFG_VENDOR_ID, /* 2 bytes */
+ USB_CFG_DEVICE_ID, /* 2 bytes */
+ USB_CFG_DEVICE_VERSION, /* 2 bytes */
+ USB_CFG_DESCR_PROPS_STRING_VENDOR != 0 ? 1 : 0, /* manufacturer string index */
+ USB_CFG_DESCR_PROPS_STRING_DEVICE != 0 ? 2 : 0, /* product string index */
+ USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER != 0 ? 3 : 0, /* serial number string index */
+ 1, /* number of configurations */
+};
+#endif
+
+#if USB_CFG_DESCR_PROPS_HID_REPORT != 0 && USB_CFG_DESCR_PROPS_HID == 0
+#undef USB_CFG_DESCR_PROPS_HID
+#define USB_CFG_DESCR_PROPS_HID 9 /* length of HID descriptor in config descriptor below */
+#endif
-static char usbDescrConfig[] PROGMEM = { /* USB configuration descriptor */
- 9, /* sizeof(usbDescrConfig): length of descriptor in bytes */
- 2, /* descriptor type */
- (18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT), 0, /* total length of data returned (including inlined descriptors) */
- 1, /* number of interfaces in this configuration */
- 1, /* index of this configuration */
- 0, /* configuration name string index */
+#if USB_CFG_DESCR_PROPS_CONFIGURATION == 0
+#undef USB_CFG_DESCR_PROPS_CONFIGURATION
+#define USB_CFG_DESCR_PROPS_CONFIGURATION sizeof(usbDescriptorConfiguration)
+PROGMEM char usbDescriptorConfiguration[] = { /* USB configuration descriptor */
+ 9, /* sizeof(usbDescriptorConfiguration): length of descriptor in bytes */
+ USBDESCR_CONFIG, /* descriptor type */
+ 18 + 7 * USB_CFG_HAVE_INTRIN_ENDPOINT + (USB_CFG_DESCR_PROPS_HID & 0xff), 0,
+ /* total length of data returned (including inlined descriptors) */
+ 1, /* number of interfaces in this configuration */
+ 1, /* index of this configuration */
+ 0, /* configuration name string index */
#if USB_CFG_IS_SELF_POWERED
- USBATTR_SELFPOWER, /* attributes */
+ USBATTR_SELFPOWER, /* attributes */
#else
- USBATTR_BUSPOWER, /* attributes */
+ USBATTR_BUSPOWER, /* attributes */
#endif
- USB_CFG_MAX_BUS_POWER/2, /* max USB current in 2mA units */
+ USB_CFG_MAX_BUS_POWER/2, /* max USB current in 2mA units */
/* interface descriptor follows inline: */
- 9, /* sizeof(usbDescrInterface): length of descriptor in bytes */
- 4, /* descriptor type */
- 0, /* index of this interface */
- 0, /* alternate setting for this interface */
- USB_CFG_HAVE_INTRIN_ENDPOINT, /* endpoints excl 0: number of endpoint descriptors to follow */
- USB_CFG_INTERFACE_CLASS,
- USB_CFG_INTERFACE_SUBCLASS,
- USB_CFG_INTERFACE_PROTOCOL,
- 0, /* string index for interface */
-#if USB_CFG_HAVE_INTRIN_ENDPOINT /* endpoint descriptor for endpoint 1 */
- 7, /* sizeof(usbDescrEndpoint) */
- 5, /* descriptor type = endpoint */
- 0x81, /* IN endpoint number 1 */
- 0x03, /* attrib: Interrupt endpoint */
- 8, 0, /* maximum packet size */
- USB_CFG_INTR_POLL_INTERVAL, /* in ms */
+ 9, /* sizeof(usbDescrInterface): length of descriptor in bytes */
+ USBDESCR_INTERFACE, /* descriptor type */
+ 0, /* index of this interface */
+ 0, /* alternate setting for this interface */
+ USB_CFG_HAVE_INTRIN_ENDPOINT, /* endpoints excl 0: number of endpoint descriptors to follow */
+ USB_CFG_INTERFACE_CLASS,
+ USB_CFG_INTERFACE_SUBCLASS,
+ USB_CFG_INTERFACE_PROTOCOL,
+ 0, /* string index for interface */
+#if (USB_CFG_DESCR_PROPS_HID & 0xff) /* HID descriptor */
+ 9, /* sizeof(usbDescrHID): length of descriptor in bytes */
+ USBDESCR_HID, /* descriptor type: HID */
+ 0x01, 0x01, /* BCD representation of HID version */
+ 0x00, /* target country code */
+ 0x01, /* number of HID Report (or other HID class) Descriptor infos to follow */
+ 0x22, /* descriptor type: report */
+ USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH, 0, /* total length of report descriptor */
#endif
-};
-
-static char usbDescrString0[] PROGMEM = { /* language descriptor */
- 4, /* sizeof(usbDescrString0): length of descriptor in bytes */
- 3, /* descriptor type */
- 0x09, 0x04, /* language index (0x0409 = US-English) */
-};
-
-#if USB_CFG_VENDOR_NAME_LEN
-static int usbDescrString1[] PROGMEM = {
- (2 * USB_CFG_VENDOR_NAME_LEN + 2) | (3<<8), /* length of descriptor in bytes | descriptor type */
- USB_CFG_VENDOR_NAME
-};
+#if USB_CFG_HAVE_INTRIN_ENDPOINT /* endpoint descriptor for endpoint 1 */
+ 7, /* sizeof(usbDescrEndpoint) */
+ USBDESCR_ENDPOINT, /* descriptor type = endpoint */
+ 0x81, /* IN endpoint number 1 */
+ 0x03, /* attrib: Interrupt endpoint */
+ 8, 0, /* maximum packet size */
+ USB_CFG_INTR_POLL_INTERVAL, /* in ms */
#endif
-#if USB_CFG_DEVICE_NAME_LEN
-static int usbDescrString2[] PROGMEM = {
- (2 * USB_CFG_DEVICE_NAME_LEN + 2) | (3<<8), /* length of descriptor in bytes | descriptor type */
- USB_CFG_DEVICE_NAME
};
#endif
* versions. Here's an other compatibility hack:
*/
#ifndef PRG_RDB
-#define PRG_RDB(addr) pgm_read_byte(addr)
+#define PRG_RDB(addr) pgm_read_byte(addr)
#endif
typedef union{
- unsigned word;
- uchar *ptr;
- uchar bytes[2];
+ unsigned word;
+ uchar *ptr;
+ uchar bytes[2];
}converter_t;
/* We use this union to do type conversions. This is better optimized than
* type casts in gcc 3.4.3 and much better than using bit shifts to build
/* ------------------------------------------------------------------------- */
#if USB_CFG_HAVE_INTRIN_ENDPOINT
-static uchar usbTxPacketCnt1;
+uchar usbTxPacketCnt1;
-void usbSetInterrupt(uchar *data, uchar len)
+void usbSetInterrupt(uchar *data, uchar len)
{
-uchar *p, i;
-converter_t crc;
-
- if(len > 7)
- len = 7;
- i = USBPID_DATA1;
- if(usbTxPacketCnt1 & 1)
- i = USBPID_DATA0;
- if(usbTxLen1 < 0){ /* packet buffer was empty */
- usbTxPacketCnt1++;
- }else{
- usbTxLen1 = -1; /* avoid sending incomplete interrupt data */
- }
- p = usbTxBuf1;
- *p++ = i;
- for(i=len;i--;)
- *p++ = *data++;
- crc.word = usbCrc16(&usbTxBuf1[1], len);
- usbTxBuf1[len + 1] = crc.bytes[0];
- usbTxBuf1[len + 2] = crc.bytes[1];
- usbTxLen1 = len + 4; /* len must be given including sync byte */
+uchar *p, i;
+
+#if USB_CFG_IMPLEMENT_HALT
+ if(usbTxLen1 == USBPID_STALL)
+ return;
+#endif
+#if 0 /* No runtime checks! Caller is responsible for valid data! */
+ if(len > 8) /* interrupt transfers are limited to 8 bytes */
+ len = 8;
+#endif
+ i = USBPID_DATA1;
+ if(usbTxPacketCnt1 & 1)
+ i = USBPID_DATA0;
+ if(usbTxLen1 & 0x10){ /* packet buffer was empty */
+ usbTxPacketCnt1++;
+ }else{
+ usbTxLen1 = USBPID_NAK; /* avoid sending incomplete interrupt data */
+ }
+ p = usbTxBuf1;
+ *p++ = i;
+ for(i=len;i--;)
+ *p++ = *data++;
+ usbCrc16Append(&usbTxBuf1[1], len);
+ usbTxLen1 = len + 4; /* len must be given including sync byte */
+ DBG2(0x21, usbTxBuf1, len + 3);
}
#endif
-static void usbWrite(uchar *data, uchar len)
+#if USB_CFG_HAVE_INTRIN_ENDPOINT3
+uchar usbTxPacketCnt3;
+
+void usbSetInterrupt3(uchar *data, uchar len)
{
-#if USB_CFG_IMPLEMENT_FN_WRITE
- if(!(usbMsgFlags & USB_FLG_USE_DEFAULT_RW)){
- if(usbFunctionWrite(data, len) == 0xff){ /* an error occurred */
- /* usbMsgLen = 0xff; cancel potentially pending ACK [has been done by ASM module when OUT token arrived] */
- usbTxBuf[0] = USBPID_STALL;
- usbTxLen = 2; /* length including sync byte */
- return;
- }
- }
-#endif
- usbMsgLen = 0; /* send zero-sized block as ACK */
- usbMsgFlags = 0; /* start with a DATA1 package */
+uchar *p, i;
+
+ i = USBPID_DATA1;
+ if(usbTxPacketCnt3 & 1)
+ i = USBPID_DATA0;
+ if(usbTxLen3 & 0x10){ /* packet buffer was empty */
+ usbTxPacketCnt3++;
+ }else{
+ usbTxLen3 = USBPID_NAK; /* avoid sending incomplete interrupt data */
+ }
+ p = usbTxBuf3;
+ *p++ = i;
+ for(i=len;i--;)
+ *p++ = *data++;
+ usbCrc16Append(&usbTxBuf3[1], len);
+ usbTxLen3 = len + 4; /* len must be given including sync byte */
+ DBG2(0x23, usbTxBuf3, len + 3);
}
+#endif
+
-static uchar usbRead(uchar *data, uchar len)
+static uchar usbRead(uchar *data, uchar len)
{
#if USB_CFG_IMPLEMENT_FN_READ
- if(usbMsgFlags & USB_FLG_USE_DEFAULT_RW){
-#endif
- uchar i = len, *r = usbMsgPtr;
- if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){ /* ROM data */
- while(i--){
- char c = PRG_RDB(r); /* assign to char size variable to enforce byte ops */
- *data++ = c;
- r++;
- }
- }else{ /* RAM data */
- while(i--)
- *data++ = *r++;
- }
- usbMsgPtr = r;
- return len;
+ if(usbMsgFlags & USB_FLG_USE_DEFAULT_RW){
+#endif
+ uchar i = len, *r = usbMsgPtr;
+ if(usbMsgFlags & USB_FLG_MSGPTR_IS_ROM){ /* ROM data */
+ while(i--){
+ uchar c = PRG_RDB(r); /* assign to char size variable to enforce byte ops */
+ *data++ = c;
+ r++;
+ }
+ }else{ /* RAM data */
+ while(i--)
+ *data++ = *r++;
+ }
+ usbMsgPtr = r;
+ return len;
#if USB_CFG_IMPLEMENT_FN_READ
- }else{
- if(len != 0) /* don't bother app with 0 sized reads */
- return usbFunctionRead(data, len);
- return 0;
- }
+ }else{
+ if(len != 0) /* don't bother app with 0 sized reads */
+ return usbFunctionRead(data, len);
+ return 0;
+ }
#endif
}
+
+#define GET_DESCRIPTOR(cfgProp, staticName) \
+ if(cfgProp){ \
+ if((cfgProp) & USB_PROP_IS_RAM) \
+ flags &= ~USB_FLG_MSGPTR_IS_ROM; \
+ if((cfgProp) & USB_PROP_IS_DYNAMIC){ \
+ replyLen = usbFunctionDescriptor(rq); \
+ }else{ \
+ replyData = (uchar *)(staticName); \
+ SET_REPLY_LEN((cfgProp) & 0xff); \
+ } \
+ }
+/* We use if() instead of #if in the macro above because #if can't be used
+ * in macros and the compiler optimizes constant conditions anyway.
+ */
+
+
/* Don't make this function static to avoid inlining.
* The entire function would become too large and exceed the range of
* relative jumps.
+ * 2006-02-25: Either gcc 3.4.3 is better than the gcc used when the comment
+ * above was written, or other parts of the code have changed. We now get
+ * better results with an inlined function. Test condition: PowerSwitch code.
*/
-void usbProcessRx(uchar *data, uchar len)
+static void usbProcessRx(uchar *data, uchar len)
{
+usbRequest_t *rq = (void *)data;
+uchar replyLen = 0, flags = USB_FLG_USE_DEFAULT_RW;
/* We use if() cascades because the compare is done byte-wise while switch()
* is int-based. The if() cascades are therefore more efficient.
*/
- DBG2(0x10 + (usbRxToken == (uchar)USBPID_SETUP), data, len);
- if(usbRxToken == (uchar)USBPID_SETUP){
- uchar replyLen = 0, flags = USB_FLG_USE_DEFAULT_RW;
- if(len == 8){ /* Setup size must be always 8 bytes. Ignore otherwise. */
- uchar type = data[0] & (3 << 5);
- if(type == USBRQ_TYPE_STANDARD << 5){
- uchar *replyData = usbTxBuf + 9; /* there is 3 bytes free space at the end of the buffer */
- replyData[0] = 0;
- if(data[1] == 0){/* GET_STATUS */
+ DBG2(0x10 + ((usbRxToken >> 6) & 3), data, len);
+#if USB_CFG_IMPLEMENT_FN_WRITEOUT
+ if(usbRxToken & 0x80){
+ usbFunctionWriteOut(data, len);
+ return; /* no reply expected, hence no usbMsgPtr, usbMsgFlags, usbMsgLen set */
+ }
+ if(usbRxToken == (uchar)(USBPID_SETUP & 0x7f)){ /* MSb contains endpoint (== 0) */
+#else
+ if(usbRxToken == (uchar)USBPID_SETUP){
+#endif
+ if(len == 8){ /* Setup size must be always 8 bytes. Ignore otherwise. */
+ uchar type = rq->bmRequestType & USBRQ_TYPE_MASK;
+ if(type == USBRQ_TYPE_STANDARD){
+ #define SET_REPLY_LEN(len) replyLen = (len); usbMsgPtr = replyData
+ /* This macro ensures that replyLen and usbMsgPtr are always set in the same way.
+ * That allows optimization of common code in if() branches */
+ uchar *replyData = usbTxBuf + 9; /* there is 3 bytes free space at the end of the buffer */
+ replyData[0] = 0; /* common to USBRQ_GET_STATUS and USBRQ_GET_INTERFACE */
+ if(rq->bRequest == USBRQ_GET_STATUS){ /* 0 */
+ uchar __attribute__((__unused__)) recipient = rq->bmRequestType & USBRQ_RCPT_MASK; /* assign arith ops to variables to enforce byte size */
#if USB_CFG_IS_SELF_POWERED
- uchar recipient = data[0] & 0x1f; /* assign arith ops to variables to enforce byte size */
- if(recipient == USBRQ_RCPT_DEVICE)
- replyData[0] = USB_CFG_IS_SELF_POWERED;
-#endif
- replyData[1] = 0;
- replyLen = 2;
- }else if(data[1] == 5){ /* SET_ADDRESS */
- usbNewDeviceId = data[2];
- }else if(data[1] == 6){ /* GET_DESCRIPTOR */
- flags = USB_FLG_MSGPTR_IS_ROM | USB_FLG_USE_DEFAULT_RW;
- if(data[3] == 1){ /* descriptor type requested */
- replyLen = sizeof(usbDescrDevice);
- replyData = (uchar *)usbDescrDevice;
- }else if(data[3] == 2){
- replyLen = sizeof(usbDescrConfig);
- replyData = (uchar *)usbDescrConfig;
- }else if(data[3] == 3){ /* string descriptor */
- if(data[2] == 0){ /* descriptor index */
- replyLen = sizeof(usbDescrString0);
- replyData = (uchar *)usbDescrString0;
-#if USB_CFG_VENDOR_NAME_LEN
- }else if(data[2] == 1){
- replyLen = sizeof(usbDescrString1);
- replyData = (uchar *)usbDescrString1;
-#endif
-#if USB_CFG_DEVICE_NAME_LEN
- }else if(data[2] == 2){
- replyLen = sizeof(usbDescrString2);
- replyData = (uchar *)usbDescrString2;
-#endif
- }
- }
- }else if(data[1] == 8){ /* GET_CONFIGURATION */
- replyLen = 1;
- replyData[0] = 1; /* config is always 1, no setConfig required */
- }else if(data[1] == 10){ /* GET_INTERFACE */
- replyLen = 1;
+ if(recipient == USBRQ_RCPT_DEVICE)
+ replyData[0] = USB_CFG_IS_SELF_POWERED;
+#endif
+#if USB_CFG_HAVE_INTRIN_ENDPOINT && USB_CFG_IMPLEMENT_HALT
+ if(recipient == USBRQ_RCPT_ENDPOINT && rq->wIndex.bytes[0] == 0x81) /* request status for endpoint 1 */
+ replyData[0] = usbTxLen1 == USBPID_STALL;
+#endif
+ replyData[1] = 0;
+ SET_REPLY_LEN(2);
+ }else if(rq->bRequest == USBRQ_SET_ADDRESS){ /* 5 */
+ usbNewDeviceAddr = rq->wValue.bytes[0];
+ }else if(rq->bRequest == USBRQ_GET_DESCRIPTOR){ /* 6 */
+ flags = USB_FLG_MSGPTR_IS_ROM | USB_FLG_USE_DEFAULT_RW;
+ if(rq->wValue.bytes[1] == USBDESCR_DEVICE){ /* 1 */
+ GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_DEVICE, usbDescriptorDevice)
+ }else if(rq->wValue.bytes[1] == USBDESCR_CONFIG){ /* 2 */
+ GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_CONFIGURATION, usbDescriptorConfiguration)
+ }else if(rq->wValue.bytes[1] == USBDESCR_STRING){ /* 3 */
+#if USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC
+ if(USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_RAM)
+ flags &= ~USB_FLG_MSGPTR_IS_ROM;
+ replyLen = usbFunctionDescriptor(rq);
+#else /* USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC */
+ if(rq->wValue.bytes[0] == 0){ /* descriptor index */
+ GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_0, usbDescriptorString0)
+ }else if(rq->wValue.bytes[0] == 1){
+ GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_VENDOR, usbDescriptorStringVendor)
+ }else if(rq->wValue.bytes[0] == 2){
+ GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_DEVICE, usbDescriptorStringDevice)
+ }else if(rq->wValue.bytes[0] == 3){
+ GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER, usbDescriptorStringSerialNumber)
+ }else if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_DYNAMIC){
+ replyLen = usbFunctionDescriptor(rq);
+ }
+#endif /* USB_CFG_DESCR_PROPS_STRINGS & USB_PROP_IS_DYNAMIC */
+ }else if(rq->wValue.bytes[1] == USBDESCR_HID){ /* 0x21 */
+ GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_HID, usbDescriptorConfiguration + 18)
+ }else if(rq->wValue.bytes[1] == USBDESCR_HID_REPORT){ /* 0x22 */
+ GET_DESCRIPTOR(USB_CFG_DESCR_PROPS_HID_REPORT, usbDescriptorHidReport)
+ }else if(USB_CFG_DESCR_PROPS_UNKNOWN & USB_PROP_IS_DYNAMIC){
+ replyLen = usbFunctionDescriptor(rq);
+ }
+ }else if(rq->bRequest == USBRQ_GET_CONFIGURATION){ /* 8 */
+ replyData = &usbConfiguration; /* send current configuration value */
+ SET_REPLY_LEN(1);
+ }else if(rq->bRequest == USBRQ_SET_CONFIGURATION){ /* 9 */
+ usbConfiguration = rq->wValue.bytes[0];
+#if USB_CFG_IMPLEMENT_HALT
+ usbTxLen1 = USBPID_NAK;
+#endif
+ }else if(rq->bRequest == USBRQ_GET_INTERFACE){ /* 10 */
+ SET_REPLY_LEN(1);
#if USB_CFG_HAVE_INTRIN_ENDPOINT
- }else if(data[1] == 11){ /* SET_INTERFACE */
- usbTxPacketCnt1 = 0; /* reset data toggling for interrupt socket */
-#endif
- }else{
- /* the following requests can be ignored, send default reply */
- /* 1: CLEAR_FEATURE, 3: SET_FEATURE, 7: SET_DESCRIPTOR */
- /* 9: SET_CONFIGURATION, 11: SET_INTERFACE, 12: SYNCH_FRAME */
- }
- usbMsgPtr = replyData;
- if(!data[7] && replyLen > data[6]) /* max length is in data[7]:data[6] */
- replyLen = data[6];
- }else{ /* not a standard request -- must be vendor or class request */
+ }else if(rq->bRequest == USBRQ_SET_INTERFACE){ /* 11 */
+ usbTxPacketCnt1 = 0; /* reset data toggling for interrupt endpoint */
+# if USB_CFG_HAVE_INTRIN_ENDPOINT3
+ usbTxPacketCnt3 = 0; /* reset data toggling for interrupt endpoint */
+# endif
+# if USB_CFG_IMPLEMENT_HALT
+ usbTxLen1 = USBPID_NAK;
+ }else if(rq->bRequest == USBRQ_CLEAR_FEATURE || rq->bRequest == USBRQ_SET_FEATURE){ /* 1|3 */
+ if(rq->wValue.bytes[0] == 0 && rq->wIndex.bytes[0] == 0x81){ /* feature 0 == HALT for endpoint == 1 */
+ usbTxLen1 = rq->bRequest == USBRQ_CLEAR_FEATURE ? USBPID_NAK : USBPID_STALL;
+ usbTxPacketCnt1 = 0; /* reset data toggling for interrupt endpoint */
+# if USB_CFG_HAVE_INTRIN_ENDPOINT3
+ usbTxPacketCnt3 = 0; /* reset data toggling for interrupt endpoint */
+# endif
+ }
+# endif
+#endif
+ }else{
+ /* the following requests can be ignored, send default reply */
+ /* 1: CLEAR_FEATURE, 3: SET_FEATURE, 7: SET_DESCRIPTOR */
+ /* 12: SYNCH_FRAME */
+ }
+ #undef SET_REPLY_LEN
+ }else{ /* not a standard request -- must be vendor or class request */
+ replyLen = usbFunctionSetup(data);
+ }
#if USB_CFG_IMPLEMENT_FN_READ || USB_CFG_IMPLEMENT_FN_WRITE
- uchar len;
- replyLen = data[6]; /* if this is an OUT operation, the next token will reset usbMsgLen */
- if((len = usbFunctionSetup(data)) != 0xff){
- replyLen = len;
- }else{
- flags = 0; /* we have no valid msg, use read/write functions */
- }
-#else
- replyLen = usbFunctionSetup(data);
-#endif
- }
- }
- usbMsgLen = replyLen;
- usbMsgFlags = flags;
- }else{ /* out request */
- usbWrite(data, len);
- }
+ if(replyLen == 0xff){ /* use user-supplied read/write function */
+ if((rq->bmRequestType & USBRQ_DIR_MASK) == USBRQ_DIR_DEVICE_TO_HOST){
+ replyLen = rq->wLength.bytes[0]; /* IN transfers only */
+ }
+ flags &= ~USB_FLG_USE_DEFAULT_RW; /* we have no valid msg, use user supplied read/write functions */
+ }else /* The 'else' prevents that we limit a replyLen of 0xff to the maximum transfer len. */
+#endif
+ if(!rq->wLength.bytes[1] && replyLen > rq->wLength.bytes[0]) /* limit length to max */
+ replyLen = rq->wLength.bytes[0];
+ }
+ /* make sure that data packets which are sent as ACK to an OUT transfer are always zero sized */
+ }else{ /* DATA packet from out request */
+#if USB_CFG_IMPLEMENT_FN_WRITE
+ if(!(usbMsgFlags & USB_FLG_USE_DEFAULT_RW)){
+ uchar rval = usbFunctionWrite(data, len);
+ replyLen = 0xff;
+ if(rval == 0xff){ /* an error occurred */
+ usbMsgLen = 0xff; /* cancel potentially pending data packet for ACK */
+ usbTxLen = USBPID_STALL;
+ }else if(rval != 0){ /* This was the final package */
+ replyLen = 0; /* answer with a zero-sized data packet */
+ }
+ flags = 0; /* start with a DATA1 package, stay with user supplied write() function */
+ }
+#endif
+ }
+ usbMsgFlags = flags;
+ usbMsgLen = replyLen;
}
/* ------------------------------------------------------------------------- */
-static void usbBuildTxBlock(void)
+static void usbBuildTxBlock(void)
{
-uchar wantLen, len, txLen, x;
-converter_t crc;
-
- x = USBPID_DATA1;
- if(usbMsgFlags & USB_FLG_TX_PACKET)
- x = USBPID_DATA0;
- usbMsgFlags++;
- usbTxBuf[0] = x;
- wantLen = usbMsgLen;
- if(wantLen > 8)
- wantLen = 8;
- usbMsgLen -= wantLen;
- len = usbRead(usbTxBuf + 1, wantLen);
- if(len <= 8){ /* valid data packet */
- crc.word = usbCrc16(&usbTxBuf[1], len);
- usbTxBuf[len + 1] = crc.bytes[0];
- usbTxBuf[len + 2] = crc.bytes[1];
- txLen = len + 4; /* length including sync byte */
- if(len < 8) /* a partial package identifies end of message */
- usbMsgLen = 0xff;
- }else{
- usbTxBuf[0] = USBPID_STALL;
- txLen = 2; /* length including sync byte */
- usbMsgLen = 0xff;
- }
- usbTxLen = txLen;
- DBG2(0x20, usbTxBuf, txLen-1);
+uchar wantLen, len, txLen, token;
+
+ wantLen = usbMsgLen;
+ if(wantLen > 8)
+ wantLen = 8;
+ usbMsgLen -= wantLen;
+ token = USBPID_DATA1;
+ if(usbMsgFlags & USB_FLG_TX_PACKET)
+ token = USBPID_DATA0;
+ usbMsgFlags++;
+ len = usbRead(usbTxBuf + 1, wantLen);
+ if(len <= 8){ /* valid data packet */
+ usbCrc16Append(&usbTxBuf[1], len);
+ txLen = len + 4; /* length including sync byte */
+ if(len < 8) /* a partial package identifies end of message */
+ usbMsgLen = 0xff;
+ }else{
+ txLen = USBPID_STALL; /* stall the endpoint */
+ usbMsgLen = 0xff;
+ }
+ usbTxBuf[0] = token;
+ usbTxLen = txLen;
+ DBG2(0x20, usbTxBuf, txLen-1);
}
-static inline uchar isNotSE0(void)
+static inline uchar isNotSE0(void)
{
-uchar rval;
+uchar rval;
/* We want to do
* return (USBIN & USBMASK);
* here, but the compiler does int-expansion acrobatics.
* We can avoid this by assigning to a char-sized variable.
*/
- rval = USBIN & USBMASK;
- return rval;
+ rval = USBIN & USBMASK;
+ return rval;
}
/* ------------------------------------------------------------------------- */
-void usbPoll(void)
+void usbPoll(void)
{
-uchar len;
+uchar len;
- if((len = usbRxLen) > 0){
+ if((len = usbRxLen) > 0){
/* We could check CRC16 here -- but ACK has already been sent anyway. If you
* need data integrity checks with this driver, check the CRC in your app
* code and report errors back to the host. Since the ACK was already sent,
* retries must be handled on application level.
* unsigned crc = usbCrc16((uchar *)(unsigned)(usbAppBuf + 1), usbRxLen - 3);
*/
- len -= 3; /* remove PID and CRC */
- if(len < 128){
- usbProcessRx((uchar *)(unsigned)(usbAppBuf + 1), len);
- }
- usbRxLen = 0; /* mark rx buffer as available */
- }
- if(usbTxLen < 0){ /* TX system is idle */
- if(usbMsgLen != 0xff){
- usbBuildTxBlock();
- }else if(usbNewDeviceId){
- usbDeviceId = usbNewDeviceId;
- DBG1(1, &usbNewDeviceId, 1);
- usbNewDeviceId = 0;
- }
- }
- if(isNotSE0()){ /* SE0 state */
- usbIsReset = 0;
- }else{
- /* check whether SE0 lasts for more than 2.5us (3.75 bit times) */
- if(!usbIsReset){
- uchar i;
- for(i=100;i;i--){
- if(isNotSE0())
- goto notUsbReset;
- }
- usbIsReset = 1;
- usbDeviceId = 0;
- usbNewDeviceId = 0;
- DBG1(0xff, 0, 0);
+ len -= 3; /* remove PID and CRC */
+ if(len < 128){ /* no overflow */
+ converter_t appBuf;
+ appBuf.ptr = (uchar *)usbRxBuf;
+ appBuf.bytes[0] = usbAppBuf;
+ appBuf.bytes[0]++;
+ usbProcessRx(appBuf.ptr, len);
+ }
+#if USB_CFG_HAVE_FLOWCONTROL
+ if(usbRxLen > 0) /* only mark as available if not inactivated */
+ usbRxLen = 0;
+#else
+ usbRxLen = 0; /* mark rx buffer as available */
+#endif
+ }
+ if(usbMsgLen != 0xff){ /* transmit data pending? */
+ if(usbTxLen & 0x10) /* transmit system idle */
+ usbBuildTxBlock();
+ }
+ if(isNotSE0()){ /* SE0 state */
+ usbIsReset = 0;
+ }else{
+ /* check whether SE0 lasts for more than 2.5us (3.75 bit times) */
+ if(!usbIsReset){
+ uchar i;
+ for(i=100;i;i--){
+ if(isNotSE0())
+ goto notUsbReset;
+ }
+ usbIsReset = 1;
+ usbNewDeviceAddr = 0;
+ usbDeviceAddr = 0;
+#if USB_CFG_IMPLEMENT_HALT
+ usbTxLen1 = USBPID_NAK;
+#if USB_CFG_HAVE_INTRIN_ENDPOINT3
+ usbTxLen3 = USBPID_NAK;
+#endif
+#endif
+ DBG1(0xff, 0, 0);
notUsbReset:;
- }
- }
+ }
+ }
}
/* ------------------------------------------------------------------------- */
-void usbInit(void)
+void usbInit(void)
{
- usbInputBuf = (uchar)usbRxBuf[0];
- usbAppBuf = (uchar)usbRxBuf[1];
+ usbInputBuf = (uchar)usbRxBuf[0];
+ usbAppBuf = (uchar)usbRxBuf[1];
#if USB_INTR_CFG_SET != 0
- USB_INTR_CFG |= USB_INTR_CFG_SET;
+ USB_INTR_CFG |= USB_INTR_CFG_SET;
#endif
#if USB_INTR_CFG_CLR != 0
- USB_INTR_CFG &= ~(USB_INTR_CFG_CLR);
+ USB_INTR_CFG &= ~(USB_INTR_CFG_CLR);
#endif
- USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT);
+ USB_INTR_ENABLE |= (1 << USB_INTR_ENABLE_BIT);
}
/* ------------------------------------------------------------------------- */
* Tabsize: 4
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
* License: Proprietary, free under certain conditions. See Documentation.
- * This Revision: $Id: usbdrv.h 52 2005-04-12 16:57:29Z cs $
+ * This Revision: $Id: usbdrv.h 230 2006-07-18 11:29:00Z cs $
*/
#ifndef __usbdrv_h_included__
-#define __usbdrv_h_included__
+#define __usbdrv_h_included__
#include "usbconfig.h"
+#include "iarcompat.h"
/*
Hardware Prerequisites:
=======================
-USB lines D+ and D- MUST be wired to the same I/O port. Line D- MUST be wired
-to bit number 0. D+ must also be connected to INT0. D- requires a pullup of
-1.5k to +3.5V (and the device must be powered at 3.5V) to identify as
-low-speed USB device. A pullup of 1M SHOULD be connected from D+ to +3.5V to
-prevent interference when no USB master is connected. We use D+ as interrupt
-source and not D- because it does not trigger on keep-alive and RESET states.
+USB lines D+ and D- MUST be wired to the same I/O port. D+ must (also) be
+connected to INT0. D- requires a pullup of 1.5k to +3.5V (and the device
+must be powered at 3.5V) to identify as low-speed USB device. A pullup of
+1M SHOULD be connected from D+ to +3.5V to prevent interference when no USB
+master is connected. We use D+ as interrupt source and not D- because it
+does not trigger on keep-alive and RESET states.
+
+As a compile time option, the 1.5k pullup resistor on D- can be made
+switchable to allow the device to disconnect at will. See the definition of
+usbDeviceConnect() and usbDeviceDisconnect() further down in this file.
Please adapt the values in usbconfig.h according to your hardware!
Limitations:
============
Compiling:
-The bss segment of the driver must be in the first 256 bytes of the address
-space because byte wide variables are used as pointers for efficiency reasons.
-This is not a problem on devices with 128 byte RAM since the entire RAM
-meets this condition. For larger devices please link usbdrv first.
+You should link the usbdrv.o module first because it has special alignment
+requirements for the receive buffer (the buffer must not cross a 256 byte
+page boundary, it must not even touch it at the end). If you can't link it
+first, you must use other measures to ensure alignment.
+Note: gcc does not always assign variable addresses in the order as the modules
+are linked or the variables are declared. You can choose a memory section for
+the receive buffer with the configuration option "USB_BUFFER_SECTION". This
+option defaults to ".bss". If you use your own section, you can place it at
+an arbitrary location with a linker option similar to
+"-Wl,--section-start=.mybuffer=0x800060". Use "avr-nm -ng" on the binary and
+search for "usbRxBuf" to find tbe base address of the 22 bytes rx buffer.
Robustness with respect to communication errors:
The driver assumes error-free communication. It DOES check for errors in
requires detection of asymmetric states at high bit rate for SE0 detection.
Number of endpoints:
-The driver supports up to two endpoints: One control endpoint (endpoint 0) and
-one interrupt-in endpoint (endpoint 1) where the device can send interrupt
-data to the host. Endpoint 1 is only compiled in if
-USB_CFG_HAVE_INTRIN_ENDPOINT is defined to 1 in usbconfig.h.
+The driver supports up to four endpoints: One control endpoint (endpoint 0),
+two interrupt-in (or bulk-in) endpoints (endpoint 1 and 3) and one
+interrupt-out (or bulk-out) endpoint (endpoint 1). Please note that the USB
+standard forbids bulk endpoints for low speed devices! Most operating systems
+allow them anyway, but the AVR will spend 90% of the CPU time in the USB
+interrupt polling for bulk data.
+By default, only the control endpoint 0 is enabled. To get the other endpoints,
+define USB_CFG_HAVE_INTRIN_ENDPOINT, USB_CFG_HAVE_INTRIN_ENDPOINT3 and/or
+USB_CFG_IMPLEMENT_FN_WRITEOUT respectively (see usbconfig-prototype.h for
+details).
Maximum data payload:
-Data payload of control in and out transfers may be up to 255 bytes. In order
+Data payload of control in and out transfers may be up to 254 bytes. In order
to accept payload data of out transfers, you need to implement
'usbFunctionWrite()'.
CPU in sleep mode. The driver does not implement suspend handling by itself.
However, the application may implement activity monitoring and wakeup from
sleep. The host sends regular SE0 states on the bus to keep it active. These
-SE0 states can be detected by wiring the INT1 pin to D+. It is not necessary
+SE0 states can be detected by wiring the INT1 pin to D-. It is not necessary
to enable the interrupt, checking the interrupt pending flag should suffice.
Before entering sleep mode, the application should enable INT1 for a wakeup
on the next bus activity.
Interrupt latency:
The application must ensure that the USB interrupt is not disabled for more
-than 20 cycles.
+than 20 cycles. This implies that all interrupt routines must either be
+declared as "INTERRUPT" instead of "SIGNAL" (see "avr/signal.h") or that they
+are written in assembler with "sei" as the first instruction.
Maximum interrupt duration / CPU cycle consumption:
The driver handles all USB communication during the interrupt service
routine. The routine will not return before an entire USB message is received
and the reply is sent. This may be up to ca. 1200 cycles = 100us if the host
conforms to the standard. The driver will consume CPU cycles for all USB
-messages, even if they address an other (low-speed) device on the same bus.
+messages, even if they address another (low-speed) device on the same bus.
*/
/* --------------------------- Module Interface ---------------------------- */
/* ------------------------------------------------------------------------- */
+#define USBDRV_VERSION 20060718
+/* This define uniquely identifies a driver version. It is a decimal number
+ * constructed from the driver's release date in the form YYYYMMDD. If the
+ * driver's behavior or interface changes, you can use this constant to
+ * distinguish versions. If it is not defined, the driver's release date is
+ * older than 2006-01-25.
+ */
+
#ifndef __ASSEMBLER__
#ifndef uchar
-#define uchar unsigned char
+#define uchar unsigned char
+#endif
+#ifndef schar
+#define schar signed char
#endif
+/* shortcuts for well defined 8 bit integer types */
-#if USB_CFG_HAVE_INTRIN_ENDPOINT
-void usbSetInterrupt(uchar *data, uchar len);
-/* This function sets the message which will be sent during the next interrupt
- * IN transfer. The message is copied to an internal buffer and must not exceed
- * a length of 7 bytes. The message may be 0 bytes long just to indicate the
- * interrupt status to the host.
- * If you need to transfer more bytes, use a control read after the interrupt.
- */
-#endif /* USB_CFG_HAVE_INTRIN_ENDPOINT */
+struct usbRequest; /* forward declaration */
-extern void usbInit(void);
+extern void usbInit(void);
/* This function must be called before interrupts are enabled and the main
* loop is entered.
*/
-extern void usbPoll(void);
+extern void usbPoll(void);
/* This function must be called at regular intervals from the main loop.
- * Maximum delay between calls is somewhat less than 50ms (USB timeout between
- * packages of a message).
+ * Maximum delay between calls is somewhat less than 50ms (USB timeout for
+ * accepting a Setup message). Otherwise the device will not be recognized.
+ * Please note that debug outputs through the UART take ~ 0.5ms per byte
+ * at 19200 bps.
*/
-extern uchar *usbMsgPtr;
+extern uchar *usbMsgPtr;
/* This variable may be used to pass transmit data to the driver from the
* implementation of usbFunctionWrite(). It is also used internally by the
* driver for standard control requests.
*/
-extern uchar usbFunctionSetup(uchar data[8]);
-/* This function is called for all setup requests which are not of type
- * "Standard" (in practice: class and vendor requests). The 8 bytes setup
- * data is passed in 'data'. Data for control-out transfers is passed to the
- * application in separate calls to usbFunctionWrite() (unless you have turned
- * this option off). You should store the setup context in global/static
- * variables to have it available in usbFunctionWrite(). Data for control-in
- * transfers can be provided in two ways: (1) immediately as a result of
- * usbFunctionSetup() or (2) on demand of the driver in calls to the separate
- * function usbFunctionRead() (if enabled). For (1) write the data to a static
- * buffer, set the global variable 'usbMsgPtr' to this buffer and return the
- * data length (may be 0). To implement (2), simply return 0xff (== -1) in
- * usbFunctionSetup(). The driver will call usbFunctionRead() when data is
- * needed. You may use 'usbMsgPtr' to save your own status in this case.
- * The data passed in 'data' has the following content (see USB 1.1 spec):
- * struct usbControlData{
- * uchar requestType; //[0]
- * uchar request; //[1]
- * unsigned value; //[2], [3]
- * unsigned index; //[4], [5]
- * unsigned length; //[6], [7]
- * };
+extern uchar usbFunctionSetup(uchar data[8]);
+/* This function is called when the driver receives a SETUP transaction from
+ * the host which is not answered by the driver itself (in practice: class and
+ * vendor requests). All control transfers start with a SETUP transaction where
+ * the host communicates the parameters of the following (optional) data
+ * transfer. The SETUP data is available in the 'data' parameter which can
+ * (and should) be casted to 'usbRequest_t *' for a more user-friendly access
+ * to parameters.
+ *
+ * If the SETUP indicates a control-in transfer, you should provide the
+ * requested data to the driver. There are two ways to transfer this data:
+ * (1) Set the global pointer 'usbMsgPtr' to the base of the static RAM data
+ * block and return the length of the data in 'usbFunctionSetup()'. The driver
+ * will handle the rest. Or (2) return 0xff in 'usbFunctionSetup()'. The driver
+ * will then call 'usbFunctionRead()' when data is needed. See the
+ * documentation for usbFunctionRead() for details.
+ *
+ * If the SETUP indicates a control-out transfer, the only way to receive the
+ * data from the host is through the 'usbFunctionWrite()' call. If you
+ * implement this function, you must return 0xff in 'usbFunctionSetup()' to
+ * indicate that 'usbFunctionWrite()' should be used. See the documentation of
+ * this function for more information. If you just want to ignore the data sent
+ * by the host, return 0 in 'usbFunctionSetup()'.
+ *
+ * Note that calls to the functions usbFunctionRead() and usbFunctionWrite()
+ * are only done if enabled by the configuration in usbconfig.h.
+ */
+extern uchar usbFunctionDescriptor(struct usbRequest *rq);
+/* You need to implement this function ONLY if you provide USB descriptors at
+ * runtime (which is an expert feature). It is very similar to
+ * usbFunctionSetup() above, but it is called only to request USB descriptor
+ * data. See the documentation of usbFunctionSetup() above for more info.
*/
+#if USB_CFG_HAVE_INTRIN_ENDPOINT
+void usbSetInterrupt(uchar *data, uchar len);
+/* This function sets the message which will be sent during the next interrupt
+ * IN transfer. The message is copied to an internal buffer and must not exceed
+ * a length of 8 bytes. The message may be 0 bytes long just to indicate the
+ * interrupt status to the host.
+ * If you need to transfer more bytes, use a control read after the interrupt.
+ */
+extern volatile uchar usbTxLen1;
+#define usbInterruptIsReady() (usbTxLen1 & 0x10)
+/* This macro indicates whether the last interrupt message has already been
+ * sent. If you set a new interrupt message before the old was sent, the
+ * message already buffered will be lost.
+ */
+#if USB_CFG_HAVE_INTRIN_ENDPOINT3
+void usbSetInterrupt3(uchar *data, uchar len);
+extern volatile uchar usbTxLen3;
+#define usbInterruptIsReady3() (usbTxLen3 & 0x10)
+/* Same as above for endpoint 3 */
+#endif
+#endif /* USB_CFG_HAVE_INTRIN_ENDPOINT */
+#if USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH /* simplified interface for backward compatibility */
+#define usbHidReportDescriptor usbDescriptorHidReport
+/* should be declared as: PROGMEM char usbHidReportDescriptor[]; */
+/* If you implement an HID device, you need to provide a report descriptor.
+ * The HID report descriptor syntax is a bit complex. If you understand how
+ * report descriptors are constructed, we recommend that you use the HID
+ * Descriptor Tool from usb.org, see http://www.usb.org/developers/hidpage/.
+ * Otherwise you should probably start with a working example.
+ */
+#endif /* USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH */
#if USB_CFG_IMPLEMENT_FN_WRITE
-extern uchar usbFunctionWrite(uchar *data, uchar len);
+extern uchar usbFunctionWrite(uchar *data, uchar len);
/* This function is called by the driver to provide a control transfer's
* payload data (control-out). It is called in chunks of up to 8 bytes. The
* total count provided in the current control transfer can be obtained from
* the 'length' property in the setup data. If an error occurred during
* processing, return 0xff (== -1). The driver will answer the entire transfer
- * with a STALL token in this case. Otherwise return any number which is not
- * 0xff. NOTE: Only the return value of the LAST usbFunctionWrite() call
- * (the one immediately before the status phase) is used.
+ * with a STALL token in this case. If you have received the entire payload
+ * successfully, return 1. If you expect more data, return 0. If you don't
+ * know whether the host will send more data (you should know, the total is
+ * provided in the usbFunctionSetup() call!), return 1.
+ * NOTE: If you return 0xff for STALL, 'usbFunctionWrite()' may still be called
+ * for the remaining data. You must continue to return 0xff for STALL in these
+ * calls.
+ * In order to get usbFunctionWrite() called, define USB_CFG_IMPLEMENT_FN_WRITE
+ * to 1 in usbconfig.h and return 0xff in usbFunctionSetup()..
*/
#endif /* USB_CFG_IMPLEMENT_FN_WRITE */
#if USB_CFG_IMPLEMENT_FN_READ
extern uchar usbFunctionRead(uchar *data, uchar len);
/* This function is called by the driver to ask the application for a control
- * transfer's payload data (control-in). You should supply up to 'len' bytes of
- * data in this chunk. 'len' will be 8 bytes for all but the last chunk. If
- * you return less than 8 bytes, the control transfer ends. If you return an
- * invalid value (e.g. -1), the driver sends a STALL token.
+ * transfer's payload data (control-in). It is called in chunks of up to 8
+ * bytes each. You should copy the data to the location given by 'data' and
+ * return the actual number of bytes copied. If you return less than requested,
+ * the control-in transfer is terminated. If you return 0xff, the driver aborts
+ * the transfer with a STALL token.
+ * In order to get usbFunctionRead() called, define USB_CFG_IMPLEMENT_FN_READ
+ * to 1 in usbconfig.h and return 0xff in usbFunctionSetup()..
*/
#endif /* USB_CFG_IMPLEMENT_FN_READ */
-extern unsigned usbCrc16(uchar *data, uchar len);
+#if USB_CFG_IMPLEMENT_FN_WRITEOUT
+extern void usbFunctionWriteOut(uchar *data, uchar len);
+/* This function is called by the driver when data on interrupt-out or bulk-
+ * out endpoint 1 is received. You must define USB_CFG_IMPLEMENT_FN_WRITEOUT
+ * to 1 in usbconfig.h to get this function called.
+ */
+#endif /* USB_CFG_IMPLEMENT_FN_WRITEOUT */
+#ifdef USB_CFG_PULLUP_IOPORTNAME
+#define usbDeviceConnect() ((USB_PULLUP_DDR |= (1<<USB_CFG_PULLUP_BIT)), \
+ (USB_PULLUP_OUT |= (1<<USB_CFG_PULLUP_BIT)))
+/* This macro (intended to look like a function) connects the device to the
+ * USB bus. It is only available if you have defined the constants
+ * USB_CFG_PULLUP_IOPORT and USB_CFG_PULLUP_BIT in usbconfig.h.
+ */
+#define usbDeviceDisconnect() (USB_PULLUP_OUT &= ~(1<<USB_CFG_PULLUP_BIT))
+/* This macro (intended to look like a function) disconnects the device from
+ * the USB bus. It is only available if you have defined the constants
+ * USB_CFG_PULLUP_IOPORT and USB_CFG_PULLUP_BIT in usbconfig.h.
+ */
+#endif /* USB_CFG_PULLUP_IOPORT */
+extern unsigned usbCrc16(unsigned data, uchar len);
+#define usbCrc16(data, len) usbCrc16((unsigned)(data), len)
/* This function calculates the binary complement of the data CRC used in
* USB data packets. The value is used to build raw transmit packets.
- * You may want to use this function for data checksums.
+ * You may want to use this function for data checksums or to verify received
+ * data. We enforce 16 bit calling conventions for compatibility with IAR's
+ * tiny memory model.
+ */
+extern unsigned usbCrc16Append(unsigned data, uchar len);
+#define usbCrc16Append(data, len) usbCrc16Append((unsigned)(data), len)
+/* This function is equivalent to usbCrc16() above, except that it appends
+ * the 2 bytes CRC (lowbyte first) in the 'data' buffer after reading 'len'
+ * bytes.
+ */
+extern uchar usbConfiguration;
+/* This value contains the current configuration set by the host. The driver
+ * allows setting and querying of this variable with the USB SET_CONFIGURATION
+ * and GET_CONFIGURATION requests, but does not use it otherwise.
+ * You may want to reflect the "configured" status with a LED on the device or
+ * switch on high power parts of the circuit only if the device is configured.
+ */
+#define USB_STRING_DESCRIPTOR_HEADER(stringLength) ((2*(stringLength)+2) | (3<<8))
+/* This macro builds a descriptor header for a string descriptor given the
+ * string's length. See usbdrv.c for an example how to use it.
+ */
+#if USB_CFG_HAVE_FLOWCONTROL
+extern volatile schar usbRxLen;
+#define usbDisableAllRequests() usbRxLen = -1
+/* Must be called from usbFunctionWrite(). This macro disables all data input
+ * from the USB interface. Requests from the host are answered with a NAK
+ * while they are disabled.
+ */
+#define usbEnableAllRequests() usbRxLen = 0
+/* May only be called if requests are disabled. This macro enables input from
+ * the USB interface after it has been disabled with usbDisableAllRequests().
+ */
+#define usbAllRequestsAreDisabled() (usbRxLen < 0)
+/* Use this macro to find out whether requests are disabled. It may be needed
+ * to ensure that usbEnableAllRequests() is never called when requests are
+ * enabled.
+ */
+#endif
+
+extern uchar usbTxPacketCnt1;
+extern uchar usbTxPacketCnt3;
+/* The two variables above are mostly for internal use by the driver. You may
+ * have to reset usbTxPacketCnt1 to 0 if you start data toggling at DATA0 for
+ * interrupt-IN endpoint 1 and usbTxPacketCnt3 for interrupt-IN endpoint 3
+ * respectively.
*/
-#endif /* __ASSEMBLER__ */
+#endif /* __ASSEMBLER__ */
+
+
+/* ------------------------------------------------------------------------- */
+/* ----------------- Definitions for Descriptor Properties ----------------- */
+/* ------------------------------------------------------------------------- */
+/* This is advanced stuff. See usbconfig-prototype.h for more information
+ * about the various methods to define USB descriptors. If you do nothing,
+ * the default descriptors will be used.
+ */
+#define USB_PROP_IS_DYNAMIC (1 << 8)
+/* If this property is set for a descriptor, usbFunctionDescriptor() will be
+ * used to obtain the particular descriptor.
+ */
+#define USB_PROP_IS_RAM (1 << 9)
+/* If this property is set for a descriptor, the data is read from RAM
+ * memory instead of Flash. The property is used for all methods to provide
+ * external descriptors.
+ */
+#define USB_PROP_LENGTH(len) ((len) & 0xff)
+/* If a static external descriptor is used, this is the total length of the
+ * descriptor in bytes.
+ */
+
+/* all descriptors which may have properties: */
+#ifndef USB_CFG_DESCR_PROPS_DEVICE
+#define USB_CFG_DESCR_PROPS_DEVICE 0
+#endif
+#ifndef USB_CFG_DESCR_PROPS_CONFIGURATION
+#define USB_CFG_DESCR_PROPS_CONFIGURATION 0
+#endif
+#ifndef USB_CFG_DESCR_PROPS_STRINGS
+#define USB_CFG_DESCR_PROPS_STRINGS 0
+#endif
+#ifndef USB_CFG_DESCR_PROPS_STRING_0
+#define USB_CFG_DESCR_PROPS_STRING_0 0
+#endif
+#ifndef USB_CFG_DESCR_PROPS_STRING_VENDOR
+#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0
+#endif
+#ifndef USB_CFG_DESCR_PROPS_STRING_DEVICE
+#define USB_CFG_DESCR_PROPS_STRING_DEVICE 0
+#endif
+#ifndef USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER
+#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0
+#endif
+#ifndef USB_CFG_DESCR_PROPS_HID
+#define USB_CFG_DESCR_PROPS_HID 0
+#endif
+#if !(USB_CFG_DESCR_PROPS_HID_REPORT)
+# undef USB_CFG_DESCR_PROPS_HID_REPORT
+# if USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH /* do some backward compatibility tricks */
+# define USB_CFG_DESCR_PROPS_HID_REPORT USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH
+# else
+# define USB_CFG_DESCR_PROPS_HID_REPORT 0
+# endif
+#endif
+#ifndef USB_CFG_DESCR_PROPS_UNKNOWN
+#define USB_CFG_DESCR_PROPS_UNKNOWN 0
+#endif
+
+/* ------------------ forward declaration of descriptors ------------------- */
+/* If you use external static descriptors, they must be stored in global
+ * arrays as declared below:
+ */
+#ifndef __ASSEMBLER__
+extern
+#if !(USB_CFG_DESCR_PROPS_DEVICE & USB_PROP_IS_RAM)
+PROGMEM
+#endif
+char usbDescriptorDevice[];
+
+extern
+#if !(USB_CFG_DESCR_PROPS_CONFIGURATION & USB_PROP_IS_RAM)
+PROGMEM
+#endif
+char usbDescriptorConfiguration[];
+
+extern
+#if !(USB_CFG_DESCR_PROPS_HID_REPORT & USB_PROP_IS_RAM)
+PROGMEM
+#endif
+char usbDescriptorHidReport[];
+
+extern
+#if !(USB_CFG_DESCR_PROPS_STRING_0 & USB_PROP_IS_RAM)
+PROGMEM
+#endif
+char usbDescriptorString0[];
+
+extern
+#if !(USB_CFG_DESCR_PROPS_STRING_VENDOR & USB_PROP_IS_RAM)
+PROGMEM
+#endif
+int usbDescriptorStringVendor[];
+
+extern
+#if !(USB_CFG_DESCR_PROPS_STRING_PRODUCT & USB_PROP_IS_RAM)
+PROGMEM
+#endif
+int usbDescriptorStringDevice[];
+
+extern
+#if !(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER & USB_PROP_IS_RAM)
+PROGMEM
+#endif
+int usbDescriptorStringSerialNumber[];
+
+#endif /* __ASSEMBLER__ */
+
+/* ------------------------------------------------------------------------- */
+/* ------------------------ General Purpose Macros ------------------------- */
+/* ------------------------------------------------------------------------- */
+
+#define USB_CONCAT(a, b) a ## b
+#define USB_CONCAT_EXPANDED(a, b) USB_CONCAT(a, b)
+
+#define USB_OUTPORT(name) USB_CONCAT(PORT, name)
+#define USB_INPORT(name) USB_CONCAT(PIN, name)
+#define USB_DDRPORT(name) USB_CONCAT(DDR, name)
+/* The double-define trick above lets us concatenate strings which are
+ * defined by macros.
+ */
/* ------------------------------------------------------------------------- */
/* ------------------------- Constant definitions -------------------------- */
/* ------------------------------------------------------------------------- */
-/* I/O definitions for assembler module */
-#define USBOUT USB_CFG_IOPORT /* output port for USB bits */
-#ifdef __ASSEMBLER__
-#define USBIN (USB_CFG_IOPORT - 2) /* input port for USB bits */
-#define USBDDR (USB_CFG_IOPORT - 1) /* data direction for USB bits */
-#else
-#define USBIN (*(&USB_CFG_IOPORT - 2)) /* input port for USB bits */
-#define USBDDR (*(&USB_CFG_IOPORT - 1)) /* data direction for USB bits */
+#if !defined USB_CFG_VENDOR_ID || !defined USB_CFG_DEVICE_ID
+static uchar Warning_You_should_define_USB_CFG_VENDOR_ID_and_USB_CFG_DEVICE_ID_in_usbconfig_h;
+/* The unused variable above should generate a warning on all compilers. IAR cc
+ * does not understand the "#warning" preprocessor direcetive.
+ * If the user has not defined IDs, we default to obdev's free IDs.
+ * See USBID-License.txt for details.
+ */
+#endif
+
+/* make sure we have a VID and PID defined, byte order is lowbyte, highbyte */
+#ifndef USB_CFG_VENDOR_ID
+# define USB_CFG_VENDOR_ID 0xc0, 0x16 /* 5824 in dec, stands for VOTI */
+#endif
+
+#ifndef USB_CFG_DEVICE_ID
+# if USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH
+# define USB_CFG_DEVICE_ID 0xdf, 0x05 /* 1503 in dec, shared PID for HIDs */
+# elif USB_CFG_INTERFACE_CLASS == 2
+# define USB_CFG_DEVICE_ID 0xe1, 0x05 /* 1505 in dec, shared PID for CDC Modems */
+# else
+# define USB_CFG_DEVICE_ID 0xdc, 0x05 /* 1500 in dec, obdev's free PID */
+# endif
+#endif
+
+#ifndef USB_BUFFER_SECTION
+# define USB_BUFFER_SECTION ".bss" /* if user has not selected a named section */
+#endif
+
+/* Derive Output, Input and DataDirection ports from port names */
+#ifndef USB_CFG_IOPORTNAME
+#error "You must define USB_CFG_IOPORTNAME in usbconfig.h, see usbconfig-prototype.h"
#endif
-#if USB_CFG_DMINUS_BIT != 0
-# error "USB_CFG_DMINUS_BIT MUST be 0!"
+
+#define USBOUT USB_OUTPORT(USB_CFG_IOPORTNAME)
+#define USB_PULLUP_OUT USB_OUTPORT(USB_CFG_PULLUP_IOPORTNAME)
+#define USBIN USB_INPORT(USB_CFG_IOPORTNAME)
+#define USBDDR USB_DDRPORT(USB_CFG_IOPORTNAME)
+#define USB_PULLUP_DDR USB_DDRPORT(USB_CFG_PULLUP_IOPORTNAME)
+
+#define USBMINUS USB_CFG_DMINUS_BIT
+#define USBPLUS USB_CFG_DPLUS_BIT
+#define USBIDLE (1<<USB_CFG_DMINUS_BIT) /* value representing J state */
+#define USBMASK ((1<<USB_CFG_DPLUS_BIT) | (1<<USB_CFG_DMINUS_BIT)) /* mask for USB I/O bits */
+
+/* defines for backward compatibility with older driver versions: */
+#define USB_CFG_IOPORT USB_OUTPORT(USB_CFG_IOPORTNAME)
+#ifdef USB_CFG_PULLUP_IOPORTNAME
+#define USB_CFG_PULLUP_IOPORT USB_OUTPORT(USB_CFG_PULLUP_IOPORTNAME)
#endif
-#define USBMINUS 0 /* D- MUST be on bit 0 */
-#define USBIDLE 0x01 /* value representing J state */
-#define USBMASK ((1<<USB_CFG_DPLUS_BIT) | 1) /* mask for USB I/O bits */
-#define USB_BUFSIZE 11 /* PID, 8 bytes data, 2 bytes CRC */
-/* Try to find registers and bits responsible for ext interrupt 0 */
+#define USB_BUFSIZE 11 /* PID, 8 bytes data, 2 bytes CRC */
+
+/* ----- Try to find registers and bits responsible for ext interrupt 0 ----- */
-#if defined EICRA
-# define USB_INTR_CFG EICRA
-#else
-# define USB_INTR_CFG MCUCR
+#ifndef USB_INTR_CFG /* allow user to override our default */
+# if defined EICRA
+# define USB_INTR_CFG EICRA
+# else
+# define USB_INTR_CFG MCUCR
+# endif
+#endif
+#ifndef USB_INTR_CFG_SET /* allow user to override our default */
+# define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) /* cfg for rising edge */
+#endif
+#ifndef USB_INTR_CFG_CLR /* allow user to override our default */
+# define USB_INTR_CFG_CLR 0 /* no bits to clear */
#endif
-#define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) /* cfg for rising edge */
-#define USB_INTR_CFG_CLR 0 /* no bits to clear */
-#if defined GIMSK
-# define USB_INTR_ENABLE GIMSK
-#elif defined EIMSK
-# define USB_INTR_ENABLE EIMSK
-#else
-# define USB_INTR_ENABLE GICR
+#ifndef USB_INTR_ENABLE /* allow user to override our default */
+# if defined GIMSK
+# define USB_INTR_ENABLE GIMSK
+# elif defined EIMSK
+# define USB_INTR_ENABLE EIMSK
+# else
+# define USB_INTR_ENABLE GICR
+# endif
+#endif
+#ifndef USB_INTR_ENABLE_BIT /* allow user to override our default */
+# define USB_INTR_ENABLE_BIT INT0
#endif
-#define USB_INTR_ENABLE_BIT INT0
-#if defined EIFR
-# define USB_INTR_PENDING EIFR
-#else
-# define USB_INTR_PENDING GIFR
+#ifndef USB_INTR_PENDING /* allow user to override our default */
+# if defined EIFR
+# define USB_INTR_PENDING EIFR
+# else
+# define USB_INTR_PENDING GIFR
+# endif
+#endif
+#ifndef USB_INTR_PENDING_BIT /* allow user to override our default */
+# define USB_INTR_PENDING_BIT INTF0
#endif
-#define USB_INTR_PENDING_BIT INTF0
/*
The defines above don't work for the following chips
at90c8534: no ISC0?, no PORTB, can't find a data sheet
-at86rf401: no PORTB, no MCUCR etc
+at86rf401: no PORTB, no MCUCR etc, low clock rate
atmega103: no ISC0? (maybe omission in header, can't find data sheet)
atmega603: not defined in avr-libc
at43usb320, at43usb355, at76c711: have USB anyway
*/
/* ------------------------------------------------------------------------- */
-/* ---------------------- USB Specification Constants ---------------------- */
+/* ----------------- USB Specification Constants and Types ----------------- */
/* ------------------------------------------------------------------------- */
/* USB Token values */
-#define USBPID_SETUP 0x2d
-#define USBPID_OUT 0xe1
-#define USBPID_IN 0x69
-#define USBPID_DATA0 0xc3
-#define USBPID_DATA1 0x4b
+#define USBPID_SETUP 0x2d
+#define USBPID_OUT 0xe1
+#define USBPID_IN 0x69
+#define USBPID_DATA0 0xc3
+#define USBPID_DATA1 0x4b
-#define USBPID_ACK 0xd2
-#define USBPID_NAK 0x5a
-#define USBPID_STALL 0x1e
+#define USBPID_ACK 0xd2
+#define USBPID_NAK 0x5a
+#define USBPID_STALL 0x1e
-/* USB descriptor constants */
-#define USBATTR_BUSPOWER 0x80
-#define USBATTR_SELFPOWER 0x40
-#define USBATTR_REMOTEWAKE 0x20
+#ifndef __ASSEMBLER__
+typedef union usbWord{
+ unsigned word;
+ uchar bytes[2];
+}usbWord_t;
+
+typedef struct usbRequest{
+ uchar bmRequestType;
+ uchar bRequest;
+ usbWord_t wValue;
+ usbWord_t wIndex;
+ usbWord_t wLength;
+}usbRequest_t;
+/* This structure matches the 8 byte setup request */
+#endif
+
+/* bmRequestType field in USB setup:
+ * d t t r r r r r, where
+ * d ..... direction: 0=host->device, 1=device->host
+ * t ..... type: 0=standard, 1=class, 2=vendor, 3=reserved
+ * r ..... recipient: 0=device, 1=interface, 2=endpoint, 3=other
+ */
/* USB setup recipient values */
-#define USBRQ_RCPT_DEVICE 0
-#define USBRQ_RCPT_INTERFACE 1
-#define USBRQ_RCPT_ENDPOINT 2
+#define USBRQ_RCPT_MASK 0x1f
+#define USBRQ_RCPT_DEVICE 0
+#define USBRQ_RCPT_INTERFACE 1
+#define USBRQ_RCPT_ENDPOINT 2
/* USB request type values */
-#define USBRQ_TYPE_STANDARD 0
-#define USBRQ_TYPE_CLASS 1
-#define USBRQ_TYPE_VENDOR 2
+#define USBRQ_TYPE_MASK 0x60
+#define USBRQ_TYPE_STANDARD (0<<5)
+#define USBRQ_TYPE_CLASS (1<<5)
+#define USBRQ_TYPE_VENDOR (2<<5)
+
+/* USB direction values: */
+#define USBRQ_DIR_MASK 0x80
+#define USBRQ_DIR_HOST_TO_DEVICE (0<<7)
+#define USBRQ_DIR_DEVICE_TO_HOST (1<<7)
+
+/* USB Standard Requests */
+#define USBRQ_GET_STATUS 0
+#define USBRQ_CLEAR_FEATURE 1
+#define USBRQ_SET_FEATURE 3
+#define USBRQ_SET_ADDRESS 5
+#define USBRQ_GET_DESCRIPTOR 6
+#define USBRQ_SET_DESCRIPTOR 7
+#define USBRQ_GET_CONFIGURATION 8
+#define USBRQ_SET_CONFIGURATION 9
+#define USBRQ_GET_INTERFACE 10
+#define USBRQ_SET_INTERFACE 11
+#define USBRQ_SYNCH_FRAME 12
+/* USB descriptor constants */
+#define USBDESCR_DEVICE 1
+#define USBDESCR_CONFIG 2
+#define USBDESCR_STRING 3
+#define USBDESCR_INTERFACE 4
+#define USBDESCR_ENDPOINT 5
+#define USBDESCR_HID 0x21
+#define USBDESCR_HID_REPORT 0x22
+#define USBDESCR_HID_PHYS 0x23
+
+#define USBATTR_BUSPOWER 0x80
+#define USBATTR_SELFPOWER 0x40
+#define USBATTR_REMOTEWAKE 0x20
+
+/* USB HID Requests */
+#define USBRQ_HID_GET_REPORT 0x01
+#define USBRQ_HID_GET_IDLE 0x02
+#define USBRQ_HID_GET_PROTOCOL 0x03
+#define USBRQ_HID_SET_REPORT 0x09
+#define USBRQ_HID_SET_IDLE 0x0a
+#define USBRQ_HID_SET_PROTOCOL 0x0b
/* ------------------------------------------------------------------------- */
* Tabsize: 4
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
* License: Proprietary, free under certain conditions. See Documentation.
- * This Revision: $Id: usbdrvasm.S 52 2005-04-12 16:57:29Z cs $
+ * This Revision: $Id: usbdrvasm.S 218 2006-07-15 17:08:14Z cs $
*/
/*
Since almost all of this code is timing critical, don't change unless you
really know what you are doing! Many parts require not only a maximum number
of CPU cycles, but even an exact number of cycles!
-*/
-/* configs for io.h */
-#define __SFR_OFFSET 0
-#define _VECTOR(N) __vector_ ## N /* io.h does not define this for asm */
-#include <avr/io.h> /* for CPU I/O register definitions and vectors */
-#include "usbdrv.h" /* for common defs */
+Timing constraints according to spec (in bit times):
+timing subject min max CPUcycles
+---------------------------------------------------------------------------
+EOP of OUT/SETUP to sync pattern of DATA0 (both rx) 2 16 16-128
+EOP of IN to sync pattern of DATA0 (rx, then tx) 2 7.5 16-60
+DATAx (rx) to ACK/NAK/STALL (tx) 2 7.5 16-60
+*/
+
+#include "iarcompat.h"
+#ifndef __IAR_SYSTEMS_ASM__
+ /* configs for io.h */
+# define __SFR_OFFSET 0
+# define _VECTOR(N) __vector_ ## N /* io.h does not define this for asm */
+# include <avr/io.h> /* for CPU I/O register definitions and vectors */
+#endif /* __IAR_SYSTEMS_ASM__ */
+#include "usbdrv.h" /* for common defs */
/* register names */
-#define x1 r16
-#define x2 r17
-#define shift r18
-#define cnt r19
-#define x3 r20
-#define x4 r21
+#define x1 r16
+#define x2 r17
+#define shift r18
+#define cnt r19
+#define x3 r20
+#define x4 r21
+
+/* Some assembler dependent definitions and declarations: */
+
+#ifdef __IAR_SYSTEMS_ASM__
+
+# define nop2 rjmp $+2 /* jump to next instruction */
+# define XL r26
+# define XH r27
+# define YL r28
+# define YH r29
+# define ZL r30
+# define ZH r31
+# define lo8(x) LOW(x)
+# define hi8(x) ((x)>>8) /* not HIGH to allow XLINK to make a proper range check */
+
+ extern usbRxBuf, usbDeviceAddr, usbNewDeviceAddr, usbInputBuf
+ extern usbCurrentTok, usbRxLen, usbRxToken, usbAppBuf, usbTxLen
+ extern usbTxBuf, usbMsgLen, usbTxLen1, usbTxBuf1, usbTxLen3, usbTxBuf3
+ public usbCrc16
+ public usbCrc16Append
+
+ COMMON INTVEC
+ ORG INT0_vect
+ rjmp SIG_INTERRUPT0
+ RSEG CODE
+
+#else /* __IAR_SYSTEMS_ASM__ */
+
+# define nop2 rjmp .+0 /* jump to next instruction */
-#define nop2 rjmp .+0 /* jump to next instruction */
+ .text
+ .global SIG_INTERRUPT0
+ .type SIG_INTERRUPT0, @function
+ .global usbCrc16
+ .global usbCrc16Append
+
+#endif /* __IAR_SYSTEMS_ASM__ */
-.text
-.global SIG_INTERRUPT0
- .type SIG_INTERRUPT0, @function
SIG_INTERRUPT0:
;Software-receiver engine. Strict timing! Don't change unless you can preserve timing!
;interrupt response time: 4 cycles + insn running = 7 max if interrupts always enabled
usbInterrupt:
;order of registers pushed:
;x1, SREG, x2, cnt, shift, [YH, YL, x3]
- push x1 ;2 push only what is necessary to sync with edge ASAP
- in x1, SREG ;1
- push x1 ;2
+ push x1 ;2 push only what is necessary to sync with edge ASAP
+ in x1, SREG ;1
+ push x1 ;2
;sync byte (D-) pattern LSb to MSb: 01010100 [1 = idle = J, 0 = K]
;sync up with J to K edge during sync pattern -- use fastest possible loops
;first part has no timeout because it waits for IDLE or SE1 (== disconnected)
#if !USB_CFG_SAMPLE_EXACT
- ldi x1, 5 ;1 setup a timeout for waitForK
+ ldi x1, 5 ;1 setup a timeout for waitForK
#endif
waitForJ:
- sbis USBIN, USBMINUS ;1 wait for D- == 1
- rjmp waitForJ ;2
+ sbis USBIN, USBMINUS ;1 wait for D- == 1
+ rjmp waitForJ ;2
#if USB_CFG_SAMPLE_EXACT
;The following code represents the unrolled loop in the else branch. It
;results in a sampling window of 1/4 bit which meets the spec.
- sbis USBIN, USBMINUS
- rjmp foundK
- sbis USBIN, USBMINUS
- rjmp foundK
- sbis USBIN, USBMINUS
- rjmp foundK
- nop
- nop2
+ sbis USBIN, USBMINUS
+ rjmp foundK
+ sbis USBIN, USBMINUS
+ rjmp foundK
+ sbis USBIN, USBMINUS
+ rjmp foundK
+ nop
+ nop2
foundK:
#else
waitForK:
- dec x1 ;1
- sbic USBIN, USBMINUS ;1 wait for D- == 0
- brne waitForK ;2
+ dec x1 ;1
+ sbic USBIN, USBMINUS ;1 wait for D- == 0
+ brne waitForK ;2
#endif
;{2, 6} after falling D- edge, average delay: 4 cycles [we want 4 for center sampling]
;we have 1 bit time for setup purposes, then sample again:
- push x2 ;2
- push cnt ;2
- push shift ;2
+ push x2 ;2
+ push cnt ;2
+ push shift ;2
shortcutEntry:
- ldi cnt, 1 ;1 pre-init bit counter (-1 because no dec follows, -1 because 1 bit already sampled)
- ldi x2, 1<<USB_CFG_DPLUS_BIT ;1 -> 8 edge sync ended with D- == 0
+ ldi cnt, 1 ;1 pre-init bit counter (-1 because no dec follows, -1 because 1 bit already sampled)
+ ldi x2, 1<<USB_CFG_DPLUS_BIT ;1 -> 8 edge sync ended with D- == 0
;now wait until SYNC byte is over. Wait for either 2 bits low (success) or 2 bits high (failure)
waitNoChange:
- in x1, USBIN ;1 <-- sample, timing: edge + {2, 6} cycles
- eor x2, x1 ;1
- sbrc x2, 0 ;1 | 2
- ldi cnt, 2 ;1 | 0 cnt = numBits - 1 (because dec follows)
- mov x2, x1 ;1
- dec cnt ;1
- brne waitNoChange ;2 | 1
- sbrc x1, USBMINUS ;2
- rjmp sofError ;0 two consecutive "1" bits -> framing error
+ in x1, USBIN ;1 <-- sample, timing: edge + {2, 6} cycles
+ eor x2, x1 ;1
+ sbrc x2, USBMINUS ;1 | 2
+ ldi cnt, 2 ;1 | 0 cnt = numBits - 1 (because dec follows)
+ mov x2, x1 ;1
+ dec cnt ;1
+ brne waitNoChange ;2 | 1
+ sbrc x1, USBMINUS ;2
+ rjmp sofError ;0 two consecutive "1" bits -> framing error
;start reading data, but don't check for bitstuffing because these are the
;first bits. Use the cycles for initialization instead. Note that we read and
;store the binary complement of the data stream because eor results in 1 for
;a change and 0 for no change.
- in x1, USBIN ;1 <-- sample bit 0, timing: edge + {3, 7} cycles
- eor x2, x1 ;1
- ror x2 ;1
- ldi shift, 0x7f ;1 The last bit of the sync pattern was a "no change"
- ror shift ;1
- push YH ;2 -> 7
- in x2, USBIN ;1 <-- sample bit 1, timing: edge + {2, 6} cycles
- eor x1, x2 ;1
- ror x1 ;1
- ror shift ;1
- push YL ;2
- lds YL, usbInputBuf ;2 -> 8
- in x1, USBIN ;1 <-- sample bit 2, timing: edge + {2, 6} cycles
- eor x2, x1 ;1
- ror x2 ;1
- ror shift ;1
- ldi cnt, USB_BUFSIZE;1
- clr YH ;1
- push x3 ;2 -> 8
- in x2, USBIN ;1 <-- sample bit 3, timing: edge + {2, 6} cycles
- eor x1, x2 ;1
- ror x1 ;1
- ror shift ;1
- ser x3 ;1
- nop ;1
- rjmp rxbit4 ;2 -> 8
-
-shortcutToStart: ;{,43} into next frame: max 5.5 sync bits missed
+ in x1, USBIN ;1 <-- sample bit 0, timing: edge + {3, 7} cycles
+ eor x2, x1 ;1
+ ldi shift, 0x00 ;1 prepare for bitstuff check later on in loop
+ bst x2, USBMINUS ;1
+ bld shift, 0 ;1
+ push YH ;2 -> 7
+ in x2, USBIN ;1 <-- sample bit 1, timing: edge + {2, 6} cycles
+ eor x1, x2 ;1
+ bst x1, USBMINUS ;1
+ bld shift, 1 ;1
+ push YL ;2
+ lds YL, usbInputBuf ;2 -> 8
+ in x1, USBIN ;1 <-- sample bit 2, timing: edge + {2, 6} cycles
+ eor x2, x1 ;1
+ bst x2, USBMINUS ;1
+ bld shift, 2 ;1
+ ldi cnt, USB_BUFSIZE;1
+ ldi YH, hi8(usbRxBuf);1 assume that usbRxBuf does not cross a page
+ push x3 ;2 -> 8
+ in x2, USBIN ;1 <-- sample bit 3, timing: edge + {2, 6} cycles
+ eor x1, x2 ;1
+ bst x1, USBMINUS ;1
+ bld shift, 3 ;1
+ ser x3 ;1
+ nop ;1
+ rjmp rxbit4 ;2 -> 8
+
+shortcutToStart: ;{,43} into next frame: max 5.5 sync bits missed
#if !USB_CFG_SAMPLE_EXACT
- ldi x1, 5 ;2 setup timeout
+ ldi x1, 5 ;2 setup timeout
#endif
waitForJ1:
- sbis USBIN, USBMINUS ;1 wait for D- == 1
- rjmp waitForJ1 ;2
+ sbis USBIN, USBMINUS ;1 wait for D- == 1
+ rjmp waitForJ1 ;2
#if USB_CFG_SAMPLE_EXACT
;The following code represents the unrolled loop in the else branch. It
;results in a sampling window of 1/4 bit which meets the spec.
- sbis USBIN, USBMINUS
- rjmp foundK1
- sbis USBIN, USBMINUS
- rjmp foundK1
- sbis USBIN, USBMINUS
- rjmp foundK1
- nop
- nop2
+ sbis USBIN, USBMINUS
+ rjmp foundK1
+ sbis USBIN, USBMINUS
+ rjmp foundK1
+ sbis USBIN, USBMINUS
+ rjmp foundK1
+ nop
+ nop2
foundK1:
#else
waitForK1:
- dec x1 ;1
- sbic USBIN, USBMINUS ;1 wait for D- == 0
- brne waitForK1 ;2
+ dec x1 ;1
+ sbic USBIN, USBMINUS ;1 wait for D- == 0
+ brne waitForK1 ;2
#endif
- pop YH ;2 correct stack alignment
- nop2 ;2 delay for the same time as the pushes in the original code
- rjmp shortcutEntry ;2
+ pop YH ;2 correct stack alignment
+ nop2 ;2 delay for the same time as the pushes in the original code
+ rjmp shortcutEntry ;2
; ################# receiver loop #################
; extra jobs done during bit interval:
-; bit 6: se0 check
-; bit 7: or, store, clear
-; bit 0: recover from delay [SE0 is unreliable here due to bit dribbling in hubs]
-; bit 1: se0 check
-; bit 2: se0 check
-; bit 3: overflow check
-; bit 4: se0 check
-; bit 5: rjmp
+; bit 6: se0 check
+; bit 7: or, store, clear
+; bit 0: recover from delay [SE0 is unreliable here due to bit dribbling in hubs]
+; bit 1: se0 check
+; bit 2: se0 check
+; bit 3: overflow check
+; bit 4: se0 check
+; bit 5: rjmp
; stuffed* helpers have the functionality of a subroutine, but we can't afford
; the overhead of a call. We therefore need a separate routine for each caller
; which jumps back appropriately.
-stuffed5: ;1 for branch taken
- in x2, USBIN ;1 <-- sample @ +1
- andi x2, USBMASK ;1
- breq se0a ;1
- andi x3, 0xc0 ;1 (0xff03 >> 2) & 0xff
- ori shift, 0xfc ;1
- rjmp rxbit6 ;2
-
-stuffed6: ;1 for branch taken
- in x1, USBIN ;1 <-- sample @ +1
- andi x1, USBMASK ;1
- breq se0a ;1
- andi x3, 0x81 ;1 (0xff03 >> 1) & 0xff
- ori shift, 0xfc ;1
- rjmp rxbit7 ;2
+stuffed5: ;1 for branch taken
+ in x2, USBIN ;1 <-- sample @ +1
+ andi x2, USBMASK ;1
+ breq se0a ;1
+ andi x3, ~0x20 ;1
+ ori shift, 0x20 ;1
+ rjmp rxbit6 ;2
+
+stuffed6: ;1 for branch taken
+ in x1, USBIN ;1 <-- sample @ +1
+ andi x1, USBMASK ;1
+ breq se0a ;1
+ andi x3, ~0x40 ;1
+ ori shift, 0x40 ;1
+ rjmp rxbit7 ;2
; This is somewhat special because it has to compensate for the delay in bit 7
-stuffed7: ;1 for branch taken
- andi x1, USBMASK ;1 already sampled by caller
- breq se0a ;1
- mov x2, x1 ;1 ensure correct NRZI sequence [we can save andi x3 here]
- ori shift, 0xfc ;1
- in x1, USBIN ;1 <-- sample bit 0
- rjmp unstuffed7 ;2
-
-stuffed0: ;1 for branch taken
- in x1, USBIN ;1 <-- sample @ +1
- andi x1, USBMASK ;1
- breq se0a ;1
- andi x3, 0xfe ;1 (0xff03 >> 7) & 0xff
- ori shift, 0xfc ;1
- rjmp rxbit1 ;2
+stuffed7: ;1 for branch taken
+ andi x1, USBMASK ;1 already sampled by caller
+ breq se0a ;1
+ mov x2, x1 ;1 ensure correct NRZI sequence
+ ori shift, 0x80 ;1 no need to set reconstruction in x3: shift has already been used
+ in x1, USBIN ;1 <-- sample bit 0
+ rjmp unstuffed7 ;2
+
+stuffed0: ;1 for branch taken
+ in x1, USBIN ;1 <-- sample @ +1
+ andi x1, USBMASK ;1
+ breq se0a ;1
+ andi x3, ~0x01 ;1
+ ori shift, 0x01 ;1
+ rjmp rxbit1 ;2
;-----------------------------
rxLoop:
- brlo stuffed5 ;1
+ breq stuffed5 ;1
rxbit6:
- in x1, USBIN ;1 <-- sample bit 6
- andi x1, USBMASK ;1
- breq se0a ;1
- eor x2, x1 ;1
- ror x2 ;1
- ror shift ;1
- cpi shift, 4 ;1
- brlo stuffed6 ;1
+ in x1, USBIN ;1 <-- sample bit 6
+ andi x1, USBMASK ;1
+ breq se0a ;1
+ eor x2, x1 ;1
+ bst x2, USBMINUS;1
+ bld shift, 6 ;1
+ cpi shift, 0x02 ;1
+ brlo stuffed6 ;1
rxbit7:
- in x2, USBIN ;1 <-- sample bit 7
- eor x1, x2 ;1
- ror x1 ;1
- ror shift ;1
- eor x3, shift ;1 x3 is 0 at bit locations we changed, 1 at others
- st y+, x3 ;2 the eor above reconstructed modified bits and inverted rx data
- ser x3 ;1
+ in x2, USBIN ;1 <-- sample bit 7
+ eor x1, x2 ;1
+ bst x1, USBMINUS;1
+ bld shift, 7 ;1
+ eor x3, shift ;1 x3 is 0 at bit locations we changed, 1 at others
+ st y+, x3 ;2 the eor above reconstructed modified bits and inverted rx data
+ ser x3 ;1
rxbit0:
- in x1, USBIN ;1 <-- sample bit 0
- cpi shift, 4 ;1
- brlo stuffed7 ;1
+ in x1, USBIN ;1 <-- sample bit 0
+ cpi shift, 0x04 ;1
+ brlo stuffed7 ;1
unstuffed7:
- eor x2, x1 ;1
- ror x2 ;1
- ror shift ;1
- cpi shift, 4 ;1
- brlo stuffed0 ;1
+ eor x2, x1 ;1
+ bst x2, USBMINUS;1
+ bld shift, 0 ;1
+ andi shift, 0xf9 ;1
+ breq stuffed0 ;1
rxbit1:
- in x2, USBIN ;1 <-- sample bit 1
- andi x2, USBMASK ;1
-se0a: ; enlarge jump range to SE0
- breq se0 ;1 check for SE0 more often close to start of byte
- eor x1, x2 ;1
- ror x1 ;1
- ror shift ;1
- cpi shift, 4 ;1
- brlo stuffed1 ;1
+ in x2, USBIN ;1 <-- sample bit 1
+ andi x2, USBMASK ;1
+se0a: ; enlarge jump range to SE0
+ breq se0 ;1 check for SE0 more often close to start of byte
+ eor x1, x2 ;1
+ bst x1, USBMINUS;1
+ bld shift, 1 ;1
+ andi shift, 0xf3 ;1
+ breq stuffed1 ;1
rxbit2:
- in x1, USBIN ;1 <-- sample bit 2
- andi x1, USBMASK ;1
- breq se0 ;1
- eor x2, x1 ;1
- ror x2 ;1
- ror shift ;1
- cpi shift, 4 ;1
- brlo stuffed2 ;1
+ in x1, USBIN ;1 <-- sample bit 2
+ andi x1, USBMASK ;1
+ breq se0 ;1
+ eor x2, x1 ;1
+ bst x2, USBMINUS;1
+ bld shift, 2 ;1
+ andi shift, 0xe7 ;1
+ breq stuffed2 ;1
rxbit3:
- in x2, USBIN ;1 <-- sample bit 3
- eor x1, x2 ;1
- ror x1 ;1
- ror shift ;1
- dec cnt ;1 check for buffer overflow
- breq overflow ;1
- cpi shift, 4 ;1
- brlo stuffed3 ;1
+ in x2, USBIN ;1 <-- sample bit 3
+ eor x1, x2 ;1
+ bst x1, USBMINUS;1
+ bld shift, 3 ;1
+ dec cnt ;1 check for buffer overflow
+ breq overflow ;1
+ andi shift, 0xcf ;1
+ breq stuffed3 ;1
rxbit4:
- in x1, USBIN ;1 <-- sample bit 4
- andi x1, USBMASK ;1
- breq se0 ;1
- eor x2, x1 ;1
- ror x2 ;1
- ror shift ;1
- cpi shift, 4 ;1
- brlo stuffed4 ;1
+ in x1, USBIN ;1 <-- sample bit 4
+ andi x1, USBMASK ;1
+ breq se0 ;1
+ eor x2, x1 ;1
+ bst x2, USBMINUS;1
+ bld shift, 4 ;1
+ andi shift, 0x9f ;1
+ breq stuffed4 ;1
rxbit5:
- in x2, USBIN ;1 <-- sample bit 5
- eor x1, x2 ;1
- ror x1 ;1
- ror shift ;1
- cpi shift, 4 ;1
- rjmp rxLoop ;2
+ in x2, USBIN ;1 <-- sample bit 5
+ eor x1, x2 ;1
+ bst x1, USBMINUS;1
+ bld shift, 5 ;1
+ andi shift, 0x3f ;1
+ rjmp rxLoop ;2
;-----------------------------
-stuffed1: ;1 for branch taken
- in x2, USBIN ;1 <-- sample @ +1
- andi x2, USBMASK ;1
- breq se0 ;1
- andi x3, 0xfc ;1 (0xff03 >> 6) & 0xff
- ori shift, 0xfc ;1
- rjmp rxbit2 ;2
-
-stuffed2: ;1 for branch taken
- in x1, USBIN ;1 <-- sample @ +1
- andi x1, USBMASK ;1
- breq se0 ;1
- andi x3, 0xf8 ;1 (0xff03 >> 5) & 0xff
- ori shift, 0xfc ;1
- rjmp rxbit3 ;2
-
-stuffed3: ;1 for branch taken
- in x2, USBIN ;1 <-- sample @ +1
- andi x2, USBMASK ;1
- breq se0 ;1
- andi x3, 0xf0 ;1 (0xff03 >> 4) & 0xff
- ori shift, 0xfc ;1
- rjmp rxbit4 ;2
-
-stuffed4: ;1 for branch taken
- in x1, USBIN ;1 <-- sample @ +1
- andi x1, USBMASK ;1
- breq se0 ;1
- andi x3, 0xe0 ;1 (0xff03 >> 3) & 0xff
- ori shift, 0xfc ;1
- rjmp rxbit5 ;2
+stuffed1: ;1 for branch taken
+ in x2, USBIN ;1 <-- sample @ +1
+ andi x2, USBMASK ;1
+ breq se0 ;1
+ andi x3, ~0x02 ;1
+ ori shift, 0x02 ;1
+ rjmp rxbit2 ;2
+
+stuffed2: ;1 for branch taken
+ in x1, USBIN ;1 <-- sample @ +1
+ andi x1, USBMASK ;1
+ breq se0 ;1
+ andi x3, ~0x04 ;1
+ ori shift, 0x04 ;1
+ rjmp rxbit3 ;2
+
+stuffed3: ;1 for branch taken
+ in x2, USBIN ;1 <-- sample @ +1
+ andi x2, USBMASK ;1
+ breq se0 ;1
+ andi x3, ~0x08 ;1
+ ori shift, 0x08 ;1
+ rjmp rxbit4 ;2
+
+stuffed4: ;1 for branch taken
+ in x1, USBIN ;1 <-- sample @ +1
+ andi x1, USBMASK ;1
+ breq se0 ;1
+ andi x3, ~0x10 ;1
+ ori shift, 0x10 ;1
+ rjmp rxbit5 ;2
;################ end receiver loop ###############
-overflow: ; ignore package if buffer overflow
- rjmp rxDoReturn ; enlarge jump range
+overflow: ; ignore package if buffer overflow
+ rjmp rxDoReturn ; enlarge jump range
;This is the only non-error exit point for the software receiver loop
;{4, 20} cycles after start of SE0, typically {10, 18} after SE0 start = {-6, 2} from end of SE0
;next sync starts {16,} cycles after SE0 -> worst case start: +4 from next sync start
;we don't check any CRCs here because there is no time left.
-se0: ;{-6, 2} from end of SE0 / {,4} into next frame
- mov cnt, YL ;1 assume buffer in lower 256 bytes of memory
- lds YL, usbInputBuf ;2 reposition to buffer start
- sub cnt, YL ;1 length of message
- ldi x1, 1<<USB_INTR_PENDING_BIT ;1
- cpi cnt, 3 ;1
- out USB_INTR_PENDING, x1;1 clear pending intr and check flag later. SE0 must be over. {,10} into next frame
- brlo rxDoReturn ;1 ensure valid packet size, ignore others
- ld x1, y ;2 PID
- ldd x2, y+1 ;2 ADDR + 1 bit endpoint number
- mov x3, x2 ;1 store for endpoint number
- andi x2, 0x7f ;1 mask endpoint number bit
- lds shift, usbDeviceId ;2
- cpi x1, USBPID_SETUP ;1
- breq isSetupOrOut ;2 -> 19 = {13, 21} from SE0 end
- cpi x1, USBPID_OUT ;1
- breq isSetupOrOut ;2 -> 22 = {16, 24} from SE0 end / {,24} into next frame
- cpi x1, USBPID_IN ;1
- breq handleIn ;1
- cpi x1, USBPID_DATA0 ;1
- breq isData ;1
- cpi x1, USBPID_DATA1 ;1
- brne rxDoReturn ;1 ignore all other PIDs
+se0: ;{-6, 2} from end of SE0 / {,4} into next frame
+ mov cnt, YL ;1 assume buffer in lower 256 bytes of memory
+ lds YL, usbInputBuf ;2 reposition to buffer start
+ sub cnt, YL ;1 length of message
+ ldi x1, 1<<USB_INTR_PENDING_BIT ;1
+ cpi cnt, 3 ;1
+ out USB_INTR_PENDING, x1;1 clear pending intr and check flag later. SE0 must be over. {,10} into next frame
+ brlo rxDoReturn ;1 ensure valid packet size, ignore others
+ ld x1, y ;2 PID
+ ldd x2, y+1 ;2 ADDR + 1 bit endpoint number
+ mov x3, x2 ;1 store for endpoint number
+ andi x2, 0x7f ;1 mask endpoint number bit
+ lds shift, usbDeviceAddr;2
+ cpi x1, USBPID_SETUP ;1
+ breq isSetupOrOut ;2 -> 19 = {13, 21} from SE0 end
+ cpi x1, USBPID_OUT ;1
+ breq isSetupOrOut ;2 -> 22 = {16, 24} from SE0 end / {,24} into next frame
+ cpi x1, USBPID_IN ;1
+ breq handleIn ;1
+#define USB_DATA_MASK ~(USBPID_DATA0 ^ USBPID_DATA1)
+ andi x1, USB_DATA_MASK ;1
+ cpi x1, USBPID_DATA0 & USB_DATA_MASK ;1
+ brne rxDoReturn ;1 not a data PID -- ignore
isData:
- lds x2, usbCurrentTok ;2
- tst x2 ;1
- breq rxDoReturn ;1 for other device or spontaneous data -- ignore
- lds x1, usbRxLen ;2
- cpi x1, 0 ;1
- brne sendNakAndReti ;1 no buffer space available / {30, 38} from SE0 end
- sts usbRxLen, cnt ;2 store received data, swap buffers
- sts usbRxToken, x2 ;2
- lds x1, usbAppBuf ;2
- sts usbAppBuf, YL ;2
- sts usbInputBuf, x1 ;2 buffers now swapped
- rjmp sendAckAndReti ;2 -> {42, 50} from SE0 end
-
-handleIn: ; {18, 26} from SE0 end
- cp x2, shift ;1 shift contains our device ID
- brne rxDoReturn ;1 other device
+ lds x2, usbCurrentTok ;2
+ tst x2 ;1
+ breq rxDoReturn ;1 for other device or spontaneous data -- ignore
+ lds x1, usbRxLen ;2
+ cpi x1, 0 ;1
+ brne sendNakAndReti ;1 no buffer space available / {30, 38} from SE0 end
+; 2006-03-11: The following two lines fix a problem where the device was not
+; recognized if usbPoll() was called less frequently than once every 4 ms.
+ cpi cnt, 4 ;1 zero sized data packets are status phase only -- ignore and ack
+ brmi sendAckAndReti ;1 keep rx buffer clean -- we must not NAK next SETUP
+ sts usbRxLen, cnt ;2 store received data, swap buffers
+ sts usbRxToken, x2 ;2
+ lds x1, usbAppBuf ;2
+ sts usbAppBuf, YL ;2
+ sts usbInputBuf, x1 ;2 buffers now swapped
+ rjmp sendAckAndReti ;2 -> {43, 51} from SE0 end
+
+handleIn: ; {18, 26} from SE0 end
+ cp x2, shift ;1 shift contains our device addr
+ brne rxDoReturn ;1 other device
#if USB_CFG_HAVE_INTRIN_ENDPOINT
- sbrc x3, 7 ;2
- rjmp handleIn1 ;0
+ sbrc x3, 7 ;2 x3 contains addr + endpoint
+ rjmp handleIn1 ;0
#endif
- lds cnt, usbTxLen ;2
- cpi cnt, -1 ;1
- breq sendNakAndReti ;1 -> {27, 35} from SE0 end
- ldi x1, -1 ;1
- sts usbTxLen, x1 ;2 buffer is now free
- ldi YL, lo8(usbTxBuf) ;1
- ldi YH, hi8(usbTxBuf) ;1
- rjmp usbSendAndReti ;2 -> {34, 43} from SE0 end
-
-; Comment about when to set usbTxLen to -1:
-; We should set it back to -1 when we receive the ACK from the host. This would
+ lds cnt, usbTxLen ;2
+ sbrc cnt, 4 ;2
+ rjmp sendCntAndReti ;0 -> {27, 35} from SE0 end
+ ldi x1, USBPID_NAK ;1
+ sts usbTxLen, x1 ;2 buffer is now free
+ ldi YL, lo8(usbTxBuf) ;1
+ ldi YH, hi8(usbTxBuf) ;1
+ rjmp usbSendAndReti ;2 -> {34, 43} from SE0 end
+
+; Comment about when to set usbTxLen to USBPID_NAK:
+; We should set it back when we receive the ACK from the host. This would
; be simple to implement: One static variable which stores whether the last
; tx was for endpoint 0 or 1 and a compare in the receiver to distinguish the
-; ACK. However, we set it back to -1 immediately when we send the package,
+; ACK. However, we set it back immediately when we send the package,
; assuming that no error occurs and the host sends an ACK. We save one byte
; RAM this way and avoid potential problems with endless retries. The rest of
; the driver assumes error-free transfers anyway.
otherOutOrSetup:
- clr x1
- sts usbCurrentTok, x1
+ clr x1
+ sts usbCurrentTok, x1
rxDoReturn:
- pop x3 ;2
- pop YL ;2
- pop YH ;2
- rjmp sofError ;2
-
-isSetupOrOut: ; we must be fast here -- a data package may follow / {,24} into next frame
- cp x2, shift ;1 shift contains our device ID
- brne otherOutOrSetup ;1 other device -- ignore
- sts usbCurrentTok, x1 ;2
-#if 0 /* we implement only one rx endpoint */
- sts usbRxEndp, x3 ;2 only stored if we may have to distinguish endpoints
+ pop x3 ;2
+ pop YL ;2
+ pop YH ;2
+ rjmp sofError ;2
+
+isSetupOrOut: ; we must be fast here -- a data package may follow / {,24} into next frame
+ cp x2, shift ;1 shift contains our device addr
+ brne otherOutOrSetup ;1 other device -- ignore
+#if USB_CFG_IMPLEMENT_FN_WRITEOUT /* if we need second OUT endpoint, store endpoint address */
+ andi x1, 0x7f ;1 mask out MSb in token
+ andi x3, 0x80 ;1 mask out all but endpoint address
+ or x1, x3 ;1 merge endpoint into currentToken
+ sts usbCurrentTok, x1 ;2
+ brmi dontResetEP0 ;1 endpoint 1 -> don't reset endpoint 0 input
+#else
+ sts usbCurrentTok, x1 ;2
#endif
;A transmission can still have data in the output buffer while we receive a
;SETUP package with an IN phase. To avoid that the old data is sent as a reply,
-;we abort transmission. ### This mechanism assumes that NO OUT OR SETUP package
-;is ever sent to endpoint 1. We would abort transmission for endpoint 0
-;in this case.
- ldi x1, -1 ;1
- sts usbMsgLen, x1 ;2
- sts usbTxLen, x1 ;2 abort transmission
- pop x3 ;2
- pop YL ;2
- in x1, USB_INTR_PENDING;1
- sbrc x1, USB_INTR_PENDING_BIT;1 check whether data is already arriving {,41} into next frame
- rjmp shortcutToStart ;2 save the pops and pushes -- a new interrupt is aready pending
+;we abort transmission. We don't need to reset usbMsgLen because it is used
+;from the main loop only where the setup is processed anyway.
+ ldi x1, USBPID_NAK ;1
+ sts usbTxLen, x1 ;2 abort transmission
+dontResetEP0:
+ pop x3 ;2
+ pop YL ;2
+ in x1, USB_INTR_PENDING;1
+ sbrc x1, USB_INTR_PENDING_BIT;1 check whether data is already arriving {,41} into next frame
+ rjmp shortcutToStart ;2 save the pops and pushes -- a new interrupt is aready pending
;If the jump above was not taken, we can be at {,2} into the next frame here
- pop YH ;2
-sofError: ; error in start of frame -- ignore frame
- ldi x1, 1<<USB_INTR_PENDING_BIT;1 many int0 events occurred during our processing -- clear pending flag
- out USB_INTR_PENDING, x1;1
- pop shift ;2
- pop cnt ;2
- pop x2 ;2
- pop x1 ;2
- out SREG, x1 ;1
- pop x1 ;2
- reti ;4 -> {,21} into next frame -> up to 3 sync bits missed
-
-
-sendNakAndReti: ; 21 cycles until SOP
- ldi YL, lo8(usbNakBuf) ;1
- ldi YH, hi8(usbNakBuf) ;1
- rjmp usbSendToken ;2
-
-sendAckAndReti: ; 19 cycles until SOP
- ldi YL, lo8(usbAckBuf) ;1
- ldi YH, hi8(usbAckBuf) ;1
-usbSendToken:
- ldi cnt, 2 ;1
-;;;;rjmp usbSendAndReti fallthrough
+ pop YH ;2
+txDoReturn:
+sofError: ; error in start of frame -- ignore frame
+ ldi x1, 1<<USB_INTR_PENDING_BIT;1 many int0 events occurred during our processing -- clear pending flag
+ out USB_INTR_PENDING, x1;1
+ pop shift ;2
+ pop cnt ;2
+ pop x2 ;2
+ pop x1 ;2
+ out SREG, x1 ;1
+ pop x1 ;2
+ reti ;4 -> {,21} into next frame -> up to 3 sync bits missed
+
+sendCntAndReti: ; 19 cycles until SOP
+ mov x3, cnt ;1
+ rjmp usbSendX3 ;2
+sendNakAndReti: ; 19 cycles until SOP
+ ldi x3, USBPID_NAK ;1
+ rjmp usbSendX3 ;2
+sendAckAndReti: ; 17 cycles until SOP
+ ldi x3, USBPID_ACK ;1
+usbSendX3:
+ ldi YL, 20 ;1 'x3' is R20
+ ldi YH, 0 ;1
+ ldi cnt, 2 ;1
+;;;;rjmp usbSendAndReti fallthrough
; USB spec says:
; idle = J
;usbSend:
;pointer to data in 'Y'
-;number of bytes in 'cnt'
+;number of bytes in 'cnt' -- including sync byte
;uses: x1...x4, shift, cnt, Y
-usbSendAndReti: ; SOP starts 16 cycles after call
- push x4 ;2
- in x1, USBOUT ;1
- cbr x1, USBMASK ;1 mask out data bits
- ori x1, USBIDLE ;1 idle
- out USBOUT, x1 ;1 prepare idle state
- ldi x4, USBMASK ;1 exor mask
- in x2, USBDDR ;1
- ori x2, USBMASK ;1 set both pins to output
- out USBDDR, x2 ;1 <-- acquire bus now
+usbSendAndReti: ; SOP starts 13 cycles after call
+ push x4 ;2
+ ldi x4, USBMASK ;1 exor mask
+ sbi USBOUT, USBMINUS;1 prepare idle state; D+ and D- must have been 0 (no pullups)
+ in x1, USBOUT ;1 port mirror for tx loop
+ sbi USBDDR, USBMINUS;1
+ sbi USBDDR, USBPLUS ;1 set D+ and D- to output: acquire bus
; need not init x2 (bitstuff history) because sync starts with 0
- ldi shift, 0x80 ;1 sync byte is first byte sent
- rjmp txLoop ;2 -> 13 + 3 = 16 cycles until SOP
-
-#if USB_CFG_HAVE_INTRIN_ENDPOINT /* placed here due to relative jump range */
-handleIn1:
- lds cnt, usbTxLen1
- cpi cnt, -1
- breq sendNakAndReti
- ldi x1, -1
- sts usbTxLen1, x1
- ldi YL, lo8(usbTxBuf1)
- ldi YH, hi8(usbTxBuf1)
- rjmp usbSendAndReti
+ ldi shift, 0x80 ;1 sync byte is first byte sent
+ rjmp txLoop ;2 -> 13 + 3 = 16 cycles until SOP
+
+#if USB_CFG_HAVE_INTRIN_ENDPOINT /* placed here due to relative jump range */
+handleIn1: ;{23, 31} from SE0
+ ldi x1, USBPID_NAK ;1
+#if USB_CFG_HAVE_INTRIN_ENDPOINT3
+; 2006-06-10 as suggested by O.Tamura: support second INTR IN / BULK IN endpoint
+ ldd x2, y+2 ;2
+ sbrc x2, 0 ;2 1
+ rjmp handleIn3 ;0 2
+#endif
+ lds cnt, usbTxLen1 ;2
+ sbrc cnt, 4 ;2
+ rjmp sendCntAndReti ;0
+ sts usbTxLen1, x1 ;2
+ ldi YL, lo8(usbTxBuf1);1
+ ldi YH, hi8(usbTxBuf1);1
+ rjmp usbSendAndReti ;2 -> arrives at usbSendAndReti {34, 42} from SE0
+
+#if USB_CFG_HAVE_INTRIN_ENDPOINT3
+handleIn3:
+ lds cnt, usbTxLen3 ;2
+ sbrc cnt, 4 ;2
+ rjmp sendCntAndReti ;0
+ sts usbTxLen3, x1 ;2
+ ldi YL, lo8(usbTxBuf3);1
+ ldi YH, hi8(usbTxBuf3);1
+ rjmp usbSendAndReti ;2 -> arrives at usbSendAndReti {39, 47} from SE0
+#endif
#endif
-bitstuff0: ;1 (for branch taken)
- eor x1, x4 ;1
- ldi x2, 0 ;1
- out USBOUT, x1 ;1 <-- out
- rjmp didStuff0 ;2 branch back 2 cycles earlier
-bitstuff1: ;1 (for branch taken)
- eor x1, x4 ;1
- ldi x2, 0 ;1
- sec ;1 set carry so that brsh will not jump
- out USBOUT, x1 ;1 <-- out
- rjmp didStuff1 ;2 jump back 1 cycle earler
-bitstuff2: ;1 (for branch taken)
- eor x1, x4 ;1
- ldi x2, 0 ;1
- rjmp didStuff2 ;2 jump back 3 cycles earlier and do out
-bitstuff3: ;1 (for branch taken)
- eor x1, x4 ;1
- ldi x2, 0 ;1
- rjmp didStuff3 ;2 jump back earlier
+bitstuff0: ;1 (for branch taken)
+ eor x1, x4 ;1
+ ldi x2, 0 ;1
+ out USBOUT, x1 ;1 <-- out
+ rjmp didStuff0 ;2 branch back 2 cycles earlier
+bitstuff1: ;1 (for branch taken)
+ eor x1, x4 ;1
+ ldi x2, 0 ;1
+ sec ;1 set carry so that brsh will not jump
+ out USBOUT, x1 ;1 <-- out
+ rjmp didStuff1 ;2 jump back 1 cycle earler
+bitstuff2: ;1 (for branch taken)
+ eor x1, x4 ;1
+ ldi x2, 0 ;1
+ rjmp didStuff2 ;2 jump back 3 cycles earlier and do out
+bitstuff3: ;1 (for branch taken)
+ eor x1, x4 ;1
+ ldi x2, 0 ;1
+ rjmp didStuff3 ;2 jump back earlier
txLoop:
- sbrs shift, 0 ;1
- eor x1, x4 ;1
- out USBOUT, x1 ;1 <-- out
- ror shift ;1
- ror x2 ;1
+ sbrs shift, 0 ;1
+ eor x1, x4 ;1
+ out USBOUT, x1 ;1 <-- out
+ ror shift ;1
+ ror x2 ;1
didStuff0:
- cpi x2, 0xfc ;1
- brsh bitstuff0 ;1
- sbrs shift, 0 ;1
- eor x1, x4 ;1
- ror shift ;1
- out USBOUT, x1 ;1 <-- out
- ror x2 ;1
- cpi x2, 0xfc ;1
+ cpi x2, 0xfc ;1
+ brsh bitstuff0 ;1
+ sbrs shift, 0 ;1
+ eor x1, x4 ;1
+ ror shift ;1
+ out USBOUT, x1 ;1 <-- out
+ ror x2 ;1
+ cpi x2, 0xfc ;1
didStuff1:
- brsh bitstuff1 ;1
- sbrs shift, 0 ;1
- eor x1, x4 ;1
- ror shift ;1
- ror x2 ;1
+ brsh bitstuff1 ;1
+ sbrs shift, 0 ;1
+ eor x1, x4 ;1
+ ror shift ;1
+ ror x2 ;1
didStuff2:
- out USBOUT, x1 ;1 <-- out
- cpi x2, 0xfc ;1
- brsh bitstuff2 ;1
- sbrs shift, 0 ;1
- eor x1, x4 ;1
- ror shift ;1
- ror x2 ;1
+ out USBOUT, x1 ;1 <-- out
+ cpi x2, 0xfc ;1
+ brsh bitstuff2 ;1
+ sbrs shift, 0 ;1
+ eor x1, x4 ;1
+ ror shift ;1
+ ror x2 ;1
didStuff3:
- cpi x2, 0xfc ;1
- out USBOUT, x1 ;1 <-- out
- brsh bitstuff3 ;1
- nop2 ;2
- ld x3, y+ ;2
- sbrs shift, 0 ;1
- eor x1, x4 ;1
- out USBOUT, x1 ;1 <-- out
- ror shift ;1
- ror x2 ;1
+ cpi x2, 0xfc ;1
+ out USBOUT, x1 ;1 <-- out
+ brsh bitstuff3 ;1
+ nop2 ;2
+ ld x3, y+ ;2
+ sbrs shift, 0 ;1
+ eor x1, x4 ;1
+ out USBOUT, x1 ;1 <-- out
+ ror shift ;1
+ ror x2 ;1
didStuff4:
- cpi x2, 0xfc ;1
- brsh bitstuff4 ;1
- sbrs shift, 0 ;1
- eor x1, x4 ;1
- ror shift ;1
- out USBOUT, x1 ;1 <-- out
- ror x2 ;1
- cpi x2, 0xfc ;1
+ cpi x2, 0xfc ;1
+ brsh bitstuff4 ;1
+ sbrs shift, 0 ;1
+ eor x1, x4 ;1
+ ror shift ;1
+ out USBOUT, x1 ;1 <-- out
+ ror x2 ;1
+ cpi x2, 0xfc ;1
didStuff5:
- brsh bitstuff5 ;1
- sbrs shift, 0 ;1
- eor x1, x4 ;1
- ror shift ;1
- ror x2 ;1
+ brsh bitstuff5 ;1
+ sbrs shift, 0 ;1
+ eor x1, x4 ;1
+ ror shift ;1
+ ror x2 ;1
didStuff6:
- out USBOUT, x1 ;1 <-- out
- cpi x2, 0xfc ;1
- brsh bitstuff6 ;1
- sbrs shift, 0 ;1
- eor x1, x4 ;1
- ror shift ;1
- ror x2 ;1
+ out USBOUT, x1 ;1 <-- out
+ cpi x2, 0xfc ;1
+ brsh bitstuff6 ;1
+ sbrs shift, 0 ;1
+ eor x1, x4 ;1
+ ror shift ;1
+ ror x2 ;1
didStuff7:
- cpi x2, 0xfc ;1
- out USBOUT, x1 ;1 <-- out
- brsh bitstuff7 ;1
- mov shift, x3 ;1
- dec cnt ;1
- brne txLoop ;2 | 1
- cbr x1, USBMASK ;1 prepare SE0
- pop x4 ;2
- out USBOUT, x1 ;1 <-- out SE0
- ldi cnt, 4 ;1 two bits = 16 cycles
-se0Delay:
- dec cnt ;1
- brne se0Delay ;2 | 1
- ori x1, USBIDLE ;1
- in x2, USBDDR ;1
- cbr x2, USBMASK ;1 set both pins to input
- out USBOUT, x1 ;1 <-- out J (idle)
- cbr x1, USBMASK ;1 configure no pullup on both pins
- pop x3 ;2
- pop YL ;2
- out USBDDR, x2 ;1 <-- release bus now
- out USBOUT, x1 ;1 set pullup state
- pop YH ;2
- rjmp sofError ;2 [we want to jump to rxDoReturn, but this saves cycles]
-
-bitstuff4: ;1 (for branch taken)
- eor x1, x4 ;1
- ldi x2, 0 ;1
- out USBOUT, x1 ;1 <-- out
- rjmp didStuff4 ;2 jump back 2 cycles earlier
-bitstuff5: ;1 (for branch taken)
- eor x1, x4 ;1
- ldi x2, 0 ;1
- sec ;1 set carry so that brsh is not taken
- out USBOUT, x1 ;1 <-- out
- rjmp didStuff5 ;2 jump back 1 cycle earlier
-bitstuff6: ;1 (for branch taken)
- eor x1, x4 ;1
- ldi x2, 0 ;1
- rjmp didStuff6 ;2 jump back 3 cycles earlier and do out there
-bitstuff7: ;1 (for branch taken)
- eor x1, x4 ;1
- ldi x2, 0 ;1
- rjmp didStuff7 ;2 jump back 4 cycles earlier
+ cpi x2, 0xfc ;1
+ out USBOUT, x1 ;1 <-- out
+ brsh bitstuff7 ;1
+ mov shift, x3 ;1
+ dec cnt ;1
+ brne txLoop ;2 | 1
+ cbr x1, USBMASK ;1 prepare SE0 [spec says EOP may be 15 to 18 cycles]
+ pop x4 ;2
+ out USBOUT, x1 ;1 <-- out SE0 -- from now 2 bits = 16 cycles until bus idle
+ ldi cnt, 2 ;| takes cnt * 3 cycles
+se0Delay: ;|
+ dec cnt ;|
+ brne se0Delay ;| -> 2 * 3 = 6 cycles
+;2006-03-06: moved transfer of new address to usbDeviceAddr from C-Code to asm:
+;set address only after data packet was sent, not after handshake
+ lds x2, usbNewDeviceAddr;2
+ subi YL, 20 + 2 ;1
+ sbci YH, 0 ;1
+ breq skipAddrAssign ;2
+ sts usbDeviceAddr, x2 ;0 if not skipped: SE0 is one cycle longer
+skipAddrAssign:
+;end of usbDeviceAddress transfer
+ ori x1, USBIDLE ;1
+ in x2, USBDDR ;1
+ cbr x2, USBMASK ;1 set both pins to input
+ out USBOUT, x1 ;1 <-- out J (idle) -- end of SE0 (EOP signal)
+ cbr x1, USBMASK ;1 configure no pullup on both pins
+ pop x3 ;2
+ pop YL ;2
+ out USBDDR, x2 ;1 <-- release bus now
+ out USBOUT, x1 ;1 set pullup state
+ pop YH ;2
+ rjmp txDoReturn ;2 [we want to jump to rxDoReturn, but this saves cycles]
+
+
+bitstuff4: ;1 (for branch taken)
+ eor x1, x4 ;1
+ ldi x2, 0 ;1
+ out USBOUT, x1 ;1 <-- out
+ rjmp didStuff4 ;2 jump back 2 cycles earlier
+bitstuff5: ;1 (for branch taken)
+ eor x1, x4 ;1
+ ldi x2, 0 ;1
+ sec ;1 set carry so that brsh is not taken
+ out USBOUT, x1 ;1 <-- out
+ rjmp didStuff5 ;2 jump back 1 cycle earlier
+bitstuff6: ;1 (for branch taken)
+ eor x1, x4 ;1
+ ldi x2, 0 ;1
+ rjmp didStuff6 ;2 jump back 3 cycles earlier and do out there
+bitstuff7: ;1 (for branch taken)
+ eor x1, x4 ;1
+ ldi x2, 0 ;1
+ rjmp didStuff7 ;2 jump back 4 cycles earlier
; ######################## utility functions ########################
+#ifdef __IAR_SYSTEMS_ASM__
+/* Register assignments for usbCrc16 on IAR cc */
+/* Calling conventions on IAR:
+ * First parameter passed in r16/r17, second in r18/r19 and so on.
+ * Callee must preserve r4-r15, r24-r29 (r28/r29 is frame pointer)
+ * Result is passed in r16/r17
+ * In case of the "tiny" memory model, pointers are only 8 bit with no
+ * padding. We therefore pass argument 1 as "16 bit unsigned".
+ */
+RTMODEL "__rt_version", "3"
+/* The line above will generate an error if cc calling conventions change.
+ * The value "3" above is valid for IAR 4.10B/W32
+ */
+# define argLen r18 /* argument 2 */
+# define argPtrL r16 /* argument 1 */
+# define argPtrH r17 /* argument 1 */
+
+# define resCrcL r16 /* result */
+# define resCrcH r17 /* result */
+
+# define ptrL ZL
+# define ptrH ZH
+# define ptr Z
+# define byte r22
+# define bitCnt r19
+# define polyL r20
+# define polyH r21
+# define scratch r23
+
+#else /* __IAR_SYSTEMS_ASM__ */
+/* Register assignments for usbCrc16 on gcc */
+/* Calling conventions on gcc:
+ * First parameter passed in r24/r25, second in r22/23 and so on.
+ * Callee must preserve r1-r17, r28/r29
+ * Result is passed in r24/r25
+ */
+# define argLen r22 /* argument 2 */
+# define argPtrL r24 /* argument 1 */
+# define argPtrH r25 /* argument 1 */
+
+# define resCrcL r24 /* result */
+# define resCrcH r25 /* result */
+
+# define ptrL XL
+# define ptrH XH
+# define ptr x
+# define byte r18
+# define bitCnt r19
+# define polyL r20
+# define polyH r21
+# define scratch r23
+
+#endif
+
; extern unsigned usbCrc16(unsigned char *data, unsigned char len);
; data: r24/25
; len: r22
; r23: scratch
; r24/25: crc-sum
; r26/27=X: ptr
-.global usbCrc16
usbCrc16:
- mov XL, r24
- mov XH, r25
- ldi r24, 0xff
- ldi r25, 0xff
- ldi r20, lo8(0xa001)
- ldi r21, hi8(0xa001)
+ mov ptrL, argPtrL
+ mov ptrH, argPtrH
+ ldi resCrcL, 0xff
+ ldi resCrcH, 0xff
+ ldi polyL, lo8(0xa001)
+ ldi polyH, hi8(0xa001)
crcByteLoop:
- subi r22, 1
- brcs crcReady
- ld r18, x+
- ldi r19, 8
+ subi argLen, 1
+ brcs crcReady
+ ld byte, ptr+
+ ldi bitCnt, 8
crcBitLoop:
- mov r23, r18
- eor r23, r24
- lsr r25
- ror r24
- lsr r18
- sbrs r23, 0
- rjmp crcNoXor
- eor r24, r20
- eor r25, r21
+ mov scratch, byte
+ eor scratch, resCrcL
+ lsr resCrcH
+ ror resCrcL
+ lsr byte
+ sbrs scratch, 0
+ rjmp crcNoXor
+ eor resCrcL, polyL
+ eor resCrcH, polyH
crcNoXor:
- dec r19
- brne crcBitLoop
- rjmp crcByteLoop
+ dec bitCnt
+ brne crcBitLoop
+ rjmp crcByteLoop
crcReady:
- com r24
- com r25
- ret
+ com resCrcL
+ com resCrcH
+ ret
+
+; extern unsigned usbCrc16Append(unsigned char *data, unsigned char len);
+usbCrc16Append:
+ rcall usbCrc16
+ st ptr+, resCrcL
+ st ptr+, resCrcH
+ ret
--- /dev/null
+/* Name: usbdrvasm.asm
+ * Project: AVR USB driver
+ * Author: Christian Starkjohann
+ * Creation Date: 2006-03-01
+ * Tabsize: 4
+ * Copyright: (c) 2006 by OBJECTIVE DEVELOPMENT Software GmbH
+ * License: Proprietary, free under certain conditions. See Documentation.
+ * This Revision: $Id$
+ */
+
+/*
+General Description:
+The IAR compiler/assembler system prefers assembler files with file extension
+".asm". We simply provide this file as an alias for usbdrvasm.S.
+
+Thanks to Oleg Semyonov for his help with the IAR tools port!
+*/
+
+#include "usbdrvasm.S"
+
+end
+++ /dev/null
-diff -Naur avrdude-5.0/Makefile.am avrdude-5.0-usbasp/Makefile.am
---- avrdude-5.0/Makefile.am Sun Sep 18 22:12:23 2005
-+++ avrdude-5.0-usbasp/Makefile.am Mon Nov 14 20:57:20 2005
-@@ -98,6 +98,8 @@
- stk500v2.c \
- stk500v2.h \
- stk500v2_private.h \
-+ usbasp.c \
-+ usbasp.h \
- term.c \
- term.h \
- usb_libusb.c
-diff -Naur avrdude-5.0/avrdude.conf.in avrdude-5.0-usbasp/avrdude.conf.in
---- avrdude-5.0/avrdude.conf.in Sun Sep 18 02:44:20 2005
-+++ avrdude-5.0-usbasp/avrdude.conf.in Mon Nov 14 20:57:33 2005
-@@ -262,6 +262,12 @@
- ;
-
- programmer
-+ id = "usbasp";
-+ desc = "usbasp";
-+ type = usbasp;
-+;
-+
-+programmer
- id = "butterfly";
- desc = "Atmel Butterfly Development Board";
- type = butterfly;
-diff -Naur avrdude-5.0/config_gram.y avrdude-5.0-usbasp/config_gram.y
---- avrdude-5.0/config_gram.y Sun Sep 18 22:12:23 2005
-+++ avrdude-5.0-usbasp/config_gram.y Mon Nov 14 20:57:50 2005
-@@ -37,6 +37,7 @@
- #include "stk500v2.h"
- #include "avr910.h"
- #include "butterfly.h"
-+#include "usbasp.h"
- #include "avr.h"
- #include "jtagmkII.h"
-
-@@ -118,6 +119,7 @@
- %token K_STK500
- %token K_STK500V2
- %token K_AVR910
-+%token K_USBASP
- %token K_BUTTERFLY
- %token K_TYPE
- %token K_VCC
-@@ -349,6 +351,12 @@
- K_TYPE TKN_EQUAL K_AVR910 {
- {
- avr910_initpgm(current_prog);
-+ }
-+ } |
-+
-+ K_TYPE TKN_EQUAL K_USBASP {
-+ {
-+ usbasp_initpgm(current_prog);
- }
- } |
-
-diff -Naur avrdude-5.0/configure.ac avrdude-5.0-usbasp/configure.ac
---- avrdude-5.0/configure.ac Wed Sep 21 03:37:02 2005
-+++ avrdude-5.0-usbasp/configure.ac Mon Nov 14 20:58:07 2005
-@@ -46,7 +46,24 @@
- AC_CHECK_LIB([readline], [readline])
- # usb_get_string_simple is only available in recent enough
- # versions of libusb, so use that as a decision base.
--AC_CHECK_LIB([usb], [usb_get_string_simple])
-+#AC_CHECK_LIB([usb], [usb_get_string_simple])
-+
-+AH_TEMPLATE([HAVE_LIBUSB],
-+ [Define if USB support is enabled via libusb])
-+AC_CHECK_LIB(usb, main, have_libusb=yes)
-+if test x$have_libusb = xyes; then
-+ case $target in
-+ *-*-darwin*)
-+ LIBS="$LIBS -lusb -framework CoreFoundation -framework IOKit"
-+ ;;
-+ *)
-+ LIBS="$LIBS -lusb"
-+;;
-+ esac
-+ AC_DEFINE([HAVE_LIBUSB])
-+fi
-+
-+
-
- # Checks for header files.
- AC_HEADER_STDC
-diff -Naur avrdude-5.0/lexer.l avrdude-5.0-usbasp/lexer.l
---- avrdude-5.0/lexer.l Sun Sep 18 22:12:23 2005
-+++ avrdude-5.0-usbasp/lexer.l Mon Nov 14 20:58:24 2005
-@@ -118,6 +118,7 @@
- allowfullpagebitstream { yylval=NULL; return K_ALLOWFULLPAGEBITSTREAM; }
- avr910 { yylval=NULL; return K_AVR910; }
- avr910_devcode { yylval=NULL; return K_AVR910_DEVCODE; }
-+usbasp { yylval=NULL; return K_USBASP; }
- bank_size { yylval=NULL; return K_PAGE_SIZE; }
- banked { yylval=NULL; return K_PAGED; }
- baudrate { yylval=NULL; return K_BAUDRATE; }
+++ /dev/null
-#include "ac_cfg.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <unistd.h>
-
-#include "avr.h"
-#include "pgm.h"
-#include "usbasp.h"
-
-#ifdef HAVE_LIBUSB
-#include <usb.h> /* this is libusb, see http://libusb.sourceforge.net/ */
-
-extern char * progname;
-extern int do_cycles;
-
-static usb_dev_handle *usbhandle;
-
-/*
- * wrapper for usb_control_msg call
- */
-static int usbasp_transmit(unsigned char receive, unsigned char functionid,
- unsigned char send[4], unsigned char * buffer, int buffersize)
-{
- int nbytes;
- nbytes = usb_control_msg(usbhandle,
- USB_TYPE_VENDOR | USB_RECIP_DEVICE | (receive << 7),
- functionid,
- (send[1] << 8) | send[0],
- (send[3] << 8) | send[2],
- buffer, buffersize,
- 5000);
- if(nbytes < 0){
- fprintf(stderr, "%s: error: usbasp_transmit: %s\n", progname, usb_strerror());
- exit(1);
- }
-
- return nbytes;
-}
-
-static int usbasp_open(PROGRAMMER * pgm, char * port)
-{
- struct usb_bus *bus;
- struct usb_device *dev = 0;
-
- usb_init();
- usb_find_busses();
- usb_find_devices();
- for(bus=usb_busses; bus; bus=bus->next){
- for(dev=bus->devices; dev; dev=dev->next){
- if(dev->descriptor.idVendor == USBDEV_VENDOR && dev->descriptor.idProduct == USBDEV_PRODUCT)
- break;
- }
- if(dev)
- break;
- }
- if(!dev){
- fprintf(stderr, "%s: error: could not find USB device vendor=0x%x product=0x%x\n",
- progname, USBDEV_VENDOR, USBDEV_PRODUCT);
- exit(1);
- }
-
- usbhandle = usb_open(dev);
- if(!usbhandle){
- fprintf(stderr, "%s: error: opening usb device: %s\n",
- progname, usb_strerror());
- exit(1);
- }
-
- return 0;
-}
-
-
-static void usbasp_close(PROGRAMMER * pgm)
-{
- unsigned char temp[4];
- memset(temp, 0, sizeof(temp));
- usbasp_transmit(1, USBASP_FUNC_DISCONNECT, temp, temp, sizeof(temp));
-
- usb_close(usbhandle);
-}
-
-
-static int usbasp_initialize(PROGRAMMER * pgm, AVRPART * p)
-{
-
- unsigned char temp[4];
- memset(temp, 0, sizeof(temp));
- usbasp_transmit(1, USBASP_FUNC_CONNECT, temp, temp, sizeof(temp));
-
- usleep(100000);
-
- pgm->program_enable(pgm, p);
- return 0;
-}
-
-static void usbasp_disable(PROGRAMMER * pgm)
-{
- /* Do nothing. */
-
- return;
-}
-
-static void usbasp_enable(PROGRAMMER * pgm)
-{
- /* Do nothing. */
-
- return;
-}
-
-static void usbasp_display(PROGRAMMER * pgm, char * p)
-{
- return;
-}
-
-
-static int usbasp_cmd(PROGRAMMER * pgm, unsigned char cmd[4],
- unsigned char res[4])
-{
- int nbytes =
- usbasp_transmit(1, USBASP_FUNC_TRANSMIT, cmd, res, sizeof(res));
-
- if(nbytes != 4){
- fprintf(stderr, "%s: error: wrong responds size\n",
- progname);
- return -1;
- }
-
- return 0;
-}
-
-
-static int usbasp_program_enable(PROGRAMMER * pgm, AVRPART * p)
-{
- unsigned char res[4];
- unsigned char cmd[4];
- memset(cmd, 0, sizeof(cmd));
- memset(res, 0, sizeof(res));
-
- cmd[0] = 0;
-
- int nbytes =
- usbasp_transmit(1, USBASP_FUNC_ENABLEPROG, cmd, res, sizeof(res));
-
- if ((nbytes != 1) | (res[0] != 0)) {
- fprintf(stderr, "%s: error: programm enable: target doesn't answer. %x \n",
- progname, res[0]);
- return -1;
- }
-
- return 0;
-}
-
-
-static int usbasp_chip_erase(PROGRAMMER * pgm, AVRPART * p)
-{
- unsigned char cmd[4];
- unsigned char res[4];
-
- if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
- fprintf(stderr, "chip erase instruction not defined for part \"%s\"\n",
- p->desc);
- return -1;
- }
-
- memset(cmd, 0, sizeof(cmd));
-
- avr_set_bits(p->op[AVR_OP_CHIP_ERASE], cmd);
- pgm->cmd(pgm, cmd, res);
- usleep(p->chip_erase_delay);
- pgm->initialize(pgm, p);
-
- return 0;
-}
-
-
-static int usbasp_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
- int page_size, int n_bytes)
-{
- int n;
- unsigned char cmd[4];
- int address = 0;
- int wbytes = n_bytes;
- int blocksize;
- unsigned char * buffer = m->buf;
- int function;
-
- if (strcmp(m->desc, "flash") == 0) {
- function = USBASP_FUNC_READFLASH;
- } else if (strcmp(m->desc, "eeprom") == 0) {
- function = USBASP_FUNC_READEEPROM;
- } else {
- return -2;
- }
-
- while (wbytes) {
- if (wbytes > USBASP_READBLOCKSIZE) {
- blocksize = USBASP_READBLOCKSIZE;
- wbytes -= USBASP_READBLOCKSIZE;
- } else {
- blocksize = wbytes;
- wbytes = 0;
- }
-
- cmd[0] = address & 0xFF;
- cmd[1] = address >> 8;
-
- n = usbasp_transmit(1, function, cmd, buffer, blocksize);
-
- if (n != blocksize) {
- fprintf(stderr, "%s: error: wrong reading bytes %x\n",
- progname, n);
- exit(1);
- }
-
- buffer += blocksize;
- address += blocksize;
-
- report_progress (address, n_bytes, NULL);
- }
-
- return n_bytes;
-}
-
-static int usbasp_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
- int page_size, int n_bytes)
-{
- int n;
- unsigned char cmd[4];
- int address = 0;
- int wbytes = n_bytes;
- int blocksize;
- unsigned char * buffer = m->buf;
- unsigned char blockflags = USBASP_BLOCKFLAG_FIRST;
- int function;
-
- if (strcmp(m->desc, "flash") == 0) {
- function = USBASP_FUNC_WRITEFLASH;
- } else if (strcmp(m->desc, "eeprom") == 0) {
- function = USBASP_FUNC_WRITEEEPROM;
- } else {
- return -2;
- }
-
- while (wbytes) {
- if (wbytes > USBASP_WRITEBLOCKSIZE) {
- blocksize = USBASP_WRITEBLOCKSIZE;
- wbytes -= USBASP_WRITEBLOCKSIZE;
- } else {
- blocksize = wbytes;
- wbytes = 0;
- blockflags |= USBASP_BLOCKFLAG_LAST;
- }
-
- cmd[0] = address & 0xFF;
- cmd[1] = address >> 8;
- cmd[2] = page_size & 0xFF;
- cmd[3] = (blockflags & 0x0F) + ((page_size & 0xF00) >> 4); //TP: Mega128 fix
- blockflags = 0;
-
- n = usbasp_transmit(0, function, cmd, buffer, blocksize);
-
- if (n != blocksize) {
- fprintf(stderr, "%s: error: wrong count at writing %x\n",
- progname, n);
- exit(1);
- }
-
-
- buffer += blocksize;
- address += blocksize;
-
- report_progress (address, n_bytes, NULL);
- }
-
- return n_bytes;
-}
-
-void usbasp_initpgm(PROGRAMMER * pgm)
-{
- strcpy(pgm->type, "usbasp");
-
- /*
- * mandatory functions
- */
-
- pgm->initialize = usbasp_initialize;
- pgm->display = usbasp_display;
- pgm->enable = usbasp_enable;
- pgm->disable = usbasp_disable;
- pgm->program_enable = usbasp_program_enable;
- pgm->chip_erase = usbasp_chip_erase;
- pgm->cmd = usbasp_cmd;
- pgm->open = usbasp_open;
- pgm->close = usbasp_close;
-
- /*
- * optional functions
- */
-
- pgm->paged_write = usbasp_paged_write;
- pgm->paged_load = usbasp_paged_load;
-
-}
-
-
-#else /* HAVE_LIBUSB */
-
-extern char * progname;
-
-static int usbasp_nousb_open (struct programmer_t *pgm, char * name)
-{
- fprintf(stderr, "%s: error: no usb support. please compile again with libusb installed.\n",
- progname);
-
- exit(1);
-}
-
-void usbasp_initpgm(PROGRAMMER * pgm)
-{
- strcpy(pgm->type, "usbasp");
-
- pgm->open = usbasp_nousb_open;
-}
-
-#endif /* HAVE_LIBUSB */
+++ /dev/null
-#ifndef __usbasp_h__
-#define __usbasp_h__
-
-#include "avrpart.h"
-
-
-#define USBDEV_VENDOR 0x03eb /* ATMEL */
-#define USBDEV_PRODUCT 0xc7B4 /* USBasp */
-
-#define USBASP_FUNC_CONNECT 1
-#define USBASP_FUNC_DISCONNECT 2
-#define USBASP_FUNC_TRANSMIT 3
-#define USBASP_FUNC_READFLASH 4
-#define USBASP_FUNC_ENABLEPROG 5
-#define USBASP_FUNC_WRITEFLASH 6
-#define USBASP_FUNC_READEEPROM 7
-#define USBASP_FUNC_WRITEEEPROM 8
-
-#define USBASP_BLOCKFLAG_FIRST 1
-#define USBASP_BLOCKFLAG_LAST 2
-
-#define USBASP_READBLOCKSIZE 200
-#define USBASP_WRITEBLOCKSIZE 200
-
-
-void usbasp_initpgm (PROGRAMMER * pgm);
-
-#endif /* __usbasp_h__ */