Completely trimmed avr build down to bare bones, only completing

enumeration with host, no vendor/class requests handled.
move avr builds into avr_release dir
move original source files into source/old for future reference.

avr-size avr_kazzo.elf
text    data     bss     dec     hex filename
1496       2      43    1541     605 avr_kazzo.elf
This commit is contained in:
Paul Molloy 2017-07-22 14:30:03 -05:00
parent 1ec74eaf68
commit 895bd6a737
30 changed files with 559 additions and 420 deletions

View File

@ -8,6 +8,7 @@
DEVICE = atmega164a DEVICE = atmega164a
F_CPU = 16000000 # in Hz F_CPU = 16000000 # in Hz
PROJ = avr_kazzo
# Fuses and ISP programming handled in bootloader firmware build # Fuses and ISP programming handled in bootloader firmware build
#SOURCES=$(wildcard source/**/*.c source/*.c) #SOURCES=$(wildcard source/**/*.c source/*.c)
@ -21,22 +22,22 @@ COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
# symbolic targets: # symbolic targets:
help: help:
@echo "This Makefile has no default rule. Use one of the following:" @echo "This Makefile has no default rule. Use one of the following:"
@echo "make hex ............ to build main.hex" @echo "make hex ............ to build $(PROJ).hex"
@echo "make program ........ windows flash firmware via bootloader" @echo "make program ........ windows flash firmware via bootloader"
@echo "make program_unix ... unix flash firmware via bootloader" @echo "make program_unix ... unix flash firmware via bootloader"
@echo "make clean .......... to delete objects and hex file" @echo "make clean .......... to delete objects and hex file"
hex: main.hex hex: $(PROJ).hex
program: main.hex program: $(PROJ).hex
../bootloader/commandline/bootloadHID.exe -r $< ../bootloader/commandline/bootloadHID.exe -r $<
program_unix: main.hex program_unix: $(PROJ).hex
../bootloader/commandline/bootloadHID -r $< ../bootloader/commandline/bootloadHID -r $<
# rule for deleting dependent files (those which can be built by Make): # rule for deleting dependent files (those which can be built by Make):
clean: clean:
rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.elf $(OBJECTS) main.s usbdrv_Vusb/oddebug.s usbdrv_Vusb/usbdrv.s source/shared_* rm -f $(PROJ).hex $(PROJ).lst $(PROJ).obj $(PROJ).cof $(PROJ).list $(PROJ).map $(PROJ).eep.hex $(PROJ).elf $(OBJECTS) $(PROJ).s usbdrv_Vusb/oddebug.s usbdrv_Vusb/usbdrv.s source/shared_*
# Generic rule for compiling C files: # Generic rule for compiling C files:
.c.o: .c.o:
@ -56,22 +57,22 @@ clean:
# file targets: # file targets:
main.elf: shared $(OBJECTS) $(PROJ).elf: shared $(OBJECTS)
$(COMPILE) -o main.elf $(OBJECTS) $(COMPILE) -o $(PROJ).elf $(OBJECTS)
main.hex: main.elf $(PROJ).hex: $(PROJ).elf
rm -f main.hex main.eep.hex rm -f $(PROJ).hex $(PROJ).eep.hex
avr-objcopy -j .text -j .data -O ihex main.elf main.hex avr-objcopy -j .text -j .data -O ihex $(PROJ).elf $(PROJ).hex
# avr-size -C --mcu=${DEVICE} main.elf # avr-size -C --mcu=${DEVICE} $(PROJ).elf
avr-size main.elf avr-size $(PROJ).elf
# debugging targets: # debugging targets:
disasm: main.elf disasm: $(PROJ).elf
avr-objdump -d main.elf avr-objdump -d $(PROJ).elf
cpp: cpp:
$(COMPILE) -E main.c $(COMPILE) -E $(PROJ).c
#copy shared .h files which are used in host and firmware #copy shared .h files which are used in host and firmware
shared: shared:

Binary file not shown.

View File

@ -1,4 +1,4 @@
:100000000C9476000C94450B0C9493000C94930084 :100000000C9476000C94B8010C9493000C9493001B
:100010000C9493000C9493000C9493000C94930014 :100010000C9493000C9493000C9493000C94930014
:100020000C9493000C9493000C9493000C94930004 :100020000C9493000C9493000C9493000C94930004
:100030000C9493000C9493000C9493000C949300F4 :100030000C9493000C9493000C9493000C949300F4
@ -13,391 +13,84 @@
:1000C00049006E00660069006E00690074006500FA :1000C00049006E00660069006E00690074006500FA
:1000D0004E00650073004C006900760065007300F7 :1000D0004E00650073004C006900760065007300F7
:1000E0002E0063006F006D000403090411241FBE7D :1000E0002E0063006F006D000403090411241FBE7D
:1000F000CFEFD4E0DEBFCDBF11E0A0E0B1E0E6E09D :1000F000CFEFD4E0DEBFCDBF11E0A0E0B1E0E8ED8E
:10010000F9E102C005900D92A031B107D9F723E0C3 :10010000F5E002C005900D92A230B107D9F721E0C9
:10011000A0E1B1E001C01D92A23BB207E1F70E944D :10011000A2E0B1E001C01D92AD32B207E1F70E944A
:10012000590C0C94810C0C940000CF92DF92EF924A :10012000CC020C94EA020C94000080E0089580E078
:10013000FF92CF93DF93DB01F701E601813509F4EC :100130000895CF93DF9360911301635067FD91C0E1
:100140003FC020F48035F1F085EB15C0803649F0D2 :1001400080911001CCE0D0E0C81BD109C95EDE4F20
:100150008136D1F7A0912A01B0912B0113968C9191 :1001500080910F018D3209F0CFC0683009F07FC067
:1001600005C0A22FB0E0A35ABE4F8C918083888136 :1001600083EC809303018AE58093010110920201E0
:100170008F5F888380E0DF91CF91FF90EF90DF90D9 :100170008881807679F0CE010E9495008F3F09F446
:10018000CF90089512968C911297808313968C913C :1001800066C09F81911169C09E81981708F065C073
:100190001397818314968C911497828315968C9172 :10019000892F63C02A8110920C01998191110AC0A4
:1001A0001597838316968C911697848317968C9156 :1001A00010920D012CE031E082E030931201209397
:1001B0001797858318968C9186838881895FD9CF1C :1001B0001101E7CF953029F4209314012CE031E0B0
:1001C00019968C91199780831A968C911A9781832E :1001C000F4CF963099F59B81913059F48EE890E008
:1001D0001B968C911B9782831C968C911C97838312 :1001D000909312018093110182E190E490930201C7
:1001E0001D968C911D9784831E968C911E978583F6 :1001E000D0CF923019F48CE790E0F2CF9330A9F79A
:1001F0001F968C91E1CF0F931F93CF93DF93EC0168 :1001F000211108C088EE90E09093120180931101C4
:10020000FB01D90100914D0110914E01888187FFBA :1002000084E0EBCF213041F48EEB90E0909312012B
:1002100009C08E818C93442399F00081118180E87C :10021000809311018AE2E1CF2230F9F680EA90E082
:1002200083831DC08FEF8C938E8180933C01442388 :1002200090931201809311018EE1D7CF983059F04D
:1002300009F447C070936E0360936D0380E9F0CFBB :10023000993019F420931601C1CF81E09A3009F466
:10024000E0912A01F0912B018381883DA1F5008185 :10024000BDCF80E0BBCF26E131E081E0AECF988129
:10025000118180E88383E0912A01F0912B011482BF :1002500097FD8E8190E890930201809300011092A7
:10026000E0912A01F0912B0183818039F1F48A8198 :1002600013018091010184FF3AC0809100018F3F0A
:10027000813711F08034C9F4E0916D03F0916E0381 :10027000B1F1C82F893008F0C8E08C1B80930001D1
:100280000190F081E02D8D818083E0916D03F091EC :100280008091030198E8892780930301CC23D1F062
:100290006E030190F081E02D8C818183E0916D03EC :1002900080911101909112012091020126FF3FC02F
:1002A000F0916E0384818E5F8483C801DF91CF91CA :1002A000A4E0B1E0FC012C2F34913D933196215014
:1002B0001F910F9108958FEF8C9380E10E94F106BA :1002B000D9F701962FEF2C0F820F911D9093120109
:1002C000CACFE0912A01F0912B0183818111F5CFF2 :1002C000809311016C2F84E091E00E94B401CC5F17
:1002D000F0936E03E0936D0380E9BCCFEDE5F1E0B0 :1002D000CC3019F08FEF80930001C093010184E1CD
:1002E0008FEF819391E0ED36F907D9F780935001B4 :1002E00099B1947131F48150D9F7109214011092A0
:1002F00080932F01809353018093320180934001BA :1002F0000E01DF91CF9108958091020187FFAFCF6A
:1003000080931D01809343018093200181E00C9430 :10030000CE010E9497008F3F21F48EE1809301017E
:10031000F106CF93DF931F92CDB7DEB7FB01813398 :10031000A6CF882309F4A3CF10920001A0CFE4E078
:10032000C9F030F4882351F0803381F084EB0AC0A7 :10032000F1E0DC012C2F3D9131932150E1F7C1CF59
:10033000823399F08333D1F727870AC089830E94DB :10033000E9E6F0E0808182608083E89A0895A82F42
:100340006E0189810F90DF91CF91089541872287B7 :10034000B92F80E090E041E050EA609530E009C0CC
:1003500080E0F8CF43872487FBCF45872687F8CFF7 :100350002D9182279795879510F084279527305EF9
:10036000CF93DF93FC0150E0CA01820F911D4197AA :10036000C8F36F5FA8F30895EADF8D939D93089516
:10037000C4F52223C1F183818F3FB9F586818F3F78 :10037000CF93CFB7CF93DF93C3954C9BE9F74C9BBB
:10038000B1F5DA01A35ABE4FED0180E099919F3F8C :100380000BC04C9B09C04C9B07C04C9B05C04C9BB1
:1003900081F58F5F2813FACF66831382982F929589 :1003900003C04C9B01C089C06F93C0911001DD2741
:1003A000990F907E91509283148215821086178245 :1003A000C95EDE4F2F9365E54C9B03C02F916F9183
:1003B000118612861386148615861686178695E092 :1003B000E6CF0F931F934F9320E040E15F9309B185
:1003C000440F551F9A95E1F743595E4F518340837F :1003C000047104FB27F93F9350E03BE039C01471FE
:1003D00090E06D939F5F8913FCCF80E0DF91CF9118 :1003D00040642F77012F5F5F1EC0406819B1147110
:1003E00008958EEBFBCF82ECF9CF8FEBF7CF80EC4B :1003E0002F7752501FC0406409B12F770471D1F1AB
:1003F000F5CF81ECF3CF0F93FB01642F422F202F19 :1003F0005F5F00C023C0406219B12F77147191F183
:10040000803828F0883828F08059883030F086EB22 :100400005F5F00C025C004711027515012F45D5F7A
:100410000AC0CF010F910C94B001058350E0562B18 :100410000000115027952C3F19B1C8F6147101271F
:100420005087478380E00F910895CF92DF92EF923B :10042000015027952C3FC8F64227499309B1047122
:10043000FF920F93CF93DF93FC01EB016A0182815E :1004300010274F73115027952C3FA8F646954695E7
:1004400090ED980F903378F59381913099F058F1B1 :1004400019B1147179F00127015027952C3F98F6C6
:10045000923019F1933021F186E8888381E0D6014A :100450006B5A60F3315009B1B0F600C011E01CBB1B
:100460008C93CE01DF91CF910F91FF90EF90DF90B1 :10046000002717C03B503195C31BD04011E01CBB87
:10047000CF9008956CE271E08037C0F4803520F5AC :100470000881033CF9F00B34E9F020910E01198159
:10048000803408F04BC00381248145810E9489019A :10048000110F1213EDCF093651F10D3211F0013E6B
:10049000888381E0F6018083E4CF6DE371E0ECCFE7 :1004900039F7009315013F915F914F911F910F9193
:1004A0006AE171E0E9CF6DE471E0E6CF8038B8F43D :1004A0002F916F91CCB3C0FD67CFDF91CF91CFBFBC
:1004B000960140E0CF01DF91CF910F91FF90EF9037 :1004B000CF91189520911501222369F31091130112
:1004C000DF90CF900C94FB007E019FEFE91AF90AB0 :1004C000112339F534303AF13093130120930F01A1
:1004D0000381248145810E9495008883C2CF982F93 :1004D000109110013BE0311B309310011CC00091C2
:1004E0009770913049F090F0923099F0933009F084 :1004E00013010130B4F40AE53091010134FD14C068
:1004F000B3CF6AE171E002C06CE271E0803F60F46A :1004F00000930101C3E0D1E013C0052710E000C064
:10050000803CA8F4803868F485E8E7CF6DE471E0BA :1005000000000BB91AC0052710E0221F1DC010E023
:10051000F5CF6DE371E0F2CF883FB0F796014FEF72 :1005100021C04AE502C032ED432FC4E1D0E032E011
:10052000C9CF0381248145810E94FB01D6CFDB0125 :100520001AB114615C9A0BB11AB954E120E865E381
:10053000CD91DC918681AECF20E030E0261708F027 :1005300020FF05270BB9279517951C3FF0F6669508
:100540000895E0914D01F0914E01E20FF31F4081BB :10054000B8F7B1F720FF05270BB9279517951C3F82
:10055000FC014193CF012F5F3F4FF0CF20E030E00F :10055000D0F62795179517FF052700001C3F0BB90C
:10056000261708F00895FC014191CF01E0914D015B :10056000B0F629913A9519F70B7E10911401110FED
:10057000F0914E01E20FF31F40832F5F3F4FF0CF0A :10057000C651D0400BB911F010930E0111E01CBB15
:100580009091500180912F018F3F79F481E09F3F3E :1005800000611AB11B7E402F4B7E54E05A95F1F763
:1005900009F480E0909140019F3F09F083E0909141 :100590000BB91AB94BB97FCF9EE088E10FB6F8943A
:1005A0001D019F3F09F084E0089582E0F3CF62309F :1005A000A895809360000FBE909360000E94980110
:1005B00059F421E08D34920749F121E08C32920701 :1005B000549A80E0815031F454987894A8950E9420
:1005C00089F48DE491E00EC0633069F421E08D344C :1005C0009900FCCFA895EFE9FFE03197F1F700C063
:1005D0009207E1F021E08C329207D9F021E08D33CF :0805D0000000F0CFF894FFCF0A
:1005E000920779F308956430E9F721E08D3492079A :0205D800FF5AC8
:1005F00069F021E08C32920761F021E08D3392079F
:1006000059F021E08A31920769F7DBCF8CE291E063
:1006100008958DE391E008958AE191E008951F9394
:10062000CF93DF930E94F706823D09F071C00E94CC
:10063000C002809310018DE491E090932B01809390
:100640002A010E94F706823DA1F4D0911001809109
:100650002A0190912B01C1E0CD1708F45FC090935F
:100660002B0180932A0120E8FC01238380ED0E9466
:10067000F1060E94F706823F41F480EF0E94F106E6
:10068000E0912A01F0912B0113820E94F706C82FF6
:10069000803DE1F480912A0190912B01FC0123819E
:1006A0002038A1F4609110010E94D70290932B0191
:1006B00080932A01FC011482C3830E94A703E09166
:1006C0002A01F0912B01882371F183830E94F706A0
:1006D000182F803FC9F4C0912A01D0912B018B8142
:1006E000883991F460911001CE010E94D702909355
:1006F0002B0180932A01FC0113821B83CE010E94EF
:100700002F048823D1F08B83DF91CF911F9108951F
:100710000E94F706823F09F094CF89CF6D2F0E9487
:10072000D702CF5F99CF88ED83832581878190851C
:10073000820F911D90878783C9CF84EF8B832D8192
:100740008F819885820F911D98878F83DDCF0F93BE
:10075000CF93DF93EC016F8189858C3001F130F408
:100760008A3059F08B3091F083EC03C08F30E0F782
:1007700080E0DF91CF910F91089560680FEF2A819B
:100780004E81888199810E94C90507C00FEF2A8197
:100790004E81888199810E9400068C83E9CF606632
:1007A000EDCF9F92AF92BF92CF92DF92EF92FF92E6
:1007B0000F931F93CF93DF93B62E7A016901DA016D
:1007C0001496CC91D0E0AC2ED70112968C91129752
:1007D00090E08C179D0778F41496CC9380E0DF911D
:1007E000CF911F910F91FF90EF90DF90CF90BF902E
:1007F000AF909F900895E0910001F0910101478131
:1008000066818581F6010995E0910001F091010171
:10081000438562858185F6010995E0910001F0919B
:100820000101478566858585F6010995D701ED911A
:10083000FC91EC0FF11D40816C2F8B2DF601099579
:100840000E94260A6A2D8B2DF8010995982E6A2D93
:100850008B2DF80109959812F3CF2196B4CF0F9301
:100860001F93AC01FC01678181858B30A1F020F4DE
:100870008A3041F083EC03C08F30E0F780E01F91B5
:100880000F910895606800E115E028EE34E080E003
:100890000E94D103F3CF06E315E028E435E0F7CF5B
:1008A00011B88FEF82B914B885B917B888B98AB171
:1008B00084718AB98BB18B6E8BB9509858985198C6
:1008C000599A08950E945004399A419A389A40984A
:1008D0003A9A429A3C9A449A3D9A459A3F9A479A44
:1008E00047988FEF84B915B8479A479814B812B84B
:1008F00081B914B885B908950E945004399A419A73
:100900003C9A449A3D9A459A509A589A3F9A479AE7
:100910004798579A5F9A5F988FEF84B915B8479AAE
:10092000479814B884B915B85F9A5F9814B812B88C
:1009300081B914B885B90895CF93DF931F92CDB7CD
:10094000DEB7813069F020F0823071F086E904C0B2
:1009500089830E94500489810F90DF91CF9108957F
:100960000E94620480E0F8CF0E947C04FBCFFC016F
:1009700081E080835898509A000089B18183509813
:100980005898908181818923981308C08AEA8683C8
:100990008483828385E58583838308955098589A5C
:1009A00089B1818389B1828389B1838389B1848349
:1009B00089B1858389B18683509858980895803885
:1009C00029F4CB010E94B70480E0089587E90895D7
:1009D0009FEF94B985B9479A479862B945B9589835
:1009E000509A5098589A14B808955098589840982A
:1009F000419A429A62B99FEF94B985B9479A47984C
:100A000014B800000000409A87FD419800000000E3
:100A1000000000000000000083B14098419A089552
:100A200062B99FEF94B985B9479A479814B8409A2C
:100A300087FD4198000000000000000083B140984D
:100A4000419A0895509858989FEF94B962B985B922
:100A5000479A4798429845B9409A87FD41980000C7
:100A600000004098419A429A14B808959FEF94B9B3
:100A7000803208F4806885B9479A479814B862B9FB
:100A80004498000000000000000083B1449A0895DB
:100A90009FEF94B9803208F4806885B9479A4798E7
:100AA00062B945B9000045980000459A14B8089508
:100AB000CF93C82F862F642F422FC13051F020F0E2
:100AC000C23059F0C0EA02C00E94E8048C2FCF91D6
:100AD00008950E944805C0E0F9CF0E942205FBCF8F
:100AE0008FEF84B984E085B9479A479899B188E037
:100AF00085B9479A479889B1807214B821E0592F77
:100B0000507295FD20E041E0811140E0222311F078
:100B1000411116C031E0511101C030E091E0811166
:100B200001C090E0332311F091110CC0442311F067
:100B300031110AC0222311F0911108C08FEF0895DE
:100B400080E1089581E1089582E1089583E10895A7
:100B5000CF93DF93982F862F642FE901913899F076
:100B600020F4903849F081EA0BC0923879F093383C
:100B7000D1F70E94700502C00E94F504888380E0CE
:100B8000DF91CF9108950E941005F8CF0E9436059D
:100B9000F5CFEF92FF920F93CF93DF9300D01F9288
:100BA000CDB7DEB77C018FEF84B965B9479A479816
:100BB00014B8409A67FD419842B980E0011117C00E
:100BC0000000000093B1F701E80FF11D90834F5F23
:100BD00042B98F5F281790F74098419A0F900F9075
:100BE0000F90DF91CF910F91FF90EF9008952B839D
:100BF0004A8389830E94260A89814A812B81E2CF18
:100C0000EF92FF920F93CF93DF9300D01F92CDB757
:100C1000DEB77C018FEF84B9603208F4606865B993
:100C2000479A479814B8449842B980E0011116C019
:100C30000000000093B1F701E80FF11D90834F5FB2
:100C400042B98F5F281790F7449A0F900F900F903A
:100C5000DF91CF910F91FF90EF9008952B834A83FE
:100C600089830E94260A89814A812B81E3CF8330C0
:100C700061F46058633048F4E62FF0E0EE0FFF1F98
:100C8000E65FFE4F8081918108958FEF9FEF089579
:100C9000833059F4633048F4E62FF0E0EE0FFF1F85
:100CA000EC5FFE4F8081918108958FEF9FEF089553
:100CB0000F931F93CF93DF93982F862F642F092FC5
:100CC00010E00730110508F043C0F801E659F94F6C
:100CD0000C947B0C71067C06850683068D069606B1
:100CE0009F06E0910001F09101014083892FDF917F
:100CF000CF911F910F91089563E180910001909130
:100D000001010E949C0290E0F1CF63E1809100011B
:100D1000909101010E94AE02F6CFC0910001D091E6
:100D200001010E9437069C8B8B8BEDCFC091000197
:100D3000D09101010E9448069E8B8D8BE4CFC0911B
:100D40000001D09101010E944806988F8F8BDBCF64
:100D500092EDCCCF0F931F93CF93DF93FC01EB0168
:100D60008A018281803488F0803800F58034E1F493
:100D7000E0910001F091010180818983FA01808175
:100D80008F5F808380E0888309C0238144816581EF
:100D90000E945806888381E0F8018083CE01DF91AC
:100DA000CF911F910F91089583EDEDCF87E8EBCFA1
:100DB000EF92FF920F931F93F701803481F4A0917B
:100DC0000001B09101018C91D8018C9380818F5FDB
:100DD000808380E01F910F91FF90EF90089583ED45
:100DE000F9CFE0910001F091010180830895E09135
:100DF0000001F091010180810895482F50E04B35AA
:100E0000510508F0FCC0FA01E85FF84F0C947B0C28
:100E10006307650769076B076E0770077307750738
:100E200078077A077C077F0781078307850787078D
:100E300089078B078D07FF07FF07FF07FF078F074E
:100E4000910793079507FF07FF07FF07FF0797071E
:100E500099079B079D079F07A107A307A507A7075A
:100E6000A907AB07AD07AF07B107B307B507FF0782
:100E7000FF07FF07FF07B707B907FD07BB07BD0758
:100E8000C107C507C807CB07D107CE07CA07CD07DB
:100E9000D007D307D507D707D907DB07DD07DF075B
:100EA000E107E307E507E707E907EB07ED07EF07CA
:100EB000F107F307F507FF07FF07FF07FF07FA072B
:100EC000F707F907FC0711B808958FEF81B980E0A3
:100ED000089512B8FCCF8FEF82B9F9CF14B8F7CFCD
:100EE0008FEF84B9F4CF15B8F2CF8FEF85B9EFCF7C
:100EF00017B8EDCF18B8EBCF8FEF88B9E8CF389897
:100F0000E6CF389AE4CF4098E2CF409AE0CF3998C4
:100F1000DECF399ADCCF4198DACF419AD8CF3A98D0
:100F2000D6CF3A9AD4CF4298D2CF429AD0CF3B98DC
:100F3000CECF3B9ACCCF4398CACF439AC8CF3C98E8
:100F4000C6CF3C9AC4CF4498C2CF449AC0CF3D98F4
:100F5000BECF3D9ABCCF4598BACF459AB8CF3E9800
:100F6000B6CF3E9AB4CF4698B2CF469AB0CF3F980C
:100F7000AECF3F9AACCF479AAACF8AB184718AB9D3
:100F8000A6CF8BB184718BB9A2CF8BB18B6EFBCF07
:100F900050989DCF5898509A9ACF5098589A97CF7A
:100FA0005098589894CF519892CF519A90CF599881
:100FB0008ECF599A8CCF53988ACF539A88CF5B980B
:100FC00086CF5B9A84CF559882CF559A80CF5D9813
:100FD0007ECF5D9A7CCF56987ACF569A78CF5E981E
:100FE00076CF5E9A74CF579872CF579A70CF5F9A28
:100FF0006ECF5F9A5F986BCF479A479868CF8CE81F
:10100000089590E0FC01E058F109EB30F10508F09B
:101010003FC0E35FF74F0C947B0C18081D081B08BA
:101020001F0826082C082E08300832083C083E0805
:1010300062B980E008958FEF84B965B9FACF8FEF78
:1010400084B965B9479A479814B8F3CF8FEF84B93C
:1010500065B95F9A5F98F8CF61B9EBCF64B9E9CF12
:1010600067B9E7CF9AB1862F846189238AB98AB19B
:101070006B7E682B6AB9DDCF68B9DBCF9BB1862F59
:10108000846189238BB98BB16B7E682B6BB9D1CF0F
:101090008DE80895813A69F0823AC1F0803A11F5FD
:1010A0008FEF84B965B9479A479814B842B980E080
:1010B00008958FEF84B965B9479A479814B842B933
:1010C00067FF02C04198F3CF419AF1CF42B98FEF49
:1010D00084B9603228F415B8479A479814B8E7CF16
:1010E00065B9FACF8EE80895803B61F422B98FEF9D
:1010F00084B945B9479A479865B95F9A5F9814B81B
:1011000080E008958FE80895DB01482F50E0FA0150
:10111000E05CF109EC30F10550F5EF56F74F0C9417
:101120007B0C9D08A108A308A508A708A908AB087F
:10113000AD08AF08B108B308B50880B18C9380E062
:10114000089583B1FBCF86B1F9CF89B1F7CF82B1D2
:10115000F5CF85B1F3CF88B1F1CF8BB1EFCF81B1AE
:10116000EDCF84B1EBCF87B1E9CF8AB1E7CF80E98A
:1011700008950F93811111C0589A8FEF84B922B945
:1011800045B9479A479805B9459800000000459A27
:10119000419A14B858980F9108955898EECF0F932C
:1011A000CF93C82F022F813079F020F08230A1F048
:1011B000CAEA06C0242F462F6FEF81E00E94B908CB
:1011C0008C2FCF910F910895242F462F6FEF80E041
:1011D0000E94B908C0E0F4CF242F462F60E0F7CF7B
:1011E0000F93811116C0589A8FEF84B902B925B9AF
:1011F000479A479845B95F9A5F9814B84498000099
:1012000000000000000083B1449A419A58980F9161
:1012100008955898E9CF0F931F93CF93DF93E80178
:10122000813891F08238B1F08038C9F4022F242F30
:10123000462F6FEF81E00E94F008888380E0DF9105
:10124000CF911F910F910895022F242F462F6FEFFA
:1012500080E0F1CF022F242F462F60E0F9CF8BEAF8
:10126000EECF0F931F93CF93DF931F92CDB7DEB7CF
:10127000DC0181E191E090939703809396031982BA
:101280008C9187FF02C081E089831196EC911197C0
:101290004E2F50E0FA013197E730F10508F0ACC06D
:1012A000EC5AF64F0C947B0C5B098C09A209BC0923
:1012B000D909E609F30912968C911297803B48F4FC
:1012C000803AC8F4803890F40E94FD0680931101A2
:1012D00032C0803CC0F414962C91149715964C9112
:1012E000159713966C910E947408F0CF14966C9128
:1012F0000E940108EBCF14964C91149715966C91AF
:101300000E944A08E3CF62E171E00E948408809362
:10131000110189818F5F0EC012968C91803818F46C
:101320000E949C04D3CF62E171E00E94DF048093AD
:10133000110188E0898389810F90DF91CF911F91FE
:101340000F91089512968C911297803858F4139645
:101350002C91139714964C91149715966C910E94AA
:101360005805B4CF22E131E014964C9114971596AC
:101370006C910E94A805CBCF12968C911297803861
:1013800058F413962C91139714964C911497159624
:101390006C910E94CF089ACF02E111E014962C9133
:1013A000149715964C91159713966C910E940B0902
:1013B000AECFAE014F5F5F4F61E171E0CD010E94A2
:1013C00015029093970380939603B5CF1092110165
:1013D00010921201E0916D03F0916E03828180936F
:1013E000130183E0A7CFAE014F5F5F4F61E171E072
:1013F000CD010E94AA06E5CF80E868CFE0916D0399
:10140000F0916E03248140815181322F360F2313D6
:1014100012C0E0916D03F0916E038481860F848386
:1014200080913C01861B80933C0181110DC088E9AD
:10143000838381E00895FC017191CF01FA01E20FED
:10144000F11D70832F5FE3CF80E00895CF93DF938A
:1014500060919803635067FD91C080919503CCE043
:10146000D0E0C81BD109C456DC4F809194038D3263
:1014700009F0CFC0683009F07FC083EC8093880307
:101480008AE580930301109219018881807679F0B2
:10149000CE010E9431098F3F09F466C09F819111EE
:1014A00069C09E81981708F065C0892F63C02A81A2
:1014B00010929103998191110AC01092920321E92F
:1014C00033E082E03093970320939603E7CF953083
:1014D00029F42093990321E933E0F4CF963099F56C
:1014E0009B81913059F48EE890E09093970380931C
:1014F000960382E190E490931901D0CF923019F4D1
:101500008CE790E0F2CF9330A9F7211108C088EE64
:1015100090E0909397038093960384E0EBCF213083
:1015200041F48EEB90E090939703809396038AE2C8
:10153000E1CF2230F9F680EA90E090939703809310
:1015400096038EE1D7CF983059F0993019F4209353
:101550009B03C1CF81E09A3009F4BDCF80E0BBCFBF
:101560002BE933E081E0AECF988197FD8E8190E842
:1015700090931901809302011092980380910301C6
:1015800084FF3AC0809102018F3FB1F1C82F8930AA
:1015900008F0C8E08C1B809302018091880398E8D2
:1015A000892780938803CC23D1F080919603909172
:1015B00097032091190126FF3FC0A9E8B3E0FC0181
:1015C0002C2F34913D9331962150D9F701962FEF6E
:1015D0002C0F820F911D90939703809396036C2F8D
:1015E00089E893E00E94410BCC5FCC3019F08FEF7B
:1015F00080930201C093030184E199B1947131F4A5
:101600008150D9F71092990310929303DF91CF91F3
:1016100008958091190187FFAFCFCE010E94FE0986
:101620008F3F21F48EE180930301A6CF882309F434
:10163000A3CF10920201A0CFE9E8F3E0DC012C2F48
:101640003D9131932150E1F7C1CFE9E6F0E080818F
:1016500082608083E89A0895A82FB92F80E090E0F7
:1016600041E050EA609530E009C02D9182279795BE
:10167000879510F084279527305EC8F36F5FA8F335
:101680000895EADF8D939D930895CF93CFB7CF93BD
:10169000DF93C3954C9BE9F74C9B0BC04C9B09C057
:1016A0004C9B07C04C9B05C04C9B03C04C9B01C08E
:1016B00089C06F93C0919503DD27C456DC4F2F93EB
:1016C00065E54C9B03C02F916F91E6CF0F931F935D
:1016D0004F9320E040E15F9309B1047104FB27F9C7
:1016E0003F9350E03BE039C0147140642F77012FE5
:1016F0005F5F1EC0406819B114712F7752501FC030
:10170000406409B12F770471D1F15F5F00C023C03D
:10171000406219B12F77147191F15F5F00C025C04D
:1017200004711027515012F45D5F0000115027958D
:101730002C3F19B1C8F614710127015027952C3F91
:10174000C8F64227499309B1047110274F7311500D
:1017500027952C3FA8F64695469519B1147179F056
:101760000127015027952C3F98F66B5A60F33150B2
:1017700009B1B0F600C011E01CBB002717C03B50F8
:101780003195C31BD04011E01CBB0881033CF9F02C
:101790000B34E9F0209193031981110F1213EDCF4F
:1017A000093651F10D3211F0013E39F700939A03D9
:1017B0003F915F914F911F910F912F916F91CCB3FA
:1017C000C0FD67CFDF91CF91CFBFCF91189520910A
:1017D0009A03222369F310919803112339F53430C9
:1017E0003AF13093980320939403109195033BE0D2
:1017F000311B309395031CC0009198030130B4F461
:101800000AE53091030134FD14C000930301C8E8D8
:10181000D3E013C0052710E000C000000BB91AC0C8
:10182000052710E0221F1DC010E021C04AE502C0BC
:1018300032ED432FC4E1D0E032E01AB114615C9A7A
:101840000BB11AB954E120E865E320FF05270BB975
:10185000279517951C3FF0F66695B8F7B1F720FF6E
:1018600005270BB9279517951C3FD0F62795179597
:1018700017FF052700001C3F0BB9B0F629913A95D8
:1018800019F70B7E10919903110FC651D0400BB977
:1018900011F01093930311E01CBB00611AB11B7E81
:1018A000402F4B7E54E05A95F1F70BB91AB94BB95A
:1018B0007FCF9EE088E10FB6F894A89580936000F2
:1018C0000FBE909360000E94250B549A80E08150D7
:1018D00051F454980E9450047894A8950E94260AC6
:1018E0000E940F03FACFA895EFE9FFE03197F1F7D7
:1018F00000C00000ECCFEE0FFF1F0590F491E02D2B
:061900000994F894FFCFEA
:101906006F03FF5AE80448052205F504100536055D
:00000001FF :00000001FF

View File

@ -3,9 +3,9 @@
#include <util/delay.h> #include <util/delay.h>
#include "usbdrv.h" #include "usbdrv.h"
#include "io.h" //#include "io.h"
#include "pinport.h" //#include "pinport.h"
#include "buffer.h" //#include "buffer.h"
int main(void) int main(void)
{ {
@ -39,7 +39,7 @@ int main(void)
usbDeviceConnect(); usbDeviceConnect();
//intialize i/o and LED to pullup state //intialize i/o and LED to pullup state
io_reset(); // io_reset();
//enable interrupts //enable interrupts
sei(); sei();
@ -67,6 +67,6 @@ int main(void)
//+ cpu operations that can't be hid behind flash wait time //+ cpu operations that can't be hid behind flash wait time
//another thought would be to call usbPoll mid programming //another thought would be to call usbPoll mid programming
//a few times to prevent incoming data from being delayed too long //a few times to prevent incoming data from being delayed too long
update_buffers(); // update_buffers();
} }
} }

View File

@ -0,0 +1,72 @@
#include <avr/interrupt.h>
#include <avr/wdt.h>
#include <util/delay.h>
#include "usbdrv.h"
#include "io.h"
#include "pinport.h"
#include "buffer.h"
int main(void)
{
//set watch dog timer with 1 second timer
wdt_enable(WDTO_1S);
/* Even if you don't use the watchdog, turn it off here. On newer devices,
* the status of the watchdog (on/off, period) is PRESERVED OVER RESET!
*/
/* RESET status: all port bits are inputs without pull-up.
* That's the way we need D+ and D-. Therefore we don't need any
* additional hardware initialization.
*/
//odDebugInit(); //intialize debuging printing via serial port
//DBG1(0x00, 0, 0); //debug serial op: main starts
//initialize V-usb driver before interupts enabled and entering main loop
usbInit();
//disconnect from host enforce re-enumeration, interupts must be disabled during this.
usbDeviceDisconnect();
//fake USB disconnect for over 250ms
uint8_t index = 0;
while(--index){ //loop 256 times
wdt_reset(); //keep wdt happy during this time
_delay_ms(1); //delay 256msec
}
//reconnect to host
usbDeviceConnect();
//intialize i/o and LED to pullup state
io_reset();
//enable interrupts
sei();
//=================
//MAIN LOOP
//=================
while (1) {
//pet the watch doggie to keep him happy
wdt_reset();
//must call at regular intervals no longer than 50msec
//checks for setup packets from what I understand
usbPoll();
//check buffer status' and instruct them to
//flash/dump as needed to keep data moving
//currently assuming this operation doesn't take longer
//than 50msec to meet usbPoll's req't
//considering using a timer counter interupt to call
//usbPoll more often but going to see how speed is
//impacted first..
//256Bytes * 20usec Tbp = 5.12msec programming time
//+ cpu operations that can't be hid behind flash wait time
//another thought would be to call usbPoll mid programming
//a few times to prevent incoming data from being delayed too long
update_buffers();
}
}

334
firmware/source/old/usb.c Normal file
View File

@ -0,0 +1,334 @@
#include "usb.h"
//used to store success/error code of last transfer for debugging
static uint8_t usbWrite_status;
//USB_PUBLIC usbMsgLen_t 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 USB_NO_MSG 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 USB_NO_MSG 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.
*/
//typedef struct usbRequest{
// uchar bmRequestType;
// uchar bRequest;
// usbWord_t wValue;
// usbWord_t wIndex;
// usbWord_t wLength;
//}usbRequest_t;
USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) {
//defined and controled by buffer.c
extern buffer *cur_usb_load_buff;
//cast incoming data into the the usb setup packet it is
setup_packet *spacket = (void *)data;
//8 Byte buffer to be used for returning error code and return values
//must be static so V-USB driver can still access after function return
static uint8_t rv[RETURN_BUFF_SIZE];
//rv[RV_ERR_IDX] contains opcode success/error code
//rv[1-7] available for return data, start with index 1
//rv[RETURN_BUFF_FIRST_IDX-RETURN_BUFFER_LAST_IDX]
/* (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 USB_NO_MSG in 'usbFunctionSetup()'. The
* driver will then call 'usbFunctionRead()' when data is needed. See the
*/
//by default want to return some portion of the 8 byte rv "return value"
//buffer. If no return data requested from host rlen = 0, so this wouldn't matter
//Some dictionaries/opcodes that want to return larger buffers though
//this function will set usbMsgPtr to point to that larger buffer when supported
//avr-gcc doesn't like this and gives warning
//source/usb.c:64: warning: assignment makes integer from pointer without a cast
//tried casting it to usbMsgPtr
usbMsgPtr = (usbMsgPtr_t)rv;
//#if USB_CFG_LONG_TRANSFERS
// //number of bytes to return to host
// //16bit meets max possible 16KBytes with V-USB long transfers enabled
//uint16_t rlen = 0; //the speed loss doesn't make long transfers worth it for now
//#else
// //8bit is enough for 254 bit non-long xfrs
// //also gives ~0.7KBps speed up compared to 16bit rlen
uint8_t rlen = 0;
//#endif
//determine endpoint IN/OUT
if ( (spacket->bmRequestType & ENDPOINT_BIT) == ENDPOINT_IN ) {
//read from device request
//send error code and return value
rlen = 1; //min value of error code
} else {
//write to device request
//host doesn't want to waste time with reading back error codes
rlen = 0;
//must also come here if opcode has payload coming in data packets to follow
//in that case host would have to send follow up read request to get error code
}
switch(spacket->bRequest) {
case DICT_PINPORT:
switch (spacket->opcode) {
case PP_OPCODE_ONLY_MIN ... PP_OPCODE_ONLY_MAX:
rv[RV_ERR_IDX] = pinport_opcode_only( spacket->opcode );
break;
case PP_OPCODE_8BOP_MIN ... PP_OPCODE_8BOP_MAX:
rv[RV_ERR_IDX] = pinport_opcode_8b_operand(
spacket->opcode, spacket->operandLSB );
break;
case PP_OPCODE_16BOP_MIN ... PP_OPCODE_16BOP_MAX:
rv[RV_ERR_IDX] = pinport_opcode_16b_operand(
spacket->opcode, spacket->operandMSB, spacket->operandLSB );
break;
case PP_OPCODE_24BOP_MIN ... PP_OPCODE_24BOP_MAX:
rv[RV_ERR_IDX] = pinport_opcode_24b_operand( spacket->opcode,
spacket->miscdata, spacket->operandMSB, spacket->operandLSB );
break;
case PP_OPCODE_8BRV_MIN ... PP_OPCODE_8BRV_MAX:
rv[RV_ERR_IDX] = pinport_opcode_8b_return( spacket->opcode, &rv[RV_DATA0_IDX]);
rlen ++;
break;
default: //pinport opcode min/max definition error
rv[RV_ERR_IDX] = ERR_BAD_PP_OP_MINMAX;
}
break; //end of PINPORT
case DICT_IO:
switch (spacket->opcode) {
case IO_OPCODE_ONLY_MIN ... IO_OPCODE_ONLY_MAX:
rv[RV_ERR_IDX] = io_opcode_only( spacket->opcode );
break;
case IO_OPCODE_RTN_MIN ... IO_OPCODE_RTN_MAX:
rv[RV_ERR_IDX] = io_opcode_return(
spacket->opcode, &rv[RV_DATA0_IDX] );
rlen = 8;
break;
default: //io opcode min/max definition error
rv[RV_ERR_IDX] = ERR_BAD_IO_OP_MINMAX;
}
break; //end of IO
case DICT_NES:
switch (spacket->opcode) {
case NES_OPCODE_24BOP_MIN ... NES_OPCODE_24BOP_MAX:
rv[RV_ERR_IDX] = nes_opcode_24b_operand( spacket->opcode,
spacket->operandMSB, spacket->operandLSB, spacket->miscdata );
break;
case NES_OPCODE_16BOP_8BRV_MIN ... NES_OPCODE_16BOP_8BRV_MAX:
rv[RV_ERR_IDX] = nes_opcode_16b_operand_8b_return( spacket->opcode,
spacket->operandMSB, spacket->operandLSB, &rv[RV_DATA0_IDX]);
rlen++;
break;
default: //nes opcode min/max definition error
rv[RV_ERR_IDX] = ERR_BAD_NES_OP_MINMAX;
}
break; //end of NES
case DICT_SNES:
switch (spacket->opcode) {
case SNES_OPCODE_24BOP_MIN ... SNES_OPCODE_24BOP_MAX:
rv[RV_ERR_IDX] = snes_opcode_24b_operand( spacket->opcode,
spacket->operandMSB, spacket->operandLSB, spacket->miscdata );
break;
case SNES_OPCODE_24BOP_8BRV_MIN ... SNES_OPCODE_24BOP_8BRV_MAX:
rv[RV_ERR_IDX] = snes_opcode_24b_operand_8b_return( spacket->opcode,
spacket->miscdata, spacket->operandMSB, spacket->operandLSB, &rv[RV_DATA0_IDX]);
rlen++;
break;
default: //snes opcode min/max definition error
rv[RV_ERR_IDX] = ERR_BAD_SNES_OP_MINMAX;
}
break; //end of SNES
case DICT_BUFFER:
//just give buffer.c the setup packet and let it figure things out for itself
usbMsgPtr = (usbMsgPtr_t)buffer_usb_call( spacket, rv, &rlen );
break; //end of BUFFER
case DICT_USB:
//currently just a simple way to read back usbFunctionWrite status SUCCESS/ERROR
//if there are future status' to read back may have to create some functions
rv[RV_ERR_IDX] = SUCCESS;
rv[RV_DATA0_IDX] = usbWrite_status;
rv[RV_DATA0_IDX+1] = cur_usb_load_buff->last_idx;
rlen = 3;
break; //end of USB
case DICT_OPER:
//just give operation.c the setup packet and let it figure things out for itself
usbMsgPtr = (usbMsgPtr_t)operation_usb_call( spacket, rv, &rlen );
break; //end of OPER
default:
//request (aka dictionary) is unknown
rv[RV_ERR_IDX] = ERR_UNKN_DICTIONARY;
}
//TODO add check that verifies rlen == setup packet return lenght request
//current state has error checking somewhat embeded in the fact the host
//will detect when return length differs from requested
return rlen;
//need to return USB_NO_MSG for OUT transfers to make usbFunctionWrite called
//return USB_NO_MSG; //if want usbFunctionRead called during IN token data packets
//Don't have a use for usbFunctionRead yet.. Not expecting to anytime soon
//probably easier and perhaps faster to send cart dump commands and store rom image
//in a buffer to be returned here.
}
//USB_PUBLIC 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). 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()..
*/
//USB_PUBLIC uchar usbFunctionRead(uchar *data, uchar len) {
// //this function should only get called if usbFunctionSetup returns USB_NO_MSG
// return len;
//}
// V-USB description of this function:
//USB_PUBLIC 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. 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()..
*/
/* Desc:USB Write routine for OUT transfers
* the V-USB drivers call this function on OUT tokens
* and provide upto 8 byte data packet's payload
* for payloads longer than 8Bytes this gets called multiple times
* until all bytes have been transferred. Real thing to understand
* is that this function gets called once per data packet (max 8bytes)
* based on USB 1.1 low speed standard.
* buffer.c is the govnerning module for what buffer gets filled
* Pre: buffer.c must have set current usb loading buffer with global var
* the current buffer must have enough room for incoming data
* possible to use mutliple buffers for a single transfer, but
* buffer.c must orchestrate the swap to new buffer object.
* buffer.c sets global incoming bytes remain so it can keep
* track of this function's progress
* buffer object must be initialized, allocated, and status USB_LOADING
* Post:usbWrite_status updated with SUCCESS/ERROR number
* incoming data packet copied to cur_usb_load_buff
* global incoming_bytes_remain updated
* cur_usb_load_buff cur_byte updated based on data length
* cur_usb_load_buff status updated when it's full
* Rtn: message to V-USB driver so it can respond to host
*/
//removing checks from this function speeds up transfers by ~1KBps
//this data is based on doing nothing with data once it arrives
//long transfers disabled, and using 254 byte transfers with 2 bytes stuffed in setup packet
// with checks: 512KByte = 18.7sec = 27.4KBps
// w/o checks: 512KByte = 17.9sec = 28.5KBps
// w/o checks: using 8bit rlen = 17.5sec = 29.2KBps
// with checks: using 8bit rlen = 18sec = 28.3KBps
//#define MAKECHECKS 0
USB_PUBLIC uchar usbFunctionWrite(uchar *data, uchar len) {
//defined and controled by buffer.c
extern buffer *cur_usb_load_buff;
extern uint8_t incoming_bytes_remain;
uint8_t data_cur = 0; //current incoming byte to copy
uint8_t buf_cur = cur_usb_load_buff->cur_byte; //current buffer byte
uint8_t *buf_data = cur_usb_load_buff->data; //current buffer data array
#ifdef MAKECHECKS
//check that current buffer's status is USB_LOADING
if (cur_usb_load_buff->status != USB_LOADING) {
usbWrite_status = ERR_OUT_CURLDBUF_STATUS;
return STALL;
}
//check that current buffer's has enough room
if ( ((cur_usb_load_buff->last_idx) + 1 - buf_cur) < len ) {
usbWrite_status = ERR_OUT_CURLDBUF_TO_SMALL;
return STALL;
}
#endif
//copy 1-8bytes of payload into buffer
while ( data_cur < len ) {
buf_data[buf_cur] = data[data_cur];
buf_cur++;
data_cur++;
}
#ifdef MAKECHECKS
//need to account for the fact that cur_byte will roll over being 8bit value
if ( cur_usb_load_buff->last_idx == (cur_usb_load_buff->cur_byte + len - 1) ) {
//this signals to buffer.c so it can update cur_usb_load_buf
//and start tasking this buffer to programming
cur_usb_load_buff->status = USB_FULL;
}
#endif
//update counters and status
cur_usb_load_buff->cur_byte += len;
incoming_bytes_remain -= len;
//usbWrite_status = SUCCESS;
//want this function to be as fast as possible, so buffer.c checks if
//the buffer is full 'behind the scenes' outside of this function.
if ( incoming_bytes_remain == 0 ) { //done with OUT transfer
//alternate to MAKECHECKS should be faster but require transfer sizes to match buffer size
cur_usb_load_buff->status = USB_FULL;
return PAYLD_DONE;
} else { //more data packets remain to complete OUT transfer
return NOT_DONE;
}
}

31
firmware/source/old/usb.h Normal file
View File

@ -0,0 +1,31 @@
#ifndef _usb_h
#define _usb_h
#include <avr/io.h>
#include "usbdrv.h"
#include "logic.h"
#include "types.h"
#include "shared_dictionaries.h"
#include "shared_errors.h"
#include "pinport.h"
#include "io.h"
#include "nes.h"
#include "snes.h"
#include "buffer.h"
#define ENDPOINT_BIT 0x80 //Bit 7 of bmRequest type determines endpoint
#define ENDPOINT_IN 0x80 //In: device-to-host.
#define ENDPOINT_OUT 0x00 //Out: host-to-device.
//usbFunctionWrite return values
//return 0xFF (-1) "STALL" if error
//return 1 if entire payload received successfully
//return 0 if more data expected to complete transfer
#define STALL 0xFF
#define PAYLD_DONE 1
#define NOT_DONE 0
#endif

View File

@ -45,17 +45,17 @@ static uint8_t usbWrite_status;
USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) { USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) {
//defined and controled by buffer.c //defined and controled by buffer.c
extern buffer *cur_usb_load_buff; // extern buffer *cur_usb_load_buff;
//
//cast incoming data into the the usb setup packet it is // //cast incoming data into the the usb setup packet it is
setup_packet *spacket = (void *)data; // setup_packet *spacket = (void *)data;
//
//8 Byte buffer to be used for returning error code and return values // //8 Byte buffer to be used for returning error code and return values
//must be static so V-USB driver can still access after function return // //must be static so V-USB driver can still access after function return
static uint8_t rv[RETURN_BUFF_SIZE]; // static uint8_t rv[RETURN_BUFF_SIZE];
//rv[RV_ERR_IDX] contains opcode success/error code // //rv[RV_ERR_IDX] contains opcode success/error code
//rv[1-7] available for return data, start with index 1 // //rv[1-7] available for return data, start with index 1
//rv[RETURN_BUFF_FIRST_IDX-RETURN_BUFFER_LAST_IDX] // //rv[RETURN_BUFF_FIRST_IDX-RETURN_BUFFER_LAST_IDX]
/* (1) Set the global pointer 'usbMsgPtr' to the base of the static RAM 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 * block and return the length of the data in 'usbFunctionSetup()'. The driver
@ -69,7 +69,7 @@ USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) {
//avr-gcc doesn't like this and gives warning //avr-gcc doesn't like this and gives warning
//source/usb.c:64: warning: assignment makes integer from pointer without a cast //source/usb.c:64: warning: assignment makes integer from pointer without a cast
//tried casting it to usbMsgPtr //tried casting it to usbMsgPtr
usbMsgPtr = (usbMsgPtr_t)rv; // usbMsgPtr = (usbMsgPtr_t)rv;
//#if USB_CFG_LONG_TRANSFERS //#if USB_CFG_LONG_TRANSFERS
// //number of bytes to return to host // //number of bytes to return to host
@ -81,6 +81,7 @@ USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) {
uint8_t rlen = 0; uint8_t rlen = 0;
//#endif //#endif
/*
//determine endpoint IN/OUT //determine endpoint IN/OUT
if ( (spacket->bmRequestType & ENDPOINT_BIT) == ENDPOINT_IN ) { if ( (spacket->bmRequestType & ENDPOINT_BIT) == ENDPOINT_IN ) {
//read from device request //read from device request
@ -192,6 +193,7 @@ USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) {
//request (aka dictionary) is unknown //request (aka dictionary) is unknown
rv[RV_ERR_IDX] = ERR_UNKN_DICTIONARY; rv[RV_ERR_IDX] = ERR_UNKN_DICTIONARY;
} }
*/
//TODO add check that verifies rlen == setup packet return lenght request //TODO add check that verifies rlen == setup packet return lenght request
//current state has error checking somewhat embeded in the fact the host //current state has error checking somewhat embeded in the fact the host
@ -275,6 +277,7 @@ USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) {
USB_PUBLIC uchar usbFunctionWrite(uchar *data, uchar len) { USB_PUBLIC uchar usbFunctionWrite(uchar *data, uchar len) {
/*
//defined and controled by buffer.c //defined and controled by buffer.c
extern buffer *cur_usb_load_buff; extern buffer *cur_usb_load_buff;
extern uint8_t incoming_bytes_remain; extern uint8_t incoming_bytes_remain;
@ -330,5 +333,8 @@ USB_PUBLIC uchar usbFunctionWrite(uchar *data, uchar len) {
return NOT_DONE; return NOT_DONE;
} }
*/
return 0;
} }

View File

@ -4,6 +4,7 @@
#include <avr/io.h> #include <avr/io.h>
#include "usbdrv.h" #include "usbdrv.h"
/*
#include "logic.h" #include "logic.h"
#include "types.h" #include "types.h"
#include "shared_dictionaries.h" #include "shared_dictionaries.h"
@ -13,6 +14,7 @@
#include "nes.h" #include "nes.h"
#include "snes.h" #include "snes.h"
#include "buffer.h" #include "buffer.h"
*/
#define ENDPOINT_BIT 0x80 //Bit 7 of bmRequest type determines endpoint #define ENDPOINT_BIT 0x80 //Bit 7 of bmRequest type determines endpoint
#define ENDPOINT_IN 0x80 //In: device-to-host. #define ENDPOINT_IN 0x80 //In: device-to-host.