Subversion Repositories svnkaklik

Compare Revisions

No changes between revisions

Ignore whitespace Rev 134 → Rev 151

/programy/Atmel_C/AVRcam/AVRcam.elf
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes:
Added: svn:mime-type
+application/octet-stream
\ No newline at end of property
/programy/Atmel_C/AVRcam/AVRcam.hex
0,0 → 1,268
:1000000063C0EAC7EAC77AC079C078C077C076C053
:10001000E5C774C073C0A8C571C070C06FC06EC0A2
:100020006DC013C66BC02AC693C692C691C690C651
:100030008FC68EC68DC622C68BC68AC689C688C69E
:1000400087C686C685C62AC683C682C681C680C6BE
:100050007FC67EC67DC625C67BC67AC679C678C6EB
:1000600077C676C675C625C673C672C671C670C613
:100070006FC66EC66DC664C66BC66AC669C668C6FC
:1000800067C666C665C664C663C662C661C660C624
:100090005FC65EC65DC623C65BC65AC659C658C68D
:1000A00057C656C655C6FDC553C652C651C650C6DC
:1000B0004FC64EC64DC61FC64BC64AC649C648C6E1
:1000C00047C646C645C636C611241FBECFE5D4E096
:1000D000DEBFCDBF10E0A0E6B0E0EEE9F0E102C087
:1000E00005900D92A037B107D9F712E0A0E7B0E074
:1000F00001C01D92A43EB107E1F731C076C78F9AC7
:100100008F9A8A98979890EF87B3892387BB87B394
:10011000892B87BB84B3892384BB8EB5887F8EBD32
:1001200085B78C6085BF85B7836085BF8BB78064DA
:100130008BBF86E083BF85B78F7885BF85B7806822
:1001400085BF80E093E020E3FC0111922A95E9F756
:1001500040E350E061E070E07DD708950895CFE579
:10016000D4E0DEBFCDBFAAD6F1D42CD5C8DF7894B9
:10017000FAD594D27FD088EE93E065D603D080E0A4
:1001800090E08CC7CF93809172008823B9F080FFF4
:1001900009C0F894809172008E7F809372007894E9
:1001A000F8D0ACD28091720081FF08C0F8948091A1
:1001B00072008D7F809372007894B9D09091700016
:1001C000809171009817F9F232D0C82F99278031A9
:1001D000910511F1813191057CF48230910509F18D
:1001E000833091051CF40197D1F0CDCF8430910577
:1001F000C1F00897B1F0C7CF8038910591F08138F0
:1002000091051CF4809769F0BECF8138910549F0C3
:100210008039910549F0B7CF8C2F33D005C08C2F92
:1002200058D28C2F2ED0AFCF8C2F53D2ACCFF89486
:10023000209171008CE692E0FC01E20FF11D9081AB
:10024000822F8F5F8770809371007894892F992710
:100250000895382FF894209170008CE692E0FC010C
:10026000E20FF11D3083822F8F5F877080937000C3
:100270007894089580E4E8E7F0E011928A95E9F730
:10028000089599278430910551F18530910534F412
:100290008130910531F1029771F008958038910510
:1002A000C1F0813891051CF48097B9F00895813828
:1002B0009105F1F0089561E081E166D56AD588EE97
:1002C00093E0C1D51092730082E0809374002FD028
:1002D000089581E08093740002C018D108950CD075
:1002E000089580917400882329F084E0B2DF089596
:1002F0001092740008950895809174008130A9F4DB
:1003000010927700809175008093760010927500AE
:1003100080E4E8E7F0E011928A95E9F7829BFECF4E
:1003200060E073E08CEB91E0F0D508950895809142
:100330007400823011F580917300880F90EBECEB24
:10034000F1E011929A95E9F790EBECE0F1E011926F
:100350009A95E9F7829BFECF8299FECF882339F0E8
:10036000849BFECF81508499FECF8823C9F76CE02F
:1003700071E08CEB91E010D608958091740081308B
:1003800039F48499FECF60E073E08CEB91E0BDD549
:100390000895DF92EF92FF920F931F93CF93DF9315
:1003A000CDB7DEB721970FB6F894DEBF0FBECDBF35
:1003B000009160001091610080917400823009F01A
:1003C00054C08BE0CDD380917300CAD3DD242D2D92
:1003D00033270F2EFCEBEF2EF1E0FF2EF02DE20E77
:1003E000F31EF7018081898389818F7089838981D8
:1003F0008295807F89838901045F1E4FF801808187
:10040000982F9F708981892B89838981A9D3F801CD
:100410008181898389818F70898389818295807F99
:100420008983F7018181982F9F708981892B898326
:10043000898196D3F2E0DF0E4FEA4D1540F68FE04A
:100440008FD3809173008F5F80937300883408F49A
:100450004AC0109273001092740089B78B7F89BFD5
:1004600060E081E191D495D443C0809174008130E3
:1004700009F03EC0A1D080917700992787709070D5
:10048000079711F5DD24F80187818130B9F4868161
:10049000282F33278481A901481B51094330510576
:1004A0006CF4809177009927821B930B039734F0AB
:1004B000178280917500815080937500085F1F4FEF
:1004C000D39457E05D15F8F6809177008F5F8093A5
:1004D0007700803941F480E2BCDE89B78B7F89BF29
:1004E0001092770005C08091720082608093720044
:1004F00021960FB6F894DEBF0FBECDBFDF91CF912E
:100500001F910F91FF90EF90DF900895DF92EF928F
:10051000FF920F931F93CF93DF93809175008823F1
:1005200009F440C08AE001D3C0916000D09161001D
:1005300080917500FAD2DD248F81813061F580E0F1
:1005400098819038D9F0903411F481E017C090323E
:1005500011F482E013C0903111F483E00FC09830A1
:1005600011F484E00BC0943011F485E007C09230A0
:1005700011F486E003C0913009F487E01B810C81FF
:10058000FD80EE80D2D2812FD0D2802FCED28F2D7F
:10059000CCD28E2DCAD22896D39487E08D1560F6E2
:1005A0008FEFC3D284E055DEDF91CF911F910F9181
:1005B000FF90EF90DF9008951F93CF93ACEBB1E0E5
:1005C00060E0C62F71E010E05D91C70F7D91670F6D
:1005D000552309F45DC0743008F45AC0E0916000FE
:1005E000F0916100412F8081581751F5878181304A
:1005F00039F58681282F3327809177009927019735
:1006000028173907E9F481819281C81710F09C17E7
:1006100040F4681710F0961720F48C1788F06917CB
:1006200078F0C18362838381C81708F4C38385810E
:10063000861708F4658380917700868311E004C0F3
:1006400038964F5F483078F2112311F5809175008C
:100650008830F0F4E0916000F0916100412F8781D3
:10066000882321F038964F5F4830C8F35083C18308
:100670006283C38380917700848365838091770050
:10068000868381E08783809175008F5F80937500FA
:10069000603B08F498CFCF911F9108951092BF004E
:1006A0001092C0001092C1001092C20080E4E3ECEE
:1006B000F0E011928A95E9F780E4E4E9F2E0119222
:1006C0008A95E9F780E2E4E7F2E011928A95E9F78A
:1006D000089599278031910551F0813191051CF4DD
:1006E000019739F008958039910529F0089506D0D1
:1006F00008950ED00895E6D1089508959091BA0016
:100700008091BB00981711F0FED12AD20895089568
:10071000CF939091B8008091B900981709F46FC0F9
:10072000C9E0DFD1382F8D3029F58091BE008823B4
:1007300011F42CD106C002D18091BE008F5F80934E
:10074000BE0084E690E07FD38091620088508230C2
:1007500020F484D180E97DDD04C077D180E979DDA2
:1007600051D01092BE0080E4E3ECF0E011928A9543
:10077000E9F73EC08032D9F48091BE00882311F49D
:1007800005D10FC08091BE00992701968034910554
:100790003CF01092BC001092BD001092BE0026C02A
:1007A000CDD08091BE008F5F8093BE0021C0815468
:1007B0008A3118F08F5E8A30C8F42091BD00822FF4
:1007C0009927FC01E154FF4F30838091BC00982FA2
:1007D0009F5F9093BC00822F8F5F8093BD00943009
:1007E00038F0C09362001092BD0002C0C093620056
:1007F0009091B8008091B900981709F092CFE894D1
:10080000CF910895DF92EF92FF920F931F93CF93B2
:10081000DF93EE2480916200813009F487C0882341
:1008200069F4C3E6D0E080916300882309F47EC0B8
:1008300089917BD188818823D9F778C08091620023
:10084000873011F48BDC72C080916200833029F410
:1008500084E690E0F8D282E028C080916200823085
:10086000B1F4FF24F3948091BE00F81670F48F2D3C
:100870009927FC01ED53FF4F6181808185D282E091
:10088000F80E8091BE00F81690F383D24FC080918D
:100890006200843029F484E690E0D5D280E805C077
:1008A00080916200853019F481E8D3DC3FC08091EB
:1008B00062008630D9F5FF248091BE00F816B0F5AD
:1008C0008F2D99278C0100501D4FFC01ED53FF4FD8
:1008D0002181F80120830196B5D3982FF8018081FA
:1008E0009817F9F0DD24F2E0FE15D0F08F2D99274E
:1008F0008C0100501D4FEC012196F8016081CE0162
:10090000BAD3E394CE019ED3982FF8018081981733
:1009100011F4DD24D394DD2019F4F2E0FE1568F71C
:10092000EE24F3948091BE00F81650F2DF91CF913F
:100930001F910F91FF90EF90DF9008958FEB90E063
:1009400055D3AC018F3F910571F068F089E0809339
:1009500062002091BE0083EC90E0FC01E20FF11DEB
:100960008FEF808308C08091BE0023EC30E0F90156
:10097000E80FF11D408383E0EFEBF0E011928A95E0
:10098000E9F71092BD001092BC0008958091BF005D
:10099000803531F48091C000873411F481E048C083
:1009A0008091BF00873439F48091C000863519F4F6
:1009B000109262003FC08091BF00843431F4809176
:1009C000C000863411F483E033C08091BF008334CB
:1009D00031F48091C000823511F482E029C0809109
:1009E000BF00853431F48091C000843511F484E077
:1009F0001FC08091BF00833531F48091C0008D34D9
:100A000011F486E015C08091BF00843431F48091E8
:100A1000C000843511F485E00BC08091BF008235A1
:100A200031F48091C000833511F487E001C089E082
:100A30008093620083E0EFEBF0E011928A95E9F792
:100A40001092BD001092BC00089581E46ED083E442
:100A50006CD08BE46AD08DE068D008958EE465D0C8
:100A600083E463D08BE461D08DE05FD00895DC0136
:100A70006623A9F0F89461506F3F81F024E932E0D9
:100A80009091BA00F901E90FF11D8D918083892FB2
:100A90008F5F8F738093BA00615090F778940895B8
:100AA0000F931F93CF938C01C62FC150CF3F31F0CE
:100AB000F80181918F0154D0C150D0F7CF911F918F
:100AC0000F9108959091BA008091BB00981741F062
:100AD0001AD046D09091BA008091BB009817C1F708
:100AE0000895F8942091B90084E792E0FC01E20FA8
:100AF000F11D9081822F8F5F8F718093B900789460
:100B0000892F99270895F8942091BB0084E992E0F9
:100B1000FC01E20FF11D9081822F8F5F8F73809314
:100B2000BB007894892F99270895382FF894209145
:100B3000BA0084E992E0FC01E20FF11D3083822FBC
:100B40008F5F8F738093BA007894089510BC82E110
:100B500089B988E98AB986E880BD82E08BB90895B1
:100B60005D9BFECF8CB908951F920F920FB60F9226
:100B700011242F938F939F93EF93FF932091B800AD
:100B800084E792E0FC01E20FF11D8CB180832F5FBE
:100B90002F712093B800209170008CE692E0FC0148
:100BA000E20FF11D81E08083280F277020937000F1
:100BB000FF91EF919F918F912F910F900FBE0F900A
:100BC0001F90189511B888E480B90895982F8091E6
:100BD00008018823E4F306B604FCFDCF90930301DB
:100BE0007093050160930401409307011092060180
:100BF0001092090185EA86BF809108018068809380
:100C000008010895982F809108018823E4F39093B8
:100C1000030170930501609304014093070181E093
:100C2000809306011092090185EA86BF8091080130
:100C3000806880930801089590E0809108018823DE
:100C40000CF491E0892F992708951F920F920FB607
:100C50000F9211248F939F93AF93BF93EF93FF93C2
:100C600081B1887F9927AA27BB27FC013897E135F6
:100C7000F10508F06DC0ED5EFF4F09948091090108
:100C8000833008F05DC080910301982F990F809107
:100C90000601890F83B986B78F7D4AC0109209017A
:100CA00011C0809109018F5F8093090186B7806B25
:100CB0003FC0809107018150809307018091070117
:100CC0008823F1F1E0910401F0910501808183B95D
:100CD000CF010196909305018093040109C0809192
:100CE0000701815080930701809107018823D9F47F
:100CF00086B780681DC0E0910401F091050183B1C1
:100D000080838091040190910501019690930501E3
:100D100080930401809107018150809307018091A5
:100D20000701882319F086B7806C02C086B78F7BD5
:100D300086BF0EC0E0910401F091050183B180836C
:100D400086B7806986BF809108018F7780930801FC
:100D5000FF91EF91BF91AF919F918F910F900FBE37
:100D60000F901F90189560E284E10ED060E489E353
:100D70000BD068E282E108D065E088E205D061E04E
:100D800083E102D006D00895282F362FC9012FD035
:100D90000895CF93DF93CDB7DEB722970FB6F894BF
:100DA000DEBF0FBECDBF90910A0180910B01981755
:100DB000A9F037D089839A8342E0BE016F5F7F4FED
:100DC00080E604DF84E690E03ED036DF8130E9F350
:100DD00090910A0180910B01981759F722960FB64E
:100DE000F894DEBF0FBECDBFDF91CF9108959C0177
:100DF00051E040910A01842F9927880F991FFC0127
:100E0000EC52FD4F20833183842F850F87708093B0
:100E10000A0190910B01891709F450E0852F992759
:100E2000089540910B01842F9927880F991FFC0189
:100E3000EC52FD4F20813181842F8F5F877080932A
:100E40000B01C9010895CF93DF93CDB7DEB7249787
:100E50000FB6F894DEBF0FBECDBF9C0119821A8277
:100E60001B821C8219821A8289819A8182179307B8
:100E7000E0F41B821C828B819C81885E934058F435
:100E800000008B819C8101968B839C838B819C814C
:100E9000885E9340A8F389819A81019689839A8319
:100EA00089819A818217930720F324960FB6F894CC
:100EB000DEBF0FBECDBFDF91CF9108951F938E9AF5
:100EC000969A84EF91E0BFDF1FEB82B3812382BB50
:100ED00084EF91E0B8DF969A84EF91E0B4DF82B3BB
:100EE000812382BB84EF91E0AEDF969A84EF91E09C
:100EF000AADF82B3812382BB84EF91E0A4DF969ABC
:100F00001F910895969A96988895E6F13EB53760B8
:100F10003EBD00E010E520E0B92FA82FF72FE62F07
:100F2000D72F39B7346039BF30E54FEF4DBD3CBDE9
:100F3000C62F3BB730683BBF969A889596983BB7CB
:100F40003F773BBF00000000E6B3C3B3CF703081F2
:100F5000E6B3488950A13423352376F03217A1F344
:100F6000969A00009698412F0CB5102F041B2D93D4
:100F70000D93232F0000E8CF0FEF011B03953D9346
:100F80000C9300C03EB5387F3EBD969A9698E89483
:100F90000895969A96988895AEF3B92FA82FD72FD3
:100FA000C62F30E54FEF4DBD3CBD3EB537603EBD71
:100FB000000039B7346039BF3BB730683BBF969A01
:100FC000889596983BB73F773BBF000033B346B355
:100FD0003D934993DEF7D6CF18951895309172005E
:100FE000316030937200689418951895FC01882739
:100FF0009927E89421912223E9F02032D9F329306E
:10100000C9F32A30B9F32C30A9F32D3099F32637E0
:1010100089F32B3219F02D3221F468942191222387
:1010200049F020333CF02A332CF420532FD0820F88
:10103000911DF4CF8115910521F01EF480959095B6
:1010400001960895E199FECF9FBB8EBBE09A992748
:101050008DB308954115510569F0DC01E199FECF8A
:101060007FBB6EBBE09A6F5F7F4F0DB20D92415018
:101070005040B1F70895E199FECF9FBB8EBB6DBB89
:101080000FB6F894E29AE19A0FBE08957AE0979F1E
:0E109000902D879F802D910D11240895FFCF84
:10109E0078000841565263616D2076312E340D0072
:00000001FF
/programy/Atmel_C/AVRcam/AVRcam.lss
0,0 → 1,4253
 
AVRcam.elf: file format elf32-avr
 
Sections:
Idx Name Size VMA LMA File off Algn
0 .noinit 00000030 00800300 00800300 00001162 2**0
ALLOC
1 .bss 00000274 00800070 00800070 00001162 2**0
ALLOC
2 .data 00000010 00800060 0000109e 00001152 2**0
CONTENTS, ALLOC, LOAD, DATA
3 .text 0000109e 00000000 00000000 000000b4 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
4 .eeprom 00000000 00810000 00810000 00001162 2**0
CONTENTS
5 .stab 00003f30 00000000 00000000 00001164 2**2
CONTENTS, READONLY, DEBUGGING
6 .stabstr 0000181e 00000000 00000000 00005094 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
 
00000000 <__vectors>:
0: 63 c0 rjmp .+198 ; 0xc8
2: ea c7 rjmp .+4052 ; 0xfd8
4: ea c7 rjmp .+4052 ; 0xfda
6: 7a c0 rjmp .+244 ; 0xfc
8: 79 c0 rjmp .+242 ; 0xfc
a: 78 c0 rjmp .+240 ; 0xfc
c: 77 c0 rjmp .+238 ; 0xfc
e: 76 c0 rjmp .+236 ; 0xfc
10: e5 c7 rjmp .+4042 ; 0xfdc
12: 74 c0 rjmp .+232 ; 0xfc
14: 73 c0 rjmp .+230 ; 0xfc
16: a8 c5 rjmp .+2896 ; 0xb68
18: 71 c0 rjmp .+226 ; 0xfc
1a: 70 c0 rjmp .+224 ; 0xfc
1c: 6f c0 rjmp .+222 ; 0xfc
1e: 6e c0 rjmp .+220 ; 0xfc
20: 6d c0 rjmp .+218 ; 0xfc
22: 13 c6 rjmp .+3110 ; 0xc4a
24: 6b c0 rjmp .+214 ; 0xfc
 
00000026 <__ctors_end>:
26: 2a c6 rjmp .+3156 ; 0xc7c
28: 93 c6 rjmp .+3366 ; 0xd50
2a: 92 c6 rjmp .+3364 ; 0xd50
2c: 91 c6 rjmp .+3362 ; 0xd50
2e: 90 c6 rjmp .+3360 ; 0xd50
30: 8f c6 rjmp .+3358 ; 0xd50
32: 8e c6 rjmp .+3356 ; 0xd50
34: 8d c6 rjmp .+3354 ; 0xd50
36: 22 c6 rjmp .+3140 ; 0xc7c
38: 8b c6 rjmp .+3350 ; 0xd50
3a: 8a c6 rjmp .+3348 ; 0xd50
3c: 89 c6 rjmp .+3346 ; 0xd50
3e: 88 c6 rjmp .+3344 ; 0xd50
40: 87 c6 rjmp .+3342 ; 0xd50
42: 86 c6 rjmp .+3340 ; 0xd50
44: 85 c6 rjmp .+3338 ; 0xd50
46: 2a c6 rjmp .+3156 ; 0xc9c
48: 83 c6 rjmp .+3334 ; 0xd50
4a: 82 c6 rjmp .+3332 ; 0xd50
4c: 81 c6 rjmp .+3330 ; 0xd50
4e: 80 c6 rjmp .+3328 ; 0xd50
50: 7f c6 rjmp .+3326 ; 0xd50
52: 7e c6 rjmp .+3324 ; 0xd50
54: 7d c6 rjmp .+3322 ; 0xd50
56: 25 c6 rjmp .+3146 ; 0xca2
58: 7b c6 rjmp .+3318 ; 0xd50
5a: 7a c6 rjmp .+3316 ; 0xd50
5c: 79 c6 rjmp .+3314 ; 0xd50
5e: 78 c6 rjmp .+3312 ; 0xd50
60: 77 c6 rjmp .+3310 ; 0xd50
62: 76 c6 rjmp .+3308 ; 0xd50
64: 75 c6 rjmp .+3306 ; 0xd50
66: 25 c6 rjmp .+3146 ; 0xcb2
68: 73 c6 rjmp .+3302 ; 0xd50
6a: 72 c6 rjmp .+3300 ; 0xd50
6c: 71 c6 rjmp .+3298 ; 0xd50
6e: 70 c6 rjmp .+3296 ; 0xd50
70: 6f c6 rjmp .+3294 ; 0xd50
72: 6e c6 rjmp .+3292 ; 0xd50
74: 6d c6 rjmp .+3290 ; 0xd50
76: 64 c6 rjmp .+3272 ; 0xd40
78: 6b c6 rjmp .+3286 ; 0xd50
7a: 6a c6 rjmp .+3284 ; 0xd50
7c: 69 c6 rjmp .+3282 ; 0xd50
7e: 68 c6 rjmp .+3280 ; 0xd50
80: 67 c6 rjmp .+3278 ; 0xd50
82: 66 c6 rjmp .+3276 ; 0xd50
84: 65 c6 rjmp .+3274 ; 0xd50
86: 64 c6 rjmp .+3272 ; 0xd50
88: 63 c6 rjmp .+3270 ; 0xd50
8a: 62 c6 rjmp .+3268 ; 0xd50
8c: 61 c6 rjmp .+3266 ; 0xd50
8e: 60 c6 rjmp .+3264 ; 0xd50
90: 5f c6 rjmp .+3262 ; 0xd50
92: 5e c6 rjmp .+3260 ; 0xd50
94: 5d c6 rjmp .+3258 ; 0xd50
96: 23 c6 rjmp .+3142 ; 0xcde
98: 5b c6 rjmp .+3254 ; 0xd50
9a: 5a c6 rjmp .+3252 ; 0xd50
9c: 59 c6 rjmp .+3250 ; 0xd50
9e: 58 c6 rjmp .+3248 ; 0xd50
a0: 57 c6 rjmp .+3246 ; 0xd50
a2: 56 c6 rjmp .+3244 ; 0xd50
a4: 55 c6 rjmp .+3242 ; 0xd50
a6: fd c5 rjmp .+3066 ; 0xca2
a8: 53 c6 rjmp .+3238 ; 0xd50
aa: 52 c6 rjmp .+3236 ; 0xd50
ac: 51 c6 rjmp .+3234 ; 0xd50
ae: 50 c6 rjmp .+3232 ; 0xd50
b0: 4f c6 rjmp .+3230 ; 0xd50
b2: 4e c6 rjmp .+3228 ; 0xd50
b4: 4d c6 rjmp .+3226 ; 0xd50
b6: 1f c6 rjmp .+3134 ; 0xcf6
b8: 4b c6 rjmp .+3222 ; 0xd50
ba: 4a c6 rjmp .+3220 ; 0xd50
bc: 49 c6 rjmp .+3218 ; 0xd50
be: 48 c6 rjmp .+3216 ; 0xd50
c0: 47 c6 rjmp .+3214 ; 0xd50
c2: 46 c6 rjmp .+3212 ; 0xd50
c4: 45 c6 rjmp .+3210 ; 0xd50
c6: 36 c6 rjmp .+3180 ; 0xd34
 
000000c8 <__init>:
c8: 11 24 eor r1, r1
ca: 1f be out 0x3f, r1 ; 63
cc: cf e5 ldi r28, 0x5F ; 95
ce: d4 e0 ldi r29, 0x04 ; 4
d0: de bf out 0x3e, r29 ; 62
d2: cd bf out 0x3d, r28 ; 61
 
000000d4 <__do_copy_data>:
d4: 10 e0 ldi r17, 0x00 ; 0
d6: a0 e6 ldi r26, 0x60 ; 96
d8: b0 e0 ldi r27, 0x00 ; 0
da: ee e9 ldi r30, 0x9E ; 158
dc: f0 e1 ldi r31, 0x10 ; 16
de: 02 c0 rjmp .+4 ; 0xe4
 
000000e0 <.do_copy_data_loop>:
e0: 05 90 lpm r0, Z+
e2: 0d 92 st X+, r0
 
000000e4 <.do_copy_data_start>:
e4: a0 37 cpi r26, 0x70 ; 112
e6: b1 07 cpc r27, r17
e8: d9 f7 brne .-10 ; 0xe0
 
000000ea <__do_clear_bss>:
ea: 12 e0 ldi r17, 0x02 ; 2
ec: a0 e7 ldi r26, 0x70 ; 112
ee: b0 e0 ldi r27, 0x00 ; 0
f0: 01 c0 rjmp .+2 ; 0xf4
 
000000f2 <.do_clear_bss_loop>:
f2: 1d 92 st X+, r1
 
000000f4 <.do_clear_bss_start>:
f4: a4 3e cpi r26, 0xE4 ; 228
f6: b1 07 cpc r27, r17
f8: e1 f7 brne .-8 ; 0xf2
fa: 31 c0 rjmp .+98 ; 0x15e
 
000000fc <__bad_interrupt>:
fc: 76 c7 rjmp .+3820 ; 0xfea
 
000000fe <CamInt_init>:
#endif
/* set up the mega8 ports that will be interfacing
with the camera */
CAM_CONTROL_PORT_DIR |= (1<<CAM_RESET_LINE); /* cam reset is output */
fe: 8f 9a sbi 0x11, 7 ; 17
CAM_CONTROL_PORT_DIR |= 0x80; /* set just the MSB as an output */
100: 8f 9a sbi 0x11, 7 ; 17
CAM_CONTROL_PORT_DIR &= 0xFB; /* make sure bit2 is clear (input) */
102: 8a 98 cbi 0x11, 2 ; 17
CAM_CONTROL_PORT &= 0x7F; /* set reset line low */
104: 97 98 cbi 0x12, 7 ; 18
CAM_G_BUS_DIR &= 0xF0; /* 4-bit G bus all inputs */
106: 90 ef ldi r25, 0xF0 ; 240
108: 87 b3 in r24, 0x17 ; 23
10a: 89 23 and r24, r25
10c: 87 bb out 0x17, r24 ; 23
CAM_G_BUS_DIR |= 0xF0; /* disable the pull-up on PB4 and PB5 */
10e: 87 b3 in r24, 0x17 ; 23
110: 89 2b or r24, r25
112: 87 bb out 0x17, r24 ; 23
CAM_RB_BUS_DIR &= 0xF0; /* 4-bit RB bus all inputs */
114: 84 b3 in r24, 0x14 ; 20
116: 89 23 and r24, r25
118: 84 bb out 0x14, r24 ; 20
/* ensure that timer1 is disabled to start...eventually, when PCLK needs
to feed timer1 through the external counter, it will be enabled on an
"as needed" basis...*/
TCCR1B &= ~( (1<<CS12)|(1<<CS11)|(1<<CS10) );
11a: 8e b5 in r24, 0x2e ; 46
11c: 88 7f andi r24, 0xF8 ; 248
11e: 8e bd out 0x2e, r24 ; 46
/* we'll turn on the interrupt after we assign the initial TCNT value */
/* set up External Interrupt1 to interrupt us on rising edges (HREF)...
this is needed to indicate when the first pixel of each line is about to start, so
we can synch up with it...this interrupt will be disabled once HREF goes high */
MCUCR |= (1<<ISC11) | (1<<ISC10); /* rising edge interrupt */
120: 85 b7 in r24, 0x35 ; 53
122: 8c 60 ori r24, 0x0C ; 12
124: 85 bf out 0x35, r24 ; 53
/* the interrupt will be enabled when we are ready to detect the rising edge of
HREF...its now primed and ready to go */
/* set up External Interrupt0 to interrupt us on rising edges (VSYNC) */
MCUCR |= (1<<ISC01) | (1<<ISC00); /* rising edge interrupt */
126: 85 b7 in r24, 0x35 ; 53
128: 83 60 ori r24, 0x03 ; 3
12a: 85 bf out 0x35, r24 ; 53
GICR |= (1<<INT0); /* interrupt request enabled */
12c: 8b b7 in r24, 0x3b ; 59
12e: 80 64 ori r24, 0x40 ; 64
130: 8b bf out 0x3b, r24 ; 59
/* set up TimerO to count and be clocked from an external pulse source
(HREF) on falling edges...eventually, we need to enable the interrupt
for this! FIX THIS */
TCCR0 = (1<<CS02)|(1<<CS01)|(0<<CS00);
132: 86 e0 ldi r24, 0x06 ; 6
134: 83 bf out 0x33, r24 ; 51
/* setting up the PCLK counter with Timer1 will be done right after
we start receiving pixels in each line...we sacrifice the first pixel
in each line, but we'll account for it...*/
/* set up the mega8 so that its sleep mode puts it in an IDLE sleep
mode, where it can wake up as fast as possible */
set_sleep_mode(SLEEP_MODE_IDLE);
136: 85 b7 in r24, 0x35 ; 53
138: 8f 78 andi r24, 0x8F ; 143
13a: 85 bf out 0x35, r24 ; 53
/* umm....we need to actually enable the sleep mode...*/
MCUCR |= 0x80;
13c: 85 b7 in r24, 0x35 ; 53
13e: 80 68 ori r24, 0x80 ; 128
140: 85 bf out 0x35, r24 ; 53
/* initialize the memLookup table */
memset(colorMap,0x00,NUM_ELEMENTS_IN_COLOR_MAP);
142: 80 e0 ldi r24, 0x00 ; 0
144: 93 e0 ldi r25, 0x03 ; 3
146: 20 e3 ldi r18, 0x30 ; 48
148: fc 01 movw r30, r24
14a: 11 92 st Z+, r1
14c: 2a 95 dec r18
14e: e9 f7 brne .-6 ; 0x14a
/* read the color map out of EEPROM */
eeprom_read_block(colorMap, (unsigned char*)0x01,NUM_ELEMENTS_IN_COLOR_MAP);
150: 40 e3 ldi r20, 0x30 ; 48
152: 50 e0 ldi r21, 0x00 ; 0
154: 61 e0 ldi r22, 0x01 ; 1
156: 70 e0 ldi r23, 0x00 ; 0
158: 7d d7 rcall .+3834 ; 0x1054
 
#if OUTPUT_INITIAL_COLOR_MAP
UIMgr_txBuffer("\r\n",2);
for (i=0; i<NUM_ELEMENTS_IN_COLOR_MAP; i++)
{
memset(asciiBuffer,0x00,5);
itoa(colorMap[i],asciiBuffer,10);
UIMgr_txBuffer(asciiBuffer,3);
UIMgr_txBuffer(" ",1);
if (i==15 || i == 31)
{
/* break up the output */
UIMgr_txBuffer("\r\n",2);
}
}
#endif
 
#ifndef NO_CRYSTAL
CamInt_resetCam();
#endif
}
15a: 08 95 ret
 
0000015c <CamInt_resetCam>:
 
/***********************************************************
Function Name: CamInt_resetCam
Function Description: This function is responsible
for resetting the camera. This is accomplished by
toggling the reset line on the OV6620 for ~100 mS.
Inputs: none
Outputs: none
IMPORTANT NOTE: This function has effectively been removed
since resetting the camera now causes the camera to not
output the clock signal. Thus, if we reset the cam, the
AVR has no clock, and thus doesn't run...
***********************************************************/
void CamInt_resetCam(void)
{
15c: 08 95 ret
 
0000015e <main>:
Inputs: none
Outputs: int
***********************************************************/
int main(void)
{
15e: cf e5 ldi r28, 0x5F ; 95
160: d4 e0 ldi r29, 0x04 ; 4
162: de bf out 0x3e, r29 ; 62
164: cd bf out 0x3d, r28 ; 61
/* initialize all of the interface modules */
DebugInt_init();
166: aa d6 rcall .+3412 ; 0xebc
UartInt_init();
168: f1 d4 rcall .+2530 ; 0xb4c
I2CInt_init();
16a: 2c d5 rcall .+2648 ; 0xbc4
CamInt_init();
16c: c8 df rcall .-112 ; 0xfe
/* initialize the remaining modules that will process
data...interrupts need to be on for these */
ENABLE_INTS();
16e: 78 94 sei
CamConfig_init();
170: fa d5 rcall .+3060 ; 0xd66
UIMgr_init();
172: 94 d2 rcall .+1320 ; 0x69c
FrameMgr_init();
174: 7f d0 rcall .+254 ; 0x274
/* provide a short delay for the camera to stabilize before
we let the executive start up */
Utility_delay(1000);
176: 88 ee ldi r24, 0xE8 ; 232
178: 93 e0 ldi r25, 0x03 ; 3
17a: 65 d6 rcall .+3274 ; 0xe46
/* the rest of the application will be under the
control of the Executive. */
Exec_run();
17c: 03 d0 rcall .+6 ; 0x184
/* this should never be reached */
return(0);
}
17e: 80 e0 ldi r24, 0x00 ; 0
180: 90 e0 ldi r25, 0x00 ; 0
182: 8c c7 rjmp .+3864 ; 0x109c
 
00000184 <Exec_run>:
Inputs: none
Outputs: none
***********************************************************/
void Exec_run(void)
{
184: cf 93 push r28
unsigned char eventGenerated;
while(1)
{
if (fastEventBitmask)
186: 80 91 72 00 lds r24, 0x0072
18a: 88 23 and r24, r24
18c: b9 f0 breq .+46 ; 0x1bc
{
/* an event needing fast processing has been received */
/* a received line needs to be processed...this
needs to be processed as quickly as possible */
if (fastEventBitmask & FEV_ACQUIRE_LINE_COMPLETE)
18e: 80 ff sbrs r24, 0
190: 09 c0 rjmp .+18 ; 0x1a4
{
DISABLE_INTS();
192: f8 94 cli
fastEventBitmask &= ~FEV_ACQUIRE_LINE_COMPLETE;
194: 80 91 72 00 lds r24, 0x0072
198: 8e 7f andi r24, 0xFE ; 254
19a: 80 93 72 00 sts 0x0072, r24
ENABLE_INTS();
19e: 78 94 sei
FrameMgr_processLine();
1a0: f8 d0 rcall .+496 ; 0x392
/* also check if serial data needs to be sent
out through UIMgr */
UIMgr_transmitPendingData();
1a2: ac d2 rcall .+1368 ; 0x6fc
 
/* we can't just call acquire line again here,
since we don't know if we need to acquire another
line or not (it depends on the FrameMgr to figure
this out) */
}
if (fastEventBitmask & FEV_PROCESS_LINE_COMPLETE)
1a4: 80 91 72 00 lds r24, 0x0072
1a8: 81 ff sbrs r24, 1
1aa: 08 c0 rjmp .+16 ; 0x1bc
{
DISABLE_INTS();
1ac: f8 94 cli
fastEventBitmask &= ~FEV_PROCESS_LINE_COMPLETE;
1ae: 80 91 72 00 lds r24, 0x0072
1b2: 8d 7f andi r24, 0xFD ; 253
1b4: 80 93 72 00 sts 0x0072, r24
ENABLE_INTS();
1b8: 78 94 sei
FrameMgr_acquireLine();
1ba: b9 d0 rcall .+370 ; 0x32e
}
}
if (IS_DATA_IN_EVENT_FIFO() == TRUE)
1bc: 90 91 70 00 lds r25, 0x0070
1c0: 80 91 71 00 lds r24, 0x0071
1c4: 98 17 cp r25, r24
1c6: f9 f2 breq .-66 ; 0x186
{
eventGenerated = Exec_readEventFifo();
1c8: 32 d0 rcall .+100 ; 0x22e
1ca: c8 2f mov r28, r24
switch(eventGenerated)
1cc: 99 27 eor r25, r25
1ce: 80 31 cpi r24, 0x10 ; 16
1d0: 91 05 cpc r25, r1
1d2: 11 f1 breq .+68 ; 0x218
1d4: 81 31 cpi r24, 0x11 ; 17
1d6: 91 05 cpc r25, r1
1d8: 7c f4 brge .+30 ; 0x1f8
1da: 82 30 cpi r24, 0x02 ; 2
1dc: 91 05 cpc r25, r1
1de: 09 f1 breq .+66 ; 0x222
1e0: 83 30 cpi r24, 0x03 ; 3
1e2: 91 05 cpc r25, r1
1e4: 1c f4 brge .+6 ; 0x1ec
1e6: 01 97 sbiw r24, 0x01 ; 1
1e8: d1 f0 breq .+52 ; 0x21e
1ea: cd cf rjmp .-102 ; 0x186
1ec: 84 30 cpi r24, 0x04 ; 4
1ee: 91 05 cpc r25, r1
1f0: c1 f0 breq .+48 ; 0x222
1f2: 08 97 sbiw r24, 0x08 ; 8
1f4: b1 f0 breq .+44 ; 0x222
1f6: c7 cf rjmp .-114 ; 0x186
1f8: 80 38 cpi r24, 0x80 ; 128
1fa: 91 05 cpc r25, r1
1fc: 91 f0 breq .+36 ; 0x222
1fe: 81 38 cpi r24, 0x81 ; 129
200: 91 05 cpc r25, r1
202: 1c f4 brge .+6 ; 0x20a
204: 80 97 sbiw r24, 0x20 ; 32
206: 69 f0 breq .+26 ; 0x222
208: be cf rjmp .-132 ; 0x186
20a: 81 38 cpi r24, 0x81 ; 129
20c: 91 05 cpc r25, r1
20e: 49 f0 breq .+18 ; 0x222
210: 80 39 cpi r24, 0x90 ; 144
212: 91 05 cpc r25, r1
214: 49 f0 breq .+18 ; 0x228
216: b7 cf rjmp .-146 ; 0x186
{
case (EV_DUMP_FRAME):
FrameMgr_dispatchEvent(eventGenerated);
break;
case (EV_ENABLE_TRACKING):
FrameMgr_dispatchEvent(eventGenerated);
break;
case (EV_DISABLE_TRACKING):
FrameMgr_dispatchEvent(eventGenerated);
break;
case (EV_ACQUIRE_LINE_COMPLETE):
FrameMgr_dispatchEvent(eventGenerated);
218: 8c 2f mov r24, r28
21a: 33 d0 rcall .+102 ; 0x282
UIMgr_dispatchEvent(eventGenerated);
21c: 05 c0 rjmp .+10 ; 0x228
break;
case (EV_ACQUIRE_FRAME_COMPLETE):
FrameMgr_dispatchEvent(eventGenerated);
break;
case (EV_PROCESS_LINE_COMPLETE):
FrameMgr_dispatchEvent(eventGenerated);
break;
case (EV_PROCESS_FRAME_COMPLETE):
FrameMgr_dispatchEvent(eventGenerated);
break;
case (EV_SERIAL_DATA_RECEIVED):
UIMgr_dispatchEvent(eventGenerated);
21e: 8c 2f mov r24, r28
220: 58 d2 rcall .+1200 ; 0x6d2
FrameMgr_dispatchEvent(eventGenerated);
222: 8c 2f mov r24, r28
224: 2e d0 rcall .+92 ; 0x282
break;
226: af cf rjmp .-162 ; 0x186
 
case (EV_SERIAL_DATA_PENDING_TX):
UIMgr_dispatchEvent(eventGenerated);
228: 8c 2f mov r24, r28
22a: 53 d2 rcall .+1190 ; 0x6d2
break;
22c: ac cf rjmp .-168 ; 0x186
 
0000022e <Exec_readEventFifo>:
default:
break;
}
}
/* toggle the debug line */
 
}
}
 
/***********************************************************
Function Name: Exec_readEventFifo
Function Description: This function is responsible for
reading a single event out of the event fifo.
Inputs: none
Outputs: unsigned char-the data read
***********************************************************/
static unsigned char Exec_readEventFifo(void)
{
unsigned char dataByte, tmpTail;
DISABLE_INTS();
22e: f8 94 cli
/* just return the current tail from the tx fifo */
dataByte = Exec_eventFifo[Exec_eventFifoTail];
230: 20 91 71 00 lds r18, 0x0071
234: 8c e6 ldi r24, 0x6C ; 108
236: 92 e0 ldi r25, 0x02 ; 2
238: fc 01 movw r30, r24
23a: e2 0f add r30, r18
23c: f1 1d adc r31, r1
23e: 90 81 ld r25, Z
tmpTail = (Exec_eventFifoTail+1) & (EXEC_EVENT_FIFO_MASK);
240: 82 2f mov r24, r18
242: 8f 5f subi r24, 0xFF ; 255
244: 87 70 andi r24, 0x07 ; 7
Exec_eventFifoTail = tmpTail;
246: 80 93 71 00 sts 0x0071, r24
ENABLE_INTS();
24a: 78 94 sei
return(dataByte);
24c: 89 2f mov r24, r25
24e: 99 27 eor r25, r25
}
250: 08 95 ret
 
00000252 <Exec_writeEventFifo>:
 
/***********************************************************
Function Name: Exec_writeEventFifo
Function Description: This function is responsible for
writing a single event to the event fifo and
updating the appropriate pointers.
Inputs: data - the byte to write to the Fifo
Outputs: none
***********************************************************/
void Exec_writeEventFifo(unsigned char event)
{
252: 38 2f mov r19, r24
unsigned char tmpHead;
 
DISABLE_INTS();
254: f8 94 cli
Exec_eventFifo[Exec_eventFifoHead] = event;
256: 20 91 70 00 lds r18, 0x0070
25a: 8c e6 ldi r24, 0x6C ; 108
25c: 92 e0 ldi r25, 0x02 ; 2
25e: fc 01 movw r30, r24
260: e2 0f add r30, r18
262: f1 1d adc r31, r1
264: 30 83 st Z, r19
 
/* now move the head up */
tmpHead = (Exec_eventFifoHead + 1) & (EXEC_EVENT_FIFO_MASK);
266: 82 2f mov r24, r18
268: 8f 5f subi r24, 0xFF ; 255
26a: 87 70 andi r24, 0x07 ; 7
Exec_eventFifoHead = tmpHead;
26c: 80 93 70 00 sts 0x0070, r24
ENABLE_INTS();
270: 78 94 sei
}
272: 08 95 ret
 
00000274 <FrameMgr_init>:
Outputs: none
***********************************************************/
void FrameMgr_init(void)
{
memset(trackedObjectTable,0x00,sizeof(trackedObjectTable));
274: 80 e4 ldi r24, 0x40 ; 64
276: e8 e7 ldi r30, 0x78 ; 120
278: f0 e0 ldi r31, 0x00 ; 0
27a: 11 92 st Z+, r1
27c: 8a 95 dec r24
27e: e9 f7 brne .-6 ; 0x27a
}
280: 08 95 ret
 
00000282 <FrameMgr_dispatchEvent>:
 
 
/***********************************************************
Function Name: FrameMgr_dispatchEvent
Function Description: This function is responsible for
taking an incoming event and performing the needed
actions with it as pertains to the FrameMgr.
Inputs: event - the generated event
Outputs: none
***********************************************************/
void FrameMgr_dispatchEvent(unsigned char event)
{
switch(event)
282: 99 27 eor r25, r25
284: 84 30 cpi r24, 0x04 ; 4
286: 91 05 cpc r25, r1
288: 51 f1 breq .+84 ; 0x2de
28a: 85 30 cpi r24, 0x05 ; 5
28c: 91 05 cpc r25, r1
28e: 34 f4 brge .+12 ; 0x29c
290: 81 30 cpi r24, 0x01 ; 1
292: 91 05 cpc r25, r1
294: 31 f1 breq .+76 ; 0x2e2
296: 02 97 sbiw r24, 0x02 ; 2
298: 71 f0 breq .+28 ; 0x2b6
{
case EV_DUMP_FRAME:
/* try re-initializing the camera before we start dumping */
CamConfig_setCamReg(0x11,0x01); /* reduce the frame rate for dumping*/
CamConfig_sendFifoCmds();
Utility_delay(1000); /* allow the new frame rate to settle */
lineCount = 0;
currentState = ST_FrameMgr_DumpingFrame;
//CamIntAsm_waitForNewDumpFrame(currentLineBuffer,previousLineBuffer);
FrameMgr_acquireLine();
break;
case EV_ENABLE_TRACKING:
currentState = ST_FrameMgr_TrackingFrame;
FrameMgr_acquireFrame();
break;
case EV_ACQUIRE_FRAME_COMPLETE:
FrameMgr_processFrame();
break;
case EV_PROCESS_FRAME_COMPLETE:
FrameMgr_acquireFrame();
break;
 
case EV_SERIAL_DATA_RECEIVED:
if (currentState != ST_FrameMgr_idle)
{
/* we need to go back to processing line data, since
serial data reception interrupted us....just trash the
frame and act like the frame has been processed, which
will kick off the system to wait for the next line */
PUBLISH_EVENT(EV_PROCESS_FRAME_COMPLETE);
}
break;
case EV_DISABLE_TRACKING:
/* tracking needs to be turned off */
currentState = ST_FrameMgr_idle;
break;
}
}
29a: 08 95 ret
29c: 80 38 cpi r24, 0x80 ; 128
29e: 91 05 cpc r25, r1
2a0: c1 f0 breq .+48 ; 0x2d2
2a2: 81 38 cpi r24, 0x81 ; 129
2a4: 91 05 cpc r25, r1
2a6: 1c f4 brge .+6 ; 0x2ae
2a8: 80 97 sbiw r24, 0x20 ; 32
2aa: b9 f0 breq .+46 ; 0x2da
2ac: 08 95 ret
2ae: 81 38 cpi r24, 0x81 ; 129
2b0: 91 05 cpc r25, r1
2b2: f1 f0 breq .+60 ; 0x2f0
2b4: 08 95 ret
2b6: 61 e0 ldi r22, 0x01 ; 1
2b8: 81 e1 ldi r24, 0x11 ; 17
2ba: 66 d5 rcall .+2764 ; 0xd88
2bc: 6a d5 rcall .+2772 ; 0xd92
2be: 88 ee ldi r24, 0xE8 ; 232
2c0: 93 e0 ldi r25, 0x03 ; 3
2c2: c1 d5 rcall .+2946 ; 0xe46
2c4: 10 92 73 00 sts 0x0073, r1
2c8: 82 e0 ldi r24, 0x02 ; 2
2ca: 80 93 74 00 sts 0x0074, r24
2ce: 2f d0 rcall .+94 ; 0x32e
2d0: 08 95 ret
2d2: 81 e0 ldi r24, 0x01 ; 1
2d4: 80 93 74 00 sts 0x0074, r24
2d8: 02 c0 rjmp .+4 ; 0x2de
2da: 18 d1 rcall .+560 ; 0x50c
2dc: 08 95 ret
2de: 0c d0 rcall .+24 ; 0x2f8
2e0: 08 95 ret
2e2: 80 91 74 00 lds r24, 0x0074
2e6: 88 23 and r24, r24
2e8: 29 f0 breq .+10 ; 0x2f4
2ea: 84 e0 ldi r24, 0x04 ; 4
2ec: b2 df rcall .-156 ; 0x252
2ee: 08 95 ret
2f0: 10 92 74 00 sts 0x0074, r1
2f4: 08 95 ret
2f6: 08 95 ret
 
000002f8 <FrameMgr_acquireFrame>:
 
/***********************************************************
Function Name: FrameMgr_acquireFrame
Function Description: This function is responsible for
beginning of the acquisition of a new frame of data
from the camera interface. The acquisition of this line
depends on the current state of the FrameMgr.
Inputs: none
Outputs: none
***********************************************************/
void FrameMgr_acquireFrame(void)
{
if (currentState == ST_FrameMgr_TrackingFrame)
2f8: 80 91 74 00 lds r24, 0x0074
2fc: 81 30 cpi r24, 0x01 ; 1
2fe: a9 f4 brne .+42 ; 0x32a
{
trackedLineCount = 0;
300: 10 92 77 00 sts 0x0077, r1
numPrevTrackedObjects = numCurrTrackedObjects;
304: 80 91 75 00 lds r24, 0x0075
308: 80 93 76 00 sts 0x0076, r24
numCurrTrackedObjects = 0;
30c: 10 92 75 00 sts 0x0075, r1
/* clear out the tracking table, and wait for the new frame
to start */
memset(trackedObjectTable,0x00,sizeof(trackedObjectTable));
310: 80 e4 ldi r24, 0x40 ; 64
312: e8 e7 ldi r30, 0x78 ; 120
314: f0 e0 ldi r31, 0x00 ; 0
316: 11 92 st Z+, r1
318: 8a 95 dec r24
31a: e9 f7 brne .-6 ; 0x316
//CamIntAsm_waitForNewTrackingFrame(currentLineBuffer,colorMap);
WAIT_FOR_VSYNC_HIGH();
31c: 82 9b sbis 0x10, 2 ; 16
31e: fe cf rjmp .-4 ; 0x31c
CamIntAsm_acquireTrackingLine(currentLineBuffer,colorMap);
320: 60 e0 ldi r22, 0x00 ; 0
322: 73 e0 ldi r23, 0x03 ; 3
324: 8c eb ldi r24, 0xBC ; 188
326: 91 e0 ldi r25, 0x01 ; 1
328: f0 d5 rcall .+3040 ; 0xf0a
}
}
32a: 08 95 ret
32c: 08 95 ret
 
0000032e <FrameMgr_acquireLine>:
 
/***********************************************************
Function Name: FrameMgr_acquireLine
Function Description: This function is responsible for
acquiring a line of data from the camera interface.
The acquisition of this line depends on the current
state of the FrameMgr.
Inputs: none
Outputs: none
***********************************************************/
void FrameMgr_acquireLine(void)
{
unsigned char tmpLineCount;
/* clearing out the buffers takes too long...we should
just overwrite the data here without a problem when
we start acquiring...at no point do we check for
a 0x00 value in the current or previous lineBuffers,
so it was a bit excessive :-) */
/* check which state we are in and proceed as needed */
if (currentState == ST_FrameMgr_DumpingFrame)
32e: 80 91 74 00 lds r24, 0x0074
332: 82 30 cpi r24, 0x02 ; 2
334: 11 f5 brne .+68 ; 0x37a
{
tmpLineCount = lineCount*2;
336: 80 91 73 00 lds r24, 0x0073
33a: 88 0f add r24, r24
/* clearing out the line data in dump mode is ok, and actually
is needed, since it is possible for the first dump line in
a frame to come back with the last line captured of the
last capture session...*/
memset(currentLineBuffer,0x00,LENGTH_OF_LINE_BUFFER);
33c: 90 eb ldi r25, 0xB0 ; 176
33e: ec eb ldi r30, 0xBC ; 188
340: f1 e0 ldi r31, 0x01 ; 1
342: 11 92 st Z+, r1
344: 9a 95 dec r25
346: e9 f7 brne .-6 ; 0x342
memset(previousLineBuffer,0x00,LENGTH_OF_LINE_BUFFER);
348: 90 eb ldi r25, 0xB0 ; 176
34a: ec e0 ldi r30, 0x0C ; 12
34c: f1 e0 ldi r31, 0x01 ; 1
34e: 11 92 st Z+, r1
350: 9a 95 dec r25
352: e9 f7 brne .-6 ; 0x34e
/* wait for another VSYNC so we know which frame to use
to start looking for a line to receive */
WAIT_FOR_VSYNC_HIGH();
354: 82 9b sbis 0x10, 2 ; 16
356: fe cf rjmp .-4 ; 0x354
WAIT_FOR_VSYNC_LOW();
358: 82 99 sbic 0x10, 2 ; 16
35a: fe cf rjmp .-4 ; 0x358
/* look at lineCount to determine how many HREFs we should
wait before we start sampling */
while(tmpLineCount != 0)
35c: 88 23 and r24, r24
35e: 39 f0 breq .+14 ; 0x36e
{
WAIT_FOR_HREF_HIGH();
360: 84 9b sbis 0x10, 4 ; 16
362: fe cf rjmp .-4 ; 0x360
tmpLineCount--;
364: 81 50 subi r24, 0x01 ; 1
WAIT_FOR_HREF_LOW();
366: 84 99 sbic 0x10, 4 ; 16
368: fe cf rjmp .-4 ; 0x366
36a: 88 23 and r24, r24
36c: c9 f7 brne .-14 ; 0x360
}
/* we should now be ready to sample our line...*/
CamIntAsm_acquireDumpLine(currentLineBuffer,previousLineBuffer);
36e: 6c e0 ldi r22, 0x0C ; 12
370: 71 e0 ldi r23, 0x01 ; 1
372: 8c eb ldi r24, 0xBC ; 188
374: 91 e0 ldi r25, 0x01 ; 1
376: 10 d6 rcall .+3104 ; 0xf98
}
else if (currentState == ST_FrameMgr_TrackingFrame)
{
WAIT_FOR_HREF_LOW();
CamIntAsm_acquireTrackingLine(currentLineBuffer,colorMap);
}
}
378: 08 95 ret
37a: 80 91 74 00 lds r24, 0x0074
37e: 81 30 cpi r24, 0x01 ; 1
380: 39 f4 brne .+14 ; 0x390
382: 84 99 sbic 0x10, 4 ; 16
384: fe cf rjmp .-4 ; 0x382
386: 60 e0 ldi r22, 0x00 ; 0
388: 73 e0 ldi r23, 0x03 ; 3
38a: 8c eb ldi r24, 0xBC ; 188
38c: 91 e0 ldi r25, 0x01 ; 1
38e: bd d5 rcall .+2938 ; 0xf0a
390: 08 95 ret
 
00000392 <FrameMgr_processLine>:
 
/***********************************************************
Function Name: FrameMgr_processLine
Function Description: This function is responsible for
parsing the received image line and performing either
connected region mapping (if in the Tracking state) or
sending out the raw sampled data (if in the Dumping
state).
Inputs: none
Outputs: none
***********************************************************/
void FrameMgr_processLine(void)
{
392: df 92 push r13
394: ef 92 push r14
396: ff 92 push r15
398: 0f 93 push r16
39a: 1f 93 push r17
39c: cf 93 push r28
39e: df 93 push r29
3a0: cd b7 in r28, 0x3d ; 61
3a2: de b7 in r29, 0x3e ; 62
3a4: 21 97 sbiw r28, 0x01 ; 1
3a6: 0f b6 in r0, 0x3f ; 63
3a8: f8 94 cli
3aa: de bf out 0x3e, r29 ; 62
3ac: 0f be out 0x3f, r0 ; 63
3ae: cd bf out 0x3d, r28 ; 61
unsigned char i;
volatile unsigned char dataToSend;
unsigned char *pTrackedObjectData = (unsigned char *)pCurrentTrackedObjectTable;
3b0: 00 91 60 00 lds r16, 0x0060
3b4: 10 91 61 00 lds r17, 0x0061
#ifdef DEBUG_TRACKED_LINE
unsigned char *pSendData;
unsigned char asciiBuffer[5];
unsigned char pixelCount = 0;
#endif
if (currentState == ST_FrameMgr_DumpingFrame)
3b8: 80 91 74 00 lds r24, 0x0074
3bc: 82 30 cpi r24, 0x02 ; 2
3be: 09 f0 breq .+2 ; 0x3c2
3c0: 54 c0 rjmp .+168 ; 0x46a
{
/* we want to sit in a tight loop and send the acquired data
sitting in current and previous line buffers out the serial
port...it is sent out the serial port immediately instead
of going into the UIMgr tx fifo because we can't do anything
until its sent out anyway...may as well just get it out now */
/* currentLineBuffer is getting "g" previousLineBuffer is getting "b-r" */
UartInt_txByte(0x0B); /* send the header byte */
3c2: 8b e0 ldi r24, 0x0B ; 11
3c4: cd d3 rcall .+1946 ; 0xb60
UartInt_txByte(lineCount); /* send the line count */
3c6: 80 91 73 00 lds r24, 0x0073
3ca: ca d3 rcall .+1940 ; 0xb60
for (i=0; i<NUM_PIXELS_IN_A_DUMP_LINE; i+=2)
3cc: dd 24 eor r13, r13
{
/* when a dump line is sampled, the upper byte can potentially
have garbage in it...we don't have time to mask it off as we're
sampling, so it is done here before we send it out...we also
combine the samples together so we really are sending up a
sample for line N as well as line N+1 */
dataToSend = currentLineBuffer[i];
3ce: 2d 2d mov r18, r13
3d0: 33 27 eor r19, r19
3d2: 0f 2e mov r0, r31
3d4: fc eb ldi r31, 0xBC ; 188
3d6: ef 2e mov r14, r31
3d8: f1 e0 ldi r31, 0x01 ; 1
3da: ff 2e mov r15, r31
3dc: f0 2d mov r31, r0
3de: e2 0e add r14, r18
3e0: f3 1e adc r15, r19
3e2: f7 01 movw r30, r14
3e4: 80 81 ld r24, Z
3e6: 89 83 std Y+1, r24 ; 0x01
dataToSend &= 0x0F;
3e8: 89 81 ldd r24, Y+1 ; 0x01
3ea: 8f 70 andi r24, 0x0F ; 15
3ec: 89 83 std Y+1, r24 ; 0x01
dataToSend <<= 4;
3ee: 89 81 ldd r24, Y+1 ; 0x01
3f0: 82 95 swap r24
3f2: 80 7f andi r24, 0xF0 ; 240
3f4: 89 83 std Y+1, r24 ; 0x01
dataToSend |= (previousLineBuffer[i] & 0x0F);
3f6: 89 01 movw r16, r18
3f8: 04 5f subi r16, 0xF4 ; 244
3fa: 1e 4f sbci r17, 0xFE ; 254
3fc: f8 01 movw r30, r16
3fe: 80 81 ld r24, Z
400: 98 2f mov r25, r24
402: 9f 70 andi r25, 0x0F ; 15
404: 89 81 ldd r24, Y+1 ; 0x01
406: 89 2b or r24, r25
408: 89 83 std Y+1, r24 ; 0x01
/* dataToSend should be packed now */
UartInt_txByte(dataToSend);
40a: 89 81 ldd r24, Y+1 ; 0x01
40c: a9 d3 rcall .+1874 ; 0xb60
/* flip the colors around since we are doing all G on Y and BR on UV */
dataToSend = previousLineBuffer[i+1];
40e: f8 01 movw r30, r16
410: 81 81 ldd r24, Z+1 ; 0x01
412: 89 83 std Y+1, r24 ; 0x01
dataToSend &= 0x0F;
414: 89 81 ldd r24, Y+1 ; 0x01
416: 8f 70 andi r24, 0x0F ; 15
418: 89 83 std Y+1, r24 ; 0x01
dataToSend <<= 4;
41a: 89 81 ldd r24, Y+1 ; 0x01
41c: 82 95 swap r24
41e: 80 7f andi r24, 0xF0 ; 240
420: 89 83 std Y+1, r24 ; 0x01
dataToSend |= (currentLineBuffer[i+1] & 0x0F);
422: f7 01 movw r30, r14
424: 81 81 ldd r24, Z+1 ; 0x01
426: 98 2f mov r25, r24
428: 9f 70 andi r25, 0x0F ; 15
42a: 89 81 ldd r24, Y+1 ; 0x01
42c: 89 2b or r24, r25
42e: 89 83 std Y+1, r24 ; 0x01
/* dataToSend should be packed now */
UartInt_txByte(dataToSend);
430: 89 81 ldd r24, Y+1 ; 0x01
432: 96 d3 rcall .+1836 ; 0xb60
434: f2 e0 ldi r31, 0x02 ; 2
436: df 0e add r13, r31
438: 4f ea ldi r20, 0xAF ; 175
43a: 4d 15 cp r20, r13
43c: 40 f6 brcc .-112 ; 0x3ce
}
UartInt_txByte(0x0F); /* send line end */
43e: 8f e0 ldi r24, 0x0F ; 15
440: 8f d3 rcall .+1822 ; 0xb60
/* once all the data is sent, increment out line count by 2 since
we really get 2 lines worth of pixels on each pass */
/* Update...increment only by 1, but only send 72 double-lines */
lineCount++;
442: 80 91 73 00 lds r24, 0x0073
446: 8f 5f subi r24, 0xFF ; 255
448: 80 93 73 00 sts 0x0073, r24
/* check to see if we have retrieved all of the needed lines */
if (lineCount >= 72) /* half 144, since we send two lines at a time */
44c: 88 34 cpi r24, 0x48 ; 72
44e: 08 f4 brcc .+2 ; 0x452
450: 4a c0 rjmp .+148 ; 0x4e6
{
/* we're done, so send the dump complete?...nope, just change
states and we should be fine */
lineCount = 0;
452: 10 92 73 00 sts 0x0073, r1
currentState = ST_FrameMgr_idle;
456: 10 92 74 00 sts 0x0074, r1
/* disable the PCLK counting overflow interrupt */
TIMSK &= DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK;
45a: 89 b7 in r24, 0x39 ; 57
45c: 8b 7f andi r24, 0xFB ; 251
45e: 89 bf out 0x39, r24 ; 57
CamConfig_setCamReg(0x11,0x00); /* reset the frame rate to normal*/
460: 60 e0 ldi r22, 0x00 ; 0
462: 81 e1 ldi r24, 0x11 ; 17
464: 91 d4 rcall .+2338 ; 0xd88
CamConfig_sendFifoCmds();
466: 95 d4 rcall .+2346 ; 0xd92
468: 43 c0 rjmp .+134 ; 0x4f0
}
else
{
/* we have more lines to acquire in this frame, so keep on truckin...*/
PUBLISH_FAST_EVENT(FEV_PROCESS_LINE_COMPLETE);
}
}
else if (currentState == ST_FrameMgr_TrackingFrame)
46a: 80 91 74 00 lds r24, 0x0074
46e: 81 30 cpi r24, 0x01 ; 1
470: 09 f0 breq .+2 ; 0x474
472: 3e c0 rjmp .+124 ; 0x4f0
{
#ifdef DEBUG_TRACKED_LINE
/* send the received line over serial...this should only send
until a pixelCount == 176 */
pSendData = currentLineBuffer;
itoa(trackedLineCount,asciiBuffer,10);
UIMgr_txBuffer(asciiBuffer,3);
UIMgr_txBuffer(" ",1);
while(pixelCount < ACTUAL_NUM_PIXELS_IN_A_LINE)
{
memset(asciiBuffer,0x00,5);
itoa(*pSendData++,asciiBuffer,10); /* color is first byte */
UIMgr_txBuffer(asciiBuffer,3); /* 3 ascii bytes for data */
UIMgr_txBuffer(" ",1);
 
pixelCount += *pSendData; /* run-length is second byte */
memset(asciiBuffer,0x00,5);
itoa(*pSendData++,asciiBuffer,10);
UIMgr_txBuffer(asciiBuffer,3);
UIMgr_txBuffer(" ",1);
}
UIMgr_txBuffer("\n\r",2);
 
trackedLineCount++;
if (trackedLineCount == 144)
{
UIMgr_txBuffer(" FC \n\r",8);
trackedLineCount = 0;
PUBLISH_EVENT(EV_PROCESS_FRAME_COMPLETE);
}
else
{
PUBLISH_EVENT(EV_PROCESS_LINE_COMPLETE);
}
#else
/* determine if any of the RLE blocks overlap */
FrameMgr_findConnectedness();
474: a1 d0 rcall .+322 ; 0x5b8
/* we also want to remove any objects that are less than
a minimum height...we already removed portions of the
run-length that are less than MIN_PIXEL_WIDTH in the
findConnectedness() routine...doing it here instead of
a function to speed things up...this may end up slowing down the
frame rate slightly, and can be removed if this isn't needed */
/* run this routine once every 8 lines */
if ( (trackedLineCount & RUN_OBJECT_FILTER_MASK) == RUN_OBJECT_FILTER_MASK)
476: 80 91 77 00 lds r24, 0x0077
47a: 99 27 eor r25, r25
47c: 87 70 andi r24, 0x07 ; 7
47e: 90 70 andi r25, 0x00 ; 0
480: 07 97 sbiw r24, 0x07 ; 7
482: 11 f5 brne .+68 ; 0x4c8
{
for (i=0; i<MAX_TRACKED_OBJECTS; i++)
484: dd 24 eor r13, r13
{
if ( *(pTrackedObjectData + VALID_OBJECT_OFFSET) == TRUE)
486: f8 01 movw r30, r16
488: 87 81 ldd r24, Z+7 ; 0x07
48a: 81 30 cpi r24, 0x01 ; 1
48c: b9 f4 brne .+46 ; 0x4bc
{
/* check to see if the object is already in
our past...i.e., its last */
if ( (*(pTrackedObjectData + Y_LOWER_RIGHT_OFFSET) -
48e: 86 81 ldd r24, Z+6 ; 0x06
490: 28 2f mov r18, r24
492: 33 27 eor r19, r19
494: 84 81 ldd r24, Z+4 ; 0x04
496: a9 01 movw r20, r18
498: 48 1b sub r20, r24
49a: 51 09 sbc r21, r1
49c: 43 30 cpi r20, 0x03 ; 3
49e: 51 05 cpc r21, r1
4a0: 6c f4 brge .+26 ; 0x4bc
*(pTrackedObjectData + Y_UPPER_LEFT_OFFSET)) < MIN_OBJECT_TRACKING_HEIGHT)
{
/* the object is less than the minimum height...see if it is adjacent
to the current line we just processed...if so, leave it here...otherwise,
it needs to be invalidated since its too small */
if ( trackedLineCount - *(pTrackedObjectData + Y_LOWER_RIGHT_OFFSET) > 2)
4a2: 80 91 77 00 lds r24, 0x0077
4a6: 99 27 eor r25, r25
4a8: 82 1b sub r24, r18
4aa: 93 0b sbc r25, r19
4ac: 03 97 sbiw r24, 0x03 ; 3
4ae: 34 f0 brlt .+12 ; 0x4bc
{
/* invalidate the object */
*(pTrackedObjectData + VALID_OBJECT_OFFSET) = FALSE;
4b0: 17 82 std Z+7, r1 ; 0x07
numCurrTrackedObjects--;
4b2: 80 91 75 00 lds r24, 0x0075
4b6: 81 50 subi r24, 0x01 ; 1
4b8: 80 93 75 00 sts 0x0075, r24
}
}
}
pTrackedObjectData += SIZE_OF_TRACKED_OBJECT;
4bc: 08 5f subi r16, 0xF8 ; 248
4be: 1f 4f sbci r17, 0xFF ; 255
4c0: d3 94 inc r13
4c2: 57 e0 ldi r21, 0x07 ; 7
4c4: 5d 15 cp r21, r13
4c6: f8 f6 brcc .-66 ; 0x486
}
}
trackedLineCount++;
4c8: 80 91 77 00 lds r24, 0x0077
4cc: 8f 5f subi r24, 0xFF ; 255
4ce: 80 93 77 00 sts 0x0077, r24
if (trackedLineCount == ACTUAL_NUM_LINES_IN_A_FRAME)
4d2: 80 39 cpi r24, 0x90 ; 144
4d4: 41 f4 brne .+16 ; 0x4e6
{
/* an entire frame of tracking data has been acquired, so
publish an event letting the system know this fact */
PUBLISH_EVENT(EV_ACQUIRE_FRAME_COMPLETE);
4d6: 80 e2 ldi r24, 0x20 ; 32
4d8: bc de rcall .-648 ; 0x252
/* disable the PCLK counting overflow interrupt */
TIMSK &= DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK;
4da: 89 b7 in r24, 0x39 ; 57
4dc: 8b 7f andi r24, 0xFB ; 251
4de: 89 bf out 0x39, r24 ; 57
trackedLineCount = 0;
4e0: 10 92 77 00 sts 0x0077, r1
4e4: 05 c0 rjmp .+10 ; 0x4f0
}
else
{
PUBLISH_FAST_EVENT(FEV_PROCESS_LINE_COMPLETE);
4e6: 80 91 72 00 lds r24, 0x0072
4ea: 82 60 ori r24, 0x02 ; 2
4ec: 80 93 72 00 sts 0x0072, r24
}
#endif
}
else
{
/* ...and here? */
}
}
4f0: 21 96 adiw r28, 0x01 ; 1
4f2: 0f b6 in r0, 0x3f ; 63
4f4: f8 94 cli
4f6: de bf out 0x3e, r29 ; 62
4f8: 0f be out 0x3f, r0 ; 63
4fa: cd bf out 0x3d, r28 ; 61
4fc: df 91 pop r29
4fe: cf 91 pop r28
500: 1f 91 pop r17
502: 0f 91 pop r16
504: ff 90 pop r15
506: ef 90 pop r14
508: df 90 pop r13
50a: 08 95 ret
 
0000050c <FrameMgr_processFrame>:
 
/***********************************************************
Function Name: FrameMgr_processFrame
Function Description: This function is responsible for
parsing the completed frame and performing all actions
needed at this level.
Inputs: none
Outputs: none
***********************************************************/
void FrameMgr_processFrame(void)
{
50c: df 92 push r13
50e: ef 92 push r14
510: ff 92 push r15
512: 0f 93 push r16
514: 1f 93 push r17
516: cf 93 push r28
518: df 93 push r29
unsigned char i,k,color;
#if DEBUG_FRAME_DATA
unsigned char asciiBuffer[5];
unsigned char j;
#endif
unsigned char *pTableData = (unsigned char *)pCurrentTrackedObjectTable;
unsigned char tmpUpperLeftX,tmpUpperLeftY,tmpLowerRightX,tmpLowerRightY;
#if DEBUG_FRAME_DATA
/* we want to send all of the currently tracked table out
the serial port for debugging */
for (i=0; i<numCurrTrackedObjects; i++)
{
UIMgr_txBuffer("----------\r\n",12);
for (j=0; j<SIZE_OF_TRACKED_OBJECT; j++)
{
memset(asciiBuffer,0x00,5);
itoa(*pTableData++,asciiBuffer,10);
UIMgr_txBuffer(asciiBuffer,3); /* 3 ascii bytes for data
+ 1 space */
UIMgr_txBuffer("\r\n",2);
}
}
/* finally, send a new line */
UIMgr_txBuffer("\r\n",2);
memset(asciiBuffer,0x00,5);
itoa(numCurrTrackedObjects,asciiBuffer,10);
UIMgr_txBuffer(asciiBuffer,3);
UIMgr_txBuffer(" PFC\r\n",5);
 
#else
/* we only send tracking packets if there are tracked objects */
if (numCurrTrackedObjects > 0)
51a: 80 91 75 00 lds r24, 0x0075
51e: 88 23 and r24, r24
520: 09 f4 brne .+2 ; 0x524
522: 40 c0 rjmp .+128 ; 0x5a4
{
UIMgr_writeTxFifo(0x0A); /* header byte for a tracking packet */
524: 8a e0 ldi r24, 0x0A ; 10
526: 01 d3 rcall .+1538 ; 0xb2a
/* reset the pointer */
pTableData = (unsigned char *)pCurrentTrackedObjectTable;
528: c0 91 60 00 lds r28, 0x0060
52c: d0 91 61 00 lds r29, 0x0061
UIMgr_writeTxFifo(numCurrTrackedObjects); /* num of objects tracked */
530: 80 91 75 00 lds r24, 0x0075
534: fa d2 rcall .+1524 ; 0xb2a
for (i=0; i<MAX_TRACKED_OBJECTS; i++)
536: dd 24 eor r13, r13
{
/* we only want to process objects that have their objectValid flag
set to TRUE */
if ( *(pTableData + VALID_OBJECT_OFFSET) == TRUE)
538: 8f 81 ldd r24, Y+7 ; 0x07
53a: 81 30 cpi r24, 0x01 ; 1
53c: 61 f5 brne .+88 ; 0x596
{
/* the object is valid...convert the color from bit position to value...remember,
each bit in the "color" byte corresponds to a color */
k=0;
53e: 80 e0 ldi r24, 0x00 ; 0
color = *(pTableData + COLOR_OFFSET);
540: 98 81 ld r25, Y
if (color == 128) k=0;
542: 90 38 cpi r25, 0x80 ; 128
544: d9 f0 breq .+54 ; 0x57c
else if (color == 64) k=1;
546: 90 34 cpi r25, 0x40 ; 64
548: 11 f4 brne .+4 ; 0x54e
54a: 81 e0 ldi r24, 0x01 ; 1
54c: 17 c0 rjmp .+46 ; 0x57c
else if (color == 32) k=2;
54e: 90 32 cpi r25, 0x20 ; 32
550: 11 f4 brne .+4 ; 0x556
552: 82 e0 ldi r24, 0x02 ; 2
554: 13 c0 rjmp .+38 ; 0x57c
else if (color == 16) k=3;
556: 90 31 cpi r25, 0x10 ; 16
558: 11 f4 brne .+4 ; 0x55e
55a: 83 e0 ldi r24, 0x03 ; 3
55c: 0f c0 rjmp .+30 ; 0x57c
else if (color == 8) k=4;
55e: 98 30 cpi r25, 0x08 ; 8
560: 11 f4 brne .+4 ; 0x566
562: 84 e0 ldi r24, 0x04 ; 4
564: 0b c0 rjmp .+22 ; 0x57c
else if (color == 4) k=5;
566: 94 30 cpi r25, 0x04 ; 4
568: 11 f4 brne .+4 ; 0x56e
56a: 85 e0 ldi r24, 0x05 ; 5
56c: 07 c0 rjmp .+14 ; 0x57c
else if (color == 2) k=6;
56e: 92 30 cpi r25, 0x02 ; 2
570: 11 f4 brne .+4 ; 0x576
572: 86 e0 ldi r24, 0x06 ; 6
574: 03 c0 rjmp .+6 ; 0x57c
else if (color == 1) k=7;
576: 91 30 cpi r25, 0x01 ; 1
578: 09 f4 brne .+2 ; 0x57c
57a: 87 e0 ldi r24, 0x07 ; 7
tmpUpperLeftX = *(pTableData + X_UPPER_LEFT_OFFSET); /* get the upper left X */
57c: 1b 81 ldd r17, Y+3 ; 0x03
tmpUpperLeftY = *(pTableData + Y_UPPER_LEFT_OFFSET); /* get the upper left Y */
57e: 0c 81 ldd r16, Y+4 ; 0x04
tmpLowerRightX = *(pTableData + X_LOWER_RIGHT_OFFSET); /* get the lower right X */
580: fd 80 ldd r15, Y+5 ; 0x05
tmpLowerRightY = *(pTableData + Y_LOWER_RIGHT_OFFSET); /* get the lower right Y */
582: ee 80 ldd r14, Y+6 ; 0x06
UIMgr_writeTxFifo(k); /* send the color first */
584: d2 d2 rcall .+1444 ; 0xb2a
UIMgr_writeTxFifo(tmpUpperLeftX);
586: 81 2f mov r24, r17
588: d0 d2 rcall .+1440 ; 0xb2a
UIMgr_writeTxFifo(tmpUpperLeftY);
58a: 80 2f mov r24, r16
58c: ce d2 rcall .+1436 ; 0xb2a
UIMgr_writeTxFifo(tmpLowerRightX);
58e: 8f 2d mov r24, r15
590: cc d2 rcall .+1432 ; 0xb2a
UIMgr_writeTxFifo(tmpLowerRightY);
592: 8e 2d mov r24, r14
594: ca d2 rcall .+1428 ; 0xb2a
}
 
/* move our pointer up to the beginning of the next object */
pTableData += SIZE_OF_TRACKED_OBJECT;
596: 28 96 adiw r28, 0x08 ; 8
598: d3 94 inc r13
59a: 87 e0 ldi r24, 0x07 ; 7
59c: 8d 15 cp r24, r13
59e: 60 f6 brcc .-104 ; 0x538
}
/* all done...send the end of tracking packets char */
UIMgr_writeTxFifo(0xFF);
5a0: 8f ef ldi r24, 0xFF ; 255
5a2: c3 d2 rcall .+1414 ; 0xb2a
}
#endif
 
/* the tracked object table will be cleared out right before we start
to wait for VSYNC to indicate a new frame...so it doesn't need to be
done now */
/* schedule the next action to acquire a new frame */
PUBLISH_EVENT(EV_PROCESS_FRAME_COMPLETE);
5a4: 84 e0 ldi r24, 0x04 ; 4
5a6: 55 de rcall .-854 ; 0x252
}
5a8: df 91 pop r29
5aa: cf 91 pop r28
5ac: 1f 91 pop r17
5ae: 0f 91 pop r16
5b0: ff 90 pop r15
5b2: ef 90 pop r14
5b4: df 90 pop r13
5b6: 08 95 ret
 
000005b8 <FrameMgr_findConnectedness>:
 
/***********************************************************
Function Name: FrameMgr_findConnectedness
Function Description: This function is responsible for
finding the connectedness between two particular run-
length encoded lines of pixel data. It updates the
trackingTable as needed.
Inputs: none
Outputs: none
***********************************************************/
static void FrameMgr_findConnectedness(void)
{
5b8: 1f 93 push r17
5ba: cf 93 push r28
trackedColor_t currColor;
unsigned char *pCurrLineColorInfo = currentLineBuffer;
5bc: ac eb ldi r26, 0xBC ; 188
5be: b1 e0 ldi r27, 0x01 ; 1
unsigned char *pTrackedObjectData;
register unsigned char currPixelRunStart=0;
5c0: 60 e0 ldi r22, 0x00 ; 0
register unsigned char currPixelRunFinish=0;
5c2: c6 2f mov r28, r22
register unsigned char lastLineXStart=0;
register unsigned char lastLineXFinish=0;
register unsigned char runLength=1;
5c4: 71 e0 ldi r23, 0x01 ; 1
unsigned char i;
bool_t colorConnected;
do
{
/* grab both the current color and the number of pixels
in the run...remember, pixels start at 1, not 0! */
colorConnected = FALSE;
5c6: 10 e0 ldi r17, 0x00 ; 0
currColor = *pCurrLineColorInfo++;
5c8: 5d 91 ld r21, X+
currPixelRunStart += runLength;
5ca: c7 0f add r28, r23
runLength = *pCurrLineColorInfo++;
5cc: 7d 91 ld r23, X+
currPixelRunFinish += runLength;
5ce: 67 0f add r22, r23
/* make sure that the run-length is at least as wide as
the minimum horizontal tracking width, and we care about the color */
if ( (currColor != notTracked) && (runLength > MIN_OBJECT_TRACKING_WIDTH) )
5d0: 55 23 and r21, r21
5d2: 09 f4 brne .+2 ; 0x5d6
5d4: 5d c0 rjmp .+186 ; 0x690
5d6: 74 30 cpi r23, 0x04 ; 4
5d8: 08 f4 brcc .+2 ; 0x5dc
5da: 5a c0 rjmp .+180 ; 0x690
{
/* this run contains a color we care about, so
either it will begin a new tracked object, or it
is connected to a currently tracked object...
compare it with each object in the tracking
table...we can't just look at the numTrackedObjects because
it is entirely possible that the first couple of objects could
be invalid...
 
NOTE: Instead of accessing each element in the trackedObjectTable
through the 'i' index, and then accessing the fields in each structure,
a pointer to each entry is established each time through the loop, followed
by accessing the elements through specified offsets. GCC seems to be
able to optimize this code much better than simply accessing the elements
of each structure in the array the more normal way...*/
pTrackedObjectData = (unsigned char *)pCurrentTrackedObjectTable;
5dc: e0 91 60 00 lds r30, 0x0060
5e0: f0 91 61 00 lds r31, 0x0061
for (i=0; i<MAX_TRACKED_OBJECTS; i++)
5e4: 41 2f mov r20, r17
{
if ( (currColor == *(pTrackedObjectData + COLOR_OFFSET)) &&
5e6: 80 81 ld r24, Z
5e8: 58 17 cp r21, r24
5ea: 51 f5 brne .+84 ; 0x640
5ec: 87 81 ldd r24, Z+7 ; 0x07
5ee: 81 30 cpi r24, 0x01 ; 1
5f0: 39 f5 brne .+78 ; 0x640
5f2: 86 81 ldd r24, Z+6 ; 0x06
5f4: 28 2f mov r18, r24
5f6: 33 27 eor r19, r19
5f8: 80 91 77 00 lds r24, 0x0077
5fc: 99 27 eor r25, r25
5fe: 01 97 sbiw r24, 0x01 ; 1
600: 28 17 cp r18, r24
602: 39 07 cpc r19, r25
604: e9 f4 brne .+58 ; 0x640
(*(pTrackedObjectData + VALID_OBJECT_OFFSET) == TRUE) &&
(*(pTrackedObjectData + Y_LOWER_RIGHT_OFFSET) == trackedLineCount - 1) )
{
/* found a color match and the object is valid...check to see if there is
connectedness */
lastLineXStart = *(pTrackedObjectData + LAST_LINE_X_START_OFFSET);
606: 81 81 ldd r24, Z+1 ; 0x01
lastLineXFinish = *(pTrackedObjectData + LAST_LINE_X_FINISH_OFFSET);
608: 92 81 ldd r25, Z+2 ; 0x02
/* Check for the 5 following types of line connectedness:
---------------------
| |
---------------------
-------------------------
| |
------------------------- */
if ( ( (currPixelRunStart >= lastLineXStart) &&
60a: c8 17 cp r28, r24
60c: 10 f0 brcs .+4 ; 0x612
60e: 9c 17 cp r25, r28
610: 40 f4 brcc .+16 ; 0x622
612: 68 17 cp r22, r24
614: 10 f0 brcs .+4 ; 0x61a
616: 96 17 cp r25, r22
618: 20 f4 brcc .+8 ; 0x622
61a: 8c 17 cp r24, r28
61c: 88 f0 brcs .+34 ; 0x640
61e: 69 17 cp r22, r25
620: 78 f0 brcs .+30 ; 0x640
(currPixelRunStart <= lastLineXFinish) ) ||
/* ---------------------
| |
---------------------
-------------------
| |
-------------------
OR
------------------------------
| |
------------------------------
---------
| |
--------- */
( (currPixelRunFinish >= lastLineXStart) &&
(currPixelRunFinish <= lastLineXFinish) ) ||
/* -------------------------------
| |
-------------------------------
-------------------------------
| |
-------------------------------
OR
-------------
| |
-------------
-------------------------------
| |
------------------------------- */
( (currPixelRunStart <= lastLineXStart) &&
(currPixelRunFinish >= lastLineXFinish) ) )
{
/* THERE IS CONNECTEDNESS...update the lastLineXStart and lastLineXFinish
data pointed to by pTrackedObjectData */
*(pTrackedObjectData + LAST_LINE_X_START_OFFSET) = currPixelRunStart;
622: c1 83 std Z+1, r28 ; 0x01
*(pTrackedObjectData + LAST_LINE_X_FINISH_OFFSET) = currPixelRunFinish;
624: 62 83 std Z+2, r22 ; 0x02
/* check if the bounding box needs to be updated */
if (*(pTrackedObjectData + X_UPPER_LEFT_OFFSET) > currPixelRunStart)
626: 83 81 ldd r24, Z+3 ; 0x03
628: c8 17 cp r28, r24
62a: 08 f4 brcc .+2 ; 0x62e
{
/* need to update the bounding box for the upper left point to
enclose this new left-most point...we never have to update the
upper left Y point, since each scan line we process moves from
top to bottom */
*(pTrackedObjectData + X_UPPER_LEFT_OFFSET) = currPixelRunStart;
62c: c3 83 std Z+3, r28 ; 0x03
}
 
if ( *(pTrackedObjectData + X_LOWER_RIGHT_OFFSET) < currPixelRunFinish)
62e: 85 81 ldd r24, Z+5 ; 0x05
630: 86 17 cp r24, r22
632: 08 f4 brcc .+2 ; 0x636
{
/* need to update the bounding box for the lower right X point to
enclose this new right-most point */
*(pTrackedObjectData + X_LOWER_RIGHT_OFFSET) = currPixelRunFinish;
634: 65 83 std Z+5, r22 ; 0x05
}
/* the lower right 'y' point always gets updated when connectedness is found */
*(pTrackedObjectData + Y_LOWER_RIGHT_OFFSET) = trackedLineCount;
636: 80 91 77 00 lds r24, 0x0077
63a: 86 83 std Z+6, r24 ; 0x06
/* set a flag indicating that that color run is part of another
object and thus doesn't need to be added as a new entry into the
tracking table */
colorConnected = TRUE;
63c: 11 e0 ldi r17, 0x01 ; 1
break;
63e: 04 c0 rjmp .+8 ; 0x648
}
}
/* go to the next object */
pTrackedObjectData += SIZE_OF_TRACKED_OBJECT;
640: 38 96 adiw r30, 0x08 ; 8
642: 4f 5f subi r20, 0xFF ; 255
644: 48 30 cpi r20, 0x08 ; 8
646: 78 f2 brcs .-98 ; 0x5e6
}
if (colorConnected == FALSE)
648: 11 23 and r17, r17
64a: 11 f5 brne .+68 ; 0x690
{
/* a new entry needs to be made to the tracking table, since we have
a run-length with a color, and it isn't connected to anything...but we
can only do this if there is space left in the trackedObject table */
if (numCurrTrackedObjects < MAX_TRACKED_OBJECTS)
64c: 80 91 75 00 lds r24, 0x0075
650: 88 30 cpi r24, 0x08 ; 8
652: f0 f4 brcc .+60 ; 0x690
{
/* space is available...add the object...but first we need to find an
invalid object in the object tracking table */
pTrackedObjectData = (unsigned char *)pCurrentTrackedObjectTable;
654: e0 91 60 00 lds r30, 0x0060
658: f0 91 61 00 lds r31, 0x0061
for (i=0; i<MAX_TRACKED_OBJECTS; i++)
65c: 41 2f mov r20, r17
{
if ( *(pTrackedObjectData + VALID_OBJECT_OFFSET) == FALSE) break;
65e: 87 81 ldd r24, Z+7 ; 0x07
660: 88 23 and r24, r24
662: 21 f0 breq .+8 ; 0x66c
/* if we haven't broken above, then the object must have been valid...
go ahead and move the pointer to the next object to check it */
pTrackedObjectData += SIZE_OF_TRACKED_OBJECT;
664: 38 96 adiw r30, 0x08 ; 8
666: 4f 5f subi r20, 0xFF ; 255
668: 48 30 cpi r20, 0x08 ; 8
66a: c8 f3 brcs .-14 ; 0x65e
}
/* now that we have a pointer to the tracked object to be updated, update all
the fields */
*(pTrackedObjectData + COLOR_OFFSET) = currColor; /* color */
66c: 50 83 st Z, r21
*(pTrackedObjectData + LAST_LINE_X_START_OFFSET) = currPixelRunStart; /* lastLineXStart */
66e: c1 83 std Z+1, r28 ; 0x01
*(pTrackedObjectData + LAST_LINE_X_FINISH_OFFSET) = currPixelRunFinish; /* lastLineXFinish */
670: 62 83 std Z+2, r22 ; 0x02
*(pTrackedObjectData + X_UPPER_LEFT_OFFSET) = currPixelRunStart; /* x_upperLeft */
672: c3 83 std Z+3, r28 ; 0x03
*(pTrackedObjectData + Y_UPPER_LEFT_OFFSET) = trackedLineCount; /* y_upperLeft */
674: 80 91 77 00 lds r24, 0x0077
678: 84 83 std Z+4, r24 ; 0x04
*(pTrackedObjectData + X_LOWER_RIGHT_OFFSET) = currPixelRunFinish; /* x_lowerRight */
67a: 65 83 std Z+5, r22 ; 0x05
*(pTrackedObjectData + Y_LOWER_RIGHT_OFFSET) = trackedLineCount; /* y_lowerRight */
67c: 80 91 77 00 lds r24, 0x0077
680: 86 83 std Z+6, r24 ; 0x06
*(pTrackedObjectData + VALID_OBJECT_OFFSET) = TRUE; /* objectValid flag */
682: 81 e0 ldi r24, 0x01 ; 1
684: 87 83 std Z+7, r24 ; 0x07
numCurrTrackedObjects++;
686: 80 91 75 00 lds r24, 0x0075
68a: 8f 5f subi r24, 0xFF ; 255
68c: 80 93 75 00 sts 0x0075, r24
}
}
/* move the pointer to the beginning of the next tracked object */
pTrackedObjectData += SIZE_OF_TRACKED_OBJECT;
}
} while(currPixelRunFinish < ACTUAL_NUM_PIXELS_IN_A_LINE);
690: 60 3b cpi r22, 0xB0 ; 176
692: 08 f4 brcc .+2 ; 0x696
694: 98 cf rjmp .-208 ; 0x5c6
}
696: cf 91 pop r28
698: 1f 91 pop r17
69a: 08 95 ret
 
0000069c <UIMgr_init>:
Outputs: none
***********************************************************/
void UIMgr_init(void)
{
memset(asciiTokenBuffer,0x00,MAX_TOKEN_LENGTH+1);
69c: 10 92 bf 00 sts 0x00BF, r1
6a0: 10 92 c0 00 sts 0x00C0, r1
6a4: 10 92 c1 00 sts 0x00C1, r1
6a8: 10 92 c2 00 sts 0x00C2, r1
memset(tokenBuffer,0x00,MAX_TOKEN_COUNT);
6ac: 80 e4 ldi r24, 0x40 ; 64
6ae: e3 ec ldi r30, 0xC3 ; 195
6b0: f0 e0 ldi r31, 0x00 ; 0
6b2: 11 92 st Z+, r1
6b4: 8a 95 dec r24
6b6: e9 f7 brne .-6 ; 0x6b2
memset(UIMgr_txFifo,0x00,UI_MGR_TX_FIFO_SIZE);
6b8: 80 e4 ldi r24, 0x40 ; 64
6ba: e4 e9 ldi r30, 0x94 ; 148
6bc: f2 e0 ldi r31, 0x02 ; 2
6be: 11 92 st Z+, r1
6c0: 8a 95 dec r24
6c2: e9 f7 brne .-6 ; 0x6be
memset(UIMgr_rxFifo,0x00,UI_MGR_RX_FIFO_SIZE);
6c4: 80 e2 ldi r24, 0x20 ; 32
6c6: e4 e7 ldi r30, 0x74 ; 116
6c8: f2 e0 ldi r31, 0x02 ; 2
6ca: 11 92 st Z+, r1
6cc: 8a 95 dec r24
6ce: e9 f7 brne .-6 ; 0x6ca
}
6d0: 08 95 ret
 
000006d2 <UIMgr_dispatchEvent>:
 
/***********************************************************
Function Name: UIMgr_dispatchEvent
Function Description: This function is responsible for
processing events that pertain to the UIMgr.
Inputs: event - the generated event
Outputs: none
***********************************************************/
void UIMgr_dispatchEvent(unsigned char event)
{
switch(event)
6d2: 99 27 eor r25, r25
6d4: 80 31 cpi r24, 0x10 ; 16
6d6: 91 05 cpc r25, r1
6d8: 51 f0 breq .+20 ; 0x6ee
6da: 81 31 cpi r24, 0x11 ; 17
6dc: 91 05 cpc r25, r1
6de: 1c f4 brge .+6 ; 0x6e6
6e0: 01 97 sbiw r24, 0x01 ; 1
6e2: 39 f0 breq .+14 ; 0x6f2
{
case EV_ACQUIRE_LINE_COMPLETE:
UIMgr_transmitPendingData();
break;
case EV_SERIAL_DATA_RECEIVED:
UIMgr_processReceivedData();
break;
case EV_SERIAL_DATA_PENDING_TX:
UIMgr_flushTxBuffer();
break;
}
}
6e4: 08 95 ret
6e6: 80 39 cpi r24, 0x90 ; 144
6e8: 91 05 cpc r25, r1
6ea: 29 f0 breq .+10 ; 0x6f6
6ec: 08 95 ret
6ee: 06 d0 rcall .+12 ; 0x6fc
6f0: 08 95 ret
6f2: 0e d0 rcall .+28 ; 0x710
6f4: 08 95 ret
6f6: e6 d1 rcall .+972 ; 0xac4
6f8: 08 95 ret
6fa: 08 95 ret
 
000006fc <UIMgr_transmitPendingData>:
/***********************************************************
Function Name: UIMgr_transmitPendingData
Function Description: This function is responsible for
transmitting a single byte of data if data is waiting
to be sent. Otherwise, if nothing is waiting, the
function just returns.
Inputs: none
Outputs: none
***********************************************************/
void UIMgr_transmitPendingData(void)
{
if (IS_DATA_IN_TX_FIFO() == TRUE)
6fc: 90 91 ba 00 lds r25, 0x00BA
700: 80 91 bb 00 lds r24, 0x00BB
704: 98 17 cp r25, r24
706: 11 f0 breq .+4 ; 0x70c
{
/* data is waiting...send a single byte */
UartInt_txByte( UIMgr_readTxFifo() );
708: fe d1 rcall .+1020 ; 0xb06
70a: 2a d2 rcall .+1108 ; 0xb60
}
}
70c: 08 95 ret
70e: 08 95 ret
 
00000710 <UIMgr_processReceivedData>:
/***********************************************************
Function Name: UIMgr_processReceivedData
Function Description: This function is responsible for
parsing any serial data waiting in the rx fifo
Inputs: none
Outputs: none
***********************************************************/
void UIMgr_processReceivedData(void)
{
710: cf 93 push r28
unsigned char tmpData = 0;
 
/* still need to add a mechanism to handle token counts
that are excessive!!! FIX ME!!! */
while(IS_DATA_IN_RX_FIFO() == TRUE)
712: 90 91 b8 00 lds r25, 0x00B8
716: 80 91 b9 00 lds r24, 0x00B9
71a: 98 17 cp r25, r24
71c: 09 f4 brne .+2 ; 0x720
71e: 6f c0 rjmp .+222 ; 0x7fe
720: c9 e0 ldi r28, 0x09 ; 9
{
tmpData = UIMgr_readRxFifo();
722: df d1 rcall .+958 ; 0xae2
724: 38 2f mov r19, r24
if (tmpData == '\r')
726: 8d 30 cpi r24, 0x0D ; 13
728: 29 f5 brne .+74 ; 0x774
{
/* we have reached a token separator */
if (tokenCount == 0)
72a: 80 91 be 00 lds r24, 0x00BE
72e: 88 23 and r24, r24
730: 11 f4 brne .+4 ; 0x736
{
/* convert the command */
UIMgr_convertTokenToCmd();
732: 2c d1 rcall .+600 ; 0x98c
734: 06 c0 rjmp .+12 ; 0x742
}
else
{
/* convert a value */
UIMgr_convertTokenToValue();
736: 02 d1 rcall .+516 ; 0x93c
tokenCount++;
738: 80 91 be 00 lds r24, 0x00BE
73c: 8f 5f subi r24, 0xFF ; 255
73e: 80 93 be 00 sts 0x00BE, r24
}
/* either way, it is time to try to process the received
token list since we have reached the end of the cmd. */
Utility_delay(100);
742: 84 e6 ldi r24, 0x64 ; 100
744: 90 e0 ldi r25, 0x00 ; 0
746: 7f d3 rcall .+1790 ; 0xe46
if (receivedCmd == invalidCmd ||
748: 80 91 62 00 lds r24, 0x0062
74c: 88 50 subi r24, 0x08 ; 8
74e: 82 30 cpi r24, 0x02 ; 2
750: 20 f4 brcc .+8 ; 0x75a
receivedCmd == noCmd )
{
UIMgr_sendNck();
752: 84 d1 rcall .+776 ; 0xa5c
PUBLISH_EVENT(EV_SERIAL_DATA_PENDING_TX);
754: 80 e9 ldi r24, 0x90 ; 144
756: 7d dd rcall .-1286 ; 0x252
758: 04 c0 rjmp .+8 ; 0x762
}
else
{
UIMgr_sendAck();
75a: 77 d1 rcall .+750 ; 0xa4a
/* publish the serial data pending event, so it
will push the ACK out before we execute the cmd */
PUBLISH_EVENT(EV_SERIAL_DATA_PENDING_TX);
75c: 80 e9 ldi r24, 0x90 ; 144
75e: 79 dd rcall .-1294 ; 0x252
UIMgr_executeCmd();
760: 51 d0 rcall .+162 ; 0x804
}
/* reset any necessary data */
tokenCount = 0;
762: 10 92 be 00 sts 0x00BE, r1
memset(tokenBuffer,0x00,MAX_TOKEN_COUNT);
766: 80 e4 ldi r24, 0x40 ; 64
768: e3 ec ldi r30, 0xC3 ; 195
76a: f0 e0 ldi r31, 0x00 ; 0
76c: 11 92 st Z+, r1
76e: 8a 95 dec r24
770: e9 f7 brne .-6 ; 0x76c
772: 3e c0 rjmp .+124 ; 0x7f0
}
else if (tmpData == ' ') /* space char */
774: 80 32 cpi r24, 0x20 ; 32
776: d9 f4 brne .+54 ; 0x7ae
{
/* the end of a token has been reached */
if (tokenCount == 0)
778: 80 91 be 00 lds r24, 0x00BE
77c: 88 23 and r24, r24
77e: 11 f4 brne .+4 ; 0x784
{
UIMgr_convertTokenToCmd();
780: 05 d1 rcall .+522 ; 0x98c
tokenCount++; /* check this...why is this being incremented here??? This
782: 0f c0 rjmp .+30 ; 0x7a2
means we have received a token, with tokenCount == 0, which means it is a
command...why is this contributing to tokenCount?
This might cause the set color map command to include too much data, since
it sets the color map based on tokenCount...CHECK*/
}
else
{
/* check to see if this token is going to push
us over the limit...if so, abort the transaction */
if (tokenCount+1 >= MAX_TOKEN_COUNT)
784: 80 91 be 00 lds r24, 0x00BE
788: 99 27 eor r25, r25
78a: 01 96 adiw r24, 0x01 ; 1
78c: 80 34 cpi r24, 0x40 ; 64
78e: 91 05 cpc r25, r1
790: 3c f0 brlt .+14 ; 0x7a0
{
/* we received too many tokens, and
need to NCK this request, since its too
large...reset everything...*/
charCount=0;
792: 10 92 bc 00 sts 0x00BC, r1
charIndex=0;
796: 10 92 bd 00 sts 0x00BD, r1
tokenCount=0;
79a: 10 92 be 00 sts 0x00BE, r1
receivedCmd = invalidCmd;
79e: 26 c0 rjmp .+76 ; 0x7ec
}
else
{
/* tokenCount is still in range...*/
UIMgr_convertTokenToValue();
7a0: cd d0 rcall .+410 ; 0x93c
tokenCount++;
7a2: 80 91 be 00 lds r24, 0x00BE
7a6: 8f 5f subi r24, 0xFF ; 255
7a8: 80 93 be 00 sts 0x00BE, r24
7ac: 21 c0 rjmp .+66 ; 0x7f0
}
}
}
else if ( (tmpData >= 'A' && tmpData <= 'Z') ||
7ae: 81 54 subi r24, 0x41 ; 65
7b0: 8a 31 cpi r24, 0x1A ; 26
7b2: 18 f0 brcs .+6 ; 0x7ba
7b4: 8f 5e subi r24, 0xEF ; 239
7b6: 8a 30 cpi r24, 0x0A ; 10
7b8: c8 f4 brcc .+50 ; 0x7ec
(tmpData >= '0' && tmpData <= '9') )
{
/* a valid range of token was received */
asciiTokenBuffer[charIndex] = tmpData;
7ba: 20 91 bd 00 lds r18, 0x00BD
7be: 82 2f mov r24, r18
7c0: 99 27 eor r25, r25
7c2: fc 01 movw r30, r24
7c4: e1 54 subi r30, 0x41 ; 65
7c6: ff 4f sbci r31, 0xFF ; 255
7c8: 30 83 st Z, r19
charCount++;
7ca: 80 91 bc 00 lds r24, 0x00BC
7ce: 98 2f mov r25, r24
7d0: 9f 5f subi r25, 0xFF ; 255
7d2: 90 93 bc 00 sts 0x00BC, r25
charIndex++;
7d6: 82 2f mov r24, r18
7d8: 8f 5f subi r24, 0xFF ; 255
7da: 80 93 bd 00 sts 0x00BD, r24
if (charCount > MAX_TOKEN_LENGTH)
7de: 94 30 cpi r25, 0x04 ; 4
7e0: 38 f0 brcs .+14 ; 0x7f0
{
/* we have received a token that cannot be handled...
set the received cmd to an invalid cmd, and wait
for the \r to process it */
receivedCmd = invalidCmd;
7e2: c0 93 62 00 sts 0x0062, r28
charIndex = 0; /* ...so we won't overwrite memory */
7e6: 10 92 bd 00 sts 0x00BD, r1
7ea: 02 c0 rjmp .+4 ; 0x7f0
}
}
else
{
/* an invalid character was received */
receivedCmd = invalidCmd;
7ec: c0 93 62 00 sts 0x0062, r28
7f0: 90 91 b8 00 lds r25, 0x00B8
7f4: 80 91 b9 00 lds r24, 0x00B9
7f8: 98 17 cp r25, r24
7fa: 09 f0 breq .+2 ; 0x7fe
7fc: 92 cf rjmp .-220 ; 0x722
}
} /* end while */
asm volatile("clt"::); /* clear out the T flag in case it wasn't
7fe: e8 94 clt
cleared already */
}
800: cf 91 pop r28
802: 08 95 ret
 
00000804 <UIMgr_executeCmd>:
 
/***********************************************************
Function Name: UIMgr_executeCmd
Function Description: This function is responsible for
executing whatever cmd is stored in the receivedCmd
object.
Inputs: none
Outputs: none
***********************************************************/
static void UIMgr_executeCmd(void)
{
804: df 92 push r13
806: ef 92 push r14
808: ff 92 push r15
80a: 0f 93 push r16
80c: 1f 93 push r17
80e: cf 93 push r28
810: df 93 push r29
unsigned char i,eepromData, num_writes=0;
812: ee 24 eor r14, r14
unsigned char *pData;
unsigned char eeprom_write_succeeded = FALSE;
#if DEBUG_COLOR_MAP
unsigned char asciiBuffer[5];
#endif
 
if (receivedCmd == pingCmd)
814: 80 91 62 00 lds r24, 0x0062
818: 81 30 cpi r24, 0x01 ; 1
81a: 09 f4 brne .+2 ; 0x81e
81c: 87 c0 rjmp .+270 ; 0x92c
{
}
else if (receivedCmd == getVersionCmd)
81e: 88 23 and r24, r24
820: 69 f4 brne .+26 ; 0x83c
{
pData = AVRcamVersion;
822: c3 e6 ldi r28, 0x63 ; 99
824: d0 e0 ldi r29, 0x00 ; 0
while(*pData != 0)
826: 80 91 63 00 lds r24, 0x0063
82a: 88 23 and r24, r24
82c: 09 f4 brne .+2 ; 0x830
82e: 7e c0 rjmp .+252 ; 0x92c
{
UIMgr_writeTxFifo(*pData++);
830: 89 91 ld r24, Y+
832: 7b d1 rcall .+758 ; 0xb2a
834: 88 81 ld r24, Y
836: 88 23 and r24, r24
838: d9 f7 brne .-10 ; 0x830
83a: 78 c0 rjmp .+240 ; 0x92c
}
}
else if (receivedCmd == resetCameraCmd)
83c: 80 91 62 00 lds r24, 0x0062
840: 87 30 cpi r24, 0x07 ; 7
842: 11 f4 brne .+4 ; 0x848
{
CamInt_resetCam();
844: 8b dc rcall .-1770 ; 0x15c
846: 72 c0 rjmp .+228 ; 0x92c
}
else if (receivedCmd == dumpFrameCmd)
848: 80 91 62 00 lds r24, 0x0062
84c: 83 30 cpi r24, 0x03 ; 3
84e: 29 f4 brne .+10 ; 0x85a
{
/* publish the event that will indicate that
a request has come to dump a frame...this will
be received by the FrameMgr, which will begin
dumping the frame...a short delay is needed
here to keep the Java demo app happy (sometimes
it wouldn't be able to receive the serial data
as quickly as AVRcam can provide it). */
Utility_delay(100);
850: 84 e6 ldi r24, 0x64 ; 100
852: 90 e0 ldi r25, 0x00 ; 0
854: f8 d2 rcall .+1520 ; 0xe46
PUBLISH_EVENT(EV_DUMP_FRAME);
856: 82 e0 ldi r24, 0x02 ; 2
858: 28 c0 rjmp .+80 ; 0x8aa
}
else if (receivedCmd == setCameraRegsCmd)
85a: 80 91 62 00 lds r24, 0x0062
85e: 82 30 cpi r24, 0x02 ; 2
860: b1 f4 brne .+44 ; 0x88e
{
/* we need to gather the tokens and
build config cmds to be sent to the camera */
for (i=1; i<tokenCount; i+=2) /* starts at 1 since first token
862: ff 24 eor r15, r15
864: f3 94 inc r15
866: 80 91 be 00 lds r24, 0x00BE
86a: f8 16 cp r15, r24
86c: 70 f4 brcc .+28 ; 0x88a
is the CR cmd */
{
CamConfig_setCamReg(tokenBuffer[i],tokenBuffer[i+1]);
86e: 8f 2d mov r24, r15
870: 99 27 eor r25, r25
872: fc 01 movw r30, r24
874: ed 53 subi r30, 0x3D ; 61
876: ff 4f sbci r31, 0xFF ; 255
878: 61 81 ldd r22, Z+1 ; 0x01
87a: 80 81 ld r24, Z
87c: 85 d2 rcall .+1290 ; 0xd88
87e: 82 e0 ldi r24, 0x02 ; 2
880: f8 0e add r15, r24
882: 80 91 be 00 lds r24, 0x00BE
886: f8 16 cp r15, r24
888: 90 f3 brcs .-28 ; 0x86e
}
CamConfig_sendFifoCmds();
88a: 83 d2 rcall .+1286 ; 0xd92
88c: 4f c0 rjmp .+158 ; 0x92c
}
else if (receivedCmd == enableTrackingCmd)
88e: 80 91 62 00 lds r24, 0x0062
892: 84 30 cpi r24, 0x04 ; 4
894: 29 f4 brne .+10 ; 0x8a0
{
/* publish the event...again with a short delay */
Utility_delay(100);
896: 84 e6 ldi r24, 0x64 ; 100
898: 90 e0 ldi r25, 0x00 ; 0
89a: d5 d2 rcall .+1450 ; 0xe46
PUBLISH_EVENT(EV_ENABLE_TRACKING);
89c: 80 e8 ldi r24, 0x80 ; 128
89e: 05 c0 rjmp .+10 ; 0x8aa
}
else if (receivedCmd == disableTrackingCmd)
8a0: 80 91 62 00 lds r24, 0x0062
8a4: 85 30 cpi r24, 0x05 ; 5
8a6: 19 f4 brne .+6 ; 0x8ae
{
PUBLISH_EVENT(EV_DISABLE_TRACKING);
8a8: 81 e8 ldi r24, 0x81 ; 129
8aa: d3 dc rcall .-1626 ; 0x252
8ac: 3f c0 rjmp .+126 ; 0x92c
}
else if (receivedCmd == setColorMapCmd)
8ae: 80 91 62 00 lds r24, 0x0062
8b2: 86 30 cpi r24, 0x06 ; 6
8b4: d9 f5 brne .+118 ; 0x92c
{
/* copy the received tokens into the color map */
for (i=0; i<tokenCount; i++)
8b6: ff 24 eor r15, r15
8b8: 80 91 be 00 lds r24, 0x00BE
8bc: f8 16 cp r15, r24
8be: b0 f5 brcc .+108 ; 0x92c
{
colorMap[i] = tokenBuffer[i+1];
8c0: 8f 2d mov r24, r15
8c2: 99 27 eor r25, r25
8c4: 8c 01 movw r16, r24
8c6: 00 50 subi r16, 0x00 ; 0
8c8: 1d 4f sbci r17, 0xFD ; 253
8ca: fc 01 movw r30, r24
8cc: ed 53 subi r30, 0x3D ; 61
8ce: ff 4f sbci r31, 0xFF ; 255
8d0: 21 81 ldd r18, Z+1 ; 0x01
8d2: f8 01 movw r30, r16
8d4: 20 83 st Z, r18
/* write each colorMap byte to EEPROM, but only those
that changed...this will help reduce wear on the EEPROM */
eepromData = eeprom_read_byte( (unsigned char*)(i+1));
8d6: 01 96 adiw r24, 0x01 ; 1
8d8: b5 d3 rcall .+1898 ; 0x1044
8da: 98 2f mov r25, r24
if (eepromData != colorMap[i])
8dc: f8 01 movw r30, r16
8de: 80 81 ld r24, Z
8e0: 98 17 cp r25, r24
8e2: f9 f0 breq .+62 ; 0x922
{
/* need to actually perform the write because the
data in eeprom is different than the current colorMap */
eeprom_write_succeeded = FALSE;
8e4: dd 24 eor r13, r13
while(eeprom_write_succeeded == FALSE && num_writes < MAX_EEPROM_WRITE_ATTEMPTS)
8e6: f2 e0 ldi r31, 0x02 ; 2
8e8: fe 15 cp r31, r14
8ea: d0 f0 brcs .+52 ; 0x920
8ec: 8f 2d mov r24, r15
8ee: 99 27 eor r25, r25
8f0: 8c 01 movw r16, r24
8f2: 00 50 subi r16, 0x00 ; 0
8f4: 1d 4f sbci r17, 0xFD ; 253
8f6: ec 01 movw r28, r24
8f8: 21 96 adiw r28, 0x01 ; 1
{
eeprom_write_byte((unsigned char*)(i+1),colorMap[i]);
8fa: f8 01 movw r30, r16
8fc: 60 81 ld r22, Z
8fe: ce 01 movw r24, r28
900: ba d3 rcall .+1908 ; 0x1076
num_writes++;
902: e3 94 inc r14
eepromData = eeprom_read_byte( (unsigned char*)(i+1));
904: ce 01 movw r24, r28
906: 9e d3 rcall .+1852 ; 0x1044
908: 98 2f mov r25, r24
if (eepromData == colorMap[i])
90a: f8 01 movw r30, r16
90c: 80 81 ld r24, Z
90e: 98 17 cp r25, r24
910: 11 f4 brne .+4 ; 0x916
{
eeprom_write_succeeded = TRUE;
912: dd 24 eor r13, r13
914: d3 94 inc r13
916: dd 20 and r13, r13
918: 19 f4 brne .+6 ; 0x920
91a: f2 e0 ldi r31, 0x02 ; 2
91c: fe 15 cp r31, r14
91e: 68 f7 brcc .-38 ; 0x8fa
}
}
num_writes = 0;
920: ee 24 eor r14, r14
922: f3 94 inc r15
924: 80 91 be 00 lds r24, 0x00BE
928: f8 16 cp r15, r24
92a: 50 f2 brcs .-108 ; 0x8c0
}
}
 
#if DEBUG_COLOR_MAP
/* for debugging...send out the entire color map */
UIMgr_txBuffer("\r\n",2);
for (i=0; i<NUM_ELEMENTS_IN_COLOR_MAP; i++)
{
memset(asciiBuffer,0x00,5);
itoa(colorMap[i],asciiBuffer,10);
UIMgr_txBuffer(asciiBuffer,3);
UIMgr_txBuffer(" ",1);
if (i==15 || i == 31)
{
/* break up the output */
UIMgr_txBuffer("\r\n",2);
}
}
#endif
}
}
92c: df 91 pop r29
92e: cf 91 pop r28
930: 1f 91 pop r17
932: 0f 91 pop r16
934: ff 90 pop r15
936: ef 90 pop r14
938: df 90 pop r13
93a: 08 95 ret
 
0000093c <UIMgr_convertTokenToValue>:
 
/***********************************************************
Function Name: UIMgr_convertTokenToValue
Function Description: This function is responsible for
converting a received token to a hex value It will
access the asciiTokenBuffer directly, and store the
result in the appropriate token buffer.
Inputs: none
Outputs: none
***********************************************************/
static void UIMgr_convertTokenToValue(void)
{
unsigned int newValue;
newValue = atoi(asciiTokenBuffer);
93c: 8f eb ldi r24, 0xBF ; 191
93e: 90 e0 ldi r25, 0x00 ; 0
940: 55 d3 rcall .+1706 ; 0xfec
942: ac 01 movw r20, r24
if (newValue > 255)
944: 8f 3f cpi r24, 0xFF ; 255
946: 91 05 cpc r25, r1
948: 71 f0 breq .+28 ; 0x966
94a: 68 f0 brcs .+26 ; 0x966
{
/* the value is too large */
receivedCmd = invalidCmd;
94c: 89 e0 ldi r24, 0x09 ; 9
94e: 80 93 62 00 sts 0x0062, r24
tokenBuffer[tokenCount] = 0xFF; /* to indicate an error */
952: 20 91 be 00 lds r18, 0x00BE
956: 83 ec ldi r24, 0xC3 ; 195
958: 90 e0 ldi r25, 0x00 ; 0
95a: fc 01 movw r30, r24
95c: e2 0f add r30, r18
95e: f1 1d adc r31, r1
960: 8f ef ldi r24, 0xFF ; 255
962: 80 83 st Z, r24
964: 08 c0 rjmp .+16 ; 0x976
}
else
{
/* copy the value into the tokenBuffer */
tokenBuffer[tokenCount] = newValue;
966: 80 91 be 00 lds r24, 0x00BE
96a: 23 ec ldi r18, 0xC3 ; 195
96c: 30 e0 ldi r19, 0x00 ; 0
96e: f9 01 movw r30, r18
970: e8 0f add r30, r24
972: f1 1d adc r31, r1
974: 40 83 st Z, r20
}
memset(asciiTokenBuffer,0x00,MAX_TOKEN_LENGTH);
976: 83 e0 ldi r24, 0x03 ; 3
978: ef eb ldi r30, 0xBF ; 191
97a: f0 e0 ldi r31, 0x00 ; 0
97c: 11 92 st Z+, r1
97e: 8a 95 dec r24
980: e9 f7 brne .-6 ; 0x97c
charIndex = 0;
982: 10 92 bd 00 sts 0x00BD, r1
charCount = 0;
986: 10 92 bc 00 sts 0x00BC, r1
}
98a: 08 95 ret
 
0000098c <UIMgr_convertTokenToCmd>:
/***********************************************************
Function Name: UIMgr_convertTokenToCmd
Function Description: This function is responsible for
parsing a received 2-character command. It will
access the asciiTokenBuffer directly.
Inputs: none
Outputs: none
***********************************************************/
static void UIMgr_convertTokenToCmd(void)
{
if ( (asciiTokenBuffer[0] == 'P') &&
98c: 80 91 bf 00 lds r24, 0x00BF
990: 80 35 cpi r24, 0x50 ; 80
992: 31 f4 brne .+12 ; 0x9a0
994: 80 91 c0 00 lds r24, 0x00C0
998: 87 34 cpi r24, 0x47 ; 71
99a: 11 f4 brne .+4 ; 0x9a0
(asciiTokenBuffer[1] == 'G') )
{
/* we got a "ping" command...but we still need to see
if we are going to get the \r */
receivedCmd = pingCmd;
99c: 81 e0 ldi r24, 0x01 ; 1
99e: 48 c0 rjmp .+144 ; 0xa30
}
else if ( (asciiTokenBuffer[0] == 'G') &&
9a0: 80 91 bf 00 lds r24, 0x00BF
9a4: 87 34 cpi r24, 0x47 ; 71
9a6: 39 f4 brne .+14 ; 0x9b6
9a8: 80 91 c0 00 lds r24, 0x00C0
9ac: 86 35 cpi r24, 0x56 ; 86
9ae: 19 f4 brne .+6 ; 0x9b6
(asciiTokenBuffer[1] == 'V') )
{
/* we got the "get version" command */
receivedCmd = getVersionCmd;
9b0: 10 92 62 00 sts 0x0062, r1
9b4: 3f c0 rjmp .+126 ; 0xa34
}
else if ( (asciiTokenBuffer[0] == 'D') &&
9b6: 80 91 bf 00 lds r24, 0x00BF
9ba: 84 34 cpi r24, 0x44 ; 68
9bc: 31 f4 brne .+12 ; 0x9ca
9be: 80 91 c0 00 lds r24, 0x00C0
9c2: 86 34 cpi r24, 0x46 ; 70
9c4: 11 f4 brne .+4 ; 0x9ca
(asciiTokenBuffer[1] == 'F') )
{
/* we should go into frame dump mode */
receivedCmd = dumpFrameCmd;
9c6: 83 e0 ldi r24, 0x03 ; 3
9c8: 33 c0 rjmp .+102 ; 0xa30
}
else if ( (asciiTokenBuffer[0] == 'C') &&
9ca: 80 91 bf 00 lds r24, 0x00BF
9ce: 83 34 cpi r24, 0x43 ; 67
9d0: 31 f4 brne .+12 ; 0x9de
9d2: 80 91 c0 00 lds r24, 0x00C0
9d6: 82 35 cpi r24, 0x52 ; 82
9d8: 11 f4 brne .+4 ; 0x9de
(asciiTokenBuffer[1] == 'R') )
{
/* the user wants to set registers in the OV6620 */
receivedCmd = setCameraRegsCmd;
9da: 82 e0 ldi r24, 0x02 ; 2
9dc: 29 c0 rjmp .+82 ; 0xa30
}
else if ( (asciiTokenBuffer[0] == 'E') &&
9de: 80 91 bf 00 lds r24, 0x00BF
9e2: 85 34 cpi r24, 0x45 ; 69
9e4: 31 f4 brne .+12 ; 0x9f2
9e6: 80 91 c0 00 lds r24, 0x00C0
9ea: 84 35 cpi r24, 0x54 ; 84
9ec: 11 f4 brne .+4 ; 0x9f2
(asciiTokenBuffer[1] == 'T') )
{
/* the user wants to enable tracking */
receivedCmd = enableTrackingCmd;
9ee: 84 e0 ldi r24, 0x04 ; 4
9f0: 1f c0 rjmp .+62 ; 0xa30
}
else if ( (asciiTokenBuffer[0] == 'S') &&
9f2: 80 91 bf 00 lds r24, 0x00BF
9f6: 83 35 cpi r24, 0x53 ; 83
9f8: 31 f4 brne .+12 ; 0xa06
9fa: 80 91 c0 00 lds r24, 0x00C0
9fe: 8d 34 cpi r24, 0x4D ; 77
a00: 11 f4 brne .+4 ; 0xa06
(asciiTokenBuffer[1] == 'M') )
{
/* the user wants to set the color map */
receivedCmd = setColorMapCmd;
a02: 86 e0 ldi r24, 0x06 ; 6
a04: 15 c0 rjmp .+42 ; 0xa30
}
else if ( (asciiTokenBuffer[0] == 'D') &&
a06: 80 91 bf 00 lds r24, 0x00BF
a0a: 84 34 cpi r24, 0x44 ; 68
a0c: 31 f4 brne .+12 ; 0xa1a
a0e: 80 91 c0 00 lds r24, 0x00C0
a12: 84 35 cpi r24, 0x54 ; 84
a14: 11 f4 brne .+4 ; 0xa1a
(asciiTokenBuffer[1] == 'T') )
{
receivedCmd = disableTrackingCmd;
a16: 85 e0 ldi r24, 0x05 ; 5
a18: 0b c0 rjmp .+22 ; 0xa30
}
else if ( (asciiTokenBuffer[0] == 'R') &&
a1a: 80 91 bf 00 lds r24, 0x00BF
a1e: 82 35 cpi r24, 0x52 ; 82
a20: 31 f4 brne .+12 ; 0xa2e
a22: 80 91 c0 00 lds r24, 0x00C0
a26: 83 35 cpi r24, 0x53 ; 83
a28: 11 f4 brne .+4 ; 0xa2e
(asciiTokenBuffer[1] == 'S') )
{
receivedCmd = resetCameraCmd;
a2a: 87 e0 ldi r24, 0x07 ; 7
a2c: 01 c0 rjmp .+2 ; 0xa30
}
else
{
/* don't recognize the cmd */
receivedCmd = invalidCmd;
a2e: 89 e0 ldi r24, 0x09 ; 9
a30: 80 93 62 00 sts 0x0062, r24
}
memset(asciiTokenBuffer,0x00,MAX_TOKEN_LENGTH);
a34: 83 e0 ldi r24, 0x03 ; 3
a36: ef eb ldi r30, 0xBF ; 191
a38: f0 e0 ldi r31, 0x00 ; 0
a3a: 11 92 st Z+, r1
a3c: 8a 95 dec r24
a3e: e9 f7 brne .-6 ; 0xa3a
charIndex = 0;
a40: 10 92 bd 00 sts 0x00BD, r1
charCount = 0;
a44: 10 92 bc 00 sts 0x00BC, r1
}
a48: 08 95 ret
 
00000a4a <UIMgr_sendAck>:
/***********************************************************
Function Name: UIMgr_sendAck
Function Description: This function is responsible for
queuing up an ACK to be sent to the user.
Inputs: none
Outputs: none
***********************************************************/
static void UIMgr_sendAck(void)
{
UIMgr_writeTxFifo('A');
a4a: 81 e4 ldi r24, 0x41 ; 65
a4c: 6e d0 rcall .+220 ; 0xb2a
UIMgr_writeTxFifo('C');
a4e: 83 e4 ldi r24, 0x43 ; 67
a50: 6c d0 rcall .+216 ; 0xb2a
UIMgr_writeTxFifo('K');
a52: 8b e4 ldi r24, 0x4B ; 75
a54: 6a d0 rcall .+212 ; 0xb2a
UIMgr_writeTxFifo('\r');
a56: 8d e0 ldi r24, 0x0D ; 13
a58: 68 d0 rcall .+208 ; 0xb2a
}
a5a: 08 95 ret
 
00000a5c <UIMgr_sendNck>:
 
/***********************************************************
Function Name: UIMgr_sendNck
Function Description: This function is responsible for
queueing up an NCK to be sent to the user.
Inputs: none
Outputs: none
***********************************************************/
static void UIMgr_sendNck(void)
{
UIMgr_writeTxFifo('N');
a5c: 8e e4 ldi r24, 0x4E ; 78
a5e: 65 d0 rcall .+202 ; 0xb2a
UIMgr_writeTxFifo('C');
a60: 83 e4 ldi r24, 0x43 ; 67
a62: 63 d0 rcall .+198 ; 0xb2a
UIMgr_writeTxFifo('K');
a64: 8b e4 ldi r24, 0x4B ; 75
a66: 61 d0 rcall .+194 ; 0xb2a
UIMgr_writeTxFifo('\r');
a68: 8d e0 ldi r24, 0x0D ; 13
a6a: 5f d0 rcall .+190 ; 0xb2a
}
a6c: 08 95 ret
 
00000a6e <UIMgr_writeBufferToTxFifo>:
 
 
/***********************************************************
Function Name: UIMgr_writeBufferToTxFifo
Function Description: This function is responsible for
placing "length" bytes into the tx FIFO.
Inputs: pData - a pointer to the data to send
length - the number of bytes to send
Outputs: none
***********************************************************/
void UIMgr_writeBufferToTxFifo(unsigned char *pData, unsigned char length)
{
a6e: dc 01 movw r26, r24
unsigned char tmpHead;
if (length == 0)
a70: 66 23 and r22, r22
a72: a9 f0 breq .+42 ; 0xa9e
{
return;
}
DISABLE_INTS();
a74: f8 94 cli
while(length-- != 0)
a76: 61 50 subi r22, 0x01 ; 1
a78: 6f 3f cpi r22, 0xFF ; 255
a7a: 81 f0 breq .+32 ; 0xa9c
a7c: 24 e9 ldi r18, 0x94 ; 148
a7e: 32 e0 ldi r19, 0x02 ; 2
{
UIMgr_txFifo[UIMgr_txFifoHead] = *pData++;
a80: 90 91 ba 00 lds r25, 0x00BA
a84: f9 01 movw r30, r18
a86: e9 0f add r30, r25
a88: f1 1d adc r31, r1
a8a: 8d 91 ld r24, X+
a8c: 80 83 st Z, r24
/* now move the head up */
tmpHead = (UIMgr_txFifoHead + 1) & (UI_MGR_TX_FIFO_MASK);
a8e: 89 2f mov r24, r25
a90: 8f 5f subi r24, 0xFF ; 255
a92: 8f 73 andi r24, 0x3F ; 63
UIMgr_txFifoHead = tmpHead;
a94: 80 93 ba 00 sts 0x00BA, r24
a98: 61 50 subi r22, 0x01 ; 1
a9a: 90 f7 brcc .-28 ; 0xa80
}
ENABLE_INTS();
a9c: 78 94 sei
}
a9e: 08 95 ret
 
00000aa0 <UIMgr_txBuffer>:
 
/***********************************************************
Function Name: UIMgr_txBuffer
Function Description: This function is responsible for
sending 'length' bytes out using the UartInterface
module.
Inputs: pData - a pointer to the data to send
length - the number of bytes to send
Outputs: none
***********************************************************/
void UIMgr_txBuffer(unsigned char *pData, unsigned char length)
{
aa0: 0f 93 push r16
aa2: 1f 93 push r17
aa4: cf 93 push r28
aa6: 8c 01 movw r16, r24
aa8: c6 2f mov r28, r22
while(length-- != 0)
aaa: c1 50 subi r28, 0x01 ; 1
aac: cf 3f cpi r28, 0xFF ; 255
aae: 31 f0 breq .+12 ; 0xabc
{
UartInt_txByte(*pData++);
ab0: f8 01 movw r30, r16
ab2: 81 91 ld r24, Z+
ab4: 8f 01 movw r16, r30
ab6: 54 d0 rcall .+168 ; 0xb60
ab8: c1 50 subi r28, 0x01 ; 1
aba: d0 f7 brcc .-12 ; 0xab0
}
}
abc: cf 91 pop r28
abe: 1f 91 pop r17
ac0: 0f 91 pop r16
ac2: 08 95 ret
 
00000ac4 <UIMgr_flushTxBuffer>:
 
/***********************************************************
Function Name: UIMgr_flushTxBuffer
Function Description: This function is responsible for
sending all data currently in the serial tx buffer
to the user.
Inputs: none
Outputs: none
***********************************************************/
void UIMgr_flushTxBuffer(void)
{
while(IS_DATA_IN_TX_FIFO() == TRUE)
ac4: 90 91 ba 00 lds r25, 0x00BA
ac8: 80 91 bb 00 lds r24, 0x00BB
acc: 98 17 cp r25, r24
ace: 41 f0 breq .+16 ; 0xae0
{
UartInt_txByte(UIMgr_readTxFifo() );
ad0: 1a d0 rcall .+52 ; 0xb06
ad2: 46 d0 rcall .+140 ; 0xb60
ad4: 90 91 ba 00 lds r25, 0x00BA
ad8: 80 91 bb 00 lds r24, 0x00BB
adc: 98 17 cp r25, r24
ade: c1 f7 brne .-16 ; 0xad0
}
}
ae0: 08 95 ret
 
00000ae2 <UIMgr_readRxFifo>:
 
/***********************************************************
Function Name: UIMgr_readRxFifo
Function Description: This function is responsible for
reading a single byte of data from the rx fifo, and
updating the appropriate pointers.
Inputs: none
Outputs: unsigned char-the data read
***********************************************************/
static unsigned char UIMgr_readRxFifo(void)
{
unsigned char dataByte, tmpTail;
/* just return the current tail from the rx fifo */
DISABLE_INTS();
ae2: f8 94 cli
dataByte = UIMgr_rxFifo[UIMgr_rxFifoTail];
ae4: 20 91 b9 00 lds r18, 0x00B9
ae8: 84 e7 ldi r24, 0x74 ; 116
aea: 92 e0 ldi r25, 0x02 ; 2
aec: fc 01 movw r30, r24
aee: e2 0f add r30, r18
af0: f1 1d adc r31, r1
af2: 90 81 ld r25, Z
tmpTail = (UIMgr_rxFifoTail+1) & (UI_MGR_RX_FIFO_MASK);
af4: 82 2f mov r24, r18
af6: 8f 5f subi r24, 0xFF ; 255
af8: 8f 71 andi r24, 0x1F ; 31
UIMgr_rxFifoTail = tmpTail;
afa: 80 93 b9 00 sts 0x00B9, r24
ENABLE_INTS();
afe: 78 94 sei
return(dataByte);
b00: 89 2f mov r24, r25
b02: 99 27 eor r25, r25
}
b04: 08 95 ret
 
00000b06 <UIMgr_readTxFifo>:
 
/***********************************************************
Function Name: UIMgr_readTxFifo
Function Description: This function is responsible for
reading a single byte of data from the tx fifo, and
updating the appropriate pointers.
Inputs: none
Outputs: unsigned char-the data read
***********************************************************/
static unsigned char UIMgr_readTxFifo(void)
{
unsigned char dataByte, tmpTail;
/* just return the current tail from the tx fifo */
DISABLE_INTS();
b06: f8 94 cli
dataByte = UIMgr_txFifo[UIMgr_txFifoTail];
b08: 20 91 bb 00 lds r18, 0x00BB
b0c: 84 e9 ldi r24, 0x94 ; 148
b0e: 92 e0 ldi r25, 0x02 ; 2
b10: fc 01 movw r30, r24
b12: e2 0f add r30, r18
b14: f1 1d adc r31, r1
b16: 90 81 ld r25, Z
tmpTail = (UIMgr_txFifoTail+1) & (UI_MGR_TX_FIFO_MASK);
b18: 82 2f mov r24, r18
b1a: 8f 5f subi r24, 0xFF ; 255
b1c: 8f 73 andi r24, 0x3F ; 63
UIMgr_txFifoTail = tmpTail;
b1e: 80 93 bb 00 sts 0x00BB, r24
ENABLE_INTS();
b22: 78 94 sei
return(dataByte);
b24: 89 2f mov r24, r25
b26: 99 27 eor r25, r25
}
b28: 08 95 ret
 
00000b2a <UIMgr_writeTxFifo>:
 
/***********************************************************
Function Name: UIMgr_writeTxFifo
Function Description: This function is responsible for
writing a single byte to the TxFifo and
updating the appropriate pointers.
Inputs: data - the byte to write to the Fifo
Outputs: none
***********************************************************/
void UIMgr_writeTxFifo(unsigned char data)
{
b2a: 38 2f mov r19, r24
unsigned char tmpHead;
 
DISABLE_INTS();
b2c: f8 94 cli
UIMgr_txFifo[UIMgr_txFifoHead] = data;
b2e: 20 91 ba 00 lds r18, 0x00BA
b32: 84 e9 ldi r24, 0x94 ; 148
b34: 92 e0 ldi r25, 0x02 ; 2
b36: fc 01 movw r30, r24
b38: e2 0f add r30, r18
b3a: f1 1d adc r31, r1
b3c: 30 83 st Z, r19
 
/* now move the head up */
tmpHead = (UIMgr_txFifoHead + 1) & (UI_MGR_TX_FIFO_MASK);
b3e: 82 2f mov r24, r18
b40: 8f 5f subi r24, 0xFF ; 255
b42: 8f 73 andi r24, 0x3F ; 63
UIMgr_txFifoHead = tmpHead;
b44: 80 93 ba 00 sts 0x00BA, r24
ENABLE_INTS();
b48: 78 94 sei
}
b4a: 08 95 ret
 
00000b4c <UartInt_init>:
void UartInt_init(void)
{
/* set up the baud rate registers so the UART will operate
at 115.2 Kbps */
UBRRH = 0x00;
b4c: 10 bc out 0x20, r1 ; 32
 
#ifdef NO_CRYSTAL
UBRRL = 18; /* 18 for double clocking at 115.2 kbps */
b4e: 82 e1 ldi r24, 0x12 ; 18
b50: 89 b9 out 0x09, r24 ; 9
#else
UBRRL = 0x08; /* for 16 MHz crystal at 115.2 kbps */
#endif
/* enable the tx and rx capabilities of the UART...as well
as the receive complete interrupt */
UCSRB = (1<<RXCIE)|(1<<RXEN)|(1<<TXEN);
b52: 88 e9 ldi r24, 0x98 ; 152
b54: 8a b9 out 0x0a, r24 ; 10
/* set up the control registers so the UART works at 8N1 */
UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0);
b56: 86 e8 ldi r24, 0x86 ; 134
b58: 80 bd out 0x20, r24 ; 32
#ifdef NO_CRYSTAL
/* set the baud rate to use the double-speed */
UCSRA = (1<<U2X);
b5a: 82 e0 ldi r24, 0x02 ; 2
b5c: 8b b9 out 0x0b, r24 ; 11
#endif
}
b5e: 08 95 ret
 
00000b60 <UartInt_txByte>:
 
/***********************************************************
Function Name: UartInt_txByte
Function Description: This function is responsible for
transmitting a single byte on the uart.
Inputs: txByte - the byte to send
Outputs: none
NOTES: When the TX UDRE (data register empty) is set, there
is puposefully no interrupt...thus, to send a string of
data out, the calling routine needs to hold up the entire
application while this takes place (or just send one
byte at a time at strtegically timed intervals, like
the stats data is sent out :-)
***********************************************************/
void UartInt_txByte(unsigned char txByte)
{
/* Wait for empty transmit buffer */
while ( !( UCSRA & (1<<UDRE)) );
b60: 5d 9b sbis 0x0b, 5 ; 11
b62: fe cf rjmp .-4 ; 0xb60
/* Put data into buffer, sends the data */
UDR = txByte;
b64: 8c b9 out 0x0c, r24 ; 12
}
b66: 08 95 ret
 
00000b68 <__vector_11>:
 
/***********************************************************
Function Name: SIG_UART_RECV ISR
Function Description: This function is responsible for
handling the interrupt caused when a data byte is
received by the UART.
Inputs: none
Outputs: none
NOTES: This function was originally written in assembly,
but moved over to C when the setting of the "T" bit at
the end of the routine was no longer necessary (this
theoretically allowed the AVRcam to respond to serial
bytes in the middle of tracking or dumping a frame.
But it wasn't really needed, and understanding the C
is easier :-)
***********************************************************/
SIGNAL(SIG_UART_RECV)
{
b68: 1f 92 push r1
b6a: 0f 92 push r0
b6c: 0f b6 in r0, 0x3f ; 63
b6e: 0f 92 push r0
b70: 11 24 eor r1, r1
b72: 2f 93 push r18
b74: 8f 93 push r24
b76: 9f 93 push r25
b78: ef 93 push r30
b7a: ff 93 push r31
unsigned char tmpHead;
/* read the data byte, put it in the serial queue, and
post the event */
UIMgr_rxFifo[UIMgr_rxFifoHead] = UDR;
b7c: 20 91 b8 00 lds r18, 0x00B8
b80: 84 e7 ldi r24, 0x74 ; 116
b82: 92 e0 ldi r25, 0x02 ; 2
b84: fc 01 movw r30, r24
b86: e2 0f add r30, r18
b88: f1 1d adc r31, r1
b8a: 8c b1 in r24, 0x0c ; 12
b8c: 80 83 st Z, r24
 
/* now move the head up */
tmpHead = (UIMgr_rxFifoHead + 1) & (UI_MGR_RX_FIFO_MASK);
b8e: 2f 5f subi r18, 0xFF ; 255
b90: 2f 71 andi r18, 0x1F ; 31
UIMgr_rxFifoHead = tmpHead;
b92: 20 93 b8 00 sts 0x00B8, r18
/* write the serial received event to the event fifo */
Exec_eventFifo[Exec_eventFifoHead] = EV_SERIAL_DATA_RECEIVED;
b96: 20 91 70 00 lds r18, 0x0070
b9a: 8c e6 ldi r24, 0x6C ; 108
b9c: 92 e0 ldi r25, 0x02 ; 2
b9e: fc 01 movw r30, r24
ba0: e2 0f add r30, r18
ba2: f1 1d adc r31, r1
ba4: 81 e0 ldi r24, 0x01 ; 1
ba6: 80 83 st Z, r24
 
/* now move the head up */
tmpHead = (Exec_eventFifoHead + 1) & (EXEC_EVENT_FIFO_MASK);
ba8: 28 0f add r18, r24
baa: 27 70 andi r18, 0x07 ; 7
Exec_eventFifoHead = tmpHead;
bac: 20 93 70 00 sts 0x0070, r18
}
bb0: ff 91 pop r31
bb2: ef 91 pop r30
bb4: 9f 91 pop r25
bb6: 8f 91 pop r24
bb8: 2f 91 pop r18
bba: 0f 90 pop r0
bbc: 0f be out 0x3f, r0 ; 63
bbe: 0f 90 pop r0
bc0: 1f 90 pop r1
bc2: 18 95 reti
 
00000bc4 <I2CInt_init>:
Outputs: none
***********************************************************/
void I2CInt_init(void)
{
TWSR = 0;
bc4: 11 b8 out 0x01, r1 ; 1
/* init the speed of the I2C interface, running at
100 Kbps */
TWBR = (FOSC / I2C_SPEED - 16)/2;
bc6: 88 e4 ldi r24, 0x48 ; 72
bc8: 80 b9 out 0x00, r24 ; 0
}
bca: 08 95 ret
 
00000bcc <I2CInt_writeData>:
 
/***********************************************************
Function Name: I2CInt_writeData
Function Description: This function is responsible for
initiating the process of writing a sequence of bytes
an I2C slave address. This function will try to write
the data three times before giving up.
Inputs: address: the address of the I2C slave device
data: a pointer to the data to be written
to the slave...for camera interfacing,
the data follows a <register #><data>
format
bytes: the number of bytes to write
Outputs: none
***********************************************************/
void I2CInt_writeData(unsigned char address, unsigned char *data, unsigned char bytes)
{
bcc: 98 2f mov r25, r24
while(status & (1<<BUSY)); /* Bus is busy wait (or exit with error code) */
bce: 80 91 08 01 lds r24, 0x0108
bd2: 88 23 and r24, r24
bd4: e4 f3 brlt .-8 ; 0xbce
while(TWCR & (1<<TWSTO));
bd6: 06 b6 in r0, 0x36 ; 54
bd8: 04 fc sbrc r0, 4
bda: fd cf rjmp .-6 ; 0xbd6
/* copy the needed data and state info to our local I2C command structure */
twi_address = address;
bdc: 90 93 03 01 sts 0x0103, r25
twi_data = data;
be0: 70 93 05 01 sts 0x0105, r23
be4: 60 93 04 01 sts 0x0104, r22
twi_bytes = bytes;
be8: 40 93 07 01 sts 0x0107, r20
twi_ddr = TW_WRITE;
bec: 10 92 06 01 sts 0x0106, r1
 
retry_cnt = 0;
bf0: 10 92 09 01 sts 0x0109, r1
/* Generate start condition, the remainder of the transfer is interrupt driven and
will be performed in the background */
TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN)|(1<<TWIE);
bf4: 85 ea ldi r24, 0xA5 ; 165
bf6: 86 bf out 0x36, r24 ; 54
status |= (1<<BUSY);
bf8: 80 91 08 01 lds r24, 0x0108
bfc: 80 68 ori r24, 0x80 ; 128
bfe: 80 93 08 01 sts 0x0108, r24
}
c02: 08 95 ret
 
00000c04 <I2CInt_readData>:
 
/***********************************************************
Function Name: I2CInt_readData
Function Description: This funcion is responsible for
reading the specified number of bytes from a slave
device.
Inputs: address: the slave address to read from
data: a pointer to where the data will be stored
bytes: the number of bytes to read
Outputs: none
***********************************************************/
void I2CInt_readData(unsigned char address, unsigned char *data, unsigned char bytes)
{
c04: 98 2f mov r25, r24
/* Bus is busy wait (or exit with error code) */
while(status & (1<<BUSY));
c06: 80 91 08 01 lds r24, 0x0108
c0a: 88 23 and r24, r24
c0c: e4 f3 brlt .-8 ; 0xc06
 
twi_address = address;
c0e: 90 93 03 01 sts 0x0103, r25
twi_data = data;
c12: 70 93 05 01 sts 0x0105, r23
c16: 60 93 04 01 sts 0x0104, r22
twi_bytes = bytes;
c1a: 40 93 07 01 sts 0x0107, r20
twi_ddr = TW_READ;
c1e: 81 e0 ldi r24, 0x01 ; 1
c20: 80 93 06 01 sts 0x0106, r24
 
retry_cnt = 0;
c24: 10 92 09 01 sts 0x0109, r1
/* Generate start condition, the remainder of the transfer is interrupt driven and
will be performed in the background */
TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN)|(1<<TWIE);
c28: 85 ea ldi r24, 0xA5 ; 165
c2a: 86 bf out 0x36, r24 ; 54
status |= (1<<BUSY);
c2c: 80 91 08 01 lds r24, 0x0108
c30: 80 68 ori r24, 0x80 ; 128
c32: 80 93 08 01 sts 0x0108, r24
}
c36: 08 95 ret
 
00000c38 <I2CInt_isI2cBusy>:
 
/***********************************************************
Function Name: I2CInt_isI2cBusy
Function Description: This funcion is responsible for
indicating if the I2C bus is currently busy to external
modules.
device.
Inputs: none
Outputs: bool_t - indicating if bus is busy
***********************************************************/
bool_t I2CInt_isI2cBusy(void)
{
bool_t retVal = FALSE;
c38: 90 e0 ldi r25, 0x00 ; 0
if ( (status & (1<<BUSY)) != 0)
c3a: 80 91 08 01 lds r24, 0x0108
c3e: 88 23 and r24, r24
c40: 0c f4 brge .+2 ; 0xc44
{
retVal = TRUE;
c42: 91 e0 ldi r25, 0x01 ; 1
}
return(retVal);
c44: 89 2f mov r24, r25
c46: 99 27 eor r25, r25
}
c48: 08 95 ret
 
00000c4a <__vector_17>:
 
/***********************************************************
Function Name: <interrupt handler for I2C>
Function Description: This function is responsible for
implementing the control logic needed to perform a
read or write operation with an I2C slave.
Inputs: none
Outputs: none
***********************************************************/
SIGNAL(SIG_2WIRE_SERIAL)
{
c4a: 1f 92 push r1
c4c: 0f 92 push r0
c4e: 0f b6 in r0, 0x3f ; 63
c50: 0f 92 push r0
c52: 11 24 eor r1, r1
c54: 8f 93 push r24
c56: 9f 93 push r25
c58: af 93 push r26
c5a: bf 93 push r27
c5c: ef 93 push r30
c5e: ff 93 push r31
unsigned char TWI_status = TWSR & TW_STATUS_MASK; /* grab just the status bits */
c60: 81 b1 in r24, 0x01 ; 1
c62: 88 7f andi r24, 0xF8 ; 248
/* the entire I2C handler is state-based...determine
what needs to be done based on TWI_status */
switch(TWI_status)
c64: 99 27 eor r25, r25
c66: aa 27 eor r26, r26
c68: bb 27 eor r27, r27
c6a: fc 01 movw r30, r24
c6c: 38 97 sbiw r30, 0x08 ; 8
c6e: e1 35 cpi r30, 0x51 ; 81
c70: f1 05 cpc r31, r1
c72: 08 f0 brcs .+2 ; 0xc76
c74: 6d c0 rjmp .+218 ; 0xd50
c76: ed 5e subi r30, 0xED ; 237
c78: ff 4f sbci r31, 0xFF ; 255
c7a: 09 94 ijmp
{
case TW_START: /* Start condition */
case TW_REP_START: /* Repeated start condition */
if(retry_cnt > MAX_TWI_RETRIES)
c7c: 80 91 09 01 lds r24, 0x0109
c80: 83 30 cpi r24, 0x03 ; 3
c82: 08 f0 brcs .+2 ; 0xc86
c84: 5d c0 rjmp .+186 ; 0xd40
{
/* generate stop condition if we've reached our retry limit */
TWCR |= (1<<TWINT)|(1<<TWSTO);
status &= ~(1<<BUSY);
return;
}
/* indicate read or write */
TWDR = (twi_address<<1) + twi_ddr;
c86: 80 91 03 01 lds r24, 0x0103
c8a: 98 2f mov r25, r24
c8c: 99 0f add r25, r25
c8e: 80 91 06 01 lds r24, 0x0106
c92: 89 0f add r24, r25
c94: 83 b9 out 0x03, r24 ; 3
/* TWSTA must be cleared...also clears TWINT */
TWCR &= ~(1<<TWSTA);
c96: 86 b7 in r24, 0x36 ; 54
c98: 8f 7d andi r24, 0xDF ; 223
c9a: 4a c0 rjmp .+148 ; 0xd30
break;
 
case TW_MT_SLA_ACK: /* Slave acknowledged address, */
retry_cnt = 0;
c9c: 10 92 09 01 sts 0x0109, r1
/* tx the data, and increment the data pointer */
TWDR = *twi_data;
ca0: 11 c0 rjmp .+34 ; 0xcc4
twi_data++;
 
/* clear the int to continue */
TWCR |= (1<<TWINT);
break;
 
case TW_MT_SLA_NACK: /* Slave didn't acknowledge address, */
case TW_MR_SLA_NACK:
retry_cnt++;
ca2: 80 91 09 01 lds r24, 0x0109
ca6: 8f 5f subi r24, 0xFF ; 255
ca8: 80 93 09 01 sts 0x0109, r24
 
/* retry...*/
TWCR |= (1<<TWINT)|(1<<TWSTA)|(1<<TWSTO);
cac: 86 b7 in r24, 0x36 ; 54
cae: 80 6b ori r24, 0xB0 ; 176
cb0: 3f c0 rjmp .+126 ; 0xd30
break;
 
case TW_MT_DATA_ACK: /* Slave Acknowledged data, */
if(--twi_bytes > 0)
cb2: 80 91 07 01 lds r24, 0x0107
cb6: 81 50 subi r24, 0x01 ; 1
cb8: 80 93 07 01 sts 0x0107, r24
cbc: 80 91 07 01 lds r24, 0x0107
cc0: 88 23 and r24, r24
cc2: f1 f1 breq .+124 ; 0xd40
{
/* more data to send, so send it */
TWDR = *twi_data;
cc4: e0 91 04 01 lds r30, 0x0104
cc8: f0 91 05 01 lds r31, 0x0105
ccc: 80 81 ld r24, Z
cce: 83 b9 out 0x03, r24 ; 3
twi_data++;
cd0: cf 01 movw r24, r30
cd2: 01 96 adiw r24, 0x01 ; 1
cd4: 90 93 05 01 sts 0x0105, r25
cd8: 80 93 04 01 sts 0x0104, r24
TWCR |= (1<<TWINT);
cdc: 09 c0 rjmp .+18 ; 0xcf0
}
else
{
/* generate the stop condition if needed */
TWCR |= (1<<TWSTO)|(1<<TWINT);
status &= ~(1<<BUSY);
}
break;
 
case TW_MT_DATA_NACK: /* Slave didn't acknowledge data */
/* send the stop condition */
TWCR |= (1<<TWINT)|(1<<TWSTO);
status &= ~(1<<BUSY);
break;
 
case TW_MR_SLA_ACK: /* Slave acknowledged address */
if(--twi_bytes > 0)
cde: 80 91 07 01 lds r24, 0x0107
ce2: 81 50 subi r24, 0x01 ; 1
ce4: 80 93 07 01 sts 0x0107, r24
ce8: 80 91 07 01 lds r24, 0x0107
cec: 88 23 and r24, r24
cee: d9 f4 brne .+54 ; 0xd26
{
/* if there is more than one byte to read, acknowledge */
TWCR |= (1<<TWEA)|(1<<TWINT);
}
else
{
/* no acknowledge */
TWCR |= (1<<TWINT);
cf0: 86 b7 in r24, 0x36 ; 54
cf2: 80 68 ori r24, 0x80 ; 128
cf4: 1d c0 rjmp .+58 ; 0xd30
}
break;
 
case TW_MR_DATA_ACK: /* Master acknowledged data */
/* grab the received data */
*twi_data = TWDR;
cf6: e0 91 04 01 lds r30, 0x0104
cfa: f0 91 05 01 lds r31, 0x0105
cfe: 83 b1 in r24, 0x03 ; 3
d00: 80 83 st Z, r24
twi_data++;
d02: 80 91 04 01 lds r24, 0x0104
d06: 90 91 05 01 lds r25, 0x0105
d0a: 01 96 adiw r24, 0x01 ; 1
d0c: 90 93 05 01 sts 0x0105, r25
d10: 80 93 04 01 sts 0x0104, r24
if(--twi_bytes > 0)
d14: 80 91 07 01 lds r24, 0x0107
d18: 81 50 subi r24, 0x01 ; 1
d1a: 80 93 07 01 sts 0x0107, r24
d1e: 80 91 07 01 lds r24, 0x0107
d22: 88 23 and r24, r24
d24: 19 f0 breq .+6 ; 0xd2c
{
/* get the next data byte and ack */
TWCR |= (1<<TWEA)|(1<<TWINT);
d26: 86 b7 in r24, 0x36 ; 54
d28: 80 6c ori r24, 0xC0 ; 192
d2a: 02 c0 rjmp .+4 ; 0xd30
}
else
{
/* clear out the enable acknowledge bit */
TWCR &= ~(1<<TWEA);
d2c: 86 b7 in r24, 0x36 ; 54
d2e: 8f 7b andi r24, 0xBF ; 191
d30: 86 bf out 0x36, r24 ; 54
}
break;
d32: 0e c0 rjmp .+28 ; 0xd50
 
case TW_MR_DATA_NACK: /* Master didn't acknowledge data -> end of read process */
/* read data, and generate the stop condition */
*twi_data = TWDR;
d34: e0 91 04 01 lds r30, 0x0104
d38: f0 91 05 01 lds r31, 0x0105
d3c: 83 b1 in r24, 0x03 ; 3
d3e: 80 83 st Z, r24
TWCR |= (1<<TWSTO)|(1<<TWINT);
d40: 86 b7 in r24, 0x36 ; 54
d42: 80 69 ori r24, 0x90 ; 144
d44: 86 bf out 0x36, r24 ; 54
status &= ~(1<<BUSY);
d46: 80 91 08 01 lds r24, 0x0108
d4a: 8f 77 andi r24, 0x7F ; 127
d4c: 80 93 08 01 sts 0x0108, r24
break;
}
}
d50: ff 91 pop r31
d52: ef 91 pop r30
d54: bf 91 pop r27
d56: af 91 pop r26
d58: 9f 91 pop r25
d5a: 8f 91 pop r24
d5c: 0f 90 pop r0
d5e: 0f be out 0x3f, r0 ; 63
d60: 0f 90 pop r0
d62: 1f 90 pop r1
d64: 18 95 reti
 
00000d66 <CamConfig_init>:
Outputs: none
***********************************************************/
void CamConfig_init(void)
{
CamConfig_setCamReg(0x14,0x20); /* reduce frame size */
d66: 60 e2 ldi r22, 0x20 ; 32
d68: 84 e1 ldi r24, 0x14 ; 20
d6a: 0e d0 rcall .+28 ; 0xd88
CamConfig_setCamReg(0x39,0x40); /* gate PCLK with HREF */
d6c: 60 e4 ldi r22, 0x40 ; 64
d6e: 89 e3 ldi r24, 0x39 ; 57
d70: 0b d0 rcall .+22 ; 0xd88
CamConfig_setCamReg(0x12,0x28); /* set RGB mode, with no AWB */
d72: 68 e2 ldi r22, 0x28 ; 40
d74: 82 e1 ldi r24, 0x12 ; 18
d76: 08 d0 rcall .+16 ; 0xd88
CamConfig_setCamReg(0x28,0x05); /* set color sequencer */
d78: 65 e0 ldi r22, 0x05 ; 5
d7a: 88 e2 ldi r24, 0x28 ; 40
d7c: 05 d0 rcall .+10 ; 0xd88
CamConfig_setCamReg(0x13,0x01); /* un-tri-state the Y/UV lines */
d7e: 61 e0 ldi r22, 0x01 ; 1
d80: 83 e1 ldi r24, 0x13 ; 19
d82: 02 d0 rcall .+4 ; 0xd88
/* send the first four cmds in the I2C fifo */
CamConfig_sendFifoCmds();
d84: 06 d0 rcall .+12 ; 0xd92
}
d86: 08 95 ret
 
00000d88 <CamConfig_setCamReg>:
 
 
/***********************************************************
Function Name: CamConfig_setCamReg
Function Description: This function is responsible for
creating an I2C cmd structure and placing it into the
cmd fifo.
Inputs: reg - the register to modify
val - the new value of the register
Outputs: none
***********************************************************/
void CamConfig_setCamReg(unsigned char reg, unsigned char val)
{
i2cCmd_t cmd;
cmd.configReg = reg;
d88: 28 2f mov r18, r24
cmd.data = val;
d8a: 36 2f mov r19, r22
#ifndef SIMULATION
CamConfig_writeTxFifo(cmd);
d8c: c9 01 movw r24, r18
d8e: 2f d0 rcall .+94 ; 0xdee
#endif
}
d90: 08 95 ret
 
00000d92 <CamConfig_sendFifoCmds>:
/***********************************************************
Function Name: CamConfig_sendFifoCmds
Function Description: This function is responsible for
sending the entire contents of the config fifo. This
function won't return until the configuration process
is complete (or an error is encountered).
Inputs: none
Outputs: none
Note: Since this function is written to use the TWI
interrupt in the I2CInterface module, there will be
some busy-waiting here...no big deal, since we end up
having to trash the frame that we are executing this
slave write in anyway (since we can't meet the strict
timing requirements and write i2c at the same time).
***********************************************************/
void CamConfig_sendFifoCmds(void)
{
d92: cf 93 push r28
d94: df 93 push r29
d96: cd b7 in r28, 0x3d ; 61
d98: de b7 in r29, 0x3e ; 62
d9a: 22 97 sbiw r28, 0x02 ; 2
d9c: 0f b6 in r0, 0x3f ; 63
d9e: f8 94 cli
da0: de bf out 0x3e, r29 ; 62
da2: 0f be out 0x3f, r0 ; 63
da4: cd bf out 0x3d, r28 ; 61
i2cCmd_t cmd;
while (CamConfig_txFifoHead != CamConfig_txFifoTail)
da6: 90 91 0a 01 lds r25, 0x010A
daa: 80 91 0b 01 lds r24, 0x010B
dae: 98 17 cp r25, r24
db0: a9 f0 breq .+42 ; 0xddc
{
cmd = CamConfig_readTxFifo();
db2: 37 d0 rcall .+110 ; 0xe22
db4: 89 83 std Y+1, r24 ; 0x01
db6: 9a 83 std Y+2, r25 ; 0x02
I2CInt_writeData(CAM_ADDRESS,&cmd.configReg,SIZE_OF_I2C_CMD);
db8: 42 e0 ldi r20, 0x02 ; 2
dba: be 01 movw r22, r28
dbc: 6f 5f subi r22, 0xFF ; 255
dbe: 7f 4f sbci r23, 0xFF ; 255
dc0: 80 e6 ldi r24, 0x60 ; 96
dc2: 04 df rcall .-504 ; 0xbcc
Utility_delay(100);
dc4: 84 e6 ldi r24, 0x64 ; 100
dc6: 90 e0 ldi r25, 0x00 ; 0
dc8: 3e d0 rcall .+124 ; 0xe46
/* wait for the I2C transaction to complete */
while(I2CInt_isI2cBusy() == TRUE);
dca: 36 df rcall .-404 ; 0xc38
dcc: 81 30 cpi r24, 0x01 ; 1
dce: e9 f3 breq .-6 ; 0xdca
dd0: 90 91 0a 01 lds r25, 0x010A
dd4: 80 91 0b 01 lds r24, 0x010B
dd8: 98 17 cp r25, r24
dda: 59 f7 brne .-42 ; 0xdb2
}
}
ddc: 22 96 adiw r28, 0x02 ; 2
dde: 0f b6 in r0, 0x3f ; 63
de0: f8 94 cli
de2: de bf out 0x3e, r29 ; 62
de4: 0f be out 0x3f, r0 ; 63
de6: cd bf out 0x3d, r28 ; 61
de8: df 91 pop r29
dea: cf 91 pop r28
dec: 08 95 ret
 
00000dee <CamConfig_writeTxFifo>:
 
/***********************************************************
Function Name: CamConfig_writeTxFifo
Function Description: This function is responsible for
adding a new command to the tx fifo. It adjusts all
needed pointers.
Inputs: cmd - the i2cCmd_t to add to the fifo
Outputs: bool_t - indicating if writing to the fifo
causes it to wrap
***********************************************************/
bool_t CamConfig_writeTxFifo(i2cCmd_t cmd)
{
dee: 9c 01 movw r18, r24
unsigned char tmpHead;
bool_t retVal = TRUE;
df0: 51 e0 ldi r21, 0x01 ; 1
CamConfig_txFifo[CamConfig_txFifoHead] = cmd;
df2: 40 91 0a 01 lds r20, 0x010A
df6: 84 2f mov r24, r20
df8: 99 27 eor r25, r25
dfa: 88 0f add r24, r24
dfc: 99 1f adc r25, r25
dfe: fc 01 movw r30, r24
e00: ec 52 subi r30, 0x2C ; 44
e02: fd 4f sbci r31, 0xFD ; 253
e04: 20 83 st Z, r18
e06: 31 83 std Z+1, r19 ; 0x01
/* see if we need to wrap */
tmpHead = (CamConfig_txFifoHead+1) & (CAM_CONFIG_TX_FIFO_MASK);
e08: 84 2f mov r24, r20
e0a: 85 0f add r24, r21
e0c: 87 70 andi r24, 0x07 ; 7
CamConfig_txFifoHead = tmpHead;
e0e: 80 93 0a 01 sts 0x010A, r24
/* check to see if we have filled up the queue */
if (CamConfig_txFifoHead == CamConfig_txFifoTail)
e12: 90 91 0b 01 lds r25, 0x010B
e16: 89 17 cp r24, r25
e18: 09 f4 brne .+2 ; 0xe1c
{
/* we wrapped the fifo...return false */
retVal = FALSE;
e1a: 50 e0 ldi r21, 0x00 ; 0
}
return(retVal);
e1c: 85 2f mov r24, r21
e1e: 99 27 eor r25, r25
}
e20: 08 95 ret
 
00000e22 <CamConfig_readTxFifo>:
 
/***********************************************************
Function Name: CamConfig_readTxFifo
Function Description: This function is responsible for
reading a cmd out of the tx fifo.
Inputs: none
Outputs: i2cCmd_t - the cmd read from the fifo
***********************************************************/
static i2cCmd_t CamConfig_readTxFifo(void)
{
i2cCmd_t cmd;
unsigned char tmpTail;
/* just return the current tail from the rx fifo */
cmd = CamConfig_txFifo[CamConfig_txFifoTail];
e22: 40 91 0b 01 lds r20, 0x010B
e26: 84 2f mov r24, r20
e28: 99 27 eor r25, r25
e2a: 88 0f add r24, r24
e2c: 99 1f adc r25, r25
e2e: fc 01 movw r30, r24
e30: ec 52 subi r30, 0x2C ; 44
e32: fd 4f sbci r31, 0xFD ; 253
e34: 20 81 ld r18, Z
e36: 31 81 ldd r19, Z+1 ; 0x01
tmpTail = (CamConfig_txFifoTail+1) & (CAM_CONFIG_TX_FIFO_MASK);
e38: 84 2f mov r24, r20
e3a: 8f 5f subi r24, 0xFF ; 255
e3c: 87 70 andi r24, 0x07 ; 7
CamConfig_txFifoTail = tmpTail;
e3e: 80 93 0b 01 sts 0x010B, r24
return(cmd);
}
e42: c9 01 movw r24, r18
e44: 08 95 ret
 
00000e46 <Utility_delay>:
if needed...this isn't really a millisecond, so DON'T
depend on it for exact timing...
***********************************************************/
void Utility_delay(unsigned short numMs)
{
e46: cf 93 push r28
e48: df 93 push r29
e4a: cd b7 in r28, 0x3d ; 61
e4c: de b7 in r29, 0x3e ; 62
e4e: 24 97 sbiw r28, 0x04 ; 4
e50: 0f b6 in r0, 0x3f ; 63
e52: f8 94 cli
e54: de bf out 0x3e, r29 ; 62
e56: 0f be out 0x3f, r0 ; 63
e58: cd bf out 0x3d, r28 ; 61
e5a: 9c 01 movw r18, r24
volatile unsigned short i=0,j=0;
e5c: 19 82 std Y+1, r1 ; 0x01
e5e: 1a 82 std Y+2, r1 ; 0x02
e60: 1b 82 std Y+3, r1 ; 0x03
e62: 1c 82 std Y+4, r1 ; 0x04
#ifndef SIMULATION
for (i=0; i<numMs; i++)
e64: 19 82 std Y+1, r1 ; 0x01
e66: 1a 82 std Y+2, r1 ; 0x02
e68: 89 81 ldd r24, Y+1 ; 0x01
e6a: 9a 81 ldd r25, Y+2 ; 0x02
e6c: 82 17 cp r24, r18
e6e: 93 07 cpc r25, r19
e70: e0 f4 brcc .+56 ; 0xeaa
{
for (j=0; j<1000; j++)
e72: 1b 82 std Y+3, r1 ; 0x03
e74: 1c 82 std Y+4, r1 ; 0x04
e76: 8b 81 ldd r24, Y+3 ; 0x03
e78: 9c 81 ldd r25, Y+4 ; 0x04
e7a: 88 5e subi r24, 0xE8 ; 232
e7c: 93 40 sbci r25, 0x03 ; 3
e7e: 58 f4 brcc .+22 ; 0xe96
{
asm volatile("nop"::);
e80: 00 00 nop
e82: 8b 81 ldd r24, Y+3 ; 0x03
e84: 9c 81 ldd r25, Y+4 ; 0x04
e86: 01 96 adiw r24, 0x01 ; 1
e88: 8b 83 std Y+3, r24 ; 0x03
e8a: 9c 83 std Y+4, r25 ; 0x04
e8c: 8b 81 ldd r24, Y+3 ; 0x03
e8e: 9c 81 ldd r25, Y+4 ; 0x04
e90: 88 5e subi r24, 0xE8 ; 232
e92: 93 40 sbci r25, 0x03 ; 3
e94: a8 f3 brcs .-22 ; 0xe80
e96: 89 81 ldd r24, Y+1 ; 0x01
e98: 9a 81 ldd r25, Y+2 ; 0x02
e9a: 01 96 adiw r24, 0x01 ; 1
e9c: 89 83 std Y+1, r24 ; 0x01
e9e: 9a 83 std Y+2, r25 ; 0x02
ea0: 89 81 ldd r24, Y+1 ; 0x01
ea2: 9a 81 ldd r25, Y+2 ; 0x02
ea4: 82 17 cp r24, r18
ea6: 93 07 cpc r25, r19
ea8: 20 f3 brcs .-56 ; 0xe72
}
}
#endif
}
eaa: 24 96 adiw r28, 0x04 ; 4
eac: 0f b6 in r0, 0x3f ; 63
eae: f8 94 cli
eb0: de bf out 0x3e, r29 ; 62
eb2: 0f be out 0x3f, r0 ; 63
eb4: cd bf out 0x3d, r28 ; 61
eb6: df 91 pop r29
eb8: cf 91 pop r28
eba: 08 95 ret
 
00000ebc <DebugInt_init>:
Inputs: none
Outputs: none
***********************************************************/
void DebugInt_init(void)
{
ebc: 1f 93 push r17
/* set PortD pin6 for output */
DDRD |= 0x40;
ebe: 8e 9a sbi 0x11, 6 ; 17
/* turn on LED */
PORTD |= 0x40;
ec0: 96 9a sbi 0x12, 6 ; 18
Utility_delay(500);
ec2: 84 ef ldi r24, 0xF4 ; 244
ec4: 91 e0 ldi r25, 0x01 ; 1
ec6: bf df rcall .-130 ; 0xe46
PORTD &= 0xBF;
ec8: 1f eb ldi r17, 0xBF ; 191
eca: 82 b3 in r24, 0x12 ; 18
ecc: 81 23 and r24, r17
ece: 82 bb out 0x12, r24 ; 18
Utility_delay(500);
ed0: 84 ef ldi r24, 0xF4 ; 244
ed2: 91 e0 ldi r25, 0x01 ; 1
ed4: b8 df rcall .-144 ; 0xe46
PORTD |= 0x40;
ed6: 96 9a sbi 0x12, 6 ; 18
Utility_delay(500);
ed8: 84 ef ldi r24, 0xF4 ; 244
eda: 91 e0 ldi r25, 0x01 ; 1
edc: b4 df rcall .-152 ; 0xe46
PORTD &= 0xBF;
ede: 82 b3 in r24, 0x12 ; 18
ee0: 81 23 and r24, r17
ee2: 82 bb out 0x12, r24 ; 18
Utility_delay(500);
ee4: 84 ef ldi r24, 0xF4 ; 244
ee6: 91 e0 ldi r25, 0x01 ; 1
ee8: ae df rcall .-164 ; 0xe46
PORTD |= 0x40;
eea: 96 9a sbi 0x12, 6 ; 18
Utility_delay(500);
eec: 84 ef ldi r24, 0xF4 ; 244
eee: 91 e0 ldi r25, 0x01 ; 1
ef0: aa df rcall .-172 ; 0xe46
PORTD &= 0xBF;
ef2: 82 b3 in r24, 0x12 ; 18
ef4: 81 23 and r24, r17
ef6: 82 bb out 0x12, r24 ; 18
Utility_delay(500);
ef8: 84 ef ldi r24, 0xF4 ; 244
efa: 91 e0 ldi r25, 0x01 ; 1
efc: a4 df rcall .-184 ; 0xe46
PORTD |= 0x40;
efe: 96 9a sbi 0x12, 6 ; 18
}
f00: 1f 91 pop r17
f02: 08 95 ret
 
00000f04 <CamIntAsm_waitForNewTrackingFrame>:
; set, and the function will return.
;*****************************************************************
CamIntAsm_waitForNewTrackingFrame:
sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
f04: 96 9a sbi 0x12, 6 ; 18
cbi _SFR_IO_ADDR(PORTD),PD6
f06: 96 98 cbi 0x12, 6 ; 18
sleep
f08: 88 95 sleep
 
00000f0a <CamIntAsm_acquireTrackingLine>:
 
;*****************************************************************
; REMEMBER...everything from here on out is critically timed to be
; synchronized with the flow of pixel data from the camera...
;*****************************************************************
 
CamIntAsm_acquireTrackingLine:
brts _cleanUp
f0a: e6 f1 brts .+120 ; 0xf84
;sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
;cbi _SFR_IO_ADDR(PORTD),PD6
in tmp1,_SFR_IO_ADDR(TCCR1B) ; Enable the PCLK line to actually
f0c: 3e b5 in r19, 0x2e ; 46
ori tmp1, 0x07 ; feed Timer1
f0e: 37 60 ori r19, 0x07 ; 7
out _SFR_IO_ADDR(TCCR1B),tmp1
f10: 3e bd out 0x2e, r19 ; 46
; The line is about to start...
ldi pixelCount,0 ; Initialize the RLE stats...
f12: 00 e0 ldi r16, 0x00 ; 0
ldi pixelRunStart,PIXEL_RUN_START_INITIAL ; Remember, we always calculate
f14: 10 e5 ldi r17, 0x50 ; 80
; the pixel run length as
; TCNT1L - pixelRunStart
ldi lastColor,0x00 ; clear out the last color before we start
f16: 20 e0 ldi r18, 0x00 ; 0
mov XH,currLineBuffHigh ; Load the pointer to the current line
f18: b9 2f mov r27, r25
mov XL,currLineBuffLow ; buffer into the X pointer regs
f1a: a8 2f mov r26, r24
mov ZH,colorMapHigh ; Load the pointers to the membership
f1c: f7 2f mov r31, r23
mov ZL,colorMapLow ; lookup tables (ZL and YL will be overwritten
f1e: e6 2f mov r30, r22
mov YH,colorMapHigh ; as soon as we start reading data) to Z and Y
f20: d7 2f mov r29, r23
in tmp1, _SFR_IO_ADDR(TIMSK) ; enable TIMER1 to start counting
f22: 39 b7 in r19, 0x39 ; 57
ori tmp1, ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK ; external PCLK pulses and interrupt on
f24: 34 60 ori r19, 0x04 ; 4
out _SFR_IO_ADDR(TIMSK),tmp1 ; overflow
f26: 39 bf out 0x39, r19 ; 57
ldi tmp1,PIXEL_RUN_START_INITIAL ; set up the TCNT1 to overflow (and
f28: 30 e5 ldi r19, 0x50 ; 80
ldi tmp2,0xFF ; interrupts) after 176 pixels
f2a: 4f ef ldi r20, 0xFF ; 255
out _SFR_IO_ADDR(TCNT1H),tmp2
f2c: 4d bd out 0x2d, r20 ; 45
out _SFR_IO_ADDR(TCNT1L),tmp1
f2e: 3c bd out 0x2c, r19 ; 44
mov YL,colorMapLow
f30: c6 2f mov r28, r22
in tmp1, _SFR_IO_ADDR(GICR) ; enable the HREF interrupt...remember, we
f32: 3b b7 in r19, 0x3b ; 59
; only use this interrupt to synchronize
; the beginning of the line
ori tmp1, HREF_INTERRUPT_ENABLE_MASK
f34: 30 68 ori r19, 0x80 ; 128
out _SFR_IO_ADDR(GICR), tmp1
f36: 3b bf out 0x3b, r19 ; 59
 
00000f38 <_trackFrame>:
;*******************************************************************************************
; Track Frame handler
;*******************************************************************************************
_trackFrame:
sbi _SFR_IO_ADDR(PORTD),PD6
f38: 96 9a sbi 0x12, 6 ; 18
sleep ; ...And we wait...
f3a: 88 95 sleep
; Returning from the interrupt/sleep wakeup will consume
; 14 clock cycles (7 to wakeup from idle sleep, 3 to vector, and 4 to return)
 
; Disable the HREF interrupt
cbi _SFR_IO_ADDR(PORTD),PD6
f3c: 96 98 cbi 0x12, 6 ; 18
in tmp1, _SFR_IO_ADDR(GICR)
f3e: 3b b7 in r19, 0x3b ; 59
andi tmp1, HREF_INTERRUPT_DISABLE_MASK
f40: 3f 77 andi r19, 0x7F ; 127
out _SFR_IO_ADDR(GICR), tmp1
f42: 3b bf out 0x3b, r19 ; 59
; A couple of NOPs are needed here to sync up the pixel data...the number (2)
; of NOPs was determined emperically by trial and error.
nop
f44: 00 00 nop
...
 
00000f48 <_acquirePixelBlock>:
nop
_acquirePixelBlock: ; Clock Cycle Count
in ZL,RB_PORT ; sample the red value (PINB) (1)
f48: e6 b3 in r30, 0x16 ; 22
in YL,G_PORT ; sample the green value (PINC) (1)
f4a: c3 b3 in r28, 0x13 ; 19
andi YL,0x0F ; clear the high nibble (1)
f4c: cf 70 andi r28, 0x0F ; 15
ldd color,Z+RED_MEM_OFFSET ; lookup the red membership (2)
f4e: 30 81 ld r19, Z
in ZL,RB_PORT ; sample the blue value (PINB) (1)
f50: e6 b3 in r30, 0x16 ; 22
ldd greenData,Y+GREEN_MEM_OFFSET; lookup the green membership (2)
f52: 48 89 ldd r20, Y+16 ; 0x10
ldd blueData,Z+BLUE_MEM_OFFSET ; lookup the blue membership (2)
f54: 50 a1 ldd r21, Z+32 ; 0x20
and color,greenData ; mask memberships together (1)
f56: 34 23 and r19, r20
and color,blueData ; to produce the final color (1)
f58: 35 23 and r19, r21
brts _cleanUpTrackingLine ; if some interrupt routine has (1...not set)
f5a: 76 f0 brts .+28 ; 0xf78
; come in and set our T flag in
; SREG, then we need to hop out
; and blow away this frames data (common cleanup)
cp color,lastColor ; check to see if the run continues (1)
f5c: 32 17 cp r19, r18
breq _acquirePixelBlock ; (2...equal)
f5e: a1 f3 breq .-24 ; 0xf48
; ___________
; 16 clock cycles
; (16 clock cycles = 1 uS = 1 pixelBlock time)
; Toggle the debug line to indicate a color change
sbi _SFR_IO_ADDR(PORTD),PD6
f60: 96 9a sbi 0x12, 6 ; 18
nop
f62: 00 00 nop
cbi _SFR_IO_ADDR(PORTD),PD6
f64: 96 98 cbi 0x12, 6 ; 18
mov tmp2,pixelRunStart ; get the count value of the
f66: 41 2f mov r20, r17
; current pixel run
in pixelCount,_SFR_IO_ADDR(TCNT1L) ; get the current TCNT1 value
f68: 0c b5 in r16, 0x2c ; 44
mov pixelRunStart,pixelCount ; reload pixelRunStart for the
f6a: 10 2f mov r17, r16
; next run
sub pixelCount,tmp2 ; pixelCount = TCNT1L - pixelRunStart
f6c: 04 1b sub r16, r20
st X+,lastColor ; record the color run in the current line buffer
f6e: 2d 93 st X+, r18
st X+,pixelCount ; with its length
f70: 0d 93 st X+, r16
mov lastColor,color ; set lastColor so we can figure out when it changes
f72: 23 2f mov r18, r19
nop ; waste one more cycle for a total of 16
f74: 00 00 nop
rjmp _acquirePixelBlock
f76: e8 cf rjmp .-48 ; 0xf48
 
00000f78 <_cleanUpTrackingLine>:
; _cleanUpTrackingLine is used to write the last run length block off to the currentLineBuffer so
; that all 176 pixels in the line are accounted for.
_cleanUpTrackingLine:
ldi pixelCount,0xFF ; the length of the last run is ALWAYS 0xFF minus the last
f78: 0f ef ldi r16, 0xFF ; 255
sub pixelCount,pixelRunStart ; pixelRunStart
f7a: 01 1b sub r16, r17
inc pixelCount ; increment pixelCount since we actually need to account
f7c: 03 95 inc r16
; for the overflow of TCNT1
st X+,color ; record the color run in the current line buffer
f7e: 3d 93 st X+, r19
st X,pixelCount
f80: 0c 93 st X, r16
rjmp _cleanUp
f82: 00 c0 rjmp .+0 ; 0xf84
 
00000f84 <_cleanUp>:
_cleanUpDumpLine:
; NOTE: If serial data is received, to interrupt the tracking of a line, we'll
; get a EV_SERIAL_DATA_RECEIVED event, and the T bit set so we will end the
; line's processing...however, the PCLK will keep on ticking for the rest of
; the frame/line, which will cause the TCNT to eventually overflow and
; interrupt us, generating a EV_ACQUIRE_LINE_COMPLETE event. We don't want
; this, so we need to actually turn off the PCLK counting each time we exit
; this loop, and only turn it on when we begin acquiring lines....
; NOT NEEDED FOR NOW...
;in tmp1, _SFR_IO_ADDR(TIMSK) ; disable TIMER1 to stop counting
;andi tmp1, DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK ; external PCLK pulses
;out _SFR_IO_ADDR(TIMSK),tmp1
 
_cleanUp:
; Disable the external clocking of the Timer1 counter
in tmp1, _SFR_IO_ADDR(TCCR1B)
f84: 3e b5 in r19, 0x2e ; 46
andi tmp1, 0xF8
f86: 38 7f andi r19, 0xF8 ; 248
out _SFR_IO_ADDR(TCCR1B),tmp1
f88: 3e bd out 0x2e, r19 ; 46
; Toggle the debug line to indicate the line is complete
sbi _SFR_IO_ADDR(PORTD),PD6
f8a: 96 9a sbi 0x12, 6 ; 18
cbi _SFR_IO_ADDR(PORTD),PD6
f8c: 96 98 cbi 0x12, 6 ; 18
clt ; clear out the T bit since we have detected
f8e: e8 94 clt
 
00000f90 <_exit>:
; the interruption and are exiting to handle it
_exit:
ret
f90: 08 95 ret
 
00000f92 <CamIntAsm_waitForNewDumpFrame>:
;*****************************************************************
; Function Name: CamIntAsm_waitForNewDumpFrame
; Function Description: This function is responsible for
; going to sleep until a new frame begins (indicated by
; VSYNC transitioning from low to high. This will wake
; the "VSYNC sleep" up and allow it to continue with
; acquiring a line of pixel data to dump out to the UI.
; Inputs: r25 - MSB of currentLineBuffer
; r24 - LSB of currentLineBuffer
; r23 - MSB of prevLineBuffer
; r22 - LSB of prevLineBuffer
; Outputs: none
; NOTES: This function doesn't really return...it sorta just
; floats into the acquireDumpLine function after the "VSYNC sleep"
; is awoken.
;*****************************************************************
CamIntAsm_waitForNewDumpFrame:
sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
f92: 96 9a sbi 0x12, 6 ; 18
cbi _SFR_IO_ADDR(PORTD),PD6
f94: 96 98 cbi 0x12, 6 ; 18
sleep
f96: 88 95 sleep
 
00000f98 <CamIntAsm_acquireDumpLine>:
 
;*****************************************************************
; REMEMBER...everything from here on out is critically timed to be
; synchronized with the flow of pixel data from the camera...
;*****************************************************************
 
CamIntAsm_acquireDumpLine:
brts _cleanUp
f98: ae f3 brts .-22 ; 0xf84
;sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
;cbi _SFR_IO_ADDR(PORTD),PD6
mov XH,currLineBuffHigh ; Load the pointer to the current line
f9a: b9 2f mov r27, r25
mov XL,currLineBuffLow ; buffer into the X pointer regs
f9c: a8 2f mov r26, r24
 
mov YH,prevLineBuffHigh ; Load the pointer to the previous line
f9e: d7 2f mov r29, r23
mov YL,prevLineBuffLow ; buffer into the Y pointer regs
fa0: c6 2f mov r28, r22
ldi tmp1,PIXEL_RUN_START_INITIAL ; set up the TCNT1 to overflow (and
fa2: 30 e5 ldi r19, 0x50 ; 80
ldi tmp2,0xFF ; interrupts) after 176 pixels
fa4: 4f ef ldi r20, 0xFF ; 255
out _SFR_IO_ADDR(TCNT1H),tmp2
fa6: 4d bd out 0x2d, r20 ; 45
out _SFR_IO_ADDR(TCNT1L),tmp1
fa8: 3c bd out 0x2c, r19 ; 44
in tmp1, _SFR_IO_ADDR(TCCR1B) ; Enable the PCLK line to actually
faa: 3e b5 in r19, 0x2e ; 46
ori tmp1, 0x07 ; feed Timer1
fac: 37 60 ori r19, 0x07 ; 7
out _SFR_IO_ADDR(TCCR1B),tmp1
fae: 3e bd out 0x2e, r19 ; 46
nop
fb0: 00 00 nop
in tmp1, _SFR_IO_ADDR(TIMSK) ; enable TIMER1 to start counting
fb2: 39 b7 in r19, 0x39 ; 57
ori tmp1, ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK ; external PCLK pulses and interrupt on
fb4: 34 60 ori r19, 0x04 ; 4
out _SFR_IO_ADDR(TIMSK),tmp1 ; overflow
fb6: 39 bf out 0x39, r19 ; 57
in tmp1, _SFR_IO_ADDR(GICR) ; enable the HREF interrupt...remember, we
fb8: 3b b7 in r19, 0x3b ; 59
; only use this interrupt to synchronize
; the beginning of the line
ori tmp1, HREF_INTERRUPT_ENABLE_MASK
fba: 30 68 ori r19, 0x80 ; 128
out _SFR_IO_ADDR(GICR), tmp1
fbc: 3b bf out 0x3b, r19 ; 59
 
00000fbe <_dumpFrame>:
;*******************************************************************************************
; Dump Frame handler
;*******************************************************************************************
_dumpFrame:
sbi _SFR_IO_ADDR(PORTD),PD6
fbe: 96 9a sbi 0x12, 6 ; 18
sleep ; ...And we wait...
fc0: 88 95 sleep
 
cbi _SFR_IO_ADDR(PORTD),PD6
fc2: 96 98 cbi 0x12, 6 ; 18
in tmp1, _SFR_IO_ADDR(GICR) ; disable the HREF interrupt
fc4: 3b b7 in r19, 0x3b ; 59
andi tmp1, HREF_INTERRUPT_DISABLE_MASK ; so we don't get interrupted
fc6: 3f 77 andi r19, 0x7F ; 127
out _SFR_IO_ADDR(GICR), tmp1 ; while dumping the line
fc8: 3b bf out 0x3b, r19 ; 59
...
 
00000fcc <_sampleDumpPixel>:
nop ; Remember...if we ever remove the "cbi" instruction above,
; we need to add two more NOPs to cover this
; Ok...the following loop needs to run in 8 clock cycles, so we can get every
; pixel in the line...this shouldn't be a problem, since the PCLK timing was
; reduced by a factor of 2 whenever we go to dump a line (this is to give us
; enough time to do the sampling and storing of the pixel data). In addition,
; it is assumed that we will have to do some minor processing on the data right
; before we send it out, like mask off the top 4-bits of each, and then pack both
; low nibbles into a single byte for transmission...we just don't have time to
; do that here (only 8 instruction cycles :-) )
_sampleDumpPixel:
in tmp1,G_PORT ; sample the G value (1)
fcc: 33 b3 in r19, 0x13 ; 19
in tmp2,RB_PORT ; sample the R/B value (1)
fce: 46 b3 in r20, 0x16 ; 22
st X+,tmp1 ; store to the currLineBuff and inc ptrs(2)
fd0: 3d 93 st X+, r19
st Y+,tmp2 ; store to the prevLineBuff and inc ptrs(2)
fd2: 49 93 st Y+, r20
brtc _sampleDumpPixel ; loop back unless flag is set (2...if not set)
fd4: de f7 brtc .-10 ; 0xfcc
; ___________
; 8 cycles normally
; if we make it here, it means the T flag is set, and we must have been interrupted
; so we need to exit (what if we were interrupted for serial? should we disable it?)
rjmp _cleanUpDumpLine
fd6: d6 cf rjmp .-84 ; 0xf84
 
00000fd8 <__vector_1>:
 
;***********************************************************
; Function Name: <interrupt handler for External Interrupt0>
; Function Description: This function is responsible
; for handling a rising edge on the Ext Interrupt 0. This
; routine simply returns, since we just want to wake up
; whenever the VSYNC transitions (meaning the start of a new
; frame).
; Inputs: none
; Outputs: none
;***********************************************************
SIG_INTERRUPT0:
; This will wake us up when VSYNC transitions high...we just want to return
reti
fd8: 18 95 reti
 
00000fda <__vector_2>:
;***********************************************************
; Function Name: <interrupt handler for External Interrupt1>
; Function Description: This function is responsible
; for handling a falling edge on the Ext Interrupt 1. This
; routine simply returns, since we just want to wake up
; whenever the HREF transitions (meaning the pixels
; are starting after VSYNC transitioned, and we need to
; start acquiring the pixel blocks
; Inputs: none
; Outputs: none
;***********************************************************
SIG_INTERRUPT1:
; This will wake us up when HREF transitions high...we just want to return
reti
fda: 18 95 reti
 
00000fdc <__vector_8>:
;***********************************************************
; Function Name: <interrupt handler for Timer0 overflow>
; Function Description: This function is responsible
; for handling the Timer0 overflow (hooked up to indicate
; when we have reached the number of HREFs required in a
; single frame). We set the T flag in the SREG to
; indicate to the _acquirePixelBlock routine that it needs
; to exit, and then set the appropriate action to take in
; the eventList of the Executive module.
; Inputs: none
; Outputs: none
; Note: Originally, the HREF pulses were also going to
; be counted by a hardware counter, but it didn't end up
; being necessary
;***********************************************************
;SIG_OVERFLOW0:
; set ; set the T bit in SREG
; lds tmp1,eventBitmask
; ori tmp1,EV_ACQUIRE_FRAME_COMPLETE
; sts eventBitmask,tmp1
; reti
;***********************************************************
; Function Name: <interrupt handler for Timer1 overflow>
; Function Description: This function is responsible
; for handling the Timer1 overflow (hooked up to indicate
; when we have reached the end of a line of pixel data,
; since PCLK is hooked up to overflow TCNT1 after 176
; pixels). This routine generates an acquire line complete
; event in the fastEventBitmask, which is streamlined for
; efficiency reasons.
;***********************************************************
SIG_OVERFLOW1:
lds tmp1,fastEventBitmask ; set a flag indicating
fdc: 30 91 72 00 lds r19, 0x0072
ori tmp1,FEV_ACQUIRE_LINE_COMPLETE ; a line is complete
fe0: 31 60 ori r19, 0x01 ; 1
sts fastEventBitmask,tmp1
fe2: 30 93 72 00 sts 0x0072, r19
set ; set the T bit in SREG
fe6: 68 94 set
;sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
;cbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
 
reti
fe8: 18 95 reti
 
00000fea <__vector_default>:
 
; This is the default handler for all interrupts that don't
; have handler routines specified for them.
.global __vector_default
__vector_default:
reti
fea: 18 95 reti
 
00000fec <atoi>:
fec: fc 01 movw r30, r24
fee: 88 27 eor r24, r24
ff0: 99 27 eor r25, r25
ff2: e8 94 clt
 
00000ff4 <.atoi_loop>:
ff4: 21 91 ld r18, Z+
ff6: 22 23 and r18, r18
ff8: e9 f0 breq .+58 ; 0x1034
ffa: 20 32 cpi r18, 0x20 ; 32
ffc: d9 f3 breq .-10 ; 0xff4
ffe: 29 30 cpi r18, 0x09 ; 9
1000: c9 f3 breq .-14 ; 0xff4
1002: 2a 30 cpi r18, 0x0A ; 10
1004: b9 f3 breq .-18 ; 0xff4
1006: 2c 30 cpi r18, 0x0C ; 12
1008: a9 f3 breq .-22 ; 0xff4
100a: 2d 30 cpi r18, 0x0D ; 13
100c: 99 f3 breq .-26 ; 0xff4
100e: 26 37 cpi r18, 0x76 ; 118
1010: 89 f3 breq .-30 ; 0xff4
1012: 2b 32 cpi r18, 0x2B ; 43
1014: 19 f0 breq .+6 ; 0x101c
1016: 2d 32 cpi r18, 0x2D ; 45
1018: 21 f4 brne .+8 ; 0x1022
 
0000101a <.atoi_neg>:
101a: 68 94 set
 
0000101c <.atoi_loop2>:
101c: 21 91 ld r18, Z+
101e: 22 23 and r18, r18
1020: 49 f0 breq .+18 ; 0x1034
 
00001022 <.atoi_digit>:
1022: 20 33 cpi r18, 0x30 ; 48
1024: 3c f0 brlt .+14 ; 0x1034
1026: 2a 33 cpi r18, 0x3A ; 58
1028: 2c f4 brge .+10 ; 0x1034
102a: 20 53 subi r18, 0x30 ; 48
102c: 2f d0 rcall .+94 ; 0x108c
102e: 82 0f add r24, r18
1030: 91 1d adc r25, r1
1032: f4 cf rjmp .-24 ; 0x101c
 
00001034 <.atoi_sig>:
1034: 81 15 cp r24, r1
1036: 91 05 cpc r25, r1
1038: 21 f0 breq .+8 ; 0x1042
103a: 1e f4 brtc .+6 ; 0x1042
103c: 80 95 com r24
103e: 90 95 com r25
1040: 01 96 adiw r24, 0x01 ; 1
 
00001042 <.atoi_done>:
1042: 08 95 ret
 
00001044 <eeprom_read_byte>:
1044: e1 99 sbic 0x1c, 1 ; 28
1046: fe cf rjmp .-4 ; 0x1044
1048: 9f bb out 0x1f, r25 ; 31
104a: 8e bb out 0x1e, r24 ; 30
104c: e0 9a sbi 0x1c, 0 ; 28
104e: 99 27 eor r25, r25
1050: 8d b3 in r24, 0x1d ; 29
1052: 08 95 ret
 
00001054 <eeprom_read_block>:
1054: 41 15 cp r20, r1
1056: 51 05 cpc r21, r1
1058: 69 f0 breq .+26 ; 0x1074
105a: dc 01 movw r26, r24
 
0000105c <eeprom_read_block_busy>:
105c: e1 99 sbic 0x1c, 1 ; 28
105e: fe cf rjmp .-4 ; 0x105c
 
00001060 <eeprom_read_block_loop>:
1060: 7f bb out 0x1f, r23 ; 31
1062: 6e bb out 0x1e, r22 ; 30
1064: e0 9a sbi 0x1c, 0 ; 28
1066: 6f 5f subi r22, 0xFF ; 255
1068: 7f 4f sbci r23, 0xFF ; 255
106a: 0d b2 in r0, 0x1d ; 29
106c: 0d 92 st X+, r0
106e: 41 50 subi r20, 0x01 ; 1
1070: 50 40 sbci r21, 0x00 ; 0
1072: b1 f7 brne .-20 ; 0x1060
 
00001074 <eeprom_read_block_done>:
1074: 08 95 ret
 
00001076 <eeprom_write_byte>:
1076: e1 99 sbic 0x1c, 1 ; 28
1078: fe cf rjmp .-4 ; 0x1076
107a: 9f bb out 0x1f, r25 ; 31
107c: 8e bb out 0x1e, r24 ; 30
107e: 6d bb out 0x1d, r22 ; 29
1080: 0f b6 in r0, 0x3f ; 63
1082: f8 94 cli
1084: e2 9a sbi 0x1c, 2 ; 28
1086: e1 9a sbi 0x1c, 1 ; 28
1088: 0f be out 0x3f, r0 ; 63
108a: 08 95 ret
 
0000108c <__mulhi_const_10>:
108c: 7a e0 ldi r23, 0x0A ; 10
108e: 97 9f mul r25, r23
1090: 90 2d mov r25, r0
1092: 87 9f mul r24, r23
1094: 80 2d mov r24, r0
1096: 91 0d add r25, r1
1098: 11 24 eor r1, r1
109a: 08 95 ret
 
0000109c <_exit>:
109c: ff cf rjmp .-2 ; 0x109c
/programy/Atmel_C/AVRcam/AVRcam.map
0,0 → 1,585
Archive member included because of file (symbol)
 
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a(_exit.o)
Main.o (exit)
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a(_copy_data.o)
CamInterface.o (__do_copy_data)
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a(_clear_bss.o)
CamInterface.o (__do_clear_bss)
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(atoi.o)
UIMgr.o (atoi)
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(ee_rb.o)
UIMgr.o (eeprom_read_byte)
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(ee_rblk.o)
CamInterface.o (eeprom_read_block)
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(ee_wb.o)
UIMgr.o (eeprom_write_byte)
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(mul10.o)
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(atoi.o) (__mulhi_const_10)
 
Allocating common symbols
Common symbol size file
 
previousLineBuffer 0xb0 CamInterface.o
UIMgr_rxFifo 0x20 UIMgr.o
currentLineBuffer 0xb0 CamInterface.o
Exec_eventFifo 0x8 Executive.o
CamConfig_txFifo 0x10 CamConfig.o
UIMgr_txFifo 0x40 UIMgr.o
 
Memory Configuration
 
Name Origin Length Attributes
text 0x00000000 0x00002000 xr
data 0x00800060 0x0000ffa0 rw !x
eeprom 0x00810000 0x00010000 rw !x
*default* 0x00000000 0xffffffff
 
Linker script and memory map
 
LOAD C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
LOAD CamInterface.o
LOAD Main.o
LOAD Executive.o
LOAD FrameMgr.o
LOAD UIMgr.o
LOAD UartInterface.o
LOAD I2CInterface.o
LOAD CamConfig.o
LOAD Utility.o
LOAD DebugInterface.o
LOAD CamInterfaceAsm.o
Address of section .noinit set to 0x800300
LOAD C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libm.a
LOAD C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a
LOAD C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a
LOAD C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a
 
.hash
*(.hash)
 
.dynsym
*(.dynsym)
 
.dynstr
*(.dynstr)
 
.gnu.version
*(.gnu.version)
 
.gnu.version_d
*(.gnu.version_d)
 
.gnu.version_r
*(.gnu.version_r)
 
.rel.init
*(.rel.init)
 
.rela.init
*(.rela.init)
 
.rel.text
*(.rel.text)
*(.rel.text.*)
*(.rel.gnu.linkonce.t*)
 
.rela.text
*(.rela.text)
*(.rela.text.*)
*(.rela.gnu.linkonce.t*)
 
.rel.fini
*(.rel.fini)
 
.rela.fini
*(.rela.fini)
 
.rel.rodata
*(.rel.rodata)
*(.rel.rodata.*)
*(.rel.gnu.linkonce.r*)
 
.rela.rodata
*(.rela.rodata)
*(.rela.rodata.*)
*(.rela.gnu.linkonce.r*)
 
.rel.data
*(.rel.data)
*(.rel.data.*)
*(.rel.gnu.linkonce.d*)
 
.rela.data
*(.rela.data)
*(.rela.data.*)
*(.rela.gnu.linkonce.d*)
 
.rel.ctors
*(.rel.ctors)
 
.rela.ctors
*(.rela.ctors)
 
.rel.dtors
*(.rel.dtors)
 
.rela.dtors
*(.rela.dtors)
 
.rel.got
*(.rel.got)
 
.rela.got
*(.rela.got)
 
.rel.bss
*(.rel.bss)
 
.rela.bss
*(.rela.bss)
 
.rel.plt
*(.rel.plt)
 
.rela.plt
*(.rela.plt)
 
.text 0x00000000 0x109e
*(.vectors)
.vectors 0x00000000 0x26 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
0x00000000 __vectors
0x00000026 __ctors_start = .
*(.ctors)
0x00000026 __ctors_end = .
0x00000026 __dtors_start = .
*(.dtors)
0x00000026 __dtors_end = .
*(.progmem.gcc*)
.progmem.gcc_sw_table
0x00000026 0xa2 I2CInterface.o
*(.progmem*)
0x000000c8 . = ALIGN (0x2)
*(.init0)
*(.init1)
*(.init2)
.init2 0x000000c8 0xc C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
*(.init3)
*(.init4)
.init4 0x000000d4 0x16 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a(_copy_data.o)
0x000000d4 __do_copy_data
.init4 0x000000ea 0x10 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a(_clear_bss.o)
0x000000ea __do_clear_bss
*(.init5)
*(.init6)
*(.init7)
*(.init8)
*(.init9)
.init9 0x000000fa 0x2 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
*(.text)
.text 0x000000fc 0x2 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
0x000000fc __vector_12
0x000000fc __bad_interrupt
0x000000fc __vector_6
0x000000fc __vector_3
0x000000fc __vector_13
0x000000fc __vector_7
0x000000fc __vector_5
0x000000fc __vector_4
0x000000fc __vector_9
0x000000fc __vector_15
0x000000fc __vector_14
0x000000fc __vector_10
0x000000fc __vector_16
0x000000fc __vector_18
.text 0x000000fe 0x60 CamInterface.o
0x000000fe CamInt_init
0x0000015c CamInt_resetCam
.text 0x0000015e 0x26 Main.o
0x0000015e main
.text 0x00000184 0xf0 Executive.o
0x00000252 Exec_writeEventFifo
0x00000184 Exec_run
.text 0x00000274 0x428 FrameMgr.o
0x000002f8 FrameMgr_acquireFrame
0x0000032e FrameMgr_acquireLine
0x00000282 FrameMgr_dispatchEvent
0x0000050c FrameMgr_processFrame
0x00000274 FrameMgr_init
0x00000392 FrameMgr_processLine
.text 0x0000069c 0x4b0 UIMgr.o
0x00000ac4 UIMgr_flushTxBuffer
0x00000b2a UIMgr_writeTxFifo
0x00000710 UIMgr_processReceivedData
0x0000069c UIMgr_init
0x00000a6e UIMgr_writeBufferToTxFifo
0x00000aa0 UIMgr_txBuffer
0x000006fc UIMgr_transmitPendingData
0x000006d2 UIMgr_dispatchEvent
.text 0x00000b4c 0x78 UartInterface.o
0x00000b4c UartInt_init
0x00000b68 __vector_11
0x00000b60 UartInt_txByte
.text 0x00000bc4 0x1a2 I2CInterface.o
0x00000c38 I2CInt_isI2cBusy
0x00000c04 I2CInt_readData
0x00000c4a __vector_17
0x00000bc4 I2CInt_init
0x00000bcc I2CInt_writeData
.text 0x00000d66 0xe0 CamConfig.o
0x00000d66 CamConfig_init
0x00000dee CamConfig_writeTxFifo
0x00000d92 CamConfig_sendFifoCmds
0x00000d88 CamConfig_setCamReg
.text 0x00000e46 0x76 Utility.o
0x00000e46 Utility_delay
.text 0x00000ebc 0x48 DebugInterface.o
0x00000ebc DebugInt_init
.text 0x00000f04 0xe8 CamInterfaceAsm.o
0x00000fd8 __vector_1
0x00000f98 CamIntAsm_acquireDumpLine
0x00000fea __vector_default
0x00000fda __vector_2
0x00000f92 CamIntAsm_waitForNewDumpFrame
0x00000f04 CamIntAsm_waitForNewTrackingFrame
0x00000f0a CamIntAsm_acquireTrackingLine
0x00000fdc __vector_8
.text 0x00000fec 0x58 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(atoi.o)
0x00000fec atoi
.text 0x00001044 0x10 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(ee_rb.o)
0x00001044 eeprom_read_byte
.text 0x00001054 0x22 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(ee_rblk.o)
0x00001054 eeprom_read_block
.text 0x00001076 0x16 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(ee_wb.o)
0x00001076 eeprom_write_byte
.text 0x0000108c 0x10 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(mul10.o)
0x0000108c __mulhi_const_10
0x0000109c . = ALIGN (0x2)
*(.text.*)
0x0000109c . = ALIGN (0x2)
*(.fini9)
*(.fini8)
*(.fini7)
*(.fini6)
*(.fini5)
*(.fini4)
*(.fini3)
*(.fini2)
*(.fini1)
*(.fini0)
.fini0 0x0000109c 0x2 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a(_exit.o)
0x0000109e _etext = .
 
.data 0x00800060 0x10 load address 0x0000109e
0x00800060 PROVIDE (__data_start, .)
*(.data)
.data 0x00800060 0x2 FrameMgr.o
.data 0x00800062 0xe UIMgr.o
*(.gnu.linkonce.d*)
0x00800070 . = ALIGN (0x2)
0x00800070 _edata = .
0x00800070 PROVIDE (__data_end, .)
 
.bss 0x00800070 0x274
0x00800070 PROVIDE (__bss_start, .)
*(.bss)
.bss 0x00800070 0x3 Executive.o
0x00800071 Exec_eventFifoTail
0x00800072 fastEventBitmask
0x00800070 Exec_eventFifoHead
.bss 0x00800073 0x45 FrameMgr.o
.bss 0x008000b8 0x4b UIMgr.o
0x008000b9 UIMgr_rxFifoTail
0x008000bb UIMgr_txFifoTail
0x008000ba UIMgr_txFifoHead
0x008000b8 UIMgr_rxFifoHead
.bss 0x00800103 0x7 I2CInterface.o
.bss 0x0080010a 0x2 CamConfig.o
0x0080010a CamConfig_txFifoHead
0x0080010b CamConfig_txFifoTail
*(COMMON)
COMMON 0x0080010c 0x160 CamInterface.o
0x0 (size before relaxing)
0x0080010c previousLineBuffer
0x008001bc currentLineBuffer
COMMON 0x0080026c 0x8 Executive.o
0x0 (size before relaxing)
0x0080026c Exec_eventFifo
COMMON 0x00800274 0x60 UIMgr.o
0x0 (size before relaxing)
0x00800274 UIMgr_rxFifo
0x00800294 UIMgr_txFifo
COMMON 0x008002d4 0x10 CamConfig.o
0x0 (size before relaxing)
0x008002d4 CamConfig_txFifo
0x008002e4 PROVIDE (__bss_end, .)
0x0000109e __data_load_start = LOADADDR (.data)
0x000010ae __data_load_end = (__data_load_start + SIZEOF (.data))
 
.noinit 0x00800300 0x30
0x00800300 PROVIDE (__noinit_start, .)
*(.noinit*)
.noinit 0x00800300 0x30 CamInterface.o
0x00800300 colorMap
0x00800330 PROVIDE (__noinit_end, .)
0x00800330 _end = .
0x00800330 PROVIDE (__heap_start, .)
 
.eeprom 0x00810000 0x0 load address 0x000010ae
*(.eeprom*)
0x00810000 __eeprom_end = .
 
.stab 0x00000000 0x3f30
*(.stab)
.stab 0x00000000 0x51c CamInterface.o
.stab 0x0000051c 0x318 Main.o
0x3fc (size before relaxing)
.stab 0x00000834 0x4bc Executive.o
0x5dc (size before relaxing)
.stab 0x00000cf0 0xce4 FrameMgr.o
0xe1c (size before relaxing)
.stab 0x000019d4 0xe4c UIMgr.o
0x1014 (size before relaxing)
.stab 0x00002820 0x300 UartInterface.o
0x390 (size before relaxing)
.stab 0x00002b20 0x5a0 I2CInterface.o
0x624 (size before relaxing)
.stab 0x000030c0 0x48c CamConfig.o
0x510 (size before relaxing)
.stab 0x0000354c 0x21c Utility.o
0x270 (size before relaxing)
.stab 0x00003768 0x258 DebugInterface.o
0x2c4 (size before relaxing)
.stab 0x000039c0 0x570 CamInterfaceAsm.o
0x57c (size before relaxing)
 
.stabstr 0x00000000 0x181e
*(.stabstr)
.stabstr 0x00000000 0x181e CamInterface.o
0x0 (size before relaxing)
 
.stab.excl
*(.stab.excl)
 
.stab.exclstr
*(.stab.exclstr)
 
.stab.index
*(.stab.index)
 
.stab.indexstr
*(.stab.indexstr)
 
.comment
*(.comment)
 
.debug
*(.debug)
 
.line
*(.line)
 
.debug_srcinfo
*(.debug_srcinfo)
 
.debug_sfnames
*(.debug_sfnames)
 
.debug_aranges
*(.debug_aranges)
 
.debug_pubnames
*(.debug_pubnames)
 
.debug_info
*(.debug_info)
*(.gnu.linkonce.wi.*)
 
.debug_abbrev
*(.debug_abbrev)
 
.debug_line
*(.debug_line)
 
.debug_frame
*(.debug_frame)
 
.debug_str
*(.debug_str)
 
.debug_loc
*(.debug_loc)
 
.debug_macinfo
*(.debug_macinfo)
OUTPUT(AVRcam.elf elf32-avr)
 
Cross Reference Table
 
Symbol File
CamConfig_init CamConfig.o
Main.o
CamConfig_sendFifoCmds CamConfig.o
UIMgr.o
FrameMgr.o
CamConfig_setCamReg CamConfig.o
UIMgr.o
FrameMgr.o
CamConfig_txFifo CamConfig.o
CamConfig_txFifoHead CamConfig.o
CamConfig_txFifoTail CamConfig.o
CamConfig_writeTxFifo CamConfig.o
CamIntAsm_acquireDumpLine CamInterfaceAsm.o
FrameMgr.o
CamIntAsm_acquireTrackingLine CamInterfaceAsm.o
FrameMgr.o
CamIntAsm_waitForNewDumpFrame CamInterfaceAsm.o
CamIntAsm_waitForNewTrackingFrame CamInterfaceAsm.o
CamInt_init CamInterface.o
Main.o
CamInt_resetCam CamInterface.o
UIMgr.o
DebugInt_init DebugInterface.o
Main.o
Exec_eventFifo UartInterface.o
Executive.o
Exec_eventFifoHead Executive.o
UartInterface.o
Exec_eventFifoTail Executive.o
Exec_run Executive.o
Main.o
Exec_writeEventFifo Executive.o
UIMgr.o
FrameMgr.o
FrameMgr_acquireFrame FrameMgr.o
FrameMgr_acquireLine FrameMgr.o
Executive.o
FrameMgr_dispatchEvent FrameMgr.o
Executive.o
FrameMgr_init FrameMgr.o
Main.o
FrameMgr_processFrame FrameMgr.o
FrameMgr_processLine FrameMgr.o
Executive.o
I2CInt_init I2CInterface.o
Main.o
I2CInt_isI2cBusy I2CInterface.o
CamConfig.o
I2CInt_readData I2CInterface.o
I2CInt_writeData I2CInterface.o
CamConfig.o
UIMgr_dispatchEvent UIMgr.o
Executive.o
UIMgr_flushTxBuffer UIMgr.o
UIMgr_init UIMgr.o
Main.o
UIMgr_processReceivedData UIMgr.o
UIMgr_rxFifo UartInterface.o
UIMgr.o
UIMgr_rxFifoHead UIMgr.o
UartInterface.o
UIMgr_rxFifoTail UIMgr.o
UIMgr_transmitPendingData UIMgr.o
Executive.o
UIMgr_txBuffer UIMgr.o
UIMgr_txFifo UIMgr.o
UIMgr_txFifoHead UIMgr.o
UIMgr_txFifoTail UIMgr.o
UIMgr_writeBufferToTxFifo UIMgr.o
UIMgr_writeTxFifo UIMgr.o
FrameMgr.o
UartInt_init UartInterface.o
Main.o
UartInt_txByte UartInterface.o
UIMgr.o
FrameMgr.o
Utility_delay Utility.o
DebugInterface.o
CamConfig.o
UIMgr.o
FrameMgr.o
Main.o
__bad_interrupt C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__bss_end C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a(_clear_bss.o)
__bss_start C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a(_clear_bss.o)
__data_end C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a(_copy_data.o)
__data_load_start C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a(_copy_data.o)
__data_start C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a(_copy_data.o)
__do_clear_bss C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a(_clear_bss.o)
DebugInterface.o
Utility.o
CamConfig.o
I2CInterface.o
UartInterface.o
UIMgr.o
FrameMgr.o
Executive.o
Main.o
CamInterface.o
__do_copy_data C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a(_copy_data.o)
DebugInterface.o
Utility.o
CamConfig.o
I2CInterface.o
UartInterface.o
UIMgr.o
FrameMgr.o
Executive.o
Main.o
CamInterface.o
__heap_end C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__init C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__mulhi_const_10 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(mul10.o)
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(atoi.o)
__stack C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
Main.o
__vector_1 CamInterfaceAsm.o
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_10 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_11 UartInterface.o
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_12 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_13 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_14 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_15 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_16 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_17 I2CInterface.o
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_18 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_2 CamInterfaceAsm.o
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_3 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_4 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_5 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_6 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_7 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_8 CamInterfaceAsm.o
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vector_9 C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
CamInterfaceAsm.o
__vector_default CamInterfaceAsm.o
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
__vectors C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
_exit C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a(_exit.o)
atoi C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(atoi.o)
UIMgr.o
colorMap CamInterface.o
UIMgr.o
FrameMgr.o
currentLineBuffer FrameMgr.o
CamInterface.o
eeprom_read_block C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(ee_rblk.o)
CamInterface.o
eeprom_read_byte C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(ee_rb.o)
UIMgr.o
eeprom_write_byte C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\libc.a(ee_wb.o)
UIMgr.o
exit C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\avr4\libgcc.a(_exit.o)
Main.o
fastEventBitmask Executive.o
CamInterfaceAsm.o
FrameMgr.o
main Main.o
C:\WinAVR\bin\..\lib\gcc-lib\avr\3.3.1\..\..\..\..\avr\lib\avr4\crtm8.o
previousLineBuffer FrameMgr.o
CamInterface.o
/programy/Atmel_C/AVRcam/CamConfig.c
0,0 → 1,192
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/**********************************************************
Module Name: CamConfig.c
Module Date: 04/10/2004
Module Auth: John Orlando
Description: This module is responsible for the
high-level configuration activities of the OV6620
camera module. This module interfaces with the
I2CInterface module to perform this configuration.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
11/15/2004 1.2 Added code to un-tri-state the
OV6620's pixel data busses at
startup after four seconds.
This was added in to
allow the user to re-program the
mega8 at startup if needed.
***********************************************************/
 
/* Includes */
#include <avr/io.h>
#include "CamConfig.h"
#include "I2CInterface.h"
#include "CommonDefs.h"
#include "Utility.h"
 
/**********************************************************/
/* Definitions */
/* The length of an I2C command is made up of a register address
plus the actual value of the register */
#define SIZE_OF_I2C_CMD 2
#define MAX_NUM_CONFIG_CMDS 8
#define CAM_CONFIG_TX_FIFO_SIZE MAX_NUM_CONFIG_CMDS
#define CAM_CONFIG_TX_FIFO_MASK CAM_CONFIG_TX_FIFO_SIZE-1
 
/* Local Variables */
 
/* Local Structures and Typedefs */
 
/* Local Function Prototypes */
static i2cCmd_t CamConfig_readTxFifo(void);
 
/* Extern Variables */
i2cCmd_t CamConfig_txFifo[CAM_CONFIG_TX_FIFO_SIZE];
unsigned char CamConfig_txFifoHead=0;
unsigned char CamConfig_txFifoTail=0;
 
/***********************************************************
Function Name: CamConfig_init
Function Description: This function is responsible for
performing the initial configuration of the camera.
Inputs: none
Outputs: none
***********************************************************/
void CamConfig_init(void)
{
CamConfig_setCamReg(0x14,0x20); /* reduce frame size */
CamConfig_setCamReg(0x39,0x40); /* gate PCLK with HREF */
CamConfig_setCamReg(0x12,0x28); /* set RGB mode, with no AWB */
CamConfig_setCamReg(0x28,0x05); /* set color sequencer */
CamConfig_setCamReg(0x13,0x01); /* un-tri-state the Y/UV lines */
/* send the first four cmds in the I2C fifo */
CamConfig_sendFifoCmds();
}
 
 
/***********************************************************
Function Name: CamConfig_setCamReg
Function Description: This function is responsible for
creating an I2C cmd structure and placing it into the
cmd fifo.
Inputs: reg - the register to modify
val - the new value of the register
Outputs: none
***********************************************************/
void CamConfig_setCamReg(unsigned char reg, unsigned char val)
{
i2cCmd_t cmd;
cmd.configReg = reg;
cmd.data = val;
#ifndef SIMULATION
CamConfig_writeTxFifo(cmd);
#endif
}
/***********************************************************
Function Name: CamConfig_sendFifoCmds
Function Description: This function is responsible for
sending the entire contents of the config fifo. This
function won't return until the configuration process
is complete (or an error is encountered).
Inputs: none
Outputs: none
Note: Since this function is written to use the TWI
interrupt in the I2CInterface module, there will be
some busy-waiting here...no big deal, since we end up
having to trash the frame that we are executing this
slave write in anyway (since we can't meet the strict
timing requirements and write i2c at the same time).
***********************************************************/
void CamConfig_sendFifoCmds(void)
{
i2cCmd_t cmd;
while (CamConfig_txFifoHead != CamConfig_txFifoTail)
{
cmd = CamConfig_readTxFifo();
I2CInt_writeData(CAM_ADDRESS,&cmd.configReg,SIZE_OF_I2C_CMD);
Utility_delay(100);
/* wait for the I2C transaction to complete */
while(I2CInt_isI2cBusy() == TRUE);
}
}
 
/***********************************************************
Function Name: CamConfig_writeTxFifo
Function Description: This function is responsible for
adding a new command to the tx fifo. It adjusts all
needed pointers.
Inputs: cmd - the i2cCmd_t to add to the fifo
Outputs: bool_t - indicating if writing to the fifo
causes it to wrap
***********************************************************/
bool_t CamConfig_writeTxFifo(i2cCmd_t cmd)
{
unsigned char tmpHead;
bool_t retVal = TRUE;
CamConfig_txFifo[CamConfig_txFifoHead] = cmd;
/* see if we need to wrap */
tmpHead = (CamConfig_txFifoHead+1) & (CAM_CONFIG_TX_FIFO_MASK);
CamConfig_txFifoHead = tmpHead;
/* check to see if we have filled up the queue */
if (CamConfig_txFifoHead == CamConfig_txFifoTail)
{
/* we wrapped the fifo...return false */
retVal = FALSE;
}
return(retVal);
}
 
/***********************************************************
Function Name: CamConfig_readTxFifo
Function Description: This function is responsible for
reading a cmd out of the tx fifo.
Inputs: none
Outputs: i2cCmd_t - the cmd read from the fifo
***********************************************************/
static i2cCmd_t CamConfig_readTxFifo(void)
{
i2cCmd_t cmd;
unsigned char tmpTail;
/* just return the current tail from the rx fifo */
cmd = CamConfig_txFifo[CamConfig_txFifoTail];
tmpTail = (CamConfig_txFifoTail+1) & (CAM_CONFIG_TX_FIFO_MASK);
CamConfig_txFifoTail = tmpTail;
return(cmd);
}
/programy/Atmel_C/AVRcam/CamConfig.d
0,0 → 1,2
CamConfig.o CamConfig.d : CamConfig.c CamConfig.h I2CInterface.h CommonDefs.h \
Utility.h
/programy/Atmel_C/AVRcam/CamConfig.h
0,0 → 1,65
#ifndef CAMCONFIG_H
#define CAMCONFIG_H
 
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: CamConfig.h
Module Date: 04/12/2004
Module Auth: John Orlando
Description: This file provides the external interface
to the CamConfig module.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
***********************************************************/
 
#include "I2CInterface.h"
/* This is the I2C slave address of the OV6620 module.
NOTE: The actual address of the camera is 0xC0. However,
the TWI interface on the mega8 needs to have the address
shifted one bit to the right, which yields 0x60. The
LSB is used to set whether the operation is read or
write. */
#define CAM_ADDRESS 0x60
extern i2cCmd_t CamConfig_txFifo[];
extern unsigned char CamConfig_txFifoHead;
extern unsigned char CamConfig_txFifoTail;
extern bool_t CamConfig_txComplete;
 
extern void CamConfig_init(void);
extern bool_t CamConfig_writeTxFifo(i2cCmd_t cmd);
extern void CamConfig_setCamReg(unsigned char reg, unsigned char val);
extern void CamConfig_sendFifoCmds(void);
#endif
 
/programy/Atmel_C/AVRcam/CamInterface.S
0,0 → 1,76
; Module Name: CanInterface.S
; Module Date: 04/14/2004
; Module Auth: John O.
;
; Description: This module provides the low-level interface
; to the OV6620 camera hardware. It is responsible for
; acquiring each pixel block (RG,GB), performing the mapping
; into an actual color (orange, purple, etc), run-length
; encoding the data, and storing the info off to the appropriate
; line buffer. This routine is synchronized with the pixel data
; so that no polling of the camera data needs to be done (the
; OV6620 is clocked off of the same crystal source as the mega8,
; thus providing inherent synchronization between the two).
 
#include <avr/io.h>
 
#define PCLK_INTERRUPT_ENABLE_MASK $40
#define PCLK_INTERRUPT_DISABLE_MASK $BF
 
.section .text
 
.global CamInt_waitForNewFrame
.global CamInt_acquireLine
.global SIG_INTERRUPT0
.global SIG_INTERRUPT1
;*****************************************************************
; Function Name: CamInt_waitForNewFrame
; Function Description: This function is responsible for
; going to sleep until a new frame begins (indicated by
; VSYNC transitioning from high to low. This will wake
; the "VSYNC sleep" up and allow it to continue with
; the acquireLine function, where the system waits for
; a "PCLK sleep" that we use to synchronize with the
; data.
; Inputs: none
; Outputs: none
; NOTES: This function doesn't really return...it sorta just
; floats into the acquireLine function after the "VSYNC sleep"
; is awoken.
;*****************************************************************
CamInt_waitForNewFrame:
sleep ; sleep mode already set to sleep idle
 
CamInt_acquireLine:
in r1,_SFR_IO_ADDR(GICR) ;enable the PCLK interrupt
or r1,PCLK_INTERRUPT_ENABLE_MASK
out _SFR_IO_ADDR(GICR),r1
sleep
in r1,_SFR_IO_ADDR(GICR) ;disable the PCLK interrupt
and r1,PCLK_INTERRUPT_DISABLE_MASK
out _SFR_IO_ADDR(GICR),r1
_acquirePixelBlock:
 
 
_exit:
ret
 
 
SIG_INTERRUPT0:
; This will wake us up when VSYNC transitions low...we just want to return
reti
SIG_INTERRUPT1:
; This will wake us up when PCLK transitions low...we just want to return
reti
 
 
.global __vector_default ; Note [10]
__vector_default:
reti
 
.end
/programy/Atmel_C/AVRcam/CamInterface.c
0,0 → 1,236
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: CamInterface.c
Module Date: 04/12/2004
Module Auth: John Orlando
Description: This file is responsible for providing an
interface to the OV6620 camera hardware. This includes
an interface to CamInterface.S for certain low-level,
optimized camera access routines.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
11/15/2004 1.2 ifdef'd out the resetCam routine, since
resetting the cam now causes the OV6620's
clock to not be output (we have to start
it up after each reset with the external
tiny12 processor).
1/16/2005 1.4 Ensure that the TCCR1B register is set so
nothing is clocking timer1 at startup.
***********************************************************/
 
/* Includes */
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <avr/sleep.h>
#include <avr/eeprom.h>
#include <stdlib.h>
#include <string.h>
#include "CommonDefs.h"
#include "CamInterface.h"
#include "Utility.h"
#include "UIMgr.h"
#include "Executive.h"
#include "UartInterface.h"
 
/* Local Variables */
 
/* Local Structures and Typedefs */
 
/* Definitions */
//#define OUTPUT_INITIAL_COLOR_MAP 1
 
#define FAST_ACQUIRE 1
#define CAM_G_BUS PINB
#define CAM_G_BUS_DIR DDRB
#define CAM_RB_BUS PINC
#define CAM_RB_BUS_DIR DDRC
 
#define CAM_CONTROL_PORT PORTD
#define CAM_CONTROL_PORT_DIR DDRD
#define CAM_RESET_LINE BIT7
#define CAM_PIXEL_CLK_COUNT BIT5
#define CAM_HREF BIT4
#define CAM_PIXEL_CLK_INT BIT3
#define CAM_VSYNC BIT2
 
/* Global Variables */
/* NOTE: This file MUST appear first in the Makefile for these variables to
be placed properly in RAM */
 
/* The colorMap[] table provides the membership lookup table to convert
RGB or YUV pixel values into actual colors. The membership table contains
16 elements for each color channel, concatenated together. The Red (or Y)
value is located in the first 16 bytes, the G (or U) value is located in
the second 16 bytes, and the B (or V) value is located in the last 16 bytes:
 
----------------------------------------------------------------------------------
|red0|red1|red2|...|red15|green0|green1|green2|...|green15|blue0|blue1|...|blue15|
mem:|0x00 0x01 0x02 0x15 0x16 0x17 0x18 0x31 0x32 0x33 0x47 |
---------------------------------------------------------------------------------
Thus, the red lookup is accessed at colorMap+0, the green lookup is accessed
at colorMap+16, and the blue lookup is accessed at colorMap+32. */
unsigned char colorMap[NUM_ELEMENTS_IN_COLOR_MAP] __attribute__ ((section (".noinit")));
 
/* Extern Variables */
/* These two buffers hold the current and previous lines
of pixel data. They are sized to the worst case scenario,
where the color changes between every pixel (unrealistic).
The format of each buffer is for all the even bytes to hold
the run-length, and the odd bytes to hold the color data. */
 
/* In addition, if we are in frameDump mode, we use these buffers
to store the acquired line data...we are actually grabbing ALL of the
pixels in a line (176) instead of the 88 we get normally during tracking.
But since we have enough to hold 88-RLE blocks, we already have the 176
allocated for this... */
unsigned char currentLineBuffer[LENGTH_OF_LINE_BUFFER];
unsigned char previousLineBuffer[LENGTH_OF_LINE_BUFFER];
 
/* Extern Functions */
/* These functions are located in assembly files, and thus
must be externed here so they can be referenced in the source below. */
extern void CamIntAsm_waitForNewTrackingFrame(unsigned char *pBuffer, unsigned char *pMemLookup);
extern void CamIntAsm_waitForNewDumpFrame(unsigned char *pCurrBuffer, unsigned char *pPrevBuffer);
extern void CamIntAsm_acquireTrackingLine(unsigned char *pBuffer, unsigned char *pMemLookup);
extern void CamIntAsm_acquireDumpLine(unsigned char *pCurrBuffer, unsigned char *pPrevBuffer);
 
/***********************************************************
Function Name: CamInt_init
Function Description: This function is responsible
for initializing the camera interface. This includes
setting up the i/o ports that are used to read the
camera busses, as well as resetting the camera.
Inputs: none
Outputs: none
***********************************************************/
void CamInt_init(void)
{
#if OUTPUT_INITIAL_COLOR_MAP
unsigned char asciiBuffer[5];
unsigned char i;
#endif
/* set up the mega8 ports that will be interfacing
with the camera */
CAM_CONTROL_PORT_DIR |= (1<<CAM_RESET_LINE); /* cam reset is output */
CAM_CONTROL_PORT_DIR |= 0x80; /* set just the MSB as an output */
CAM_CONTROL_PORT_DIR &= 0xFB; /* make sure bit2 is clear (input) */
CAM_CONTROL_PORT &= 0x7F; /* set reset line low */
CAM_G_BUS_DIR &= 0xF0; /* 4-bit G bus all inputs */
CAM_G_BUS_DIR |= 0xF0; /* disable the pull-up on PB4 and PB5 */
CAM_RB_BUS_DIR &= 0xF0; /* 4-bit RB bus all inputs */
/* ensure that timer1 is disabled to start...eventually, when PCLK needs
to feed timer1 through the external counter, it will be enabled on an
"as needed" basis...*/
TCCR1B &= ~( (1<<CS12)|(1<<CS11)|(1<<CS10) );
/* we'll turn on the interrupt after we assign the initial TCNT value */
/* set up External Interrupt1 to interrupt us on rising edges (HREF)...
this is needed to indicate when the first pixel of each line is about to start, so
we can synch up with it...this interrupt will be disabled once HREF goes high */
MCUCR |= (1<<ISC11) | (1<<ISC10); /* rising edge interrupt */
/* the interrupt will be enabled when we are ready to detect the rising edge of
HREF...its now primed and ready to go */
/* set up External Interrupt0 to interrupt us on rising edges (VSYNC) */
MCUCR |= (1<<ISC01) | (1<<ISC00); /* rising edge interrupt */
GICR |= (1<<INT0); /* interrupt request enabled */
/* set up TimerO to count and be clocked from an external pulse source
(HREF) on falling edges...eventually, we need to enable the interrupt
for this! FIX THIS */
TCCR0 = (1<<CS02)|(1<<CS01)|(0<<CS00);
/* setting up the PCLK counter with Timer1 will be done right after
we start receiving pixels in each line...we sacrifice the first pixel
in each line, but we'll account for it...*/
/* set up the mega8 so that its sleep mode puts it in an IDLE sleep
mode, where it can wake up as fast as possible */
set_sleep_mode(SLEEP_MODE_IDLE);
/* umm....we need to actually enable the sleep mode...*/
MCUCR |= 0x80;
/* initialize the memLookup table */
memset(colorMap,0x00,NUM_ELEMENTS_IN_COLOR_MAP);
/* read the color map out of EEPROM */
eeprom_read_block(colorMap, (unsigned char*)0x01,NUM_ELEMENTS_IN_COLOR_MAP);
 
#if OUTPUT_INITIAL_COLOR_MAP
UIMgr_txBuffer("\r\n",2);
for (i=0; i<NUM_ELEMENTS_IN_COLOR_MAP; i++)
{
memset(asciiBuffer,0x00,5);
itoa(colorMap[i],asciiBuffer,10);
UIMgr_txBuffer(asciiBuffer,3);
UIMgr_txBuffer(" ",1);
if (i==15 || i == 31)
{
/* break up the output */
UIMgr_txBuffer("\r\n",2);
}
}
#endif
 
#ifndef NO_CRYSTAL
CamInt_resetCam();
#endif
}
 
/***********************************************************
Function Name: CamInt_resetCam
Function Description: This function is responsible
for resetting the camera. This is accomplished by
toggling the reset line on the OV6620 for ~100 mS.
Inputs: none
Outputs: none
IMPORTANT NOTE: This function has effectively been removed
since resetting the camera now causes the camera to not
output the clock signal. Thus, if we reset the cam, the
AVR has no clock, and thus doesn't run...
***********************************************************/
void CamInt_resetCam(void)
{
 
#if 0
CAM_CONTROL_PORT |= (1<<CAM_RESET_LINE); /* cam reset line high */
Utility_delay(500);
CAM_CONTROL_PORT &= (0<<CAM_RESET_LINE); /* cam reset line low */
Utility_delay(100);
#endif
}
 
 
/programy/Atmel_C/AVRcam/CamInterface.d
0,0 → 1,2
CamInterface.o CamInterface.d : CamInterface.c CommonDefs.h CamInterface.h Utility.h \
UIMgr.h Executive.h Events.h UartInterface.h
/programy/Atmel_C/AVRcam/CamInterface.h
0,0 → 1,82
#ifndef CAMINTERFACE_H
#define CAMINTERFACE_H
 
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: CamInterface.h
Module Date: 04/14/2004
Module Auth: John Orlando
Description: This file is responsible for providing the
external interface to the CamInterface module.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
***********************************************************/
 
#define NUM_PIXELS_IN_A_TRACKED_LINE 88
#define NUM_PIXELS_IN_A_DUMP_LINE 176
#define ACTUAL_NUM_PIXELS_IN_A_LINE 176
#define ACTUAL_NUM_LINES_IN_A_FRAME 144
#define LENGTH_OF_RUN_LENGTH_BLOCK 2
#define LENGTH_OF_LINE_BUFFER NUM_PIXELS_IN_A_DUMP_LINE
 
#define WAIT_FOR_VSYNC_LOW() while( (PIND & 0x04) != 0)
#define WAIT_FOR_VSYNC_HIGH() while( (PIND & 0x04) == 0)
 
#define WAIT_FOR_HREF_LOW() while( (PIND & 0x10) != 0)
#define WAIT_FOR_HREF_HIGH() while( (PIND & 0x10) == 0)
 
#define WAIT_FOR_PCLK_LOW() while( (PIND & 0x20) != 0)
#define WAIT_FOR_PCLK_HIGH() while( (PIND & 0x20) == 0)
 
#define NUM_COLOR_STEPS 16
#define NUM_COLOR_CHANNELS 3
#define NUM_ELEMENTS_IN_COLOR_MAP (NUM_COLOR_STEPS * NUM_COLOR_CHANNELS)
 
#define RED_OFFSET 0
#define GREEN_OFFSET 16
#define BLUE_OFFSET 32
 
extern unsigned char currentLineBuffer[];
extern unsigned char previousLineBuffer[];
extern unsigned char colorMap[];
extern unsigned char frameCount;
/* Extern functions */
extern void CamInt_init(void);
extern void CamInt_resetCam(void);
extern void CamInt_waitForNewDumpFrame(void);
extern void CamInt_waitForNewTrackingFrame(void);
extern void CamInt_acquireTrackingLine(void);
extern void CamInt_acquireDumpLine(void);
#endif
 
/programy/Atmel_C/AVRcam/CamInterface.lst
0,0 → 1,781
GAS LISTING /tmp/ccAE2QZt.s page 1
 
 
1 .file "CamInterface.c"
2 .arch atmega8
3 __SREG__ = 0x3f
4 __SP_H__ = 0x3e
5 __SP_L__ = 0x3d
6 __tmp_reg__ = 0
7 __zero_reg__ = 1
8 .global __do_copy_data
9 .global __do_clear_bss
10 .stabs "/home/kaklik/projects/roboti/istrobot/2007/ATmega8/AVRcam/",100,0,2,.Ltext0
11 .stabs "CamInterface.c",100,0,2,.Ltext0
12 .text
13 .Ltext0:
14 .stabs "gcc2_compiled.",60,0,0,0
15 .stabs "int:t(0,1)=r(0,1);-32768;32767;",128,0,0,0
16 .stabs "char:t(0,2)=@s8;r(0,2);0;255;",128,0,0,0
17 .stabs "long int:t(0,3)=@s32;r(0,3);020000000000;017777777777;",128,0,0,0
18 .stabs "unsigned int:t(0,4)=r(0,4);0;0177777;",128,0,0,0
19 .stabs "long unsigned int:t(0,5)=@s32;r(0,5);0;037777777777;",128,0,0,0
20 .stabs "long long int:t(0,6)=@s64;r(0,6);01000000000000000000000;0777777777777777777777;",128,0,0,
21 .stabs "long long unsigned int:t(0,7)=@s64;r(0,7);0;01777777777777777777777;",128,0,0,0
22 .stabs "short int:t(0,8)=r(0,8);-32768;32767;",128,0,0,0
23 .stabs "short unsigned int:t(0,9)=r(0,9);0;0177777;",128,0,0,0
24 .stabs "signed char:t(0,10)=@s8;r(0,10);-128;127;",128,0,0,0
25 .stabs "unsigned char:t(0,11)=@s8;r(0,11);0;255;",128,0,0,0
26 .stabs "float:t(0,12)=r(0,1);4;0;",128,0,0,0
27 .stabs "double:t(0,13)=r(0,1);4;0;",128,0,0,0
28 .stabs "long double:t(0,14)=r(0,1);4;0;",128,0,0,0
29 .stabs "void:t(0,15)=(0,15)",128,0,0,0
30 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/interrupt.h",130,0,0,0
31 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/io.h",130,0,0,0
32 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/sfr_defs.h",130,0,0,0
33 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/inttypes.h",130,0,0,0
34 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/stdint.h",130,0,0,0
35 .stabs "int8_t:t(5,1)=(0,10)",128,0,116,0
36 .stabs "uint8_t:t(5,2)=(0,11)",128,0,117,0
37 .stabs "int16_t:t(5,3)=(0,1)",128,0,118,0
38 .stabs "uint16_t:t(5,4)=(0,4)",128,0,119,0
39 .stabs "int32_t:t(5,5)=(0,3)",128,0,120,0
40 .stabs "uint32_t:t(5,6)=(0,5)",128,0,121,0
41 .stabs "int64_t:t(5,7)=(0,6)",128,0,122,0
42 .stabs "uint64_t:t(5,8)=(0,7)",128,0,123,0
43 .stabs "intptr_t:t(5,9)=(5,3)",128,0,135,0
44 .stabs "uintptr_t:t(5,10)=(5,4)",128,0,140,0
45 .stabs "int_least8_t:t(5,11)=(5,1)",128,0,152,0
46 .stabs "uint_least8_t:t(5,12)=(5,2)",128,0,157,0
47 .stabs "int_least16_t:t(5,13)=(5,3)",128,0,162,0
48 .stabs "uint_least16_t:t(5,14)=(5,4)",128,0,167,0
49 .stabs "int_least32_t:t(5,15)=(5,5)",128,0,172,0
50 .stabs "uint_least32_t:t(5,16)=(5,6)",128,0,177,0
51 .stabs "int_least64_t:t(5,17)=(5,7)",128,0,182,0
52 .stabs "uint_least64_t:t(5,18)=(5,8)",128,0,187,0
53 .stabs "int_fast8_t:t(5,19)=(5,1)",128,0,200,0
54 .stabs "uint_fast8_t:t(5,20)=(5,2)",128,0,205,0
55 .stabs "int_fast16_t:t(5,21)=(5,3)",128,0,210,0
56 .stabs "uint_fast16_t:t(5,22)=(5,4)",128,0,215,0
57 .stabs "int_fast32_t:t(5,23)=(5,5)",128,0,220,0
GAS LISTING /tmp/ccAE2QZt.s page 2
 
 
58 .stabs "uint_fast32_t:t(5,24)=(5,6)",128,0,225,0
59 .stabs "int_fast64_t:t(5,25)=(5,7)",128,0,230,0
60 .stabs "uint_fast64_t:t(5,26)=(5,8)",128,0,235,0
61 .stabs "intmax_t:t(5,27)=(5,7)",128,0,249,0
62 .stabs "uintmax_t:t(5,28)=(5,8)",128,0,254,0
63 .stabn 162,0,0,0
64 .stabs "int_farptr_t:t(4,1)=(5,5)",128,0,76,0
65 .stabs "uint_farptr_t:t(4,2)=(5,6)",128,0,80,0
66 .stabn 162,0,0,0
67 .stabn 162,0,0,0
68 .stabn 162,0,0,0
69 .stabn 162,0,0,0
70 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h",130,0,0,0
71 .stabs "/usr/lib/gcc/avr/4.1.0/include/stddef.h",130,0,0,0
72 .stabs "size_t:t(7,1)=(0,4)",128,0,214,0
73 .stabn 162,0,0,0
74 .stabn 162,0,0,0
75 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/stdlib.h",130,0,0,0
76 .stabs "/usr/lib/gcc/avr/4.1.0/include/stddef.h",130,0,0,0
77 .stabs "wchar_t:t(9,1)=(0,1)",128,0,326,0
78 .stabn 162,0,0,0
79 .stabs "div_t:t(8,1)=(8,2)=s4quot:(0,1),0,16;rem:(0,1),16,16;;",128,0,69,0
80 .stabs "ldiv_t:t(8,3)=(8,4)=s8quot:(0,3),0,32;rem:(0,3),32,32;;",128,0,75,0
81 .stabs "__compar_fn_t:t(8,5)=(8,6)=*(8,7)=f(0,1)",128,0,78,0
82 .stabn 162,0,0,0
83 .stabs "CommonDefs.h",130,0,0,0
84 .stabs "bool_t:t(10,1)=(0,11)",128,0,56,0
85 .stabn 162,0,0,0
86 .stabs "CamInt_resetCam:F(0,15)",36,0,226,CamInt_resetCam
87 .global CamInt_resetCam
88 .type CamInt_resetCam, @function
89 CamInt_resetCam:
90 .stabd 46,0,0
1:CamInterface.c **** /*
2:CamInterface.c **** Copyright (C) 2004 John Orlando
3:CamInterface.c ****
4:CamInterface.c **** AVRcam: a small real-time image processing engine.
5:CamInterface.c ****
6:CamInterface.c **** This program is free software; you can redistribute it and/or
7:CamInterface.c **** modify it under the terms of the GNU General Public
8:CamInterface.c **** License as published by the Free Software Foundation; either
9:CamInterface.c **** version 2 of the License, or (at your option) any later version.
10:CamInterface.c ****
11:CamInterface.c **** This program is distributed in the hope that it will be useful,
12:CamInterface.c **** but WITHOUT ANY WARRANTY; without even the implied warranty of
13:CamInterface.c **** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14:CamInterface.c **** General Public License for more details.
15:CamInterface.c ****
16:CamInterface.c **** You should have received a copy of the GNU General Public
17:CamInterface.c **** License along with this program; if not, write to the Free Software
18:CamInterface.c **** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19:CamInterface.c ****
20:CamInterface.c **** For more information on the AVRcam, please contact:
21:CamInterface.c ****
22:CamInterface.c **** john@jrobot.net
23:CamInterface.c ****
24:CamInterface.c **** or go to www.jrobot.net for more details regarding the system.
GAS LISTING /tmp/ccAE2QZt.s page 3
 
 
25:CamInterface.c **** */
26:CamInterface.c **** /***********************************************************
27:CamInterface.c **** Module Name: CamInterface.c
28:CamInterface.c **** Module Date: 04/12/2004
29:CamInterface.c **** Module Auth: John Orlando
30:CamInterface.c ****
31:CamInterface.c **** Description: This file is responsible for providing an
32:CamInterface.c **** interface to the OV6620 camera hardware. This includes
33:CamInterface.c **** an interface to CamInterface.S for certain low-level,
34:CamInterface.c **** optimized camera access routines.
35:CamInterface.c ****
36:CamInterface.c **** Revision History:
37:CamInterface.c **** Date Rel Ver. Notes
38:CamInterface.c **** 4/10/2004 0.1 Module created
39:CamInterface.c **** 6/30/2004 1.0 Initial release for Circuit Cellar
40:CamInterface.c **** contest.
41:CamInterface.c **** 11/15/2004 1.2 ifdef'd out the resetCam routine, since
42:CamInterface.c **** resetting the cam now causes the OV6620's
43:CamInterface.c **** clock to not be output (we have to start
44:CamInterface.c **** it up after each reset with the external
45:CamInterface.c **** tiny12 processor).
46:CamInterface.c **** 1/16/2005 1.4 Ensure that the TCCR1B register is set so
47:CamInterface.c **** nothing is clocking timer1 at startup.
48:CamInterface.c **** ***********************************************************/
49:CamInterface.c ****
50:CamInterface.c **** /* Includes */
51:CamInterface.c **** #include <avr/interrupt.h>
52:CamInterface.c **** #include <avr/signal.h>
53:CamInterface.c **** #include <avr/sleep.h>
54:CamInterface.c **** #include <avr/eeprom.h>
55:CamInterface.c **** #include <stdlib.h>
56:CamInterface.c **** #include <string.h>
57:CamInterface.c **** #include "CommonDefs.h"
58:CamInterface.c **** #include "CamInterface.h"
59:CamInterface.c **** #include "Utility.h"
60:CamInterface.c **** #include "UIMgr.h"
61:CamInterface.c **** #include "Executive.h"
62:CamInterface.c **** #include "UartInterface.h"
63:CamInterface.c ****
64:CamInterface.c **** /* Local Variables */
65:CamInterface.c ****
66:CamInterface.c **** /* Local Structures and Typedefs */
67:CamInterface.c ****
68:CamInterface.c **** /* Definitions */
69:CamInterface.c **** //#define OUTPUT_INITIAL_COLOR_MAP 1
70:CamInterface.c ****
71:CamInterface.c **** #define FAST_ACQUIRE 1
72:CamInterface.c **** #define CAM_G_BUS PINB
73:CamInterface.c **** #define CAM_G_BUS_DIR DDRB
74:CamInterface.c **** #define CAM_RB_BUS PINC
75:CamInterface.c **** #define CAM_RB_BUS_DIR DDRC
76:CamInterface.c ****
77:CamInterface.c **** #define CAM_CONTROL_PORT PORTD
78:CamInterface.c **** #define CAM_CONTROL_PORT_DIR DDRD
79:CamInterface.c **** #define CAM_RESET_LINE BIT7
80:CamInterface.c **** #define CAM_PIXEL_CLK_COUNT BIT5
81:CamInterface.c **** #define CAM_HREF BIT4
GAS LISTING /tmp/ccAE2QZt.s page 4
 
 
82:CamInterface.c **** #define CAM_PIXEL_CLK_INT BIT3
83:CamInterface.c **** #define CAM_VSYNC BIT2
84:CamInterface.c ****
85:CamInterface.c **** /* Global Variables */
86:CamInterface.c **** /* NOTE: This file MUST appear first in the Makefile for these variables to
87:CamInterface.c **** be placed properly in RAM */
88:CamInterface.c ****
89:CamInterface.c **** /* The colorMap[] table provides the membership lookup table to convert
90:CamInterface.c **** RGB or YUV pixel values into actual colors. The membership table contains
91:CamInterface.c **** 16 elements for each color channel, concatenated together. The Red (or Y)
92:CamInterface.c **** value is located in the first 16 bytes, the G (or U) value is located in
93:CamInterface.c **** the second 16 bytes, and the B (or V) value is located in the last 16 bytes:
94:CamInterface.c ****
95:CamInterface.c **** ----------------------------------------------------------------------------------
96:CamInterface.c **** |red0|red1|red2|...|red15|green0|green1|green2|...|green15|blue0|blue1|...|blue15|
97:CamInterface.c **** mem:|0x00 0x01 0x02 0x15 0x16 0x17 0x18 0x31 0x32 0x33 0x47 |
98:CamInterface.c **** ---------------------------------------------------------------------------------
99:CamInterface.c **** Thus, the red lookup is accessed at colorMap+0, the green lookup is accessed
100:CamInterface.c **** at colorMap+16, and the blue lookup is accessed at colorMap+32. */
101:CamInterface.c **** unsigned char colorMap[NUM_ELEMENTS_IN_COLOR_MAP] __attribute__ ((section (".noinit")));
102:CamInterface.c ****
103:CamInterface.c **** /* Extern Variables */
104:CamInterface.c **** /* These two buffers hold the current and previous lines
105:CamInterface.c **** of pixel data. They are sized to the worst case scenario,
106:CamInterface.c **** where the color changes between every pixel (unrealistic).
107:CamInterface.c **** The format of each buffer is for all the even bytes to hold
108:CamInterface.c **** the run-length, and the odd bytes to hold the color data. */
109:CamInterface.c ****
110:CamInterface.c **** /* In addition, if we are in frameDump mode, we use these buffers
111:CamInterface.c **** to store the acquired line data...we are actually grabbing ALL of the
112:CamInterface.c **** pixels in a line (176) instead of the 88 we get normally during tracking.
113:CamInterface.c **** But since we have enough to hold 88-RLE blocks, we already have the 176
114:CamInterface.c **** allocated for this... */
115:CamInterface.c **** unsigned char currentLineBuffer[LENGTH_OF_LINE_BUFFER];
116:CamInterface.c **** unsigned char previousLineBuffer[LENGTH_OF_LINE_BUFFER];
117:CamInterface.c ****
118:CamInterface.c **** /* Extern Functions */
119:CamInterface.c **** /* These functions are located in assembly files, and thus
120:CamInterface.c **** must be externed here so they can be referenced in the source below. */
121:CamInterface.c **** extern void CamIntAsm_waitForNewTrackingFrame(unsigned char *pBuffer, unsigned char *pMemLookup);
122:CamInterface.c **** extern void CamIntAsm_waitForNewDumpFrame(unsigned char *pCurrBuffer, unsigned char *pPrevBuffer);
123:CamInterface.c **** extern void CamIntAsm_acquireTrackingLine(unsigned char *pBuffer, unsigned char *pMemLookup);
124:CamInterface.c **** extern void CamIntAsm_acquireDumpLine(unsigned char *pCurrBuffer, unsigned char *pPrevBuffer);
125:CamInterface.c ****
126:CamInterface.c **** /***********************************************************
127:CamInterface.c **** Function Name: CamInt_init
128:CamInterface.c **** Function Description: This function is responsible
129:CamInterface.c **** for initializing the camera interface. This includes
130:CamInterface.c **** setting up the i/o ports that are used to read the
131:CamInterface.c **** camera busses, as well as resetting the camera.
132:CamInterface.c **** Inputs: none
133:CamInterface.c **** Outputs: none
134:CamInterface.c **** ***********************************************************/
135:CamInterface.c **** void CamInt_init(void)
136:CamInterface.c **** {
137:CamInterface.c **** #if OUTPUT_INITIAL_COLOR_MAP
138:CamInterface.c **** unsigned char asciiBuffer[5];
GAS LISTING /tmp/ccAE2QZt.s page 5
 
 
139:CamInterface.c **** unsigned char i;
140:CamInterface.c **** #endif
141:CamInterface.c ****
142:CamInterface.c **** /* set up the mega8 ports that will be interfacing
143:CamInterface.c **** with the camera */
144:CamInterface.c **** CAM_CONTROL_PORT_DIR |= (1<<CAM_RESET_LINE); /* cam reset is output */
145:CamInterface.c **** CAM_CONTROL_PORT_DIR |= 0x80; /* set just the MSB as an output */
146:CamInterface.c **** CAM_CONTROL_PORT_DIR &= 0xFB; /* make sure bit2 is clear (input) */
147:CamInterface.c **** CAM_CONTROL_PORT &= 0x7F; /* set reset line low */
148:CamInterface.c **** CAM_G_BUS_DIR &= 0xF0; /* 4-bit G bus all inputs */
149:CamInterface.c **** CAM_G_BUS_DIR |= 0xF0; /* disable the pull-up on PB4 and PB5 */
150:CamInterface.c **** CAM_RB_BUS_DIR &= 0xF0; /* 4-bit RB bus all inputs */
151:CamInterface.c ****
152:CamInterface.c **** /* ensure that timer1 is disabled to start...eventually, when PCLK needs
153:CamInterface.c **** to feed timer1 through the external counter, it will be enabled on an
154:CamInterface.c **** "as needed" basis...*/
155:CamInterface.c **** TCCR1B &= ~( (1<<CS12)|(1<<CS11)|(1<<CS10) );
156:CamInterface.c ****
157:CamInterface.c **** /* we'll turn on the interrupt after we assign the initial TCNT value */
158:CamInterface.c ****
159:CamInterface.c **** /* set up External Interrupt1 to interrupt us on rising edges (HREF)...
160:CamInterface.c **** this is needed to indicate when the first pixel of each line is about to start, so
161:CamInterface.c **** we can synch up with it...this interrupt will be disabled once HREF goes high */
162:CamInterface.c ****
163:CamInterface.c **** MCUCR |= (1<<ISC11) | (1<<ISC10); /* rising edge interrupt */
164:CamInterface.c **** /* the interrupt will be enabled when we are ready to detect the rising edge of
165:CamInterface.c **** HREF...its now primed and ready to go */
166:CamInterface.c ****
167:CamInterface.c **** /* set up External Interrupt0 to interrupt us on rising edges (VSYNC) */
168:CamInterface.c **** MCUCR |= (1<<ISC01) | (1<<ISC00); /* rising edge interrupt */
169:CamInterface.c **** GICR |= (1<<INT0); /* interrupt request enabled */
170:CamInterface.c ****
171:CamInterface.c **** /* set up TimerO to count and be clocked from an external pulse source
172:CamInterface.c **** (HREF) on falling edges...eventually, we need to enable the interrupt
173:CamInterface.c **** for this! FIX THIS */
174:CamInterface.c **** TCCR0 = (1<<CS02)|(1<<CS01)|(0<<CS00);
175:CamInterface.c ****
176:CamInterface.c **** /* setting up the PCLK counter with Timer1 will be done right after
177:CamInterface.c **** we start receiving pixels in each line...we sacrifice the first pixel
178:CamInterface.c **** in each line, but we'll account for it...*/
179:CamInterface.c ****
180:CamInterface.c **** /* set up the mega8 so that its sleep mode puts it in an IDLE sleep
181:CamInterface.c **** mode, where it can wake up as fast as possible */
182:CamInterface.c **** set_sleep_mode(SLEEP_MODE_IDLE);
183:CamInterface.c **** /* umm....we need to actually enable the sleep mode...*/
184:CamInterface.c **** MCUCR |= 0x80;
185:CamInterface.c ****
186:CamInterface.c **** /* initialize the memLookup table */
187:CamInterface.c **** memset(colorMap,0x00,NUM_ELEMENTS_IN_COLOR_MAP);
188:CamInterface.c ****
189:CamInterface.c **** /* read the color map out of EEPROM */
190:CamInterface.c **** eeprom_read_block(colorMap, (unsigned char*)0x01,NUM_ELEMENTS_IN_COLOR_MAP);
191:CamInterface.c ****
192:CamInterface.c **** #if OUTPUT_INITIAL_COLOR_MAP
193:CamInterface.c **** UIMgr_txBuffer("\r\n",2);
194:CamInterface.c **** for (i=0; i<NUM_ELEMENTS_IN_COLOR_MAP; i++)
195:CamInterface.c **** {
GAS LISTING /tmp/ccAE2QZt.s page 6
 
 
196:CamInterface.c **** memset(asciiBuffer,0x00,5);
197:CamInterface.c **** itoa(colorMap[i],asciiBuffer,10);
198:CamInterface.c **** UIMgr_txBuffer(asciiBuffer,3);
199:CamInterface.c **** UIMgr_txBuffer(" ",1);
200:CamInterface.c **** if (i==15 || i == 31)
201:CamInterface.c **** {
202:CamInterface.c **** /* break up the output */
203:CamInterface.c **** UIMgr_txBuffer("\r\n",2);
204:CamInterface.c **** }
205:CamInterface.c **** }
206:CamInterface.c **** #endif
207:CamInterface.c ****
208:CamInterface.c **** #ifndef NO_CRYSTAL
209:CamInterface.c **** CamInt_resetCam();
210:CamInterface.c **** #endif
211:CamInterface.c **** }
212:CamInterface.c ****
213:CamInterface.c **** /***********************************************************
214:CamInterface.c **** Function Name: CamInt_resetCam
215:CamInterface.c **** Function Description: This function is responsible
216:CamInterface.c **** for resetting the camera. This is accomplished by
217:CamInterface.c **** toggling the reset line on the OV6620 for ~100 mS.
218:CamInterface.c **** Inputs: none
219:CamInterface.c **** Outputs: none
220:CamInterface.c **** IMPORTANT NOTE: This function has effectively been removed
221:CamInterface.c **** since resetting the camera now causes the camera to not
222:CamInterface.c **** output the clock signal. Thus, if we reset the cam, the
223:CamInterface.c **** AVR has no clock, and thus doesn't run...
224:CamInterface.c **** ***********************************************************/
225:CamInterface.c **** void CamInt_resetCam(void)
226:CamInterface.c **** {
91 .stabn 68,0,226,.LM0-CamInt_resetCam
92 .LM0:
93 /* prologue: frame size=0 */
94 /* prologue end (size=0) */
95 /* epilogue: frame size=0 */
96 0000 0895 ret
97 /* epilogue end (size=1) */
98 /* function CamInt_resetCam size 1 (0) */
99 .size CamInt_resetCam, .-CamInt_resetCam
100 .Lscope0:
101 .stabs "",36,0,0,.Lscope0-CamInt_resetCam
102 .stabd 78,0,0
103 .stabs "CamInt_init:F(0,15)",36,0,136,CamInt_init
104 .global CamInt_init
105 .type CamInt_init, @function
106 CamInt_init:
107 .stabd 46,0,0
108 .stabn 68,0,136,.LM1-CamInt_init
109 .LM1:
110 /* prologue: frame size=0 */
111 /* prologue end (size=0) */
112 .stabn 68,0,144,.LM2-CamInt_init
113 .LM2:
114 0002 8F9A sbi 49-0x20,7
115 .stabn 68,0,145,.LM3-CamInt_init
116 .LM3:
GAS LISTING /tmp/ccAE2QZt.s page 7
 
 
117 0004 8F9A sbi 49-0x20,7
118 .stabn 68,0,146,.LM4-CamInt_init
119 .LM4:
120 0006 8A98 cbi 49-0x20,2
121 .stabn 68,0,147,.LM5-CamInt_init
122 .LM5:
123 0008 9798 cbi 50-0x20,7
124 .stabn 68,0,148,.LM6-CamInt_init
125 .LM6:
126 000a 87B3 in r24,55-0x20
127 000c 807F andi r24,lo8(-16)
128 000e 87BB out 55-0x20,r24
129 .stabn 68,0,149,.LM7-CamInt_init
130 .LM7:
131 0010 87B3 in r24,55-0x20
132 0012 806F ori r24,lo8(-16)
133 0014 87BB out 55-0x20,r24
134 .stabn 68,0,150,.LM8-CamInt_init
135 .LM8:
136 0016 84B3 in r24,52-0x20
137 0018 807F andi r24,lo8(-16)
138 001a 84BB out 52-0x20,r24
139 .stabn 68,0,155,.LM9-CamInt_init
140 .LM9:
141 001c 8EB5 in r24,78-0x20
142 001e 887F andi r24,lo8(-8)
143 0020 8EBD out 78-0x20,r24
144 .stabn 68,0,163,.LM10-CamInt_init
145 .LM10:
146 0022 85B7 in r24,85-0x20
147 0024 8C60 ori r24,lo8(12)
148 0026 85BF out 85-0x20,r24
149 .stabn 68,0,168,.LM11-CamInt_init
150 .LM11:
151 0028 85B7 in r24,85-0x20
152 002a 8360 ori r24,lo8(3)
153 002c 85BF out 85-0x20,r24
154 .stabn 68,0,169,.LM12-CamInt_init
155 .LM12:
156 002e 8BB7 in r24,91-0x20
157 0030 8064 ori r24,lo8(64)
158 0032 8BBF out 91-0x20,r24
159 .stabn 68,0,174,.LM13-CamInt_init
160 .LM13:
161 0034 86E0 ldi r24,lo8(6)
162 0036 83BF out 83-0x20,r24
163 .stabn 68,0,182,.LM14-CamInt_init
164 .LM14:
165 0038 85B7 in r24,85-0x20
166 003a 8F78 andi r24,lo8(-113)
167 003c 85BF out 85-0x20,r24
168 .stabn 68,0,184,.LM15-CamInt_init
169 .LM15:
170 003e 85B7 in r24,85-0x20
171 0040 8068 ori r24,lo8(-128)
172 0042 85BF out 85-0x20,r24
173 .stabn 68,0,187,.LM16-CamInt_init
GAS LISTING /tmp/ccAE2QZt.s page 8
 
 
174 .LM16:
175 0044 E0E0 ldi r30,lo8(colorMap)
176 0046 F0E0 ldi r31,hi8(colorMap)
177 0048 80E3 ldi r24,lo8(48)
178 004a DF01 movw r26,r30
179 004c 982F mov r25,r24
180 004e 1D92 st X+,__zero_reg__
181 0050 9A95 dec r25
182 0052 E9F7 brne .-6
183 .LBB6:
184 .LBB7:
185 .LBB8:
186 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h",132,0,0,.Ltext1
187 .Ltext1:
1:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /* Copyright (c) 2002, 2003, 2004 Marek Michalkiewicz
2:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Copyright (c) 2005, 2006 Bjoern Haase
3:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** All rights reserved.
4:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
5:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Redistribution and use in source and binary forms, with or without
6:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** modification, are permitted provided that the following conditions are met:
7:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
8:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** * Redistributions of source code must retain the above copyright
9:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** notice, this list of conditions and the following disclaimer.
10:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
11:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** * Redistributions in binary form must reproduce the above copyright
12:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** notice, this list of conditions and the following disclaimer in
13:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** the documentation and/or other materials provided with the
14:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** distribution.
15:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
16:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** * Neither the name of the copyright holders nor the names of
17:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** contributors may be used to endorse or promote products derived
18:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** from this software without specific prior written permission.
19:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
20:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** POSSIBILITY OF SUCH DAMAGE. */
31:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
32:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /* $Id: eeprom.h,v 1.17.2.1 2006/02/26 21:51:04 aesok Exp $ */
33:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
34:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /*
35:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom.h
36:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
37:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Contributors:
38:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Created by Marek Michalkiewicz <marekm@linux.org.pl>
39:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_write_word and eeprom_write_block added by Artur Lipowski
40:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** <LAL@pro.onet.pl>
41:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Complete rewrite using the original interface by Bjoern Haase
42:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** <bjoern.haase@de.bosch.com>.
43:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** */
GAS LISTING /tmp/ccAE2QZt.s page 9
 
 
44:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
45:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #ifndef _EEPROM_H_
46:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define _EEPROM_H_ 1
47:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
48:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define __need_size_t
49:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #include <stddef.h>
50:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #include <inttypes.h>
51:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
52:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
53:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #ifdef __AVR_MEGA__
54:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define XCALL "call"
55:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #else
56:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define XCALL "rcall"
57:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #endif
58:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
59:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #include <avr/io.h>
60:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #ifndef __EEPROM_REG_LOCATIONS__
61:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \def __EEPROM_REG_LOCATIONS__
62:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \ingroup avr_eeprom
63:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** In order to be able to work without a requiring a multilib
64:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** approach for dealing with controllers having the EEPROM registers
65:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** at different positions in memory space, the eeprom functions evaluate
66:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** __EEPROM_REG_LOCATIONS__: It is assumed to be defined by
67:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** the device io header and contains 6 uppercase hex digits encoding the
68:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** addresses of EECR,EEDR and EEAR.
69:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** First two letters: EECR address.
70:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Second two letters: EEDR address.
71:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Last two letters: EEAR address.
72:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** The default 1C1D1E corresponds to the
73:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** register location that is valid for most controllers. The value
74:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** of this define symbol is used for appending it to the base name of the
75:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** assembler functions. */
76:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define __EEPROM_REG_LOCATIONS__ 1C1D1E
77:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #endif
78:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define _STR2(EXP) _STR1(EXP)
79:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define _STR1(EXP) #EXP
80:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define _REG_LOCATION_SUFFIX _STR2(__EEPROM_REG_LOCATIONS__)
81:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
82:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #ifndef CR_TAB
83:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define CR_TAB "\n\t"
84:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #endif
85:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
86:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
87:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \defgroup avr_eeprom <avr/eeprom.h>: EEPROM handling
88:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \code #include <avr/eeprom.h> \endcode
89:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
90:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** This header file declares the interface to some simple library
91:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** routines suitable for handling the data EEPROM contained in the
92:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** AVR microcontrollers. The implementation uses a simple polled
93:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** mode interface. Applications that require interrupt-controlled
94:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** EEPROM access to ensure that no time will be wasted in spinloops
95:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** will have to deploy their own implementation.
96:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
97:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \note All of the read/write functions first make sure the EEPROM
98:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** is ready to be accessed. Since this may cause long delays if a
99:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** write operation is still pending, time-critical applications
100:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** should first poll the EEPROM e. g. using eeprom_is_ready() before
GAS LISTING /tmp/ccAE2QZt.s page 10
 
 
101:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** attempting any actual I/O.
102:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
103:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \note This header file declares inline functions that call the
104:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** assembler subroutines directly. This prevents that the compiler
105:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** generates push/pops for the call-clobbered registers. This way
106:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** also a specific calling convention could be used for the eeprom
107:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** routines e.g. by passing values in __tmp_reg__, eeprom addresses in
108:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** X and memory addresses in Z registers. Method is optimized for code
109:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** size.
110:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
111:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \note Presently supported are two locations of the EEPROM register
112:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** set: 0x1F,0x20,0x21 and 0x1C,0x1D,0x1E
113:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** (see ::__EEPROM_REG_LOCATIONS__).
114:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
115:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \note As these functions modify IO registers, they are known to be
116:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** non-reentrant. If any of these functions are used from both,
117:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** standard and interrupt context, the applications must ensure
118:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** proper protection (e.g. by disabling interrupts before accessing
119:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** them).
120:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
121:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** */
122:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
123:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
124:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /* forward declarations of the inline functions so that doxygen does
125:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** not get confused by the attribute expression. */
126:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
127:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** static inline uint8_t __attribute__ ((always_inline))
128:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_read_byte (const uint8_t *addr);
129:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
130:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** static inline uint16_t __attribute__ ((always_inline))
131:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_read_word (const uint16_t *addr);
132:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
133:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** static inline void __attribute__ ((always_inline))
134:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_read_block (void *pointer_ram,
135:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** const void *pointer_eeprom,
136:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** size_t size);
137:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
138:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** static inline void __attribute__ ((always_inline))
139:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_write_byte (uint8_t *addr,uint8_t value);
140:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
141:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** static inline void __attribute__ ((always_inline))
142:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_write_word (uint16_t *addr,uint16_t value);
143:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
144:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** static inline void __attribute__ ((always_inline))
145:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_write_block (const void *pointer_ram,
146:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** void *pointer_eeprom,
147:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** size_t size);
148:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
149:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \name avr-libc declarations */
150:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
151:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /*@{*/
152:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
153:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \def EEMEM
154:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \ingroup avr_eeprom
155:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Attribute expression causing a variable to be allocated within the .eeprom
156:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** section. */
157:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define EEMEM __attribute__((section(".eeprom")))
GAS LISTING /tmp/ccAE2QZt.s page 11
 
 
158:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
159:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \def eeprom_is_ready
160:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \ingroup avr_eeprom
161:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \returns 1 if EEPROM is ready for a new read/write operation, 0 if not. */
162:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
163:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #if defined(__DOXYGEN__)
164:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** # define eeprom_is_ready()
165:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #elif defined(EEWE)
166:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** # define eeprom_is_ready() bit_is_clear(EECR, EEWE)
167:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #elif defined(EEPE)
168:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** # define eeprom_is_ready() bit_is_clear(EECR, EEPE)
169:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #elif defined(DEECR) && defined(EEL)
170:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** # define eeprom_is_ready() bit_is_clear(DEECR, EEL)
171:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #else
172:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** # error "No write enable bit known for this device's EEPROM."
173:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #endif
174:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
175:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \def eeprom_busy_wait
176:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \ingroup avr_eeprom
177:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
178:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Loops until the eeprom is no longer busy.
179:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
180:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \returns Nothing. */
181:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
182:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define eeprom_busy_wait() do {} while (!eeprom_is_ready())
183:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
184:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
185:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \ingroup avr_eeprom
186:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Read one byte from EEPROM address \c addr. */
187:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
188:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** uint8_t
189:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_read_byte (const uint8_t *addr)
190:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
191:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** uint8_t result;
192:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** asm volatile
193:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** ( XCALL " __eeprom_read_byte_" _REG_LOCATION_SUFFIX CR_TAB
194:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "mov %1,__tmp_reg__"
195:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "+x" (addr),
196:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "=r" (result)
197:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : );
198:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** return result;
199:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** }
200:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
201:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \ingroup avr_eeprom
202:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Read one 16-bit word (little endian) from EEPROM address \c addr. */
203:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** uint16_t
204:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_read_word (const uint16_t *addr)
205:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
206:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** uint16_t result;
207:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
208:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** asm (
209:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** XCALL " __eeprom_read_word_" _REG_LOCATION_SUFFIX CR_TAB
210:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "+x" (addr),
211:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "=z" (result)
212:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : );
213:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** return result;
214:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** }
GAS LISTING /tmp/ccAE2QZt.s page 12
 
 
215:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
216:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \ingroup avr_eeprom
217:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Read a block of \c n bytes from EEPROM address \c pointer_eeprom to
218:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \c pointer_ram. For constant n <= 256 bytes a library function is used.
219:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** For block sizes unknown at compile time or block sizes > 256 an inline
220:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** loop is expanded. */
221:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
222:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** void
223:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_read_block (void *pointer_ram,
224:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** const void *pointer_eeprom,
225:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** size_t n)
226:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
227:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** if (!__builtin_constant_p (n)
228:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** || n > 256)
229:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
230:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /* make sure size is a 16 bit variable. */
231:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** uint16_t size = n;
232:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
233:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** asm volatile (
234:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** ".%=_start:" CR_TAB
235:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "sbiw %2,1" CR_TAB
236:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "brlt .%=_finished" CR_TAB
237:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** XCALL " __eeprom_read_byte_" _REG_LOCATION_SUFFIX CR_TAB
238:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "st z+,__tmp_reg__" CR_TAB
239:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "rjmp .%=_start" CR_TAB
240:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** ".%=_finished:"
241:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "=x" (pointer_eeprom),
242:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "=z" (pointer_ram),
243:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "+w" (size)
244:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "x" (pointer_eeprom),
245:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "z" (pointer_ram)
246:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "memory");
247:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** }
248:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** else
249:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
250:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** if (n != 0)
251:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
252:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** if (n == 256)
253:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
254:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** asm volatile (
255:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** XCALL " __eeprom_read_block_" _REG_LOCATION_SUFFIX
256:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "+x" (pointer_eeprom),
257:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "=z" (pointer_ram)
258:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "z" (pointer_ram)
259:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "memory");
260:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** }
261:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** else
262:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
263:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /* Needed in order to truncate to 8 bit. */
264:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** uint8_t len;
265:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** len = (uint8_t) n;
266:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
267:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** asm volatile (
188 .stabn 68,0,267,.LM17-CamInt_init
189 .LM17:
190 0054 A1E0 ldi r26,lo8(1)
191 0056 B0E0 ldi r27,hi8(1)
GAS LISTING /tmp/ccAE2QZt.s page 13
 
 
192 /* #APP */
193 0058 182E mov __zero_reg__,r24
194 005a 00D0 rcall __eeprom_read_block_1C1D1E
195 /* #NOAPP */
196 .LBE8:
197 .LBE7:
198 .LBE6:
199 /* epilogue: frame size=0 */
200 005c 0895 ret
201 /* epilogue end (size=1) */
202 /* function CamInt_init size 48 (47) */
203 .size CamInt_init, .-CamInt_init
204 .stabs "pointer_eeprom:r(0,16)=*(0,17)=k(0,15)",64,0,190,26
205 .stabs "pointer_ram:r(0,18)=*(0,15)",64,0,190,30
206 .stabn 192,0,0,.LBB6-CamInt_init
207 .stabn 224,0,0,.LBE6-CamInt_init
208 .Lscope1:
209 .stabs "",36,0,0,.Lscope1-CamInt_init
210 .stabd 78,0,0
211 .comm currentLineBuffer,176,1
212 .comm previousLineBuffer,176,1
213 .global colorMap
214 .section .noinit,"aw",@nobits
215 .type colorMap, @object
216 .size colorMap, 48
217 colorMap:
218 0000 0000 0000 .skip 48,0
218 0000 0000
218 0000 0000
218 0000 0000
218 0000 0000
219 .stabs "currentLineBuffer:G(0,19)=ar(0,20)=r(0,20);0;0177777;;0;175;(0,11)",32,0,115,0
220 .stabs "previousLineBuffer:G(0,19)",32,0,116,0
221 .stabs "colorMap:G(0,21)=ar(0,20);0;47;(0,11)",32,0,101,0
222 .text
223 .stabs "",100,0,0,.Letext0
224 .Letext0:
225 /* File "CamInterface.c": code 49 = 0x0031 ( 47), prologues 0, epilogues 2 */
GAS LISTING /tmp/ccAE2QZt.s page 14
 
 
DEFINED SYMBOLS
*ABS*:00000000 CamInterface.c
/tmp/ccAE2QZt.s:3 *ABS*:0000003f __SREG__
/tmp/ccAE2QZt.s:4 *ABS*:0000003e __SP_H__
/tmp/ccAE2QZt.s:5 *ABS*:0000003d __SP_L__
/tmp/ccAE2QZt.s:6 *ABS*:00000000 __tmp_reg__
/tmp/ccAE2QZt.s:7 *ABS*:00000001 __zero_reg__
/tmp/ccAE2QZt.s:89 .text:00000000 CamInt_resetCam
/tmp/ccAE2QZt.s:106 .text:00000002 CamInt_init
/tmp/ccAE2QZt.s:217 .noinit:00000000 colorMap
*COM*:000000b0 currentLineBuffer
*COM*:000000b0 previousLineBuffer
 
UNDEFINED SYMBOLS
__do_copy_data
__do_clear_bss
__eeprom_read_block_1C1D1E
/programy/Atmel_C/AVRcam/CamInterfaceAsm.S
0,0 → 1,490
;
; Copyright (C) 2004 John Orlando
;
; AVRcam: a small real-time image processing engine.
 
; This program is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public
; License as published by the Free Software Foundation; either
; version 2 of the License, or (at your option) any later version.
 
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
; General Public License for more details.
 
; You should have received a copy of the GNU General Public
; License along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
; For more information on the AVRcam, please contact:
 
; john@jrobot.net
 
; or go to www.jrobot.net for more details regarding the system.
;**********************************************************************
; Module Name: CanInterfaceAsm.S
; Module Date: 04/14/2004
; Module Auth: John Orlando
;
; Description: This module provides the low-level interface
; to the OV6620 camera hardware. It is responsible for
; acquiring each pixel block (R,G,B), performing the mapping
; into an actual color (orange, purple, etc), run-length
; encoding the data, and storing the info off to the appropriate
; line buffer. This routine is synchronized with the pixel data
; so that no polling of the camera data needs to be done (the
; OV6620 is clocked off of the same crystal source as the mega8,
; thus providing inherent synchronization between the two).
;
; Revision History:
; Date Rel Ver. Notes
; 4/10/2004 0.1 Module created
; 6/30/2004 1.0 Initial release for Circuit Cellar
; contest.
; 1/16/2005 1.4 Fixed issue with the TCCR1B register
; where PCLK was getting routed to the
; timer1 even when it wasn't needed.
; This caused excessive counter overflow
; interrupts, and caused problems. Now,
; the "PCLK" pipe feeds timer1 when needed,
; and is turned off when it isn't needed.
 
#include <avr/io.h>
#include "Events.h"
.extern fastEventBitmask ; This is the flag used to indicate to the rest
; of the system that the line is complete
#define HREF_INTERRUPT_ENABLE_MASK 0x80
#define HREF_INTERRUPT_DISABLE_MASK 0x7F
#define ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK 0x04
#define DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK 0xFB
#define G_PORT _SFR_IO_ADDR(PINC)
#define RB_PORT _SFR_IO_ADDR(PINB)
#define PIXEL_RUN_START_INITIAL 0x50 ; This value causes our pixel counter (TCNT1)
; to overflow after 176 (horizontal) pixels
 
#define RED_MEM_OFFSET 0x00
#define GREEN_MEM_OFFSET 0x10
#define BLUE_MEM_OFFSET 0x20
 
; A pixelBlock is defined as a contiguous group of 4 pixels that are combined
; together to form a specific color. Typically, this is formed by sampling a
; a green value, followed by a red and blue value (since we are dealing
; with Bayer color data). We could optionally sample a second green with
; the red and average the greens, because the eye is more sensitive to
; green, but for speed we don't do this. These three values (RGB) are then
; used as indices into the color membership lookup table (memLookup) to
; determine which color the pixelBlock maps into. The memLookup table is
; manually generated for now (though it will hopefully be modified over
; the serial interface eventually).
;
; Here is a pixel block:
; ...G G G G... (row x)
; ...B R B R... (row x+1)
; | | | |--this is skipped
; | | |--this is skipped
; | |--this is sampled
; |--this is sampled
 
; As pixel blocks are sampled, the red, green, and blue values are
; used to index into their respective color maps. The color maps
; return values that can be logically ANDed together so that a
; particular RGB triplet will result in a single bit being set
; after the AND operation. This single bit indicates which color
; the RGB triplet represents. It is also possible for no bits to
; be set after the AND process, indicating that the RGB triplet
; does not map to any of the colors configured in the color map.
; This isn't quite as fast as a pure RGB lookup table, but
; it then again it doesn't require 2^12 (4-bits for each color
; channel) bytes to store the lookup table. It takes just a few
; more cycles, and only requires 48 bytes of precious RAM (16
; per color channel, since our resolution on each color channel
; is only 4-bits). Not bad....for more information, see:
; http://www.cs.cmu.edu/~trb/papers/wirevision00.pdf for more
; information on this color segmentation technique.
 
; One other note: this code does depend on the colorMap residing
; at a well-defined position in memory; specifically, it mus
; start at a 256-byte boundary so that the lowest byte in the
; map is set to 0x00. Currently, the colorMap is forced to
; start at RAM location 0x300. This could potentially be changed
; by the developer if needed, but offsets would have to be added
; in to the colorMap look-up code below to make it work.
 
 
; These are the registers that will be used throughout this
; module for acquiring each line of pixel data
pixelCount = 16
pixelRunStart = 17
lastColor = 18
tmp1 = 19 ; be sure to not use tmp1 and color simultaneously
tmp2 = 20
color = 19
greenData = 20
blueData = 21
colorMapLow = 22
colorMapHigh = 23
prevLineBuffLow = 22 ; overlaps with memLookupLow (but orthogonal)
prevLineBuffHigh = 23 ; overlaps with memLookupHigh (but orthogonal)
currLineBuffLow = 24
currLineBuffHigh = 25
 
.section .text
 
; These are the global assembly function names that are accessed via other
; C functions
.global CamIntAsm_waitForNewTrackingFrame
.global CamIntAsm_waitForNewDumpFrame
.global CamIntAsm_acquireDumpLine
.global CamIntAsm_acquireTrackingLine
.global SIG_INTERRUPT0
.global SIG_INTERRUPT1
.global SIG_OVERFLOW0
.global SIG_OVERFLOW1
;*****************************************************************
; Function Name: CamIntAsm_waitForNewTrackingFrame
; Function Description: This function is responsible for
; going to sleep until a new frame begins (indicated by
; VSYNC transitioning from low to high. This will wake
; the "VSYNC sleep" up and allow it to continue with
; the acquireLine function, where the system waits for
; an "HREF sleep" that we use to synchronize with the
; data.
; Inputs: r25 - MSB of currentLineBuffer
; r24 - LSB of currentLineBuffer
; r23 - MSB of colorMap
; r22 - LSB of colorMap
; Outputs: none
; NOTES: This function doesn't really return...it sorta just
; floats into the acquireLine function after the "VSYNC sleep"
; is awoken, then begins processing the line data. Once
; 176 pixels are sampled (and the counter overflows), then
; an interrupt will occur, the 'T' bit in the SREG will be
; set, and the function will return.
;*****************************************************************
CamIntAsm_waitForNewTrackingFrame:
sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
cbi _SFR_IO_ADDR(PORTD),PD6
sleep
 
;*****************************************************************
; REMEMBER...everything from here on out is critically timed to be
; synchronized with the flow of pixel data from the camera...
;*****************************************************************
 
CamIntAsm_acquireTrackingLine:
brts _cleanUp
;sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
;cbi _SFR_IO_ADDR(PORTD),PD6
in tmp1,_SFR_IO_ADDR(TCCR1B) ; Enable the PCLK line to actually
ori tmp1, 0x07 ; feed Timer1
out _SFR_IO_ADDR(TCCR1B),tmp1
; The line is about to start...
ldi pixelCount,0 ; Initialize the RLE stats...
ldi pixelRunStart,PIXEL_RUN_START_INITIAL ; Remember, we always calculate
; the pixel run length as
; TCNT1L - pixelRunStart
ldi lastColor,0x00 ; clear out the last color before we start
mov XH,currLineBuffHigh ; Load the pointer to the current line
mov XL,currLineBuffLow ; buffer into the X pointer regs
mov ZH,colorMapHigh ; Load the pointers to the membership
mov ZL,colorMapLow ; lookup tables (ZL and YL will be overwritten
mov YH,colorMapHigh ; as soon as we start reading data) to Z and Y
in tmp1, _SFR_IO_ADDR(TIMSK) ; enable TIMER1 to start counting
ori tmp1, ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK ; external PCLK pulses and interrupt on
out _SFR_IO_ADDR(TIMSK),tmp1 ; overflow
ldi tmp1,PIXEL_RUN_START_INITIAL ; set up the TCNT1 to overflow (and
ldi tmp2,0xFF ; interrupts) after 176 pixels
out _SFR_IO_ADDR(TCNT1H),tmp2
out _SFR_IO_ADDR(TCNT1L),tmp1
mov YL,colorMapLow
in tmp1, _SFR_IO_ADDR(GICR) ; enable the HREF interrupt...remember, we
; only use this interrupt to synchronize
; the beginning of the line
ori tmp1, HREF_INTERRUPT_ENABLE_MASK
out _SFR_IO_ADDR(GICR), tmp1
;*******************************************************************************************
; Track Frame handler
;*******************************************************************************************
_trackFrame:
sbi _SFR_IO_ADDR(PORTD),PD6
sleep ; ...And we wait...
; Returning from the interrupt/sleep wakeup will consume
; 14 clock cycles (7 to wakeup from idle sleep, 3 to vector, and 4 to return)
 
; Disable the HREF interrupt
cbi _SFR_IO_ADDR(PORTD),PD6
in tmp1, _SFR_IO_ADDR(GICR)
andi tmp1, HREF_INTERRUPT_DISABLE_MASK
out _SFR_IO_ADDR(GICR), tmp1
; A couple of NOPs are needed here to sync up the pixel data...the number (2)
; of NOPs was determined emperically by trial and error.
nop
nop
_acquirePixelBlock: ; Clock Cycle Count
in ZL,RB_PORT ; sample the red value (PINB) (1)
in YL,G_PORT ; sample the green value (PINC) (1)
andi YL,0x0F ; clear the high nibble (1)
ldd color,Z+RED_MEM_OFFSET ; lookup the red membership (2)
in ZL,RB_PORT ; sample the blue value (PINB) (1)
ldd greenData,Y+GREEN_MEM_OFFSET; lookup the green membership (2)
ldd blueData,Z+BLUE_MEM_OFFSET ; lookup the blue membership (2)
and color,greenData ; mask memberships together (1)
and color,blueData ; to produce the final color (1)
brts _cleanUpTrackingLine ; if some interrupt routine has (1...not set)
; come in and set our T flag in
; SREG, then we need to hop out
; and blow away this frames data (common cleanup)
cp color,lastColor ; check to see if the run continues (1)
breq _acquirePixelBlock ; (2...equal)
; ___________
; 16 clock cycles
; (16 clock cycles = 1 uS = 1 pixelBlock time)
; Toggle the debug line to indicate a color change
sbi _SFR_IO_ADDR(PORTD),PD6
nop
cbi _SFR_IO_ADDR(PORTD),PD6
mov tmp2,pixelRunStart ; get the count value of the
; current pixel run
in pixelCount,_SFR_IO_ADDR(TCNT1L) ; get the current TCNT1 value
mov pixelRunStart,pixelCount ; reload pixelRunStart for the
; next run
sub pixelCount,tmp2 ; pixelCount = TCNT1L - pixelRunStart
st X+,lastColor ; record the color run in the current line buffer
st X+,pixelCount ; with its length
mov lastColor,color ; set lastColor so we can figure out when it changes
nop ; waste one more cycle for a total of 16
rjmp _acquirePixelBlock
; _cleanUpTrackingLine is used to write the last run length block off to the currentLineBuffer so
; that all 176 pixels in the line are accounted for.
_cleanUpTrackingLine:
ldi pixelCount,0xFF ; the length of the last run is ALWAYS 0xFF minus the last
sub pixelCount,pixelRunStart ; pixelRunStart
inc pixelCount ; increment pixelCount since we actually need to account
; for the overflow of TCNT1
st X+,color ; record the color run in the current line buffer
st X,pixelCount
rjmp _cleanUp
_cleanUpDumpLine:
; NOTE: If serial data is received, to interrupt the tracking of a line, we'll
; get a EV_SERIAL_DATA_RECEIVED event, and the T bit set so we will end the
; line's processing...however, the PCLK will keep on ticking for the rest of
; the frame/line, which will cause the TCNT to eventually overflow and
; interrupt us, generating a EV_ACQUIRE_LINE_COMPLETE event. We don't want
; this, so we need to actually turn off the PCLK counting each time we exit
; this loop, and only turn it on when we begin acquiring lines....
; NOT NEEDED FOR NOW...
;in tmp1, _SFR_IO_ADDR(TIMSK) ; disable TIMER1 to stop counting
;andi tmp1, DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK ; external PCLK pulses
;out _SFR_IO_ADDR(TIMSK),tmp1
 
_cleanUp:
; Disable the external clocking of the Timer1 counter
in tmp1, _SFR_IO_ADDR(TCCR1B)
andi tmp1, 0xF8
out _SFR_IO_ADDR(TCCR1B),tmp1
; Toggle the debug line to indicate the line is complete
sbi _SFR_IO_ADDR(PORTD),PD6
cbi _SFR_IO_ADDR(PORTD),PD6
clt ; clear out the T bit since we have detected
; the interruption and are exiting to handle it
_exit:
ret
;*****************************************************************
; Function Name: CamIntAsm_waitForNewDumpFrame
; Function Description: This function is responsible for
; going to sleep until a new frame begins (indicated by
; VSYNC transitioning from low to high. This will wake
; the "VSYNC sleep" up and allow it to continue with
; acquiring a line of pixel data to dump out to the UI.
; Inputs: r25 - MSB of currentLineBuffer
; r24 - LSB of currentLineBuffer
; r23 - MSB of prevLineBuffer
; r22 - LSB of prevLineBuffer
; Outputs: none
; NOTES: This function doesn't really return...it sorta just
; floats into the acquireDumpLine function after the "VSYNC sleep"
; is awoken.
;*****************************************************************
CamIntAsm_waitForNewDumpFrame:
sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
cbi _SFR_IO_ADDR(PORTD),PD6
sleep
 
;*****************************************************************
; REMEMBER...everything from here on out is critically timed to be
; synchronized with the flow of pixel data from the camera...
;*****************************************************************
 
CamIntAsm_acquireDumpLine:
brts _cleanUp
;sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
;cbi _SFR_IO_ADDR(PORTD),PD6
mov XH,currLineBuffHigh ; Load the pointer to the current line
mov XL,currLineBuffLow ; buffer into the X pointer regs
 
mov YH,prevLineBuffHigh ; Load the pointer to the previous line
mov YL,prevLineBuffLow ; buffer into the Y pointer regs
ldi tmp1,PIXEL_RUN_START_INITIAL ; set up the TCNT1 to overflow (and
ldi tmp2,0xFF ; interrupts) after 176 pixels
out _SFR_IO_ADDR(TCNT1H),tmp2
out _SFR_IO_ADDR(TCNT1L),tmp1
in tmp1, _SFR_IO_ADDR(TCCR1B) ; Enable the PCLK line to actually
ori tmp1, 0x07 ; feed Timer1
out _SFR_IO_ADDR(TCCR1B),tmp1
nop
in tmp1, _SFR_IO_ADDR(TIMSK) ; enable TIMER1 to start counting
ori tmp1, ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK ; external PCLK pulses and interrupt on
out _SFR_IO_ADDR(TIMSK),tmp1 ; overflow
in tmp1, _SFR_IO_ADDR(GICR) ; enable the HREF interrupt...remember, we
; only use this interrupt to synchronize
; the beginning of the line
ori tmp1, HREF_INTERRUPT_ENABLE_MASK
out _SFR_IO_ADDR(GICR), tmp1
;*******************************************************************************************
; Dump Frame handler
;*******************************************************************************************
_dumpFrame:
sbi _SFR_IO_ADDR(PORTD),PD6
sleep ; ...And we wait...
 
cbi _SFR_IO_ADDR(PORTD),PD6
in tmp1, _SFR_IO_ADDR(GICR) ; disable the HREF interrupt
andi tmp1, HREF_INTERRUPT_DISABLE_MASK ; so we don't get interrupted
out _SFR_IO_ADDR(GICR), tmp1 ; while dumping the line
nop ; Remember...if we ever remove the "cbi" instruction above,
; we need to add two more NOPs to cover this
; Ok...the following loop needs to run in 8 clock cycles, so we can get every
; pixel in the line...this shouldn't be a problem, since the PCLK timing was
; reduced by a factor of 2 whenever we go to dump a line (this is to give us
; enough time to do the sampling and storing of the pixel data). In addition,
; it is assumed that we will have to do some minor processing on the data right
; before we send it out, like mask off the top 4-bits of each, and then pack both
; low nibbles into a single byte for transmission...we just don't have time to
; do that here (only 8 instruction cycles :-) )
_sampleDumpPixel:
in tmp1,G_PORT ; sample the G value (1)
in tmp2,RB_PORT ; sample the R/B value (1)
st X+,tmp1 ; store to the currLineBuff and inc ptrs(2)
st Y+,tmp2 ; store to the prevLineBuff and inc ptrs(2)
brtc _sampleDumpPixel ; loop back unless flag is set (2...if not set)
; ___________
; 8 cycles normally
; if we make it here, it means the T flag is set, and we must have been interrupted
; so we need to exit (what if we were interrupted for serial? should we disable it?)
rjmp _cleanUpDumpLine
 
;***********************************************************
; Function Name: <interrupt handler for External Interrupt0>
; Function Description: This function is responsible
; for handling a rising edge on the Ext Interrupt 0. This
; routine simply returns, since we just want to wake up
; whenever the VSYNC transitions (meaning the start of a new
; frame).
; Inputs: none
; Outputs: none
;***********************************************************
SIG_INTERRUPT0:
; This will wake us up when VSYNC transitions high...we just want to return
reti
;***********************************************************
; Function Name: <interrupt handler for External Interrupt1>
; Function Description: This function is responsible
; for handling a falling edge on the Ext Interrupt 1. This
; routine simply returns, since we just want to wake up
; whenever the HREF transitions (meaning the pixels
; are starting after VSYNC transitioned, and we need to
; start acquiring the pixel blocks
; Inputs: none
; Outputs: none
;***********************************************************
SIG_INTERRUPT1:
; This will wake us up when HREF transitions high...we just want to return
reti
;***********************************************************
; Function Name: <interrupt handler for Timer0 overflow>
; Function Description: This function is responsible
; for handling the Timer0 overflow (hooked up to indicate
; when we have reached the number of HREFs required in a
; single frame). We set the T flag in the SREG to
; indicate to the _acquirePixelBlock routine that it needs
; to exit, and then set the appropriate action to take in
; the eventList of the Executive module.
; Inputs: none
; Outputs: none
; Note: Originally, the HREF pulses were also going to
; be counted by a hardware counter, but it didn't end up
; being necessary
;***********************************************************
;SIG_OVERFLOW0:
; set ; set the T bit in SREG
; lds tmp1,eventBitmask
; ori tmp1,EV_ACQUIRE_FRAME_COMPLETE
; sts eventBitmask,tmp1
; reti
;***********************************************************
; Function Name: <interrupt handler for Timer1 overflow>
; Function Description: This function is responsible
; for handling the Timer1 overflow (hooked up to indicate
; when we have reached the end of a line of pixel data,
; since PCLK is hooked up to overflow TCNT1 after 176
; pixels). This routine generates an acquire line complete
; event in the fastEventBitmask, which is streamlined for
; efficiency reasons.
;***********************************************************
SIG_OVERFLOW1:
lds tmp1,fastEventBitmask ; set a flag indicating
ori tmp1,FEV_ACQUIRE_LINE_COMPLETE ; a line is complete
sts fastEventBitmask,tmp1
set ; set the T bit in SREG
;sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
;cbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
 
reti
 
; This is the default handler for all interrupts that don't
; have handler routines specified for them.
.global __vector_default
__vector_default:
reti
 
.end
/programy/Atmel_C/AVRcam/CamInterfaceAsm.lst
0,0 → 1,1103
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 1
 
 
1 # 1 "CamInterfaceAsm.S"
2 # 1 "<built-in>"
1 ;
0
0
2 ; Copyright (C) 2004 John Orlando
3 ;
4 ; AVRcam: a small real-time image processing engine.
5
6 ; This program is free software; you can redistribute it and/or
7 ; modify it under the terms of the GNU General Public
8 ; License as published by the Free Software Foundation; either
9 ; version 2 of the License, or (at your option) any later version.
10
11 ; This program is distributed in the hope that it will be useful,
12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ; General Public License for more details.
15
16 ; You should have received a copy of the GNU General Public
17 ; License along with this program; if not, write to the Free Software
18 ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 ; For more information on the AVRcam, please contact:
21
22 ; john@jrobot.net
23
24 ; or go to www.jrobot.net for more details regarding the system.
25 ;**********************************************************************
26 ; Module Name: CanInterfaceAsm.S
27 ; Module Date: 04/14/2004
28 ; Module Auth: John Orlando
29 ;
30 ; Description: This module provides the low-level interface
31 ; to the OV6620 camera hardware. It is responsible for
32 ; acquiring each pixel block (R,G,B), performing the mapping
33 ; into an actual color (orange, purple, etc), run-length
34 ; encoding the data, and storing the info off to the appropriate
35 ; line buffer. This routine is synchronized with the pixel data
36 ; so that no polling of the camera data needs to be done (the
37 ; OV6620 is clocked off of the same crystal source as the mega8,
38 ; thus providing inherent synchronization between the two).
39 ;
40 ; Revision History:
41 ; Date Rel Ver. Notes
42 ; 4/10/2004 0.1 Module created
43 ; 6/30/2004 1.0 Initial release for Circuit Cellar
44 ; contest.
45 ; 1/16/2005 1.4 Fixed issue with the TCCR1B register
46 ; where PCLK was getting routed to the
47 ; timer1 even when it wasn't needed.
48 ; This caused excessive counter overflow
49 ; interrupts, and caused problems. Now,
50 ; the "PCLK" pipe feeds timer1 when needed,
51 ; and is turned off when it isn't needed.
52
53 #include <avr/io.h>
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 2
 
 
1 /* Copyright (c) 2002,2003 Marek Michalkiewicz, Joerg Wunsch
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in
11 the documentation and/or other materials provided with the
12 distribution.
13
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 POSSIBILITY OF SUCH DAMAGE. */
25
26 /* $Id: io.h,v 1.10 2003/02/28 23:03:40 marekm Exp $ */
27
28 /** \defgroup avr_io AVR device-specific IO definitions
29 \code #include <avr/io.h> \endcode
30
31 This header file includes the apropriate IO definitions for the
32 device that has been specified by the <tt>-mmcu=</tt> compiler
33 command-line switch. This is done by diverting to the appropriate
34 file <tt>&lt;avr/io</tt><em>XXXX</em><tt>.h&gt;</tt> which should
35 never be included directly. Some register names common to all
36 AVR devices are defined directly within <tt>&lt;avr/io.h&gt;</tt>,
37 but most of the details come from the respective include file.
38
39 Note that this file always includes
40 \code #include <avr/sfr_defs.h> \endcode
41 See \ref avr_sfr for the details.
42
43 Included are definitions of the IO register set and their
44 respective bit values as specified in the Atmel documentation.
45 Note that Atmel is not very consistent in its naming conventions,
46 so even identical functions sometimes get different names on
47 different devices.
48
49 Also included are the specific names useable for interrupt
50 function definitions as documented
51 \ref avr_signames "here".
52
53 Finally, the following macros are defined:
54
55 - \b RAMEND
56 <br>
57 A constant describing the last on-chip RAM location.
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 3
 
 
58 <br>
59 - \b XRAMEND
60 <br>
61 A constant describing the last possible location in RAM.
62 This is equal to RAMEND for devices that do not allow for
63 external RAM.
64 <br>
65 - \b E2END
66 <br>
67 A constant describing the address of the last EEPROM cell.
68 <br>
69 - \b FLASHEND
70 <br>
71 A constant describing the last byte address in flash ROM.
72 <br>
73 - \b SPM_PAGESIZE
74 <br>
75 For devices with bootloader support, the flash pagesize
76 (in bytes) to be used for the \c SPM instruction. */
77
78 #ifndef _AVR_IO_H_
79 #define _AVR_IO_H_
80
81 #include <avr/sfr_defs.h>
1 /* Copyright (c) 2002, Marek Michalkiewicz <marekm@amelek.gda.pl>
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in
11 the documentation and/or other materials provided with the
12 distribution.
13
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 POSSIBILITY OF SUCH DAMAGE. */
25
26 /* avr/sfr_defs.h - macros for accessing AVR special function registers */
27
28 /* $Id: sfr_defs.h,v 1.10 2003/08/11 21:42:13 troth Exp $ */
29
30 #ifndef _AVR_SFR_DEFS_H_
31 #define _AVR_SFR_DEFS_H_ 1
32
33 /** \defgroup avr_sfr_notes Additional notes from <avr/sfr_defs.h>
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 4
 
 
34 \ingroup avr_sfr
35
36 The \c <avr/sfr_defs.h> file is included by all of the \c <avr/ioXXXX.h>
37 files, which use macros defined here to make the special function register
38 definitions look like C variables or simple constants, depending on the
39 <tt>_SFR_ASM_COMPAT</tt> define. Some examples from \c <avr/iom128.h> to
40 show how to define such macros:
41
42 \code
43 #define PORTA _SFR_IO8(0x1b)
44 #define TCNT1 _SFR_IO16(0x2c)
45 #define PORTF _SFR_MEM8(0x61)
46 #define TCNT3 _SFR_MEM16(0x88)
47 \endcode
48
49 If \c _SFR_ASM_COMPAT is not defined, C programs can use names like
50 <tt>PORTA</tt> directly in C expressions (also on the left side of
51 assignment operators) and GCC will do the right thing (use short I/O
52 instructions if possible). The \c __SFR_OFFSET definition is not used in
53 any way in this case.
54
55 Define \c _SFR_ASM_COMPAT as 1 to make these names work as simple constants
56 (addresses of the I/O registers). This is necessary when included in
57 preprocessed assembler (*.S) source files, so it is done automatically if
58 \c __ASSEMBLER__ is defined. By default, all addresses are defined as if
59 they were memory addresses (used in \c lds/sts instructions). To use these
60 addresses in \c in/out instructions, you must subtract 0x20 from them.
61
62 For more backwards compatibility, insert the following at the start of your
63 old assembler source file:
64
65 \code
66 #define __SFR_OFFSET 0
67 \endcode
68
69 This automatically subtracts 0x20 from I/O space addresses, but it's a
70 hack, so it is recommended to change your source: wrap such addresses in
71 macros defined here, as shown below. After this is done, the
72 <tt>__SFR_OFFSET</tt> definition is no longer necessary and can be removed.
73
74 Real example - this code could be used in a boot loader that is portable
75 between devices with \c SPMCR at different addresses.
76
77 \verbatim
78 <avr/iom163.h>: #define SPMCR _SFR_IO8(0x37)
79 <avr/iom128.h>: #define SPMCR _SFR_MEM8(0x68)
80 \endverbatim
81
82 \code
82
83 /*
84 * Registers common to all AVR devices.
85 */
86
87 #if __AVR_ARCH__ != 1
88 /*
89 * AVR architecture 1 has no RAM, thus no stack pointer.
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 5
 
 
90 *
91 * All other archs do have a stack pointer. Some devices have only
92 * less than 256 bytes of possible RAM locations (128 Bytes of SRAM
93 * and no option for external RAM), thus SPH is officially "reserved"
94 * for them. We catch this case below after including the
95 * device-specific ioXXXX.h file, by examining XRAMEND, and
96 * #undef-ining SP and SPH in that case.
97 */
98 /* Stack Pointer */
99 #define SP _SFR_IO16(0x3D)
100 #define SPL _SFR_IO8(0x3D)
101 #define SPH _SFR_IO8(0x3E)
102 #endif /* #if __AVR_ARCH__ != 1 */
103
104 /* Status REGister */
105 #define SREG _SFR_IO8(0x3F)
106
107 /* Status Register - SREG */
108 #define SREG_I 7
109 #define SREG_T 6
110 #define SREG_H 5
111 #define SREG_S 4
112 #define SREG_V 3
113 #define SREG_N 2
114 #define SREG_Z 1
115 #define SREG_C 0
116
117 /* Pointer definition */
118 #if __AVR_ARCH__ != 1
119 /* avr1 has only the Z pointer */
120 #define XL r26
121 #define XH r27
122 #define YL r28
123 #define YH r29
124 #endif /* #if __AVR_ARCH__ != 1 */
125 #define ZL r30
126 #define ZH r31
127
128 /*
129 * Only few devices come without EEPROM. In order to assemble the
130 * EEPROM library components without defining a specific device, we
131 * keep the EEPROM-related definitions here, and catch the devices
132 * without EEPROM (E2END == 0) below. Obviously, the EEPROM library
133 * functions will not work for them. ;-)
134 */
135 /* EEPROM Control Register */
136 #define EECR _SFR_IO8(0x1C)
137
138 /* EEPROM Data Register */
139 #define EEDR _SFR_IO8(0x1D)
140
141 /* EEPROM Address Register */
142 #define EEAR _SFR_IO16(0x1E)
143 #define EEARL _SFR_IO8(0x1E)
144 #define EEARH _SFR_IO8(0x1F)
145
146 /* EEPROM Control Register */
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 6
 
 
147 #define EERIE 3
148 #define EEMWE 2
149 #define EEWE 1
150 #define EERE 0
151
152 #if defined (__AVR_AT94K__)
153 # include <avr/ioat94k.h>
154 #elif defined (__AVR_AT43USB320__)
155 # include <avr/io43u32x.h>
156 #elif defined (__AVR_AT43USB355__)
157 # include <avr/io43u35x.h>
158 #elif defined (__AVR_AT76C711__)
159 # include <avr/io76c711.h>
160 #elif defined (__AVR_AT86RF401__)
161 # include <avr/io86r401.h>
162 #elif defined (__AVR_ATmega128__)
163 # include <avr/iom128.h>
164 #elif defined (__AVR_ATmega64__)
165 # include <avr/iom64.h>
166 #elif defined (__AVR_ATmega103__)
167 # include <avr/iom103.h>
168 #elif defined (__AVR_ATmega32__)
169 # include <avr/iom32.h>
170 #elif defined (__AVR_ATmega323__)
171 # include <avr/iom323.h>
172 #elif defined (__AVR_ATmega16__)
173 # include <avr/iom16.h>
174 #elif defined (__AVR_ATmega161__)
175 # include <avr/iom161.h>
176 #elif defined (__AVR_ATmega162__)
177 # include <avr/iom162.h>
178 #elif defined (__AVR_ATmega163__)
179 # include <avr/iom163.h>
180 #elif defined (__AVR_ATmega169__)
181 # include <avr/iom169.h>
182 #elif defined (__AVR_ATmega8__)
183 # include <avr/iom8.h>
1 /* Copyright (c) 2002, Marek Michalkiewicz
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in
11 the documentation and/or other materials provided with the
12 distribution.
13
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 7
 
 
21 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 POSSIBILITY OF SUCH DAMAGE. */
25
26 /* $Id: iom8.h,v 1.8 2003/02/17 09:57:28 marekm Exp $ */
27
28 /* avr/iom8.h - definitions for ATmega8 */
29
30 #ifndef _AVR_IOM8_H_
31 #define _AVR_IOM8_H_ 1
32
33 /* This file should only be included from <avr/io.h>, never directly. */
34
35 #ifndef _AVR_IO_H_
36 # error "Include <avr/io.h> instead of this file."
37 #endif
38
39 #ifndef _AVR_IOXXX_H_
40 # define _AVR_IOXXX_H_ "iom8.h"
41 #else
42 # error "Attempt to include more than one <avr/ioXXX.h> file."
43 #endif
44
45 /* I/O registers */
46
47 /* TWI stands for "Two Wire Interface" or "TWI Was I2C(tm)" */
48 #define TWBR _SFR_IO8(0x00)
49 #define TWSR _SFR_IO8(0x01)
50 #define TWAR _SFR_IO8(0x02)
51 #define TWDR _SFR_IO8(0x03)
52
53 /* ADC */
54 #define ADCW _SFR_IO16(0x04)
55 #ifndef __ASSEMBLER__
56 #define ADC _SFR_IO16(0x04)
57 #endif
58 #define ADCL _SFR_IO8(0x04)
59 #define ADCH _SFR_IO8(0x05)
60 #define ADCSR _SFR_IO8(0x06)
61 #define ADCSRA _SFR_IO8(0x06) /* Changed in 2486H-AVR-09/02 */
62 #define ADMUX _SFR_IO8(0x07)
63
64 /* analog comparator */
65 #define ACSR _SFR_IO8(0x08)
66
67 /* USART */
68 #define UBRRL _SFR_IO8(0x09)
69 #define UCSRB _SFR_IO8(0x0A)
70 #define UCSRA _SFR_IO8(0x0B)
71 #define UDR _SFR_IO8(0x0C)
72
73 /* SPI */
74 #define SPCR _SFR_IO8(0x0D)
75 #define SPSR _SFR_IO8(0x0E)
76 #define SPDR _SFR_IO8(0x0F)
77
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 8
 
 
78 /* Port D */
79 #define PIND _SFR_IO8(0x10)
80 #define DDRD _SFR_IO8(0x11)
81 #define PORTD _SFR_IO8(0x12)
82
83 /* Port C */
84 #define PINC _SFR_IO8(0x13)
85 #define DDRC _SFR_IO8(0x14)
86 #define PORTC _SFR_IO8(0x15)
87
88 /* Port B */
89 #define PINB _SFR_IO8(0x16)
90 #define DDRB _SFR_IO8(0x17)
91 #define PORTB _SFR_IO8(0x18)
92
93 /* 0x1C..0x1F EEPROM */
94
95 #define UCSRC _SFR_IO8(0x20)
96 #define UBRRH _SFR_IO8(0x20)
97
98 #define WDTCR _SFR_IO8(0x21)
99 #define ASSR _SFR_IO8(0x22)
100
101 /* Timer 2 */
102 #define OCR2 _SFR_IO8(0x23)
103 #define TCNT2 _SFR_IO8(0x24)
104 #define TCCR2 _SFR_IO8(0x25)
105
106 /* Timer 1 */
107 #define ICR1 _SFR_IO16(0x26)
108 #define ICR1L _SFR_IO8(0x26)
109 #define ICR1H _SFR_IO8(0x27)
110 #define OCR1B _SFR_IO16(0x28)
111 #define OCR1BL _SFR_IO8(0x28)
112 #define OCR1BH _SFR_IO8(0x29)
113 #define OCR1A _SFR_IO16(0x2A)
114 #define OCR1AL _SFR_IO8(0x2A)
115 #define OCR1AH _SFR_IO8(0x2B)
116 #define TCNT1 _SFR_IO16(0x2C)
117 #define TCNT1L _SFR_IO8(0x2C)
118 #define TCNT1H _SFR_IO8(0x2D)
119 #define TCCR1B _SFR_IO8(0x2E)
120 #define TCCR1A _SFR_IO8(0x2F)
121
122 #define SFIOR _SFR_IO8(0x30)
123
124 #define OSCCAL _SFR_IO8(0x31)
125
126 /* Timer 0 */
127 #define TCNT0 _SFR_IO8(0x32)
128 #define TCCR0 _SFR_IO8(0x33)
129
130 #define MCUCSR _SFR_IO8(0x34)
131 #define MCUCR _SFR_IO8(0x35)
132
133 #define TWCR _SFR_IO8(0x36)
134
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 9
 
 
135 #define SPMCR _SFR_IO8(0x37)
136
137 #define TIFR _SFR_IO8(0x38)
138 #define TIMSK _SFR_IO8(0x39)
139
140 #define GIFR _SFR_IO8(0x3A)
141 #define GIMSK _SFR_IO8(0x3B)
142 #define GICR _SFR_IO8(0x3B) /* Changed in 2486H-AVR-09/02 */
143
144 /* 0x3C reserved (OCR0?) */
145
146 /* 0x3D..0x3E SP */
147
148 /* 0x3F SREG */
149
150 /* Interrupt vectors */
151
152 #define SIG_INTERRUPT0 _VECTOR(1)
153 #define SIG_INTERRUPT1 _VECTOR(2)
154 #define SIG_OUTPUT_COMPARE2 _VECTOR(3)
155 #define SIG_OVERFLOW2 _VECTOR(4)
156 #define SIG_INPUT_CAPTURE1 _VECTOR(5)
157 #define SIG_OUTPUT_COMPARE1A _VECTOR(6)
158 #define SIG_OUTPUT_COMPARE1B _VECTOR(7)
159 #define SIG_OVERFLOW1 _VECTOR(8)
160 #define SIG_OVERFLOW0 _VECTOR(9)
161 #define SIG_SPI _VECTOR(10)
162 #define SIG_UART_RECV _VECTOR(11)
163 #define SIG_UART_DATA _VECTOR(12)
164 #define SIG_UART_TRANS _VECTOR(13)
165 #define SIG_ADC _VECTOR(14)
166 #define SIG_EEPROM_READY _VECTOR(15)
167 #define SIG_COMPARATOR _VECTOR(16)
168 #define SIG_2WIRE_SERIAL _VECTOR(17)
169 #define SIG_SPM_READY _VECTOR(18)
170
171 #define _VECTORS_SIZE 38
172
173 /* Bit numbers */
174
175 /* GIMSK / GICR */
176 #define INT1 7
177 #define INT0 6
178 #define IVSEL 1
179 #define IVCE 0
180
181 /* GIFR */
182 #define INTF1 7
183 #define INTF0 6
184
184 #elif defined (__AVR_ATmega8515__)
54 #include "Events.h"
1 #ifndef EVENTS_H
2 #define EVENTS_H
3
4 /*
5 Copyright (C) 2004 John Orlando
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 10
 
 
6
7 AVRcam: a small real-time image processing engine.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
18
19 You should have received a copy of the GNU General Public
20 License along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
23 For more information on the AVRcam, please contact:
24
25 john@jrobot.net
26
27 or go to www.jrobot.net for more details regarding the system.
28 */
29 /***********************************************************
30 Module Name: Events.h
31 Module Date: 05/23/2004
32 Module Auth: John Orlando
33
34 Description: This file provides the external interface
35 to the events that can be published/processed in the
36 system. It is specifically by itself (and nothing
37 else should be defined in here) so that both .c and
38 .S (assembly) files can include this file without
39 a problem.
40
41 Revision History:
42 Date Rel Ver. Notes
43 4/10/2004 0.1 Module created
44 6/30/2004 1.0 Initial release for Circuit Cellar
45 contest.
46 *******************************************************/
47
48 /* Definitions */
49 /* Originally, all events were passed in a bitmask...however,
50 an event FIFO was finally used, but the coding of the event
51 definitions were never translated back....doesn't make a
52 difference, but looks a little weird */
53 #define EV_SERIAL_DATA_RECEIVED 0x01
54 #define EV_DUMP_FRAME 0x02
55 #define EV_PROCESS_FRAME_COMPLETE 0x04
55
56 .extern fastEventBitmask ; This is the flag used to indicate to the rest
57 ; of the system that the line is complete
58
59 #define HREF_INTERRUPT_ENABLE_MASK 0x80
60 #define HREF_INTERRUPT_DISABLE_MASK 0x7F
61 #define ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK 0x04
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 11
 
 
62 #define DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK 0xFB
63 #define G_PORT _SFR_IO_ADDR(PINC)
64 #define RB_PORT _SFR_IO_ADDR(PINB)
65 #define PIXEL_RUN_START_INITIAL 0x50 ; This value causes our pixel counter (TCNT1)
66 ; to overflow after 176 (horizontal) pixels
67
68 #define RED_MEM_OFFSET 0x00
69 #define GREEN_MEM_OFFSET 0x10
70 #define BLUE_MEM_OFFSET 0x20
71
72 ; A pixelBlock is defined as a contiguous group of 4 pixels that are combined
73 ; together to form a specific color. Typically, this is formed by sampling a
74 ; a green value, followed by a red and blue value (since we are dealing
75 ; with Bayer color data). We could optionally sample a second green with
76 ; the red and average the greens, because the eye is more sensitive to
77 ; green, but for speed we don't do this. These three values (RGB) are then
78 ; used as indices into the color membership lookup table (memLookup) to
79 ; determine which color the pixelBlock maps into. The memLookup table is
80 ; manually generated for now (though it will hopefully be modified over
81 ; the serial interface eventually).
82 ;
83 ; Here is a pixel block:
84 ; ...G G G G... (row x)
85 ; ...B R B R... (row x+1)
86 ; | | | |--this is skipped
87 ; | | |--this is skipped
88 ; | |--this is sampled
89 ; |--this is sampled
90
91 ; As pixel blocks are sampled, the red, green, and blue values are
92 ; used to index into their respective color maps. The color maps
93 ; return values that can be logically ANDed together so that a
94 ; particular RGB triplet will result in a single bit being set
95 ; after the AND operation. This single bit indicates which color
96 ; the RGB triplet represents. It is also possible for no bits to
97 ; be set after the AND process, indicating that the RGB triplet
98 ; does not map to any of the colors configured in the color map.
99 ; This isn't quite as fast as a pure RGB lookup table, but
100 ; it then again it doesn't require 2^12 (4-bits for each color
101 ; channel) bytes to store the lookup table. It takes just a few
102 ; more cycles, and only requires 48 bytes of precious RAM (16
103 ; per color channel, since our resolution on each color channel
104 ; is only 4-bits). Not bad....for more information, see:
105 ; http://www.cs.cmu.edu/~trb/papers/wirevision00.pdf for more
106 ; information on this color segmentation technique.
107
108 ; One other note: this code does depend on the colorMap residing
109 ; at a well-defined position in memory; specifically, it mus
110 ; start at a 256-byte boundary so that the lowest byte in the
111 ; map is set to 0x00. Currently, the colorMap is forced to
112 ; start at RAM location 0x300. This could potentially be changed
113 ; by the developer if needed, but offsets would have to be added
114 ; in to the colorMap look-up code below to make it work.
115
116
117 ; These are the registers that will be used throughout this
118 ; module for acquiring each line of pixel data
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 12
 
 
119 pixelCount = 16
120 pixelRunStart = 17
121 lastColor = 18
122 tmp1 = 19 ; be sure to not use tmp1 and color simultaneously
123 tmp2 = 20
124 color = 19
125 greenData = 20
126 blueData = 21
127 colorMapLow = 22
128 colorMapHigh = 23
129 prevLineBuffLow = 22 ; overlaps with memLookupLow (but orthogonal)
130 prevLineBuffHigh = 23 ; overlaps with memLookupHigh (but orthogonal)
131 currLineBuffLow = 24
132 currLineBuffHigh = 25
133
134 .section .text
135
136 ; These are the global assembly function names that are accessed via other
137 ; C functions
138 .global CamIntAsm_waitForNewTrackingFrame
139 .global CamIntAsm_waitForNewDumpFrame
140 .global CamIntAsm_acquireDumpLine
141 .global CamIntAsm_acquireTrackingLine
142 .global SIG_INTERRUPT0
143 .global SIG_INTERRUPT1
144 .global SIG_OVERFLOW0
145 .global SIG_OVERFLOW1
146
147 ;*****************************************************************
148 ; Function Name: CamIntAsm_waitForNewTrackingFrame
149 ; Function Description: This function is responsible for
150 ; going to sleep until a new frame begins (indicated by
151 ; VSYNC transitioning from low to high. This will wake
152 ; the "VSYNC sleep" up and allow it to continue with
153 ; the acquireLine function, where the system waits for
154 ; an "HREF sleep" that we use to synchronize with the
155 ; data.
156 ; Inputs: r25 - MSB of currentLineBuffer
157 ; r24 - LSB of currentLineBuffer
158 ; r23 - MSB of colorMap
159 ; r22 - LSB of colorMap
160 ; Outputs: none
161 ; NOTES: This function doesn't really return...it sorta just
162 ; floats into the acquireLine function after the "VSYNC sleep"
163 ; is awoken, then begins processing the line data. Once
164 ; 176 pixels are sampled (and the counter overflows), then
165 ; an interrupt will occur, the 'T' bit in the SREG will be
166 ; set, and the function will return.
167 ;*****************************************************************
168
169 CamIntAsm_waitForNewTrackingFrame:
170:CamInterfaceAsm.S **** sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
171:CamInterfaceAsm.S **** cbi _SFR_IO_ADDR(PORTD),PD6
172:CamInterfaceAsm.S **** sleep
173
174 ;*****************************************************************
175 ; REMEMBER...everything from here on out is critically timed to be
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 13
 
 
176 ; synchronized with the flow of pixel data from the camera...
177 ;*****************************************************************
178
179 CamIntAsm_acquireTrackingLine:
180:CamInterfaceAsm.S **** brts _cleanUp
181 ;sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
182 ;cbi _SFR_IO_ADDR(PORTD),PD6
183
184:CamInterfaceAsm.S **** in tmp1,_SFR_IO_ADDR(TCCR1B) ; Enable the PCLK line to actually
185:CamInterfaceAsm.S **** ori tmp1, 0x07 ; feed Timer1
186:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TCCR1B),tmp1
187 ; The line is about to start...
188:CamInterfaceAsm.S **** ldi pixelCount,0 ; Initialize the RLE stats...
189:CamInterfaceAsm.S **** ldi pixelRunStart,PIXEL_RUN_START_INITIAL ; Remember, we always calculate
190 ; the pixel run length as
191 ; TCNT1L - pixelRunStart
192
193:CamInterfaceAsm.S **** ldi lastColor,0x00 ; clear out the last color before we start
194
195:CamInterfaceAsm.S **** mov XH,currLineBuffHigh ; Load the pointer to the current line
196:CamInterfaceAsm.S **** mov XL,currLineBuffLow ; buffer into the X pointer regs
197
198:CamInterfaceAsm.S **** mov ZH,colorMapHigh ; Load the pointers to the membership
199:CamInterfaceAsm.S **** mov ZL,colorMapLow ; lookup tables (ZL and YL will be overwritten
200:CamInterfaceAsm.S **** mov YH,colorMapHigh ; as soon as we start reading data) to Z and Y
201
202:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(TIMSK) ; enable TIMER1 to start counting
203:CamInterfaceAsm.S **** ori tmp1, ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK ; external PCLK pulses and interrupt on
204:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TIMSK),tmp1 ; overflow
205
206:CamInterfaceAsm.S **** ldi tmp1,PIXEL_RUN_START_INITIAL ; set up the TCNT1 to overflow (and
207:CamInterfaceAsm.S **** ldi tmp2,0xFF ; interrupts) after 176 pixels
208:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TCNT1H),tmp2
209:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TCNT1L),tmp1
210
211:CamInterfaceAsm.S **** mov YL,colorMapLow
212
213:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(GICR) ; enable the HREF interrupt...remember, we
214 ; only use this interrupt to synchronize
215 ; the beginning of the line
216:CamInterfaceAsm.S **** ori tmp1, HREF_INTERRUPT_ENABLE_MASK
217:CamInterfaceAsm.S **** out _SFR_IO_ADDR(GICR), tmp1
218
219 ;*******************************************************************************************
220 ; Track Frame handler
221 ;*******************************************************************************************
222
223 _trackFrame:
224:CamInterfaceAsm.S **** sbi _SFR_IO_ADDR(PORTD),PD6
225:CamInterfaceAsm.S **** sleep ; ...And we wait...
226
227 ; Returning from the interrupt/sleep wakeup will consume
228 ; 14 clock cycles (7 to wakeup from idle sleep, 3 to vector, and 4 to return)
229
230 ; Disable the HREF interrupt
231:CamInterfaceAsm.S **** cbi _SFR_IO_ADDR(PORTD),PD6
232:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(GICR)
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 14
 
 
233:CamInterfaceAsm.S **** andi tmp1, HREF_INTERRUPT_DISABLE_MASK
234:CamInterfaceAsm.S **** out _SFR_IO_ADDR(GICR), tmp1
235
236 ; A couple of NOPs are needed here to sync up the pixel data...the number (2)
237 ; of NOPs was determined emperically by trial and error.
238:CamInterfaceAsm.S **** nop
239:CamInterfaceAsm.S **** nop
240 _acquirePixelBlock: ; Clock Cycle Count
241:CamInterfaceAsm.S **** in ZL,RB_PORT ; sample the red value (PINB) (1)
242:CamInterfaceAsm.S **** in YL,G_PORT ; sample the green value (PINC) (1)
243:CamInterfaceAsm.S **** andi YL,0x0F ; clear the high nibble (1)
244:CamInterfaceAsm.S **** ldd color,Z+RED_MEM_OFFSET ; lookup the red membership (2)
245:CamInterfaceAsm.S **** in ZL,RB_PORT ; sample the blue value (PINB) (1)
246:CamInterfaceAsm.S **** ldd greenData,Y+GREEN_MEM_OFFSET; lookup the green membership (2)
247:CamInterfaceAsm.S **** ldd blueData,Z+BLUE_MEM_OFFSET ; lookup the blue membership (2)
248:CamInterfaceAsm.S **** and color,greenData ; mask memberships together (1)
249:CamInterfaceAsm.S **** and color,blueData ; to produce the final color (1)
250:CamInterfaceAsm.S **** brts _cleanUpTrackingLine ; if some interrupt routine has (1...not set)
251 ; come in and set our T flag in
252 ; SREG, then we need to hop out
253 ; and blow away this frames data (common cleanup)
254:CamInterfaceAsm.S **** cp color,lastColor ; check to see if the run continues (1)
255:CamInterfaceAsm.S **** breq _acquirePixelBlock ; (2...equal)
256 ; ___________
257 ; 16 clock cycles
258 ; (16 clock cycles = 1 uS = 1 pixelBlock time)
259
260 ; Toggle the debug line to indicate a color change
261:CamInterfaceAsm.S **** sbi _SFR_IO_ADDR(PORTD),PD6
262:CamInterfaceAsm.S **** nop
263:CamInterfaceAsm.S **** cbi _SFR_IO_ADDR(PORTD),PD6
264
265:CamInterfaceAsm.S **** mov tmp2,pixelRunStart ; get the count value of the
266 ; current pixel run
267:CamInterfaceAsm.S **** in pixelCount,_SFR_IO_ADDR(TCNT1L) ; get the current TCNT1 value
268:CamInterfaceAsm.S **** mov pixelRunStart,pixelCount ; reload pixelRunStart for the
269 ; next run
270:CamInterfaceAsm.S **** sub pixelCount,tmp2 ; pixelCount = TCNT1L - pixelRunStart
271
272:CamInterfaceAsm.S **** st X+,lastColor ; record the color run in the current line buffer
273:CamInterfaceAsm.S **** st X+,pixelCount ; with its length
274:CamInterfaceAsm.S **** mov lastColor,color ; set lastColor so we can figure out when it changes
275
276:CamInterfaceAsm.S **** nop ; waste one more cycle for a total of 16
277:CamInterfaceAsm.S **** rjmp _acquirePixelBlock
278
279 ; _cleanUpTrackingLine is used to write the last run length block off to the currentLineBuffer so
280 ; that all 176 pixels in the line are accounted for.
281 _cleanUpTrackingLine:
282:CamInterfaceAsm.S **** ldi pixelCount,0xFF ; the length of the last run is ALWAYS 0xFF minus the last
283:CamInterfaceAsm.S **** sub pixelCount,pixelRunStart ; pixelRunStart
284
285:CamInterfaceAsm.S **** inc pixelCount ; increment pixelCount since we actually need to account
286 ; for the overflow of TCNT1
287
288:CamInterfaceAsm.S **** st X+,color ; record the color run in the current line buffer
289:CamInterfaceAsm.S **** st X,pixelCount
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 15
 
 
290:CamInterfaceAsm.S **** rjmp _cleanUp
291
292 _cleanUpDumpLine:
293 ; NOTE: If serial data is received, to interrupt the tracking of a line, we'll
294 ; get a EV_SERIAL_DATA_RECEIVED event, and the T bit set so we will end the
295 ; line's processing...however, the PCLK will keep on ticking for the rest of
296 ; the frame/line, which will cause the TCNT to eventually overflow and
297 ; interrupt us, generating a EV_ACQUIRE_LINE_COMPLETE event. We don't want
298 ; this, so we need to actually turn off the PCLK counting each time we exit
299 ; this loop, and only turn it on when we begin acquiring lines....
300 ; NOT NEEDED FOR NOW...
301 ;in tmp1, _SFR_IO_ADDR(TIMSK) ; disable TIMER1 to stop counting
302 ;andi tmp1, DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK ; external PCLK pulses
303 ;out _SFR_IO_ADDR(TIMSK),tmp1
304
305 _cleanUp:
306 ; Disable the external clocking of the Timer1 counter
307:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(TCCR1B)
308:CamInterfaceAsm.S **** andi tmp1, 0xF8
309:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TCCR1B),tmp1
310
311 ; Toggle the debug line to indicate the line is complete
312:CamInterfaceAsm.S **** sbi _SFR_IO_ADDR(PORTD),PD6
313:CamInterfaceAsm.S **** cbi _SFR_IO_ADDR(PORTD),PD6
314:CamInterfaceAsm.S **** clt ; clear out the T bit since we have detected
315 ; the interruption and are exiting to handle it
316 _exit:
317:CamInterfaceAsm.S **** ret
318
319 ;*****************************************************************
320 ; Function Name: CamIntAsm_waitForNewDumpFrame
321 ; Function Description: This function is responsible for
322 ; going to sleep until a new frame begins (indicated by
323 ; VSYNC transitioning from low to high. This will wake
324 ; the "VSYNC sleep" up and allow it to continue with
325 ; acquiring a line of pixel data to dump out to the UI.
326 ; Inputs: r25 - MSB of currentLineBuffer
327 ; r24 - LSB of currentLineBuffer
328 ; r23 - MSB of prevLineBuffer
329 ; r22 - LSB of prevLineBuffer
330 ; Outputs: none
331 ; NOTES: This function doesn't really return...it sorta just
332 ; floats into the acquireDumpLine function after the "VSYNC sleep"
333 ; is awoken.
334 ;*****************************************************************
335 CamIntAsm_waitForNewDumpFrame:
336:CamInterfaceAsm.S **** sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
337:CamInterfaceAsm.S **** cbi _SFR_IO_ADDR(PORTD),PD6
338:CamInterfaceAsm.S **** sleep
339
340 ;*****************************************************************
341 ; REMEMBER...everything from here on out is critically timed to be
342 ; synchronized with the flow of pixel data from the camera...
343 ;*****************************************************************
344
345 CamIntAsm_acquireDumpLine:
346:CamInterfaceAsm.S **** brts _cleanUp
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 16
 
 
347 ;sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
348 ;cbi _SFR_IO_ADDR(PORTD),PD6
349
350:CamInterfaceAsm.S **** mov XH,currLineBuffHigh ; Load the pointer to the current line
351:CamInterfaceAsm.S **** mov XL,currLineBuffLow ; buffer into the X pointer regs
352
353:CamInterfaceAsm.S **** mov YH,prevLineBuffHigh ; Load the pointer to the previous line
354:CamInterfaceAsm.S **** mov YL,prevLineBuffLow ; buffer into the Y pointer regs
355
356:CamInterfaceAsm.S **** ldi tmp1,PIXEL_RUN_START_INITIAL ; set up the TCNT1 to overflow (and
357:CamInterfaceAsm.S **** ldi tmp2,0xFF ; interrupts) after 176 pixels
358:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TCNT1H),tmp2
359:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TCNT1L),tmp1
360
361:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(TCCR1B) ; Enable the PCLK line to actually
362:CamInterfaceAsm.S **** ori tmp1, 0x07 ; feed Timer1
363:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TCCR1B),tmp1
364:CamInterfaceAsm.S **** nop
365
366:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(TIMSK) ; enable TIMER1 to start counting
367:CamInterfaceAsm.S **** ori tmp1, ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK ; external PCLK pulses and interrupt on
368:CamInterfaceAsm.S **** out _SFR_IO_ADDR(TIMSK),tmp1 ; overflow
369
370:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(GICR) ; enable the HREF interrupt...remember, we
371 ; only use this interrupt to synchronize
372 ; the beginning of the line
373:CamInterfaceAsm.S **** ori tmp1, HREF_INTERRUPT_ENABLE_MASK
374:CamInterfaceAsm.S **** out _SFR_IO_ADDR(GICR), tmp1
375
376 ;*******************************************************************************************
377 ; Dump Frame handler
378 ;*******************************************************************************************
379
380 _dumpFrame:
381:CamInterfaceAsm.S **** sbi _SFR_IO_ADDR(PORTD),PD6
382:CamInterfaceAsm.S **** sleep ; ...And we wait...
383
384:CamInterfaceAsm.S **** cbi _SFR_IO_ADDR(PORTD),PD6
385:CamInterfaceAsm.S **** in tmp1, _SFR_IO_ADDR(GICR) ; disable the HREF interrupt
386:CamInterfaceAsm.S **** andi tmp1, HREF_INTERRUPT_DISABLE_MASK ; so we don't get interrupted
387:CamInterfaceAsm.S **** out _SFR_IO_ADDR(GICR), tmp1 ; while dumping the line
388
389:CamInterfaceAsm.S **** nop ; Remember...if we ever remove the "cbi" instruction above,
390 ; we need to add two more NOPs to cover this
391
392 ; Ok...the following loop needs to run in 8 clock cycles, so we can get every
393 ; pixel in the line...this shouldn't be a problem, since the PCLK timing was
394 ; reduced by a factor of 2 whenever we go to dump a line (this is to give us
395 ; enough time to do the sampling and storing of the pixel data). In addition,
396 ; it is assumed that we will have to do some minor processing on the data right
397 ; before we send it out, like mask off the top 4-bits of each, and then pack both
398 ; low nibbles into a single byte for transmission...we just don't have time to
399 ; do that here (only 8 instruction cycles :-) )
400 _sampleDumpPixel:
401:CamInterfaceAsm.S **** in tmp1,G_PORT ; sample the G value (1)
402:CamInterfaceAsm.S **** in tmp2,RB_PORT ; sample the R/B value (1)
403:CamInterfaceAsm.S **** st X+,tmp1 ; store to the currLineBuff and inc ptrs(2)
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 17
 
 
404:CamInterfaceAsm.S **** st Y+,tmp2 ; store to the prevLineBuff and inc ptrs(2)
405:CamInterfaceAsm.S **** brtc _sampleDumpPixel ; loop back unless flag is set (2...if not set)
406 ; ___________
407 ; 8 cycles normally
408
409 ; if we make it here, it means the T flag is set, and we must have been interrupted
410 ; so we need to exit (what if we were interrupted for serial? should we disable it?)
411:CamInterfaceAsm.S **** rjmp _cleanUpDumpLine
412
413 ;***********************************************************
414 ; Function Name: <interrupt handler for External Interrupt0>
415 ; Function Description: This function is responsible
416 ; for handling a rising edge on the Ext Interrupt 0. This
417 ; routine simply returns, since we just want to wake up
418 ; whenever the VSYNC transitions (meaning the start of a new
419 ; frame).
420 ; Inputs: none
421 ; Outputs: none
422 ;***********************************************************
423 SIG_INTERRUPT0:
424 ; This will wake us up when VSYNC transitions high...we just want to return
425:CamInterfaceAsm.S **** reti
426
427 ;***********************************************************
428 ; Function Name: <interrupt handler for External Interrupt1>
429 ; Function Description: This function is responsible
430 ; for handling a falling edge on the Ext Interrupt 1. This
431 ; routine simply returns, since we just want to wake up
432 ; whenever the HREF transitions (meaning the pixels
433 ; are starting after VSYNC transitioned, and we need to
434 ; start acquiring the pixel blocks
435 ; Inputs: none
436 ; Outputs: none
437 ;***********************************************************
438 SIG_INTERRUPT1:
439 ; This will wake us up when HREF transitions high...we just want to return
440:CamInterfaceAsm.S **** reti
441
442 ;***********************************************************
443 ; Function Name: <interrupt handler for Timer0 overflow>
444 ; Function Description: This function is responsible
445 ; for handling the Timer0 overflow (hooked up to indicate
446 ; when we have reached the number of HREFs required in a
447 ; single frame). We set the T flag in the SREG to
448 ; indicate to the _acquirePixelBlock routine that it needs
449 ; to exit, and then set the appropriate action to take in
450 ; the eventList of the Executive module.
451 ; Inputs: none
452 ; Outputs: none
453 ; Note: Originally, the HREF pulses were also going to
454 ; be counted by a hardware counter, but it didn't end up
455 ; being necessary
456 ;***********************************************************
457 ;SIG_OVERFLOW0:
458 ; set ; set the T bit in SREG
459 ; lds tmp1,eventBitmask
460 ; ori tmp1,EV_ACQUIRE_FRAME_COMPLETE
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 18
 
 
461 ; sts eventBitmask,tmp1
462 ; reti
463
464 ;***********************************************************
465 ; Function Name: <interrupt handler for Timer1 overflow>
466 ; Function Description: This function is responsible
467 ; for handling the Timer1 overflow (hooked up to indicate
468 ; when we have reached the end of a line of pixel data,
469 ; since PCLK is hooked up to overflow TCNT1 after 176
470 ; pixels). This routine generates an acquire line complete
471 ; event in the fastEventBitmask, which is streamlined for
472 ; efficiency reasons.
473 ;***********************************************************
474 SIG_OVERFLOW1:
475:CamInterfaceAsm.S **** lds tmp1,fastEventBitmask ; set a flag indicating
476:CamInterfaceAsm.S **** ori tmp1,FEV_ACQUIRE_LINE_COMPLETE ; a line is complete
477:CamInterfaceAsm.S **** sts fastEventBitmask,tmp1
478:CamInterfaceAsm.S **** set ; set the T bit in SREG
479 ;sbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
480 ;cbi _SFR_IO_ADDR(PORTD),PD6 ; For testing...
481
482:CamInterfaceAsm.S **** reti
483
484 ; This is the default handler for all interrupts that don't
485 ; have handler routines specified for them.
486 .global __vector_default
487 __vector_default:
488:CamInterfaceAsm.S **** reti
489
490 .end
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s page 19
 
 
DEFINED SYMBOLS
*ABS*:00000000 CamInterfaceAsm.S
*ABS*:00000000 Events.h
*ABS*:00000000 CamInterfaceAsm.S
*ABS*:00000000 C:/WinAVR/avr/include/avr/io.h
*ABS*:00000000 C:/WinAVR/avr/include/avr/iom8.h
*ABS*:00000000 C:/WinAVR/avr/include/avr/io.h
*ABS*:00000000 C:/WinAVR/avr/include/avr/sfr_defs.h
*ABS*:00000000 C:/WinAVR/avr/include/avr/io.h
*ABS*:00000000 CamInterfaceAsm.S
*ABS*:00000000 <command line>
*ABS*:00000000 <built-in>
*ABS*:00000000 CamInterfaceAsm.S
*ABS*:00000010 pixelCount
*ABS*:00000011 pixelRunStart
*ABS*:00000012 lastColor
*ABS*:00000013 tmp1
*ABS*:00000014 tmp2
*ABS*:00000013 color
*ABS*:00000014 greenData
*ABS*:00000015 blueData
*ABS*:00000016 colorMapLow
*ABS*:00000017 colorMapHigh
*ABS*:00000016 prevLineBuffLow
*ABS*:00000017 prevLineBuffHigh
*ABS*:00000018 currLineBuffLow
*ABS*:00000019 currLineBuffHigh
CamInterfaceAsm.S:169 .text:00000000 CamIntAsm_waitForNewTrackingFrame
CamInterfaceAsm.S:335 .text:0000008e CamIntAsm_waitForNewDumpFrame
CamInterfaceAsm.S:345 .text:00000094 CamIntAsm_acquireDumpLine
CamInterfaceAsm.S:179 .text:00000006 CamIntAsm_acquireTrackingLine
CamInterfaceAsm.S:423 .text:000000d4 __vector_1
CamInterfaceAsm.S:438 .text:000000d6 __vector_2
CamInterfaceAsm.S:474 .text:000000d8 __vector_8
CamInterfaceAsm.S:305 .text:00000080 _cleanUp
CamInterfaceAsm.S:223 .text:00000034 _trackFrame
CamInterfaceAsm.S:240 .text:00000044 _acquirePixelBlock
CamInterfaceAsm.S:281 .text:00000074 _cleanUpTrackingLine
CamInterfaceAsm.S:292 .text:00000080 _cleanUpDumpLine
CamInterfaceAsm.S:316 .text:0000008c _exit
CamInterfaceAsm.S:380 .text:000000ba _dumpFrame
CamInterfaceAsm.S:400 .text:000000c8 _sampleDumpPixel
CamInterfaceAsm.S:487 .text:000000e6 __vector_default
 
UNDEFINED SYMBOLS
__vector_9
fastEventBitmask
/programy/Atmel_C/AVRcam/CommonDefs.h
0,0 → 1,81
#ifndef COMMONDEFS_H
#define COMMONDEFS_H
 
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: CommonDefs.h
Module Date: 04/10/2004
Module Auth: John Orlando
Description: This module provides some of the generic
definitions and declarations needed by the AVRcam
system.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
11/15/2004 1.2 Added the NO_CRYSTAL definition
for when the OV6620 is providing
the mega8's clock source.
***********************************************************/
#include <avr/interrupt.h>
/* Defines */
/* FOSC defines the frequency of the crystal connected to
the mega8, supplying the instruction clock cycle */
#define FOSC 16000000
 
/* For defining boolean operations */
typedef unsigned char bool_t;
#define TRUE 1
#define FALSE 0
 
#define BIT0 0
#define BIT1 1
#define BIT2 2
#define BIT3 3
#define BIT4 4
#define BIT5 5
#define BIT6 6
#define BIT7 7
 
#define DISABLE_INTS() cli()
#define ENABLE_INTS() sei()
 
//#define SIMULATION 1
//#define SLOW_FRAMES 1
//#define DEBUG_FRAME_DATA 1
//#define DEBUG_TRACKED_LINE 1
//#define DEBUG_COLOR_MAP 1
#define COMPLETE_COLOR_MAP 1
#define NO_CRYSTAL 1
#endif
 
/programy/Atmel_C/AVRcam/DebugInterface.c
0,0 → 1,89
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: DebugInterface.c
Module Date: 04/15/2004
Module Auth: John Orlando
Description: This module is responsible for providing a
debug interface to the system. Currently, the only
debugging that is available is through the on-board
UART (which is used by the main application as well) in
addition to the LED hooked up at PORTD bit 6.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
***********************************************************/
 
/* Includes */
#include "CommonDefs.h"
#include "UartInterface.h"
#include "Utility.h"
 
/* Local Variables */
 
/* Local Structures and Typedefs */
 
/* Extern Variables */
 
/* Definitions */
 
/***********************************************************
Function Name: DebugInt_init
Function Description: This function is responsible for
initializing the debug module. It sets up the debug LED
as well as any other debugging that will be done. The
LED blinks four times, which indicates to the user
that the system is available for re-programming if
necessary. This works because the data lines on the
OV6620 are still tri-stated at this point, but won't
be for long after this function returns.
Inputs: none
Outputs: none
***********************************************************/
void DebugInt_init(void)
{
/* set PortD pin6 for output */
DDRD |= 0x40;
/* turn on LED */
PORTD |= 0x40;
Utility_delay(500);
PORTD &= 0xBF;
Utility_delay(500);
PORTD |= 0x40;
Utility_delay(500);
PORTD &= 0xBF;
Utility_delay(500);
PORTD |= 0x40;
Utility_delay(500);
PORTD &= 0xBF;
Utility_delay(500);
PORTD |= 0x40;
}
 
/programy/Atmel_C/AVRcam/DebugInterface.d
0,0 → 1,0
DebugInterface.o DebugInterface.d : DebugInterface.c CommonDefs.h UartInterface.h Utility.h
/programy/Atmel_C/AVRcam/DebugInterface.h
0,0 → 1,48
#ifndef DEBUGINTERFACE_H
#define DEBUGINTERFACE_H
 
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: DebugInterface.h
Module Date: 04/15/2004
Module Auth: John Orlando
Description: This file is responsible for providing the
external interface to the DebugInterface module.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
***********************************************************/
 
/* Extern Functions */
extern void DebugInt_init(void);
#endif
 
/programy/Atmel_C/AVRcam/DebugInterface.lst
0,0 → 1,251
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccm4aaaa.s page 1
 
 
1 .file "DebugInterface.c"
2 .arch atmega8
3 __SREG__ = 0x3f
4 __SP_H__ = 0x3e
5 __SP_L__ = 0x3d
6 __tmp_reg__ = 0
7 __zero_reg__ = 1
8 .global __do_copy_data
9 .global __do_clear_bss
10 .stabs "C:\\WinAVR\\AVRcam_dev_1_3_2/",100,0,0,.Ltext0
11 .stabs "DebugInterface.c",100,0,0,.Ltext0
12 .text
13 .Ltext0:
14 .stabs "gcc2_compiled.",60,0,0,0
15 .stabs "int:t(0,1)=r(0,1);-32768;32767;",128,0,0,0
16 .stabs "char:t(0,2)=@s8;r(0,2);0;255;",128,0,0,0
17 .stabs "long int:t(0,3)=@s32;r(0,3);0020000000000;0017777777777;",128,0,0,0
18 .stabs "unsigned int:t(0,4)=r(0,4);0000000000000;0000000177777;",128,0,0,0
19 .stabs "long unsigned int:t(0,5)=@s32;r(0,5);0000000000000;0037777777777;",128,0,0,0
20 .stabs "long long int:t(0,6)=@s64;r(0,6);01000000000000000000000;0777777777777777777777;",128,0,0,
21 .stabs "long long unsigned int:t(0,7)=@s64;r(0,7);0000000000000;01777777777777777777777;",128,0,0,
22 .stabs "short int:t(0,8)=r(0,8);-32768;32767;",128,0,0,0
23 .stabs "short unsigned int:t(0,9)=r(0,9);0000000000000;0000000177777;",128,0,0,0
24 .stabs "signed char:t(0,10)=@s8;r(0,10);-128;127;",128,0,0,0
25 .stabs "unsigned char:t(0,11)=@s8;r(0,11);0;255;",128,0,0,0
26 .stabs "float:t(0,12)=r(0,1);4;0;",128,0,0,0
27 .stabs "double:t(0,13)=r(0,1);4;0;",128,0,0,0
28 .stabs "long double:t(0,14)=r(0,1);4;0;",128,0,0,0
29 .stabs "complex int:t(0,15)=s4real:(0,1),0,16;imag:(0,1),16,16;;",128,0,0,0
30 .stabs "complex float:t(0,16)=R3;8;0;",128,0,0,0
31 .stabs "complex double:t(0,17)=R3;8;0;",128,0,0,0
32 .stabs "complex long double:t(0,18)=R3;8;0;",128,0,0,0
33 .stabs "__builtin_va_list:t(0,19)=*(0,20)=(0,20)",128,0,0,0
34 .stabs "_Bool:t(0,21)=@s8;-16;",128,0,0,0
35 .stabs "DebugInterface.c",130,0,0,0
36 .stabs "CommonDefs.h",130,0,0,0
37 .stabs "C:/WinAVR/avr/include/avr/interrupt.h",130,0,0,0
38 .stabs "C:/WinAVR/avr/include/avr/io.h",130,0,0,0
39 .stabs "C:/WinAVR/avr/include/avr/sfr_defs.h",130,0,0,0
40 .stabn 162,0,0,0
41 .stabs "C:/WinAVR/avr/include/avr/iom8.h",130,0,0,0
42 .stabn 162,0,0,0
43 .stabn 162,0,0,0
44 .stabn 162,0,0,0
45 .stabs "bool_t:t(2,1)=(0,11)",128,0,56,0
46 .stabn 162,0,0,0
47 .stabs "UartInterface.h",130,0,0,0
48 .stabn 162,0,0,0
49 .stabs "Utility.h",130,0,0,0
50 .stabn 162,0,0,0
51 .stabs "DebugInt_init:F(0,20)",36,0,71,DebugInt_init
52 .global DebugInt_init
53 .type DebugInt_init, @function
54 DebugInt_init:
1:DebugInterface.c **** /*
2:DebugInterface.c **** Copyright (C) 2004 John Orlando
3:DebugInterface.c ****
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccm4aaaa.s page 2
 
 
4:DebugInterface.c **** AVRcam: a small real-time image processing engine.
5:DebugInterface.c ****
6:DebugInterface.c **** This program is free software; you can redistribute it and/or
7:DebugInterface.c **** modify it under the terms of the GNU General Public
8:DebugInterface.c **** License as published by the Free Software Foundation; either
9:DebugInterface.c **** version 2 of the License, or (at your option) any later version.
10:DebugInterface.c ****
11:DebugInterface.c **** This program is distributed in the hope that it will be useful,
12:DebugInterface.c **** but WITHOUT ANY WARRANTY; without even the implied warranty of
13:DebugInterface.c **** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14:DebugInterface.c **** General Public License for more details.
15:DebugInterface.c ****
16:DebugInterface.c **** You should have received a copy of the GNU General Public
17:DebugInterface.c **** License along with this program; if not, write to the Free Software
18:DebugInterface.c **** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19:DebugInterface.c ****
20:DebugInterface.c **** For more information on the AVRcam, please contact:
21:DebugInterface.c ****
22:DebugInterface.c **** john@jrobot.net
23:DebugInterface.c ****
24:DebugInterface.c **** or go to www.jrobot.net for more details regarding the system.
25:DebugInterface.c **** */
26:DebugInterface.c **** /***********************************************************
27:DebugInterface.c **** Module Name: DebugInterface.c
28:DebugInterface.c **** Module Date: 04/15/2004
29:DebugInterface.c **** Module Auth: John Orlando
30:DebugInterface.c ****
31:DebugInterface.c **** Description: This module is responsible for providing a
32:DebugInterface.c **** debug interface to the system. Currently, the only
33:DebugInterface.c **** debugging that is available is through the on-board
34:DebugInterface.c **** UART (which is used by the main application as well) in
35:DebugInterface.c **** addition to the LED hooked up at PORTD bit 6.
36:DebugInterface.c ****
37:DebugInterface.c **** Revision History:
38:DebugInterface.c **** Date Rel Ver. Notes
39:DebugInterface.c **** 4/10/2004 0.1 Module created
40:DebugInterface.c **** 6/30/2004 1.0 Initial release for Circuit Cellar
41:DebugInterface.c **** contest.
42:DebugInterface.c **** ***********************************************************/
43:DebugInterface.c ****
44:DebugInterface.c **** /* Includes */
45:DebugInterface.c **** #include "CommonDefs.h"
46:DebugInterface.c **** #include "UartInterface.h"
47:DebugInterface.c **** #include "Utility.h"
48:DebugInterface.c ****
49:DebugInterface.c **** /* Local Variables */
50:DebugInterface.c ****
51:DebugInterface.c **** /* Local Structures and Typedefs */
52:DebugInterface.c ****
53:DebugInterface.c **** /* Extern Variables */
54:DebugInterface.c ****
55:DebugInterface.c **** /* Definitions */
56:DebugInterface.c ****
57:DebugInterface.c **** /***********************************************************
58:DebugInterface.c **** Function Name: DebugInt_init
59:DebugInterface.c **** Function Description: This function is responsible for
60:DebugInterface.c **** initializing the debug module. It sets up the debug LED
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccm4aaaa.s page 3
 
 
61:DebugInterface.c **** as well as any other debugging that will be done. The
62:DebugInterface.c **** LED blinks four times, which indicates to the user
63:DebugInterface.c **** that the system is available for re-programming if
64:DebugInterface.c **** necessary. This works because the data lines on the
65:DebugInterface.c **** OV6620 are still tri-stated at this point, but won't
66:DebugInterface.c **** be for long after this function returns.
67:DebugInterface.c **** Inputs: none
68:DebugInterface.c **** Outputs: none
69:DebugInterface.c **** ***********************************************************/
70:DebugInterface.c **** void DebugInt_init(void)
71:DebugInterface.c **** {
55 .stabn 68,0,71,.LM1-DebugInt_init
56 .LM1:
57 /* prologue: frame size=0 */
58 0000 1F93 push r17
59 /* prologue end (size=1) */
72:DebugInterface.c **** /* set PortD pin6 for output */
73:DebugInterface.c **** DDRD |= 0x40;
60 .stabn 68,0,73,.LM2-DebugInt_init
61 .LM2:
62 0002 8E9A sbi 49-0x20,6
74:DebugInterface.c **** /* turn on LED */
75:DebugInterface.c **** PORTD |= 0x40;
63 .stabn 68,0,75,.LM3-DebugInt_init
64 .LM3:
65 0004 969A sbi 50-0x20,6
76:DebugInterface.c **** Utility_delay(500);
66 .stabn 68,0,76,.LM4-DebugInt_init
67 .LM4:
68 0006 84EF ldi r24,lo8(500)
69 0008 91E0 ldi r25,hi8(500)
70 000a 00D0 rcall Utility_delay
77:DebugInterface.c **** PORTD &= 0xBF;
71 .stabn 68,0,77,.LM5-DebugInt_init
72 .LM5:
73 000c 1FEB ldi r17,lo8(-65)
74 000e 82B3 in r24,50-0x20
75 0010 8123 and r24,r17
76 0012 82BB out 50-0x20,r24
78:DebugInterface.c **** Utility_delay(500);
77 .stabn 68,0,78,.LM6-DebugInt_init
78 .LM6:
79 0014 84EF ldi r24,lo8(500)
80 0016 91E0 ldi r25,hi8(500)
81 0018 00D0 rcall Utility_delay
79:DebugInterface.c **** PORTD |= 0x40;
82 .stabn 68,0,79,.LM7-DebugInt_init
83 .LM7:
84 001a 969A sbi 50-0x20,6
80:DebugInterface.c **** Utility_delay(500);
85 .stabn 68,0,80,.LM8-DebugInt_init
86 .LM8:
87 001c 84EF ldi r24,lo8(500)
88 001e 91E0 ldi r25,hi8(500)
89 0020 00D0 rcall Utility_delay
81:DebugInterface.c **** PORTD &= 0xBF;
90 .stabn 68,0,81,.LM9-DebugInt_init
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccm4aaaa.s page 4
 
 
91 .LM9:
92 0022 82B3 in r24,50-0x20
93 0024 8123 and r24,r17
94 0026 82BB out 50-0x20,r24
82:DebugInterface.c **** Utility_delay(500);
95 .stabn 68,0,82,.LM10-DebugInt_init
96 .LM10:
97 0028 84EF ldi r24,lo8(500)
98 002a 91E0 ldi r25,hi8(500)
99 002c 00D0 rcall Utility_delay
83:DebugInterface.c **** PORTD |= 0x40;
100 .stabn 68,0,83,.LM11-DebugInt_init
101 .LM11:
102 002e 969A sbi 50-0x20,6
84:DebugInterface.c **** Utility_delay(500);
103 .stabn 68,0,84,.LM12-DebugInt_init
104 .LM12:
105 0030 84EF ldi r24,lo8(500)
106 0032 91E0 ldi r25,hi8(500)
107 0034 00D0 rcall Utility_delay
85:DebugInterface.c **** PORTD &= 0xBF;
108 .stabn 68,0,85,.LM13-DebugInt_init
109 .LM13:
110 0036 82B3 in r24,50-0x20
111 0038 8123 and r24,r17
112 003a 82BB out 50-0x20,r24
86:DebugInterface.c **** Utility_delay(500);
113 .stabn 68,0,86,.LM14-DebugInt_init
114 .LM14:
115 003c 84EF ldi r24,lo8(500)
116 003e 91E0 ldi r25,hi8(500)
117 0040 00D0 rcall Utility_delay
87:DebugInterface.c **** PORTD |= 0x40;
118 .stabn 68,0,87,.LM15-DebugInt_init
119 .LM15:
120 0042 969A sbi 50-0x20,6
88:DebugInterface.c **** }
121 .stabn 68,0,88,.LM16-DebugInt_init
122 .LM16:
123 /* epilogue: frame size=0 */
124 0044 1F91 pop r17
125 0046 0895 ret
126 /* epilogue end (size=2) */
127 /* function DebugInt_init size 36 (33) */
128 .size DebugInt_init, .-DebugInt_init
129 .Lscope0:
130 .stabs "",36,0,0,.Lscope0-DebugInt_init
131 .text
132 .stabs "",100,0,0,Letext
133 Letext:
134 /* File "DebugInterface.c": code 36 = 0x0024 ( 33), prologues 1, epilogues 2 */
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccm4aaaa.s page 5
 
 
DEFINED SYMBOLS
*ABS*:00000000 DebugInterface.c
*ABS*:0000003f __SREG__
*ABS*:0000003e __SP_H__
*ABS*:0000003d __SP_L__
*ABS*:00000000 __tmp_reg__
*ABS*:00000001 __zero_reg__
C:\DOCUME~1\John\LOCALS~1\Temp/ccm4aaaa.s:54 .text:00000000 DebugInt_init
C:\DOCUME~1\John\LOCALS~1\Temp/ccm4aaaa.s:133 .text:00000048 Letext
 
UNDEFINED SYMBOLS
__do_copy_data
__do_clear_bss
Utility_delay
/programy/Atmel_C/AVRcam/Events.h
0,0 → 1,78
#ifndef EVENTS_H
#define EVENTS_H
 
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: Events.h
Module Date: 05/23/2004
Module Auth: John Orlando
Description: This file provides the external interface
to the events that can be published/processed in the
system. It is specifically by itself (and nothing
else should be defined in here) so that both .c and
.S (assembly) files can include this file without
a problem.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
*******************************************************/
 
/* Definitions */
/* Originally, all events were passed in a bitmask...however,
an event FIFO was finally used, but the coding of the event
definitions were never translated back....doesn't make a
difference, but looks a little weird */
#define EV_SERIAL_DATA_RECEIVED 0x01
#define EV_DUMP_FRAME 0x02
#define EV_PROCESS_FRAME_COMPLETE 0x04
#define EV_PROCESS_LINE_COMPLETE 0x08
#define EV_ACQUIRE_LINE_COMPLETE 0x10
#define EV_ACQUIRE_FRAME_COMPLETE 0x20
#define EV_CONFIGURE_CAMERA 0x40
#define EV_ENABLE_TRACKING 0x80
#define EV_DISABLE_TRACKING 0x81
#define EV_SERIAL_DATA_PENDING_TX 0x90
#define EV_RED_COLOR_MAP_RECEIVED 0x91
#define EV_BLUE_COLOR_MAP_RECEIVED 0x92
#define EV_GREEN_COLOR_MAP_RECEIVED 0x93
 
/* This is used to pass fast events through the system
so there is a minimum of processing time needed
between lines of tracking data */
#define FEV_ACQUIRE_LINE_COMPLETE 0x01
#define FEV_PROCESS_LINE_COMPLETE 0x02
 
/* This is needed for the event fifo */
#define EXEC_EVENT_FIFO_SIZE 8
#define EXEC_EVENT_FIFO_MASK EXEC_EVENT_FIFO_SIZE-1
 
#endif
 
/programy/Atmel_C/AVRcam/Executive.c
0,0 → 1,219
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: Executive.c
Module Date: 04/12/2004
Module Auth: John Orlando
Description: This file is responsible for implementing a
minimalist event dispatcher. It keeps track of an event
fifo that waits for new events to come in, and dispatches
them to any entities that care about them.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
1/16/2005 1.4 Fixed issue where the interrupts weren't
being turned off when the fastEventBitmask
was being accessed. Also removed redundant
interrupt masking when accessing the
main event fifo. Also fixed issue where
the main event fifo wasn't being checked
for events if an event was pending in
the fast event fifo.
***********************************************************/
 
/* Includes */
#include <stdlib.h>
#include "CommonDefs.h"
#include "Executive.h"
#include "FrameMgr.h"
#include "CamInterface.h"
#include "UIMgr.h"
#include "UartInterface.h"
#include "CamConfig.h"
#include "Utility.h"
 
/* Local Variables */
unsigned char Exec_eventFifo[EXEC_EVENT_FIFO_SIZE];
unsigned char Exec_eventFifoHead=0;
unsigned char Exec_eventFifoTail=0;
 
/* Local Function Definitions */
static unsigned char Exec_readEventFifo(void);
 
/* Local Structures and Typedefs */
 
/* Extern Variables */
/* This bitmask holds events that need to be processed as fast as possible */
unsigned char fastEventBitmask = 0x00;
 
/* Definitions */
#define IS_DATA_IN_EVENT_FIFO() (!(Exec_eventFifoHead == Exec_eventFifoTail))
/***********************************************************
Function Name: Exec_run
Function Description: This function is responsible for
running the main control loop. The control loop is
based on checking both the fast-event bitmask (for high
priority events) and the event FIFO to determine if an
event needs to be handled. The event is then dispatched
to the appropriate handler.
Inputs: none
Outputs: none
***********************************************************/
void Exec_run(void)
{
unsigned char eventGenerated;
while(1)
{
if (fastEventBitmask)
{
/* an event needing fast processing has been received */
/* a received line needs to be processed...this
needs to be processed as quickly as possible */
if (fastEventBitmask & FEV_ACQUIRE_LINE_COMPLETE)
{
DISABLE_INTS();
fastEventBitmask &= ~FEV_ACQUIRE_LINE_COMPLETE;
ENABLE_INTS();
FrameMgr_processLine();
/* also check if serial data needs to be sent
out through UIMgr */
UIMgr_transmitPendingData();
 
/* we can't just call acquire line again here,
since we don't know if we need to acquire another
line or not (it depends on the FrameMgr to figure
this out) */
}
if (fastEventBitmask & FEV_PROCESS_LINE_COMPLETE)
{
DISABLE_INTS();
fastEventBitmask &= ~FEV_PROCESS_LINE_COMPLETE;
ENABLE_INTS();
FrameMgr_acquireLine();
}
}
if (IS_DATA_IN_EVENT_FIFO() == TRUE)
{
eventGenerated = Exec_readEventFifo();
switch(eventGenerated)
{
case (EV_DUMP_FRAME):
FrameMgr_dispatchEvent(eventGenerated);
break;
case (EV_ENABLE_TRACKING):
FrameMgr_dispatchEvent(eventGenerated);
break;
case (EV_DISABLE_TRACKING):
FrameMgr_dispatchEvent(eventGenerated);
break;
case (EV_ACQUIRE_LINE_COMPLETE):
FrameMgr_dispatchEvent(eventGenerated);
UIMgr_dispatchEvent(eventGenerated);
break;
case (EV_ACQUIRE_FRAME_COMPLETE):
FrameMgr_dispatchEvent(eventGenerated);
break;
case (EV_PROCESS_LINE_COMPLETE):
FrameMgr_dispatchEvent(eventGenerated);
break;
case (EV_PROCESS_FRAME_COMPLETE):
FrameMgr_dispatchEvent(eventGenerated);
break;
case (EV_SERIAL_DATA_RECEIVED):
UIMgr_dispatchEvent(eventGenerated);
FrameMgr_dispatchEvent(eventGenerated);
break;
 
case (EV_SERIAL_DATA_PENDING_TX):
UIMgr_dispatchEvent(eventGenerated);
break;
default:
break;
}
}
/* toggle the debug line */
 
}
}
 
/***********************************************************
Function Name: Exec_readEventFifo
Function Description: This function is responsible for
reading a single event out of the event fifo.
Inputs: none
Outputs: unsigned char-the data read
***********************************************************/
static unsigned char Exec_readEventFifo(void)
{
unsigned char dataByte, tmpTail;
DISABLE_INTS();
/* just return the current tail from the tx fifo */
dataByte = Exec_eventFifo[Exec_eventFifoTail];
tmpTail = (Exec_eventFifoTail+1) & (EXEC_EVENT_FIFO_MASK);
Exec_eventFifoTail = tmpTail;
ENABLE_INTS();
return(dataByte);
}
 
/***********************************************************
Function Name: Exec_writeEventFifo
Function Description: This function is responsible for
writing a single event to the event fifo and
updating the appropriate pointers.
Inputs: data - the byte to write to the Fifo
Outputs: none
***********************************************************/
void Exec_writeEventFifo(unsigned char event)
{
unsigned char tmpHead;
 
DISABLE_INTS();
Exec_eventFifo[Exec_eventFifoHead] = event;
 
/* now move the head up */
tmpHead = (Exec_eventFifoHead + 1) & (EXEC_EVENT_FIFO_MASK);
Exec_eventFifoHead = tmpHead;
ENABLE_INTS();
}
 
/programy/Atmel_C/AVRcam/Executive.d
0,0 → 1,3
Executive.o Executive.d : Executive.c CommonDefs.h Executive.h Events.h FrameMgr.h \
CamInterface.h UIMgr.h UartInterface.h CamConfig.h I2CInterface.h \
Utility.h
/programy/Atmel_C/AVRcam/Executive.h
0,0 → 1,66
#ifndef EXECUTIVE_H
#define EXECUTIVE_H
 
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
 
/***********************************************************
Module Name: Executive.h
Module Date: 04/12/2004
Module Auth: John Orlando
Description: This file provides the external interface
to the Executive module.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
*******************************************************/
#include "Events.h"
 
/* Definitions */
 
#define PUBLISH_EVENT(event) Exec_writeEventFifo(event)
#define PUBLISH_FAST_EVENT(event) fastEventBitmask |= event
/* Extern Functions */
extern void Exec_run(void);
extern void Exec_writeEventFifo(unsigned char event);
 
/* Extern Data */
extern unsigned char fastEventBitmask;
extern unsigned char Exec_eventFifo[];
extern unsigned char Exec_eventFifoHead;
extern unsigned char Exec_eventFifoTail;
#endif
 
 
 
 
 
/programy/Atmel_C/AVRcam/Executive.lst
0,0 → 1,637
GAS LISTING /tmp/cceEDT7g.s page 1
 
 
1 .file "Executive.c"
2 .arch atmega8
3 __SREG__ = 0x3f
4 __SP_H__ = 0x3e
5 __SP_L__ = 0x3d
6 __tmp_reg__ = 0
7 __zero_reg__ = 1
8 .global __do_copy_data
9 .global __do_clear_bss
10 .stabs "/home/kaklik/projects/roboti/istrobot/2007/ATmega8/AVRcam/",100,0,2,.Ltext0
11 .stabs "Executive.c",100,0,2,.Ltext0
12 .text
13 .Ltext0:
14 .stabs "gcc2_compiled.",60,0,0,0
15 .stabs "int:t(0,1)=r(0,1);-32768;32767;",128,0,0,0
16 .stabs "char:t(0,2)=@s8;r(0,2);0;255;",128,0,0,0
17 .stabs "long int:t(0,3)=@s32;r(0,3);020000000000;017777777777;",128,0,0,0
18 .stabs "unsigned int:t(0,4)=r(0,4);0;0177777;",128,0,0,0
19 .stabs "long unsigned int:t(0,5)=@s32;r(0,5);0;037777777777;",128,0,0,0
20 .stabs "long long int:t(0,6)=@s64;r(0,6);01000000000000000000000;0777777777777777777777;",128,0,0,
21 .stabs "long long unsigned int:t(0,7)=@s64;r(0,7);0;01777777777777777777777;",128,0,0,0
22 .stabs "short int:t(0,8)=r(0,8);-32768;32767;",128,0,0,0
23 .stabs "short unsigned int:t(0,9)=r(0,9);0;0177777;",128,0,0,0
24 .stabs "signed char:t(0,10)=@s8;r(0,10);-128;127;",128,0,0,0
25 .stabs "unsigned char:t(0,11)=@s8;r(0,11);0;255;",128,0,0,0
26 .stabs "float:t(0,12)=r(0,1);4;0;",128,0,0,0
27 .stabs "double:t(0,13)=r(0,1);4;0;",128,0,0,0
28 .stabs "long double:t(0,14)=r(0,1);4;0;",128,0,0,0
29 .stabs "void:t(0,15)=(0,15)",128,0,0,0
30 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/stdlib.h",130,0,0,0
31 .stabs "/usr/lib/gcc/avr/4.1.0/include/stddef.h",130,0,0,0
32 .stabs "size_t:t(2,1)=(0,4)",128,0,214,0
33 .stabs "wchar_t:t(2,2)=(0,1)",128,0,326,0
34 .stabn 162,0,0,0
35 .stabs "div_t:t(1,1)=(1,2)=s4quot:(0,1),0,16;rem:(0,1),16,16;;",128,0,69,0
36 .stabs "ldiv_t:t(1,3)=(1,4)=s8quot:(0,3),0,32;rem:(0,3),32,32;;",128,0,75,0
37 .stabs "__compar_fn_t:t(1,5)=(1,6)=*(1,7)=f(0,1)",128,0,78,0
38 .stabn 162,0,0,0
39 .stabs "CommonDefs.h",130,0,0,0
40 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/interrupt.h",130,0,0,0
41 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/io.h",130,0,0,0
42 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/sfr_defs.h",130,0,0,0
43 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/inttypes.h",130,0,0,0
44 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/stdint.h",130,0,0,0
45 .stabs "int8_t:t(8,1)=(0,10)",128,0,116,0
46 .stabs "uint8_t:t(8,2)=(0,11)",128,0,117,0
47 .stabs "int16_t:t(8,3)=(0,1)",128,0,118,0
48 .stabs "uint16_t:t(8,4)=(0,4)",128,0,119,0
49 .stabs "int32_t:t(8,5)=(0,3)",128,0,120,0
50 .stabs "uint32_t:t(8,6)=(0,5)",128,0,121,0
51 .stabs "int64_t:t(8,7)=(0,6)",128,0,122,0
52 .stabs "uint64_t:t(8,8)=(0,7)",128,0,123,0
53 .stabs "intptr_t:t(8,9)=(8,3)",128,0,135,0
54 .stabs "uintptr_t:t(8,10)=(8,4)",128,0,140,0
55 .stabs "int_least8_t:t(8,11)=(8,1)",128,0,152,0
56 .stabs "uint_least8_t:t(8,12)=(8,2)",128,0,157,0
57 .stabs "int_least16_t:t(8,13)=(8,3)",128,0,162,0
GAS LISTING /tmp/cceEDT7g.s page 2
 
 
58 .stabs "uint_least16_t:t(8,14)=(8,4)",128,0,167,0
59 .stabs "int_least32_t:t(8,15)=(8,5)",128,0,172,0
60 .stabs "uint_least32_t:t(8,16)=(8,6)",128,0,177,0
61 .stabs "int_least64_t:t(8,17)=(8,7)",128,0,182,0
62 .stabs "uint_least64_t:t(8,18)=(8,8)",128,0,187,0
63 .stabs "int_fast8_t:t(8,19)=(8,1)",128,0,200,0
64 .stabs "uint_fast8_t:t(8,20)=(8,2)",128,0,205,0
65 .stabs "int_fast16_t:t(8,21)=(8,3)",128,0,210,0
66 .stabs "uint_fast16_t:t(8,22)=(8,4)",128,0,215,0
67 .stabs "int_fast32_t:t(8,23)=(8,5)",128,0,220,0
68 .stabs "uint_fast32_t:t(8,24)=(8,6)",128,0,225,0
69 .stabs "int_fast64_t:t(8,25)=(8,7)",128,0,230,0
70 .stabs "uint_fast64_t:t(8,26)=(8,8)",128,0,235,0
71 .stabs "intmax_t:t(8,27)=(8,7)",128,0,249,0
72 .stabs "uintmax_t:t(8,28)=(8,8)",128,0,254,0
73 .stabn 162,0,0,0
74 .stabs "int_farptr_t:t(7,1)=(8,5)",128,0,76,0
75 .stabs "uint_farptr_t:t(7,2)=(8,6)",128,0,80,0
76 .stabn 162,0,0,0
77 .stabn 162,0,0,0
78 .stabn 162,0,0,0
79 .stabn 162,0,0,0
80 .stabs "bool_t:t(3,1)=(0,11)",128,0,56,0
81 .stabn 162,0,0,0
82 .stabs "CamConfig.h",130,0,0,0
83 .stabs "I2CInterface.h",130,0,0,0
84 .stabs "i2cCmd_t:t(10,1)=(10,2)=s2configReg:(0,11),0,8;data:(0,11),8,8;;",128,0,53,0
85 .stabn 162,0,0,0
86 .stabn 162,0,0,0
87 .stabs "Exec_writeEventFifo:F(0,15)",36,0,208,Exec_writeEventFifo
88 .stabs "event:P(0,11)",64,0,207,24
89 .global Exec_writeEventFifo
90 .type Exec_writeEventFifo, @function
91 Exec_writeEventFifo:
92 .stabd 46,0,0
1:Executive.c **** /*
2:Executive.c **** Copyright (C) 2004 John Orlando
3:Executive.c ****
4:Executive.c **** AVRcam: a small real-time image processing engine.
5:Executive.c ****
6:Executive.c **** This program is free software; you can redistribute it and/or
7:Executive.c **** modify it under the terms of the GNU General Public
8:Executive.c **** License as published by the Free Software Foundation; either
9:Executive.c **** version 2 of the License, or (at your option) any later version.
10:Executive.c ****
11:Executive.c **** This program is distributed in the hope that it will be useful,
12:Executive.c **** but WITHOUT ANY WARRANTY; without even the implied warranty of
13:Executive.c **** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14:Executive.c **** General Public License for more details.
15:Executive.c ****
16:Executive.c **** You should have received a copy of the GNU General Public
17:Executive.c **** License along with this program; if not, write to the Free Software
18:Executive.c **** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19:Executive.c ****
20:Executive.c **** For more information on the AVRcam, please contact:
21:Executive.c ****
22:Executive.c **** john@jrobot.net
GAS LISTING /tmp/cceEDT7g.s page 3
 
 
23:Executive.c ****
24:Executive.c **** or go to www.jrobot.net for more details regarding the system.
25:Executive.c **** */
26:Executive.c **** /***********************************************************
27:Executive.c **** Module Name: Executive.c
28:Executive.c **** Module Date: 04/12/2004
29:Executive.c **** Module Auth: John Orlando
30:Executive.c ****
31:Executive.c **** Description: This file is responsible for implementing a
32:Executive.c **** minimalist event dispatcher. It keeps track of an event
33:Executive.c **** fifo that waits for new events to come in, and dispatches
34:Executive.c **** them to any entities that care about them.
35:Executive.c ****
36:Executive.c **** Revision History:
37:Executive.c **** Date Rel Ver. Notes
38:Executive.c **** 4/10/2004 0.1 Module created
39:Executive.c **** 6/30/2004 1.0 Initial release for Circuit Cellar
40:Executive.c **** contest.
41:Executive.c **** 1/16/2005 1.4 Fixed issue where the interrupts weren't
42:Executive.c **** being turned off when the fastEventBitmask
43:Executive.c **** was being accessed. Also removed redundant
44:Executive.c **** interrupt masking when accessing the
45:Executive.c **** main event fifo. Also fixed issue where
46:Executive.c **** the main event fifo wasn't being checked
47:Executive.c **** for events if an event was pending in
48:Executive.c **** the fast event fifo.
49:Executive.c **** ***********************************************************/
50:Executive.c ****
51:Executive.c **** /* Includes */
52:Executive.c **** #include <stdlib.h>
53:Executive.c **** #include "CommonDefs.h"
54:Executive.c **** #include "Executive.h"
55:Executive.c **** #include "FrameMgr.h"
56:Executive.c **** #include "CamInterface.h"
57:Executive.c **** #include "UIMgr.h"
58:Executive.c **** #include "UartInterface.h"
59:Executive.c **** #include "CamConfig.h"
60:Executive.c **** #include "Utility.h"
61:Executive.c ****
62:Executive.c **** /* Local Variables */
63:Executive.c **** unsigned char Exec_eventFifo[EXEC_EVENT_FIFO_SIZE];
64:Executive.c **** unsigned char Exec_eventFifoHead=0;
65:Executive.c **** unsigned char Exec_eventFifoTail=0;
66:Executive.c ****
67:Executive.c **** /* Local Function Definitions */
68:Executive.c **** static unsigned char Exec_readEventFifo(void);
69:Executive.c ****
70:Executive.c **** /* Local Structures and Typedefs */
71:Executive.c ****
72:Executive.c **** /* Extern Variables */
73:Executive.c **** /* This bitmask holds events that need to be processed as fast as possible */
74:Executive.c **** unsigned char fastEventBitmask = 0x00;
75:Executive.c ****
76:Executive.c **** /* Definitions */
77:Executive.c **** #define IS_DATA_IN_EVENT_FIFO() (!(Exec_eventFifoHead == Exec_eventFifoTail))
78:Executive.c **** /***********************************************************
79:Executive.c **** Function Name: Exec_run
GAS LISTING /tmp/cceEDT7g.s page 4
 
 
80:Executive.c **** Function Description: This function is responsible for
81:Executive.c **** running the main control loop. The control loop is
82:Executive.c **** based on checking both the fast-event bitmask (for high
83:Executive.c **** priority events) and the event FIFO to determine if an
84:Executive.c **** event needs to be handled. The event is then dispatched
85:Executive.c **** to the appropriate handler.
86:Executive.c **** Inputs: none
87:Executive.c **** Outputs: none
88:Executive.c **** ***********************************************************/
89:Executive.c **** void Exec_run(void)
90:Executive.c **** {
91:Executive.c **** unsigned char eventGenerated;
92:Executive.c ****
93:Executive.c **** while(1)
94:Executive.c **** {
95:Executive.c **** if (fastEventBitmask)
96:Executive.c **** {
97:Executive.c **** /* an event needing fast processing has been received */
98:Executive.c **** /* a received line needs to be processed...this
99:Executive.c **** needs to be processed as quickly as possible */
100:Executive.c **** if (fastEventBitmask & FEV_ACQUIRE_LINE_COMPLETE)
101:Executive.c **** {
102:Executive.c **** DISABLE_INTS();
103:Executive.c **** fastEventBitmask &= ~FEV_ACQUIRE_LINE_COMPLETE;
104:Executive.c **** ENABLE_INTS();
105:Executive.c **** FrameMgr_processLine();
106:Executive.c ****
107:Executive.c **** /* also check if serial data needs to be sent
108:Executive.c **** out through UIMgr */
109:Executive.c **** UIMgr_transmitPendingData();
110:Executive.c ****
111:Executive.c **** /* we can't just call acquire line again here,
112:Executive.c **** since we don't know if we need to acquire another
113:Executive.c **** line or not (it depends on the FrameMgr to figure
114:Executive.c **** this out) */
115:Executive.c **** }
116:Executive.c **** if (fastEventBitmask & FEV_PROCESS_LINE_COMPLETE)
117:Executive.c **** {
118:Executive.c **** DISABLE_INTS();
119:Executive.c **** fastEventBitmask &= ~FEV_PROCESS_LINE_COMPLETE;
120:Executive.c **** ENABLE_INTS();
121:Executive.c **** FrameMgr_acquireLine();
122:Executive.c **** }
123:Executive.c **** }
124:Executive.c ****
125:Executive.c **** if (IS_DATA_IN_EVENT_FIFO() == TRUE)
126:Executive.c **** {
127:Executive.c **** eventGenerated = Exec_readEventFifo();
128:Executive.c **** switch(eventGenerated)
129:Executive.c **** {
130:Executive.c **** case (EV_DUMP_FRAME):
131:Executive.c **** FrameMgr_dispatchEvent(eventGenerated);
132:Executive.c **** break;
133:Executive.c ****
134:Executive.c **** case (EV_ENABLE_TRACKING):
135:Executive.c **** FrameMgr_dispatchEvent(eventGenerated);
136:Executive.c **** break;
GAS LISTING /tmp/cceEDT7g.s page 5
 
 
137:Executive.c ****
138:Executive.c **** case (EV_DISABLE_TRACKING):
139:Executive.c **** FrameMgr_dispatchEvent(eventGenerated);
140:Executive.c **** break;
141:Executive.c ****
142:Executive.c **** case (EV_ACQUIRE_LINE_COMPLETE):
143:Executive.c **** FrameMgr_dispatchEvent(eventGenerated);
144:Executive.c **** UIMgr_dispatchEvent(eventGenerated);
145:Executive.c **** break;
146:Executive.c ****
147:Executive.c **** case (EV_ACQUIRE_FRAME_COMPLETE):
148:Executive.c **** FrameMgr_dispatchEvent(eventGenerated);
149:Executive.c **** break;
150:Executive.c ****
151:Executive.c **** case (EV_PROCESS_LINE_COMPLETE):
152:Executive.c **** FrameMgr_dispatchEvent(eventGenerated);
153:Executive.c **** break;
154:Executive.c ****
155:Executive.c **** case (EV_PROCESS_FRAME_COMPLETE):
156:Executive.c **** FrameMgr_dispatchEvent(eventGenerated);
157:Executive.c **** break;
158:Executive.c ****
159:Executive.c **** case (EV_SERIAL_DATA_RECEIVED):
160:Executive.c **** UIMgr_dispatchEvent(eventGenerated);
161:Executive.c **** FrameMgr_dispatchEvent(eventGenerated);
162:Executive.c **** break;
163:Executive.c ****
164:Executive.c **** case (EV_SERIAL_DATA_PENDING_TX):
165:Executive.c **** UIMgr_dispatchEvent(eventGenerated);
166:Executive.c **** break;
167:Executive.c ****
168:Executive.c **** default:
169:Executive.c **** break;
170:Executive.c **** }
171:Executive.c **** }
172:Executive.c ****
173:Executive.c **** /* toggle the debug line */
174:Executive.c ****
175:Executive.c **** }
176:Executive.c **** }
177:Executive.c ****
178:Executive.c **** /***********************************************************
179:Executive.c **** Function Name: Exec_readEventFifo
180:Executive.c **** Function Description: This function is responsible for
181:Executive.c **** reading a single event out of the event fifo.
182:Executive.c **** Inputs: none
183:Executive.c **** Outputs: unsigned char-the data read
184:Executive.c **** ***********************************************************/
185:Executive.c **** static unsigned char Exec_readEventFifo(void)
186:Executive.c **** {
187:Executive.c **** unsigned char dataByte, tmpTail;
188:Executive.c ****
189:Executive.c **** DISABLE_INTS();
190:Executive.c **** /* just return the current tail from the tx fifo */
191:Executive.c **** dataByte = Exec_eventFifo[Exec_eventFifoTail];
192:Executive.c **** tmpTail = (Exec_eventFifoTail+1) & (EXEC_EVENT_FIFO_MASK);
193:Executive.c **** Exec_eventFifoTail = tmpTail;
GAS LISTING /tmp/cceEDT7g.s page 6
 
 
194:Executive.c **** ENABLE_INTS();
195:Executive.c ****
196:Executive.c **** return(dataByte);
197:Executive.c **** }
198:Executive.c ****
199:Executive.c **** /***********************************************************
200:Executive.c **** Function Name: Exec_writeEventFifo
201:Executive.c **** Function Description: This function is responsible for
202:Executive.c **** writing a single event to the event fifo and
203:Executive.c **** updating the appropriate pointers.
204:Executive.c **** Inputs: data - the byte to write to the Fifo
205:Executive.c **** Outputs: none
206:Executive.c **** ***********************************************************/
207:Executive.c **** void Exec_writeEventFifo(unsigned char event)
208:Executive.c **** {
93 .stabn 68,0,208,.LM0-Exec_writeEventFifo
94 .LM0:
95 /* prologue: frame size=0 */
96 /* prologue end (size=0) */
209:Executive.c **** unsigned char tmpHead;
210:Executive.c ****
211:Executive.c **** DISABLE_INTS();
97 .stabn 68,0,211,.LM1-Exec_writeEventFifo
98 .LM1:
99 /* #APP */
100 0000 F894 cli
212:Executive.c **** Exec_eventFifo[Exec_eventFifoHead] = event;
101 .stabn 68,0,212,.LM2-Exec_writeEventFifo
102 .LM2:
103 /* #NOAPP */
104 0002 9091 0000 lds r25,Exec_eventFifoHead
105 0006 E0E0 ldi r30,lo8(Exec_eventFifo)
106 0008 F0E0 ldi r31,hi8(Exec_eventFifo)
107 000a E90F add r30,r25
108 000c F11D adc r31,__zero_reg__
109 000e 8083 st Z,r24
213:Executive.c ****
214:Executive.c **** /* now move the head up */
215:Executive.c **** tmpHead = (Exec_eventFifoHead + 1) & (EXEC_EVENT_FIFO_MASK);
216:Executive.c **** Exec_eventFifoHead = tmpHead;
110 .stabn 68,0,216,.LM3-Exec_writeEventFifo
111 .LM3:
112 0010 9F5F subi r25,lo8(-(1))
113 0012 9770 andi r25,lo8(7)
114 0014 9093 0000 sts Exec_eventFifoHead,r25
217:Executive.c **** ENABLE_INTS();
115 .stabn 68,0,217,.LM4-Exec_writeEventFifo
116 .LM4:
117 /* #APP */
118 0018 7894 sei
119 /* #NOAPP */
120 /* epilogue: frame size=0 */
121 001a 0895 ret
122 /* epilogue end (size=1) */
123 /* function Exec_writeEventFifo size 16 (15) */
124 .size Exec_writeEventFifo, .-Exec_writeEventFifo
125 .Lscope0:
GAS LISTING /tmp/cceEDT7g.s page 7
 
 
126 .stabs "",36,0,0,.Lscope0-Exec_writeEventFifo
127 .stabd 78,0,0
128 .stabs "Exec_run:F(0,15)",36,0,90,Exec_run
129 .global Exec_run
130 .type Exec_run, @function
131 Exec_run:
132 .stabd 46,0,0
133 .stabn 68,0,90,.LM5-Exec_run
134 .LM5:
135 /* prologue: frame size=0 */
136 /* prologue end (size=0) */
137 .L30:
138 .stabn 68,0,95,.LM6-Exec_run
139 .LM6:
140 001c 8091 0000 lds r24,fastEventBitmask
141 0020 8823 tst r24
142 0022 99F0 breq .L6
143 .stabn 68,0,100,.LM7-Exec_run
144 .LM7:
145 0024 80FF sbrs r24,0
146 0026 07C0 rjmp .L8
147 .stabn 68,0,102,.LM8-Exec_run
148 .LM8:
149 /* #APP */
150 0028 F894 cli
151 .stabn 68,0,103,.LM9-Exec_run
152 .LM9:
153 /* #NOAPP */
154 002a 8E7F andi r24,lo8(-2)
155 002c 8093 0000 sts fastEventBitmask,r24
156 .stabn 68,0,104,.LM10-Exec_run
157 .LM10:
158 /* #APP */
159 0030 7894 sei
160 .stabn 68,0,105,.LM11-Exec_run
161 .LM11:
162 /* #NOAPP */
163 0032 00D0 rcall FrameMgr_processLine
164 .stabn 68,0,109,.LM12-Exec_run
165 .LM12:
166 0034 00D0 rcall UIMgr_transmitPendingData
167 .L8:
168 .stabn 68,0,116,.LM13-Exec_run
169 .LM13:
170 0036 8091 0000 lds r24,fastEventBitmask
171 003a 81FF sbrs r24,1
172 003c 06C0 rjmp .L6
173 .stabn 68,0,118,.LM14-Exec_run
174 .LM14:
175 /* #APP */
176 003e F894 cli
177 .stabn 68,0,119,.LM15-Exec_run
178 .LM15:
179 /* #NOAPP */
180 0040 8D7F andi r24,lo8(-3)
181 0042 8093 0000 sts fastEventBitmask,r24
182 .stabn 68,0,120,.LM16-Exec_run
GAS LISTING /tmp/cceEDT7g.s page 8
 
 
183 .LM16:
184 /* #APP */
185 0046 7894 sei
186 .stabn 68,0,121,.LM17-Exec_run
187 .LM17:
188 /* #NOAPP */
189 0048 00D0 rcall FrameMgr_acquireLine
190 .L6:
191 .stabn 68,0,125,.LM18-Exec_run
192 .LM18:
193 004a 2091 0000 lds r18,Exec_eventFifoTail
194 004e 8091 0000 lds r24,Exec_eventFifoHead
195 0052 8217 cp r24,r18
196 0054 19F3 breq .L30
197 .LBB4:
198 .LBB5:
199 .stabn 68,0,189,.LM19-Exec_run
200 .LM19:
201 /* #APP */
202 0056 F894 cli
203 .stabn 68,0,191,.LM20-Exec_run
204 .LM20:
205 /* #NOAPP */
206 0058 E22F mov r30,r18
207 005a FF27 clr r31
208 005c E050 subi r30,lo8(-(Exec_eventFifo))
209 005e F040 sbci r31,hi8(-(Exec_eventFifo))
210 0060 9081 ld r25,Z
211 .stabn 68,0,193,.LM21-Exec_run
212 .LM21:
213 0062 822F mov r24,r18
214 0064 8F5F subi r24,lo8(-(1))
215 0066 8770 andi r24,lo8(7)
216 0068 8093 0000 sts Exec_eventFifoTail,r24
217 .stabn 68,0,194,.LM22-Exec_run
218 .LM22:
219 /* #APP */
220 006c 7894 sei
221 /* #NOAPP */
222 .LBE5:
223 .LBE4:
224 .stabn 68,0,128,.LM23-Exec_run
225 .LM23:
226 006e 892F mov r24,r25
227 0070 9927 clr r25
228 0072 8031 cpi r24,lo8(16)
229 0074 31F1 breq .L16
230 0076 8131 cpi r24,lo8(17)
231 0078 68F4 brsh .L21
232 007a 8230 cpi r24,lo8(2)
233 007c C9F0 breq .L13
234 007e 8330 cpi r24,lo8(3)
235 0080 18F4 brsh .L22
236 0082 8130 cpi r24,lo8(1)
237 0084 59F6 brne .L30
238 0086 2BC0 rjmp .L12
239 .L22:
GAS LISTING /tmp/cceEDT7g.s page 9
 
 
240 0088 8430 cpi r24,lo8(4)
241 008a 31F1 breq .L14
242 008c 8830 cpi r24,lo8(8)
243 008e 09F0 breq .+2
244 0090 C5CF rjmp .L30
245 0092 1FC0 rjmp .L15
246 .L21:
247 0094 8038 cpi r24,lo8(-128)
248 0096 79F0 breq .L18
249 0098 8138 cpi r24,lo8(-127)
250 009a 20F4 brsh .L23
251 009c 8032 cpi r24,lo8(32)
252 009e 09F0 breq .+2
253 00a0 BDCF rjmp .L30
254 00a2 14C0 rjmp .L17
255 .L23:
256 00a4 8138 cpi r24,lo8(-127)
257 00a6 51F0 breq .L19
258 00a8 8039 cpi r24,lo8(-112)
259 00aa 09F0 breq .+2
260 00ac B7CF rjmp .L30
261 00ae 1CC0 rjmp .L20
262 .L13:
263 .stabn 68,0,131,.LM24-Exec_run
264 .LM24:
265 00b0 82E0 ldi r24,lo8(2)
266 00b2 00D0 rcall FrameMgr_dispatchEvent
267 00b4 B3CF rjmp .L30
268 .L18:
269 .stabn 68,0,135,.LM25-Exec_run
270 .LM25:
271 00b6 80E8 ldi r24,lo8(-128)
272 00b8 00D0 rcall FrameMgr_dispatchEvent
273 00ba B0CF rjmp .L30
274 .L19:
275 .stabn 68,0,139,.LM26-Exec_run
276 .LM26:
277 00bc 81E8 ldi r24,lo8(-127)
278 00be 00D0 rcall FrameMgr_dispatchEvent
279 00c0 ADCF rjmp .L30
280 .L16:
281 .stabn 68,0,143,.LM27-Exec_run
282 .LM27:
283 00c2 80E1 ldi r24,lo8(16)
284 00c4 00D0 rcall FrameMgr_dispatchEvent
285 .stabn 68,0,144,.LM28-Exec_run
286 .LM28:
287 00c6 80E1 ldi r24,lo8(16)
288 00c8 00D0 rcall UIMgr_dispatchEvent
289 00ca A8CF rjmp .L30
290 .L17:
291 .stabn 68,0,148,.LM29-Exec_run
292 .LM29:
293 00cc 80E2 ldi r24,lo8(32)
294 00ce 00D0 rcall FrameMgr_dispatchEvent
295 00d0 A5CF rjmp .L30
296 .L15:
GAS LISTING /tmp/cceEDT7g.s page 10
 
 
297 .stabn 68,0,152,.LM30-Exec_run
298 .LM30:
299 00d2 88E0 ldi r24,lo8(8)
300 00d4 00D0 rcall FrameMgr_dispatchEvent
301 00d6 A2CF rjmp .L30
302 .L14:
303 .stabn 68,0,156,.LM31-Exec_run
304 .LM31:
305 00d8 84E0 ldi r24,lo8(4)
306 00da 00D0 rcall FrameMgr_dispatchEvent
307 00dc 9FCF rjmp .L30
308 .L12:
309 .stabn 68,0,160,.LM32-Exec_run
310 .LM32:
311 00de 81E0 ldi r24,lo8(1)
312 00e0 00D0 rcall UIMgr_dispatchEvent
313 .stabn 68,0,161,.LM33-Exec_run
314 .LM33:
315 00e2 81E0 ldi r24,lo8(1)
316 00e4 00D0 rcall FrameMgr_dispatchEvent
317 00e6 9ACF rjmp .L30
318 .L20:
319 .stabn 68,0,165,.LM34-Exec_run
320 .LM34:
321 00e8 80E9 ldi r24,lo8(-112)
322 00ea 00D0 rcall UIMgr_dispatchEvent
323 00ec 97CF rjmp .L30
324 /* epilogue: frame size=0 */
325 /* epilogue: noreturn */
326 /* epilogue end (size=0) */
327 /* function Exec_run size 111 (111) */
328 .size Exec_run, .-Exec_run
329 .stabs "dataByte:r(0,11)",64,0,187,25
330 .stabn 192,0,0,.LBB5-Exec_run
331 .stabn 224,0,0,.LBE5-Exec_run
332 .Lscope1:
333 .stabs "",36,0,0,.Lscope1-Exec_run
334 .stabd 78,0,0
335 .global Exec_eventFifoHead
336 .global Exec_eventFifoHead
337 .section .bss
338 .type Exec_eventFifoHead, @object
339 .size Exec_eventFifoHead, 1
340 Exec_eventFifoHead:
341 0000 00 .skip 1,0
342 .global Exec_eventFifoTail
343 .global Exec_eventFifoTail
344 .type Exec_eventFifoTail, @object
345 .size Exec_eventFifoTail, 1
346 Exec_eventFifoTail:
347 0001 00 .skip 1,0
348 .global fastEventBitmask
349 .global fastEventBitmask
350 .type fastEventBitmask, @object
351 .size fastEventBitmask, 1
352 fastEventBitmask:
353 0002 00 .skip 1,0
GAS LISTING /tmp/cceEDT7g.s page 11
 
 
354 .comm Exec_eventFifo,8,1
355 .stabs "fastEventBitmask:G(0,11)",32,0,74,0
356 .stabs "Exec_eventFifo:G(0,16)=ar(0,17)=r(0,17);0;0177777;;0;7;(0,11)",32,0,63,0
357 .stabs "Exec_eventFifoHead:G(0,11)",32,0,64,0
358 .stabs "Exec_eventFifoTail:G(0,11)",32,0,65,0
359 .text
360 .stabs "",100,0,0,.Letext0
361 .Letext0:
362 /* File "Executive.c": code 127 = 0x007f ( 126), prologues 0, epilogues 1 */
GAS LISTING /tmp/cceEDT7g.s page 12
 
 
DEFINED SYMBOLS
*ABS*:00000000 Executive.c
/tmp/cceEDT7g.s:3 *ABS*:0000003f __SREG__
/tmp/cceEDT7g.s:4 *ABS*:0000003e __SP_H__
/tmp/cceEDT7g.s:5 *ABS*:0000003d __SP_L__
/tmp/cceEDT7g.s:6 *ABS*:00000000 __tmp_reg__
/tmp/cceEDT7g.s:7 *ABS*:00000001 __zero_reg__
/tmp/cceEDT7g.s:91 .text:00000000 Exec_writeEventFifo
/tmp/cceEDT7g.s:340 .bss:00000000 Exec_eventFifoHead
*COM*:00000008 Exec_eventFifo
/tmp/cceEDT7g.s:131 .text:0000001c Exec_run
/tmp/cceEDT7g.s:352 .bss:00000002 fastEventBitmask
/tmp/cceEDT7g.s:346 .bss:00000001 Exec_eventFifoTail
 
UNDEFINED SYMBOLS
__do_copy_data
__do_clear_bss
FrameMgr_processLine
UIMgr_transmitPendingData
FrameMgr_acquireLine
FrameMgr_dispatchEvent
UIMgr_dispatchEvent
/programy/Atmel_C/AVRcam/FrameMgr.c
0,0 → 1,792
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/*********************************************************
Module Name: FrameMgr.c
Module Date: 04/10/2004
Module Auth: John Orlando
Description: This modules is responsible for performing
both medium and high level processing on image data.
This is performed at both the line level as well as
the frame level. It controls the main flow of the
system, adhering to all the critical timing
requirements (such as when serial data can be transferred,
etc).
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
11/15/2004 1.2 Updated processLine() function so
it will remove objects less than
a specified length/width (reduces
shot noise)
*********************************************************/
 
/* Includes */
#include <stdlib.h>
#include <string.h>
#include <avr/io.h>
#include "Executive.h"
#include "UIMgr.h"
#include "FrameMgr.h"
#include "CamInterface.h"
#include "UartInterface.h"
#include "Utility.h"
#include "I2CInterface.h"
#include "CamConfig.h"
#include "CommonDefs.h"
 
/* Local Structures and Typedefs */
enum
{
ST_FrameMgr_idle,
ST_FrameMgr_TrackingFrame,
ST_FrameMgr_DumpingFrame
};
 
typedef unsigned char FrameMgr_State_t;
 
/* Definitions */
/* The most objects that can be tracked at any one time is 8.
This number is determined by the number of bytes that can be
sent out during a frame (one byte per line, 144 lines per frame)
with the number of bytes in a tracked object (7) + some wiggle
room :-) ... I guess this could be increased to around 20 if
we had enough room and cycles to process objects between lines */
#define MAX_TRACKED_OBJECTS 8
 
/* This defines the number of bytes that make up a trackedObject_t
structure... */
#define SIZE_OF_TRACKED_OBJECT 8
 
/* This define is used to turn off the timer overflow interrupt
that is generated when the PCLK overflows TIMER1 */
#define DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK 0xFB
 
/* This define is used to determine if a run length is too small
to be concerned with. This helps to reduce the number of false
positives. */
#define MIN_OBJECT_TRACKING_WIDTH 3
 
/* This define is used to determine if an object has enough
height to be considered worth tracking...it is used to reduce
shot noise */
#define MIN_OBJECT_TRACKING_HEIGHT 3
 
/* This define is used to indicate how often the filter routine
that removes objects less than MIN_OBJECT_TRACKING_HEIGHT should
be executed. It is measured in a number of lines (7 nominally). */
#define RUN_OBJECT_FILTER_MASK 0x07
 
/* This enum describes the possible colors that can
be tracked by the system. This can't be represented as
simple color names (red, brown, etc) due to the fact that
the user sets which colors will be associated with which
bits. Remember...after the AND operation of the indexed
color map values executes, either a single bit indicating
the color should be set, or no bits indicating that the
color isn't represented in the color map (notTracked). */
enum
{
notTracked,
color1, /* bit 1 color */
color2, /* bit 2 color */
color3, /* bit 3 color */
color4, /* bit 4 color */
color5, /* bit 5 color */
color6, /* bit 6 color */
color7, /* bit 7 color */
color8 /* bit 8 color */
};
 
typedef unsigned char trackedColor_t;
 
/* This structure defines the info that needs to be
maintained for each trackedObject in the trackingTable */
typedef struct
{
trackedColor_t color;
unsigned char lastLineXStart;
unsigned char lastLineXFinish;
unsigned char x_upperLeft;
unsigned char y_upperLeft;
unsigned char x_lowerRight;
unsigned char y_lowerRight;
unsigned char objectValid; /* used to be a fill byte...now it is
used to determine if the object is valid
or not...it gets invalidated if it is
determined that it is too small, or
that the object is within another object */
} trackedObject_t;
 
/* These defines are used to index into each individual element in the
trackedObject_t structure. This seems to be MUCH more efficient than
accessing the elements in GCC. */
#define COLOR_OFFSET 0
#define LAST_LINE_X_START_OFFSET 1
#define LAST_LINE_X_FINISH_OFFSET 2
#define X_UPPER_LEFT_OFFSET 3
#define Y_UPPER_LEFT_OFFSET 4
#define X_LOWER_RIGHT_OFFSET 5
#define Y_LOWER_RIGHT_OFFSET 6
#define VALID_OBJECT_OFFSET 7
 
/* Local Variables */
/* The trackedObjectTable is used to hold up to eight tracked objects
while they are being acquired. */
static trackedObject_t trackedObjectTable[MAX_TRACKED_OBJECTS];
static trackedObject_t *pCurrentTrackedObjectTable = trackedObjectTable;
static unsigned char lineCount = 0;
static FrameMgr_State_t currentState = ST_FrameMgr_idle;
static unsigned char numCurrTrackedObjects = 0;
static unsigned char numPrevTrackedObjects = 0;
static unsigned char trackedLineCount = 0;
 
/* Local Functions */
static void FrameMgr_findConnectedness(void);
 
/* Extern Functions */
/* These functions are located in assembly files, and thus
must be externed here so they can be referenced in the source below. */
extern void CamIntAsm_waitForNewTrackingFrame(unsigned char *pBuffer, unsigned char *pMemLookup);
extern void CamIntAsm_waitForNewDumpFrame(unsigned char *pCurrBuffer, unsigned char *pPrevBuffer);
extern void CamIntAsm_acquireTrackingLine(unsigned char *pBuffer, unsigned char *pMemLookup);
extern void CamIntAsm_acquireDumpLine(unsigned char *pCurrBuffer, unsigned char *pPrevBuffer);
 
/***********************************************************
Function Name: FrameMgr_init
Function Description: This function is responsible
for initializing the FrameMgr. This includes
setting up the various buffers and data needed to
process each frame of image data.
Inputs: none
Outputs: none
***********************************************************/
void FrameMgr_init(void)
{
memset(trackedObjectTable,0x00,sizeof(trackedObjectTable));
}
 
 
/***********************************************************
Function Name: FrameMgr_dispatchEvent
Function Description: This function is responsible for
taking an incoming event and performing the needed
actions with it as pertains to the FrameMgr.
Inputs: event - the generated event
Outputs: none
***********************************************************/
void FrameMgr_dispatchEvent(unsigned char event)
{
switch(event)
{
case EV_DUMP_FRAME:
/* try re-initializing the camera before we start dumping */
CamConfig_setCamReg(0x11,0x01); /* reduce the frame rate for dumping*/
CamConfig_sendFifoCmds();
Utility_delay(1000); /* allow the new frame rate to settle */
lineCount = 0;
currentState = ST_FrameMgr_DumpingFrame;
//CamIntAsm_waitForNewDumpFrame(currentLineBuffer,previousLineBuffer);
FrameMgr_acquireLine();
break;
case EV_ENABLE_TRACKING:
currentState = ST_FrameMgr_TrackingFrame;
FrameMgr_acquireFrame();
break;
case EV_ACQUIRE_FRAME_COMPLETE:
FrameMgr_processFrame();
break;
case EV_PROCESS_FRAME_COMPLETE:
FrameMgr_acquireFrame();
break;
 
case EV_SERIAL_DATA_RECEIVED:
if (currentState != ST_FrameMgr_idle)
{
/* we need to go back to processing line data, since
serial data reception interrupted us....just trash the
frame and act like the frame has been processed, which
will kick off the system to wait for the next line */
PUBLISH_EVENT(EV_PROCESS_FRAME_COMPLETE);
}
break;
case EV_DISABLE_TRACKING:
/* tracking needs to be turned off */
currentState = ST_FrameMgr_idle;
break;
}
}
 
/***********************************************************
Function Name: FrameMgr_acquireFrame
Function Description: This function is responsible for
beginning of the acquisition of a new frame of data
from the camera interface. The acquisition of this line
depends on the current state of the FrameMgr.
Inputs: none
Outputs: none
***********************************************************/
void FrameMgr_acquireFrame(void)
{
if (currentState == ST_FrameMgr_TrackingFrame)
{
trackedLineCount = 0;
numPrevTrackedObjects = numCurrTrackedObjects;
numCurrTrackedObjects = 0;
/* clear out the tracking table, and wait for the new frame
to start */
memset(trackedObjectTable,0x00,sizeof(trackedObjectTable));
//CamIntAsm_waitForNewTrackingFrame(currentLineBuffer,colorMap);
WAIT_FOR_VSYNC_HIGH();
CamIntAsm_acquireTrackingLine(currentLineBuffer,colorMap);
}
}
 
/***********************************************************
Function Name: FrameMgr_acquireLine
Function Description: This function is responsible for
acquiring a line of data from the camera interface.
The acquisition of this line depends on the current
state of the FrameMgr.
Inputs: none
Outputs: none
***********************************************************/
void FrameMgr_acquireLine(void)
{
unsigned char tmpLineCount;
/* clearing out the buffers takes too long...we should
just overwrite the data here without a problem when
we start acquiring...at no point do we check for
a 0x00 value in the current or previous lineBuffers,
so it was a bit excessive :-) */
/* check which state we are in and proceed as needed */
if (currentState == ST_FrameMgr_DumpingFrame)
{
tmpLineCount = lineCount*2;
/* clearing out the line data in dump mode is ok, and actually
is needed, since it is possible for the first dump line in
a frame to come back with the last line captured of the
last capture session...*/
memset(currentLineBuffer,0x00,LENGTH_OF_LINE_BUFFER);
memset(previousLineBuffer,0x00,LENGTH_OF_LINE_BUFFER);
/* wait for another VSYNC so we know which frame to use
to start looking for a line to receive */
WAIT_FOR_VSYNC_HIGH();
WAIT_FOR_VSYNC_LOW();
/* look at lineCount to determine how many HREFs we should
wait before we start sampling */
while(tmpLineCount != 0)
{
WAIT_FOR_HREF_HIGH();
tmpLineCount--;
WAIT_FOR_HREF_LOW();
}
/* we should now be ready to sample our line...*/
CamIntAsm_acquireDumpLine(currentLineBuffer,previousLineBuffer);
}
else if (currentState == ST_FrameMgr_TrackingFrame)
{
WAIT_FOR_HREF_LOW();
CamIntAsm_acquireTrackingLine(currentLineBuffer,colorMap);
}
}
 
/***********************************************************
Function Name: FrameMgr_processLine
Function Description: This function is responsible for
parsing the received image line and performing either
connected region mapping (if in the Tracking state) or
sending out the raw sampled data (if in the Dumping
state).
Inputs: none
Outputs: none
***********************************************************/
void FrameMgr_processLine(void)
{
unsigned char i;
volatile unsigned char dataToSend;
unsigned char *pTrackedObjectData = (unsigned char *)pCurrentTrackedObjectTable;
#ifdef DEBUG_TRACKED_LINE
unsigned char *pSendData;
unsigned char asciiBuffer[5];
unsigned char pixelCount = 0;
#endif
if (currentState == ST_FrameMgr_DumpingFrame)
{
/* we want to sit in a tight loop and send the acquired data
sitting in current and previous line buffers out the serial
port...it is sent out the serial port immediately instead
of going into the UIMgr tx fifo because we can't do anything
until its sent out anyway...may as well just get it out now */
/* currentLineBuffer is getting "g" previousLineBuffer is getting "b-r" */
UartInt_txByte(0x0B); /* send the header byte */
UartInt_txByte(lineCount); /* send the line count */
for (i=0; i<NUM_PIXELS_IN_A_DUMP_LINE; i+=2)
{
/* when a dump line is sampled, the upper byte can potentially
have garbage in it...we don't have time to mask it off as we're
sampling, so it is done here before we send it out...we also
combine the samples together so we really are sending up a
sample for line N as well as line N+1 */
dataToSend = currentLineBuffer[i];
dataToSend &= 0x0F;
dataToSend <<= 4;
dataToSend |= (previousLineBuffer[i] & 0x0F);
/* dataToSend should be packed now */
UartInt_txByte(dataToSend);
/* flip the colors around since we are doing all G on Y and BR on UV */
dataToSend = previousLineBuffer[i+1];
dataToSend &= 0x0F;
dataToSend <<= 4;
dataToSend |= (currentLineBuffer[i+1] & 0x0F);
/* dataToSend should be packed now */
UartInt_txByte(dataToSend);
}
UartInt_txByte(0x0F); /* send line end */
/* once all the data is sent, increment out line count by 2 since
we really get 2 lines worth of pixels on each pass */
/* Update...increment only by 1, but only send 72 double-lines */
lineCount++;
/* check to see if we have retrieved all of the needed lines */
if (lineCount >= 72) /* half 144, since we send two lines at a time */
{
/* we're done, so send the dump complete?...nope, just change
states and we should be fine */
lineCount = 0;
currentState = ST_FrameMgr_idle;
/* disable the PCLK counting overflow interrupt */
TIMSK &= DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK;
CamConfig_setCamReg(0x11,0x00); /* reset the frame rate to normal*/
CamConfig_sendFifoCmds();
}
else
{
/* we have more lines to acquire in this frame, so keep on truckin...*/
PUBLISH_FAST_EVENT(FEV_PROCESS_LINE_COMPLETE);
}
}
else if (currentState == ST_FrameMgr_TrackingFrame)
{
#ifdef DEBUG_TRACKED_LINE
/* send the received line over serial...this should only send
until a pixelCount == 176 */
pSendData = currentLineBuffer;
itoa(trackedLineCount,asciiBuffer,10);
UIMgr_txBuffer(asciiBuffer,3);
UIMgr_txBuffer(" ",1);
while(pixelCount < ACTUAL_NUM_PIXELS_IN_A_LINE)
{
memset(asciiBuffer,0x00,5);
itoa(*pSendData++,asciiBuffer,10); /* color is first byte */
UIMgr_txBuffer(asciiBuffer,3); /* 3 ascii bytes for data */
UIMgr_txBuffer(" ",1);
 
pixelCount += *pSendData; /* run-length is second byte */
memset(asciiBuffer,0x00,5);
itoa(*pSendData++,asciiBuffer,10);
UIMgr_txBuffer(asciiBuffer,3);
UIMgr_txBuffer(" ",1);
}
UIMgr_txBuffer("\n\r",2);
 
trackedLineCount++;
if (trackedLineCount == 144)
{
UIMgr_txBuffer(" FC \n\r",8);
trackedLineCount = 0;
PUBLISH_EVENT(EV_PROCESS_FRAME_COMPLETE);
}
else
{
PUBLISH_EVENT(EV_PROCESS_LINE_COMPLETE);
}
#else
/* determine if any of the RLE blocks overlap */
FrameMgr_findConnectedness();
/* we also want to remove any objects that are less than
a minimum height...we already removed portions of the
run-length that are less than MIN_PIXEL_WIDTH in the
findConnectedness() routine...doing it here instead of
a function to speed things up...this may end up slowing down the
frame rate slightly, and can be removed if this isn't needed */
/* run this routine once every 8 lines */
if ( (trackedLineCount & RUN_OBJECT_FILTER_MASK) == RUN_OBJECT_FILTER_MASK)
{
for (i=0; i<MAX_TRACKED_OBJECTS; i++)
{
if ( *(pTrackedObjectData + VALID_OBJECT_OFFSET) == TRUE)
{
/* check to see if the object is already in
our past...i.e., its last */
if ( (*(pTrackedObjectData + Y_LOWER_RIGHT_OFFSET) -
*(pTrackedObjectData + Y_UPPER_LEFT_OFFSET)) < MIN_OBJECT_TRACKING_HEIGHT)
{
/* the object is less than the minimum height...see if it is adjacent
to the current line we just processed...if so, leave it here...otherwise,
it needs to be invalidated since its too small */
if ( trackedLineCount - *(pTrackedObjectData + Y_LOWER_RIGHT_OFFSET) > 2)
{
/* invalidate the object */
*(pTrackedObjectData + VALID_OBJECT_OFFSET) = FALSE;
numCurrTrackedObjects--;
}
}
}
pTrackedObjectData += SIZE_OF_TRACKED_OBJECT;
}
}
trackedLineCount++;
if (trackedLineCount == ACTUAL_NUM_LINES_IN_A_FRAME)
{
/* an entire frame of tracking data has been acquired, so
publish an event letting the system know this fact */
PUBLISH_EVENT(EV_ACQUIRE_FRAME_COMPLETE);
/* disable the PCLK counting overflow interrupt */
TIMSK &= DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK;
trackedLineCount = 0;
}
else
{
PUBLISH_FAST_EVENT(FEV_PROCESS_LINE_COMPLETE);
}
#endif
}
else
{
/* ...and here? */
}
}
 
/***********************************************************
Function Name: FrameMgr_processFrame
Function Description: This function is responsible for
parsing the completed frame and performing all actions
needed at this level.
Inputs: none
Outputs: none
***********************************************************/
void FrameMgr_processFrame(void)
{
unsigned char i,k,color;
#if DEBUG_FRAME_DATA
unsigned char asciiBuffer[5];
unsigned char j;
#endif
unsigned char *pTableData = (unsigned char *)pCurrentTrackedObjectTable;
unsigned char tmpUpperLeftX,tmpUpperLeftY,tmpLowerRightX,tmpLowerRightY;
#if DEBUG_FRAME_DATA
/* we want to send all of the currently tracked table out
the serial port for debugging */
for (i=0; i<numCurrTrackedObjects; i++)
{
UIMgr_txBuffer("----------\r\n",12);
for (j=0; j<SIZE_OF_TRACKED_OBJECT; j++)
{
memset(asciiBuffer,0x00,5);
itoa(*pTableData++,asciiBuffer,10);
UIMgr_txBuffer(asciiBuffer,3); /* 3 ascii bytes for data
+ 1 space */
UIMgr_txBuffer("\r\n",2);
}
}
/* finally, send a new line */
UIMgr_txBuffer("\r\n",2);
memset(asciiBuffer,0x00,5);
itoa(numCurrTrackedObjects,asciiBuffer,10);
UIMgr_txBuffer(asciiBuffer,3);
UIMgr_txBuffer(" PFC\r\n",5);
 
#else
/* we only send tracking packets if there are tracked objects */
if (numCurrTrackedObjects > 0)
{
UIMgr_writeTxFifo(0x0A); /* header byte for a tracking packet */
/* reset the pointer */
pTableData = (unsigned char *)pCurrentTrackedObjectTable;
UIMgr_writeTxFifo(numCurrTrackedObjects); /* num of objects tracked */
for (i=0; i<MAX_TRACKED_OBJECTS; i++)
{
/* we only want to process objects that have their objectValid flag
set to TRUE */
if ( *(pTableData + VALID_OBJECT_OFFSET) == TRUE)
{
/* the object is valid...convert the color from bit position to value...remember,
each bit in the "color" byte corresponds to a color */
k=0;
color = *(pTableData + COLOR_OFFSET);
if (color == 128) k=0;
else if (color == 64) k=1;
else if (color == 32) k=2;
else if (color == 16) k=3;
else if (color == 8) k=4;
else if (color == 4) k=5;
else if (color == 2) k=6;
else if (color == 1) k=7;
tmpUpperLeftX = *(pTableData + X_UPPER_LEFT_OFFSET); /* get the upper left X */
tmpUpperLeftY = *(pTableData + Y_UPPER_LEFT_OFFSET); /* get the upper left Y */
tmpLowerRightX = *(pTableData + X_LOWER_RIGHT_OFFSET); /* get the lower right X */
tmpLowerRightY = *(pTableData + Y_LOWER_RIGHT_OFFSET); /* get the lower right Y */
UIMgr_writeTxFifo(k); /* send the color first */
UIMgr_writeTxFifo(tmpUpperLeftX);
UIMgr_writeTxFifo(tmpUpperLeftY);
UIMgr_writeTxFifo(tmpLowerRightX);
UIMgr_writeTxFifo(tmpLowerRightY);
}
 
/* move our pointer up to the beginning of the next object */
pTableData += SIZE_OF_TRACKED_OBJECT;
}
/* all done...send the end of tracking packets char */
UIMgr_writeTxFifo(0xFF);
}
#endif
 
/* the tracked object table will be cleared out right before we start
to wait for VSYNC to indicate a new frame...so it doesn't need to be
done now */
/* schedule the next action to acquire a new frame */
PUBLISH_EVENT(EV_PROCESS_FRAME_COMPLETE);
}
 
/***********************************************************
Function Name: FrameMgr_findConnectedness
Function Description: This function is responsible for
finding the connectedness between two particular run-
length encoded lines of pixel data. It updates the
trackingTable as needed.
Inputs: none
Outputs: none
***********************************************************/
static void FrameMgr_findConnectedness(void)
{
trackedColor_t currColor;
unsigned char *pCurrLineColorInfo = currentLineBuffer;
unsigned char *pTrackedObjectData;
register unsigned char currPixelRunStart=0;
register unsigned char currPixelRunFinish=0;
register unsigned char lastLineXStart=0;
register unsigned char lastLineXFinish=0;
register unsigned char runLength=1;
unsigned char i;
bool_t colorConnected;
do
{
/* grab both the current color and the number of pixels
in the run...remember, pixels start at 1, not 0! */
colorConnected = FALSE;
currColor = *pCurrLineColorInfo++;
currPixelRunStart += runLength;
runLength = *pCurrLineColorInfo++;
currPixelRunFinish += runLength;
/* make sure that the run-length is at least as wide as
the minimum horizontal tracking width, and we care about the color */
if ( (currColor != notTracked) && (runLength > MIN_OBJECT_TRACKING_WIDTH) )
{
/* this run contains a color we care about, so
either it will begin a new tracked object, or it
is connected to a currently tracked object...
compare it with each object in the tracking
table...we can't just look at the numTrackedObjects because
it is entirely possible that the first couple of objects could
be invalid...
 
NOTE: Instead of accessing each element in the trackedObjectTable
through the 'i' index, and then accessing the fields in each structure,
a pointer to each entry is established each time through the loop, followed
by accessing the elements through specified offsets. GCC seems to be
able to optimize this code much better than simply accessing the elements
of each structure in the array the more normal way...*/
pTrackedObjectData = (unsigned char *)pCurrentTrackedObjectTable;
for (i=0; i<MAX_TRACKED_OBJECTS; i++)
{
if ( (currColor == *(pTrackedObjectData + COLOR_OFFSET)) &&
(*(pTrackedObjectData + VALID_OBJECT_OFFSET) == TRUE) &&
(*(pTrackedObjectData + Y_LOWER_RIGHT_OFFSET) == trackedLineCount - 1) )
{
/* found a color match and the object is valid...check to see if there is
connectedness */
lastLineXStart = *(pTrackedObjectData + LAST_LINE_X_START_OFFSET);
lastLineXFinish = *(pTrackedObjectData + LAST_LINE_X_FINISH_OFFSET);
/* Check for the 5 following types of line connectedness:
---------------------
| |
---------------------
-------------------------
| |
------------------------- */
if ( ( (currPixelRunStart >= lastLineXStart) &&
(currPixelRunStart <= lastLineXFinish) ) ||
/* ---------------------
| |
---------------------
-------------------
| |
-------------------
OR
------------------------------
| |
------------------------------
---------
| |
--------- */
( (currPixelRunFinish >= lastLineXStart) &&
(currPixelRunFinish <= lastLineXFinish) ) ||
/* -------------------------------
| |
-------------------------------
-------------------------------
| |
-------------------------------
OR
-------------
| |
-------------
-------------------------------
| |
------------------------------- */
( (currPixelRunStart <= lastLineXStart) &&
(currPixelRunFinish >= lastLineXFinish) ) )
{
/* THERE IS CONNECTEDNESS...update the lastLineXStart and lastLineXFinish
data pointed to by pTrackedObjectData */
*(pTrackedObjectData + LAST_LINE_X_START_OFFSET) = currPixelRunStart;
*(pTrackedObjectData + LAST_LINE_X_FINISH_OFFSET) = currPixelRunFinish;
/* check if the bounding box needs to be updated */
if (*(pTrackedObjectData + X_UPPER_LEFT_OFFSET) > currPixelRunStart)
{
/* need to update the bounding box for the upper left point to
enclose this new left-most point...we never have to update the
upper left Y point, since each scan line we process moves from
top to bottom */
*(pTrackedObjectData + X_UPPER_LEFT_OFFSET) = currPixelRunStart;
}
 
if ( *(pTrackedObjectData + X_LOWER_RIGHT_OFFSET) < currPixelRunFinish)
{
/* need to update the bounding box for the lower right X point to
enclose this new right-most point */
*(pTrackedObjectData + X_LOWER_RIGHT_OFFSET) = currPixelRunFinish;
}
/* the lower right 'y' point always gets updated when connectedness is found */
*(pTrackedObjectData + Y_LOWER_RIGHT_OFFSET) = trackedLineCount;
/* set a flag indicating that that color run is part of another
object and thus doesn't need to be added as a new entry into the
tracking table */
colorConnected = TRUE;
break;
}
}
/* go to the next object */
pTrackedObjectData += SIZE_OF_TRACKED_OBJECT;
}
if (colorConnected == FALSE)
{
/* a new entry needs to be made to the tracking table, since we have
a run-length with a color, and it isn't connected to anything...but we
can only do this if there is space left in the trackedObject table */
if (numCurrTrackedObjects < MAX_TRACKED_OBJECTS)
{
/* space is available...add the object...but first we need to find an
invalid object in the object tracking table */
pTrackedObjectData = (unsigned char *)pCurrentTrackedObjectTable;
for (i=0; i<MAX_TRACKED_OBJECTS; i++)
{
if ( *(pTrackedObjectData + VALID_OBJECT_OFFSET) == FALSE) break;
/* if we haven't broken above, then the object must have been valid...
go ahead and move the pointer to the next object to check it */
pTrackedObjectData += SIZE_OF_TRACKED_OBJECT;
}
/* now that we have a pointer to the tracked object to be updated, update all
the fields */
*(pTrackedObjectData + COLOR_OFFSET) = currColor; /* color */
*(pTrackedObjectData + LAST_LINE_X_START_OFFSET) = currPixelRunStart; /* lastLineXStart */
*(pTrackedObjectData + LAST_LINE_X_FINISH_OFFSET) = currPixelRunFinish; /* lastLineXFinish */
*(pTrackedObjectData + X_UPPER_LEFT_OFFSET) = currPixelRunStart; /* x_upperLeft */
*(pTrackedObjectData + Y_UPPER_LEFT_OFFSET) = trackedLineCount; /* y_upperLeft */
*(pTrackedObjectData + X_LOWER_RIGHT_OFFSET) = currPixelRunFinish; /* x_lowerRight */
*(pTrackedObjectData + Y_LOWER_RIGHT_OFFSET) = trackedLineCount; /* y_lowerRight */
*(pTrackedObjectData + VALID_OBJECT_OFFSET) = TRUE; /* objectValid flag */
numCurrTrackedObjects++;
}
}
/* move the pointer to the beginning of the next tracked object */
pTrackedObjectData += SIZE_OF_TRACKED_OBJECT;
}
} while(currPixelRunFinish < ACTUAL_NUM_PIXELS_IN_A_LINE);
}
 
/programy/Atmel_C/AVRcam/FrameMgr.d
0,0 → 1,3
FrameMgr.o FrameMgr.d : FrameMgr.c Executive.h Events.h UIMgr.h FrameMgr.h \
CamInterface.h UartInterface.h Utility.h I2CInterface.h CommonDefs.h \
CamConfig.h
/programy/Atmel_C/AVRcam/FrameMgr.h
0,0 → 1,58
#ifndef FRAMEMGR_H
#define FRAMEMGR_H
 
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: FrameMgr.h
Module Date: 04/10/2004
Module Auth: John Orlando
Description: This module provides the external interface
to the FrameMgr module.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
***********************************************************/
 
/* Extern Variables */
extern unsigned char testLineCount;
/* External Function Declarations */
extern void FrameMgr_init(void);
extern void FrameMgr_processLine(void);
extern void FrameMgr_processFrame(void);
extern void FrameMgr_acquireLine(void);
extern void FrameMgr_acquireFrame(void);
extern void FrameMgr_dispatchEvent(unsigned char event);
 
#endif
 
/programy/Atmel_C/AVRcam/FrameMgr.lst
0,0 → 1,2036
GAS LISTING /tmp/ccf43P2i.s page 1
 
 
1 .file "FrameMgr.c"
2 .arch atmega8
3 __SREG__ = 0x3f
4 __SP_H__ = 0x3e
5 __SP_L__ = 0x3d
6 __tmp_reg__ = 0
7 __zero_reg__ = 1
8 .global __do_copy_data
9 .global __do_clear_bss
10 .stabs "/home/kaklik/projects/roboti/istrobot/2007/ATmega8/AVRcam/",100,0,2,.Ltext0
11 .stabs "FrameMgr.c",100,0,2,.Ltext0
12 .text
13 .Ltext0:
14 .stabs "gcc2_compiled.",60,0,0,0
15 .stabs "int:t(0,1)=r(0,1);-32768;32767;",128,0,0,0
16 .stabs "char:t(0,2)=@s8;r(0,2);0;255;",128,0,0,0
17 .stabs "long int:t(0,3)=@s32;r(0,3);020000000000;017777777777;",128,0,0,0
18 .stabs "unsigned int:t(0,4)=r(0,4);0;0177777;",128,0,0,0
19 .stabs "long unsigned int:t(0,5)=@s32;r(0,5);0;037777777777;",128,0,0,0
20 .stabs "long long int:t(0,6)=@s64;r(0,6);01000000000000000000000;0777777777777777777777;",128,0,0,
21 .stabs "long long unsigned int:t(0,7)=@s64;r(0,7);0;01777777777777777777777;",128,0,0,0
22 .stabs "short int:t(0,8)=r(0,8);-32768;32767;",128,0,0,0
23 .stabs "short unsigned int:t(0,9)=r(0,9);0;0177777;",128,0,0,0
24 .stabs "signed char:t(0,10)=@s8;r(0,10);-128;127;",128,0,0,0
25 .stabs "unsigned char:t(0,11)=@s8;r(0,11);0;255;",128,0,0,0
26 .stabs "float:t(0,12)=r(0,1);4;0;",128,0,0,0
27 .stabs "double:t(0,13)=r(0,1);4;0;",128,0,0,0
28 .stabs "long double:t(0,14)=r(0,1);4;0;",128,0,0,0
29 .stabs "void:t(0,15)=(0,15)",128,0,0,0
30 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/stdlib.h",130,0,0,0
31 .stabs "/usr/lib/gcc/avr/4.1.0/include/stddef.h",130,0,0,0
32 .stabs "size_t:t(2,1)=(0,4)",128,0,214,0
33 .stabs "wchar_t:t(2,2)=(0,1)",128,0,326,0
34 .stabn 162,0,0,0
35 .stabs "div_t:t(1,1)=(1,2)=s4quot:(0,1),0,16;rem:(0,1),16,16;;",128,0,69,0
36 .stabs "ldiv_t:t(1,3)=(1,4)=s8quot:(0,3),0,32;rem:(0,3),32,32;;",128,0,75,0
37 .stabs "__compar_fn_t:t(1,5)=(1,6)=*(1,7)=f(0,1)",128,0,78,0
38 .stabn 162,0,0,0
39 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/io.h",130,0,0,0
40 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/sfr_defs.h",130,0,0,0
41 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/inttypes.h",130,0,0,0
42 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/stdint.h",130,0,0,0
43 .stabs "int8_t:t(6,1)=(0,10)",128,0,116,0
44 .stabs "uint8_t:t(6,2)=(0,11)",128,0,117,0
45 .stabs "int16_t:t(6,3)=(0,1)",128,0,118,0
46 .stabs "uint16_t:t(6,4)=(0,4)",128,0,119,0
47 .stabs "int32_t:t(6,5)=(0,3)",128,0,120,0
48 .stabs "uint32_t:t(6,6)=(0,5)",128,0,121,0
49 .stabs "int64_t:t(6,7)=(0,6)",128,0,122,0
50 .stabs "uint64_t:t(6,8)=(0,7)",128,0,123,0
51 .stabs "intptr_t:t(6,9)=(6,3)",128,0,135,0
52 .stabs "uintptr_t:t(6,10)=(6,4)",128,0,140,0
53 .stabs "int_least8_t:t(6,11)=(6,1)",128,0,152,0
54 .stabs "uint_least8_t:t(6,12)=(6,2)",128,0,157,0
55 .stabs "int_least16_t:t(6,13)=(6,3)",128,0,162,0
56 .stabs "uint_least16_t:t(6,14)=(6,4)",128,0,167,0
57 .stabs "int_least32_t:t(6,15)=(6,5)",128,0,172,0
GAS LISTING /tmp/ccf43P2i.s page 2
 
 
58 .stabs "uint_least32_t:t(6,16)=(6,6)",128,0,177,0
59 .stabs "int_least64_t:t(6,17)=(6,7)",128,0,182,0
60 .stabs "uint_least64_t:t(6,18)=(6,8)",128,0,187,0
61 .stabs "int_fast8_t:t(6,19)=(6,1)",128,0,200,0
62 .stabs "uint_fast8_t:t(6,20)=(6,2)",128,0,205,0
63 .stabs "int_fast16_t:t(6,21)=(6,3)",128,0,210,0
64 .stabs "uint_fast16_t:t(6,22)=(6,4)",128,0,215,0
65 .stabs "int_fast32_t:t(6,23)=(6,5)",128,0,220,0
66 .stabs "uint_fast32_t:t(6,24)=(6,6)",128,0,225,0
67 .stabs "int_fast64_t:t(6,25)=(6,7)",128,0,230,0
68 .stabs "uint_fast64_t:t(6,26)=(6,8)",128,0,235,0
69 .stabs "intmax_t:t(6,27)=(6,7)",128,0,249,0
70 .stabs "uintmax_t:t(6,28)=(6,8)",128,0,254,0
71 .stabn 162,0,0,0
72 .stabs "int_farptr_t:t(5,1)=(6,5)",128,0,76,0
73 .stabs "uint_farptr_t:t(5,2)=(6,6)",128,0,80,0
74 .stabn 162,0,0,0
75 .stabn 162,0,0,0
76 .stabn 162,0,0,0
77 .stabs "I2CInterface.h",130,0,0,0
78 .stabs "CommonDefs.h",130,0,0,0
79 .stabs "bool_t:t(8,1)=(0,11)",128,0,56,0
80 .stabn 162,0,0,0
81 .stabs "i2cCmd_t:t(7,1)=(7,2)=s2configReg:(0,11),0,8;data:(0,11),8,8;;",128,0,53,0
82 .stabn 162,0,0,0
83 .stabs " :T(0,16)=@s8;eST_FrameMgr_idle:0,ST_FrameMgr_TrackingFrame:1,ST_FrameMgr_DumpingFrame:2,;
84 .stabs "FrameMgr_State_t:t(0,17)=(0,11)",128,0,72,0
85 .stabs " :T(0,18)=@s8;enotTracked:0,color1:1,color2:2,color3:3,color4:4,color5:5,color6:6,color7:7
86 .stabs "trackedColor_t:t(0,19)=(0,11)",128,0,127,0
87 .stabs "trackedObject_t:t(0,20)=(0,21)=s8color:(0,19),0,8;lastLineXStart:(0,11),8,8;lastLineXFinis
88 .stabs "FrameMgr_processFrame:F(0,15)",36,0,517,FrameMgr_processFrame
89 .global FrameMgr_processFrame
90 .type FrameMgr_processFrame, @function
91 FrameMgr_processFrame:
92 .stabd 46,0,0
1:FrameMgr.c **** /*
2:FrameMgr.c **** Copyright (C) 2004 John Orlando
3:FrameMgr.c ****
4:FrameMgr.c **** AVRcam: a small real-time image processing engine.
5:FrameMgr.c ****
6:FrameMgr.c **** This program is free software; you can redistribute it and/or
7:FrameMgr.c **** modify it under the terms of the GNU General Public
8:FrameMgr.c **** License as published by the Free Software Foundation; either
9:FrameMgr.c **** version 2 of the License, or (at your option) any later version.
10:FrameMgr.c ****
11:FrameMgr.c **** This program is distributed in the hope that it will be useful,
12:FrameMgr.c **** but WITHOUT ANY WARRANTY; without even the implied warranty of
13:FrameMgr.c **** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14:FrameMgr.c **** General Public License for more details.
15:FrameMgr.c ****
16:FrameMgr.c **** You should have received a copy of the GNU General Public
17:FrameMgr.c **** License along with this program; if not, write to the Free Software
18:FrameMgr.c **** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19:FrameMgr.c ****
20:FrameMgr.c **** For more information on the AVRcam, please contact:
21:FrameMgr.c ****
22:FrameMgr.c **** john@jrobot.net
GAS LISTING /tmp/ccf43P2i.s page 3
 
 
23:FrameMgr.c ****
24:FrameMgr.c **** or go to www.jrobot.net for more details regarding the system.
25:FrameMgr.c **** */
26:FrameMgr.c **** /*********************************************************
27:FrameMgr.c **** Module Name: FrameMgr.c
28:FrameMgr.c **** Module Date: 04/10/2004
29:FrameMgr.c **** Module Auth: John Orlando
30:FrameMgr.c ****
31:FrameMgr.c **** Description: This modules is responsible for performing
32:FrameMgr.c **** both medium and high level processing on image data.
33:FrameMgr.c **** This is performed at both the line level as well as
34:FrameMgr.c **** the frame level. It controls the main flow of the
35:FrameMgr.c **** system, adhering to all the critical timing
36:FrameMgr.c **** requirements (such as when serial data can be transferred,
37:FrameMgr.c **** etc).
38:FrameMgr.c ****
39:FrameMgr.c **** Revision History:
40:FrameMgr.c **** Date Rel Ver. Notes
41:FrameMgr.c **** 4/10/2004 0.1 Module created
42:FrameMgr.c **** 6/30/2004 1.0 Initial release for Circuit Cellar
43:FrameMgr.c **** contest.
44:FrameMgr.c **** 11/15/2004 1.2 Updated processLine() function so
45:FrameMgr.c **** it will remove objects less than
46:FrameMgr.c **** a specified length/width (reduces
47:FrameMgr.c **** shot noise)
48:FrameMgr.c **** *********************************************************/
49:FrameMgr.c ****
50:FrameMgr.c **** /* Includes */
51:FrameMgr.c **** #include <stdlib.h>
52:FrameMgr.c **** #include <string.h>
53:FrameMgr.c **** #include <avr/io.h>
54:FrameMgr.c **** #include "Executive.h"
55:FrameMgr.c **** #include "UIMgr.h"
56:FrameMgr.c **** #include "FrameMgr.h"
57:FrameMgr.c **** #include "CamInterface.h"
58:FrameMgr.c **** #include "UartInterface.h"
59:FrameMgr.c **** #include "Utility.h"
60:FrameMgr.c **** #include "I2CInterface.h"
61:FrameMgr.c **** #include "CamConfig.h"
62:FrameMgr.c **** #include "CommonDefs.h"
63:FrameMgr.c ****
64:FrameMgr.c **** /* Local Structures and Typedefs */
65:FrameMgr.c **** enum
66:FrameMgr.c **** {
67:FrameMgr.c **** ST_FrameMgr_idle,
68:FrameMgr.c **** ST_FrameMgr_TrackingFrame,
69:FrameMgr.c **** ST_FrameMgr_DumpingFrame
70:FrameMgr.c **** };
71:FrameMgr.c ****
72:FrameMgr.c **** typedef unsigned char FrameMgr_State_t;
73:FrameMgr.c ****
74:FrameMgr.c **** /* Definitions */
75:FrameMgr.c **** /* The most objects that can be tracked at any one time is 8.
76:FrameMgr.c **** This number is determined by the number of bytes that can be
77:FrameMgr.c **** sent out during a frame (one byte per line, 144 lines per frame)
78:FrameMgr.c **** with the number of bytes in a tracked object (7) + some wiggle
79:FrameMgr.c **** room :-) ... I guess this could be increased to around 20 if
GAS LISTING /tmp/ccf43P2i.s page 4
 
 
80:FrameMgr.c **** we had enough room and cycles to process objects between lines */
81:FrameMgr.c **** #define MAX_TRACKED_OBJECTS 8
82:FrameMgr.c ****
83:FrameMgr.c **** /* This defines the number of bytes that make up a trackedObject_t
84:FrameMgr.c **** structure... */
85:FrameMgr.c **** #define SIZE_OF_TRACKED_OBJECT 8
86:FrameMgr.c ****
87:FrameMgr.c **** /* This define is used to turn off the timer overflow interrupt
88:FrameMgr.c **** that is generated when the PCLK overflows TIMER1 */
89:FrameMgr.c **** #define DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK 0xFB
90:FrameMgr.c ****
91:FrameMgr.c **** /* This define is used to determine if a run length is too small
92:FrameMgr.c **** to be concerned with. This helps to reduce the number of false
93:FrameMgr.c **** positives. */
94:FrameMgr.c **** #define MIN_OBJECT_TRACKING_WIDTH 3
95:FrameMgr.c ****
96:FrameMgr.c **** /* This define is used to determine if an object has enough
97:FrameMgr.c **** height to be considered worth tracking...it is used to reduce
98:FrameMgr.c **** shot noise */
99:FrameMgr.c **** #define MIN_OBJECT_TRACKING_HEIGHT 3
100:FrameMgr.c ****
101:FrameMgr.c **** /* This define is used to indicate how often the filter routine
102:FrameMgr.c **** that removes objects less than MIN_OBJECT_TRACKING_HEIGHT should
103:FrameMgr.c **** be executed. It is measured in a number of lines (7 nominally). */
104:FrameMgr.c **** #define RUN_OBJECT_FILTER_MASK 0x07
105:FrameMgr.c ****
106:FrameMgr.c **** /* This enum describes the possible colors that can
107:FrameMgr.c **** be tracked by the system. This can't be represented as
108:FrameMgr.c **** simple color names (red, brown, etc) due to the fact that
109:FrameMgr.c **** the user sets which colors will be associated with which
110:FrameMgr.c **** bits. Remember...after the AND operation of the indexed
111:FrameMgr.c **** color map values executes, either a single bit indicating
112:FrameMgr.c **** the color should be set, or no bits indicating that the
113:FrameMgr.c **** color isn't represented in the color map (notTracked). */
114:FrameMgr.c **** enum
115:FrameMgr.c **** {
116:FrameMgr.c **** notTracked,
117:FrameMgr.c **** color1, /* bit 1 color */
118:FrameMgr.c **** color2, /* bit 2 color */
119:FrameMgr.c **** color3, /* bit 3 color */
120:FrameMgr.c **** color4, /* bit 4 color */
121:FrameMgr.c **** color5, /* bit 5 color */
122:FrameMgr.c **** color6, /* bit 6 color */
123:FrameMgr.c **** color7, /* bit 7 color */
124:FrameMgr.c **** color8 /* bit 8 color */
125:FrameMgr.c **** };
126:FrameMgr.c ****
127:FrameMgr.c **** typedef unsigned char trackedColor_t;
128:FrameMgr.c ****
129:FrameMgr.c **** /* This structure defines the info that needs to be
130:FrameMgr.c **** maintained for each trackedObject in the trackingTable */
131:FrameMgr.c **** typedef struct
132:FrameMgr.c **** {
133:FrameMgr.c **** trackedColor_t color;
134:FrameMgr.c **** unsigned char lastLineXStart;
135:FrameMgr.c **** unsigned char lastLineXFinish;
136:FrameMgr.c **** unsigned char x_upperLeft;
GAS LISTING /tmp/ccf43P2i.s page 5
 
 
137:FrameMgr.c **** unsigned char y_upperLeft;
138:FrameMgr.c **** unsigned char x_lowerRight;
139:FrameMgr.c **** unsigned char y_lowerRight;
140:FrameMgr.c **** unsigned char objectValid; /* used to be a fill byte...now it is
141:FrameMgr.c **** used to determine if the object is valid
142:FrameMgr.c **** or not...it gets invalidated if it is
143:FrameMgr.c **** determined that it is too small, or
144:FrameMgr.c **** that the object is within another object */
145:FrameMgr.c **** } trackedObject_t;
146:FrameMgr.c ****
147:FrameMgr.c **** /* These defines are used to index into each individual element in the
148:FrameMgr.c **** trackedObject_t structure. This seems to be MUCH more efficient than
149:FrameMgr.c **** accessing the elements in GCC. */
150:FrameMgr.c **** #define COLOR_OFFSET 0
151:FrameMgr.c **** #define LAST_LINE_X_START_OFFSET 1
152:FrameMgr.c **** #define LAST_LINE_X_FINISH_OFFSET 2
153:FrameMgr.c **** #define X_UPPER_LEFT_OFFSET 3
154:FrameMgr.c **** #define Y_UPPER_LEFT_OFFSET 4
155:FrameMgr.c **** #define X_LOWER_RIGHT_OFFSET 5
156:FrameMgr.c **** #define Y_LOWER_RIGHT_OFFSET 6
157:FrameMgr.c **** #define VALID_OBJECT_OFFSET 7
158:FrameMgr.c ****
159:FrameMgr.c **** /* Local Variables */
160:FrameMgr.c **** /* The trackedObjectTable is used to hold up to eight tracked objects
161:FrameMgr.c **** while they are being acquired. */
162:FrameMgr.c **** static trackedObject_t trackedObjectTable[MAX_TRACKED_OBJECTS];
163:FrameMgr.c **** static trackedObject_t *pCurrentTrackedObjectTable = trackedObjectTable;
164:FrameMgr.c **** static unsigned char lineCount = 0;
165:FrameMgr.c **** static FrameMgr_State_t currentState = ST_FrameMgr_idle;
166:FrameMgr.c **** static unsigned char numCurrTrackedObjects = 0;
167:FrameMgr.c **** static unsigned char numPrevTrackedObjects = 0;
168:FrameMgr.c **** static unsigned char trackedLineCount = 0;
169:FrameMgr.c ****
170:FrameMgr.c **** /* Local Functions */
171:FrameMgr.c **** static void FrameMgr_findConnectedness(void);
172:FrameMgr.c ****
173:FrameMgr.c **** /* Extern Functions */
174:FrameMgr.c **** /* These functions are located in assembly files, and thus
175:FrameMgr.c **** must be externed here so they can be referenced in the source below. */
176:FrameMgr.c **** extern void CamIntAsm_waitForNewTrackingFrame(unsigned char *pBuffer, unsigned char *pMemLookup);
177:FrameMgr.c **** extern void CamIntAsm_waitForNewDumpFrame(unsigned char *pCurrBuffer, unsigned char *pPrevBuffer);
178:FrameMgr.c **** extern void CamIntAsm_acquireTrackingLine(unsigned char *pBuffer, unsigned char *pMemLookup);
179:FrameMgr.c **** extern void CamIntAsm_acquireDumpLine(unsigned char *pCurrBuffer, unsigned char *pPrevBuffer);
180:FrameMgr.c ****
181:FrameMgr.c **** /***********************************************************
182:FrameMgr.c **** Function Name: FrameMgr_init
183:FrameMgr.c **** Function Description: This function is responsible
184:FrameMgr.c **** for initializing the FrameMgr. This includes
185:FrameMgr.c **** setting up the various buffers and data needed to
186:FrameMgr.c **** process each frame of image data.
187:FrameMgr.c **** Inputs: none
188:FrameMgr.c **** Outputs: none
189:FrameMgr.c **** ***********************************************************/
190:FrameMgr.c **** void FrameMgr_init(void)
191:FrameMgr.c **** {
192:FrameMgr.c **** memset(trackedObjectTable,0x00,sizeof(trackedObjectTable));
193:FrameMgr.c **** }
GAS LISTING /tmp/ccf43P2i.s page 6
 
 
194:FrameMgr.c ****
195:FrameMgr.c ****
196:FrameMgr.c **** /***********************************************************
197:FrameMgr.c **** Function Name: FrameMgr_dispatchEvent
198:FrameMgr.c **** Function Description: This function is responsible for
199:FrameMgr.c **** taking an incoming event and performing the needed
200:FrameMgr.c **** actions with it as pertains to the FrameMgr.
201:FrameMgr.c **** Inputs: event - the generated event
202:FrameMgr.c **** Outputs: none
203:FrameMgr.c **** ***********************************************************/
204:FrameMgr.c **** void FrameMgr_dispatchEvent(unsigned char event)
205:FrameMgr.c **** {
206:FrameMgr.c **** switch(event)
207:FrameMgr.c **** {
208:FrameMgr.c **** case EV_DUMP_FRAME:
209:FrameMgr.c **** /* try re-initializing the camera before we start dumping */
210:FrameMgr.c ****
211:FrameMgr.c **** CamConfig_setCamReg(0x11,0x01); /* reduce the frame rate for dumping*/
212:FrameMgr.c **** CamConfig_sendFifoCmds();
213:FrameMgr.c **** Utility_delay(1000); /* allow the new frame rate to settle */
214:FrameMgr.c **** lineCount = 0;
215:FrameMgr.c **** currentState = ST_FrameMgr_DumpingFrame;
216:FrameMgr.c **** //CamIntAsm_waitForNewDumpFrame(currentLineBuffer,previousLineBuffer);
217:FrameMgr.c **** FrameMgr_acquireLine();
218:FrameMgr.c **** break;
219:FrameMgr.c ****
220:FrameMgr.c **** case EV_ENABLE_TRACKING:
221:FrameMgr.c **** currentState = ST_FrameMgr_TrackingFrame;
222:FrameMgr.c **** FrameMgr_acquireFrame();
223:FrameMgr.c **** break;
224:FrameMgr.c ****
225:FrameMgr.c **** case EV_ACQUIRE_FRAME_COMPLETE:
226:FrameMgr.c **** FrameMgr_processFrame();
227:FrameMgr.c **** break;
228:FrameMgr.c ****
229:FrameMgr.c **** case EV_PROCESS_FRAME_COMPLETE:
230:FrameMgr.c **** FrameMgr_acquireFrame();
231:FrameMgr.c **** break;
232:FrameMgr.c ****
233:FrameMgr.c **** case EV_SERIAL_DATA_RECEIVED:
234:FrameMgr.c **** if (currentState != ST_FrameMgr_idle)
235:FrameMgr.c **** {
236:FrameMgr.c **** /* we need to go back to processing line data, since
237:FrameMgr.c **** serial data reception interrupted us....just trash the
238:FrameMgr.c **** frame and act like the frame has been processed, which
239:FrameMgr.c **** will kick off the system to wait for the next line */
240:FrameMgr.c **** PUBLISH_EVENT(EV_PROCESS_FRAME_COMPLETE);
241:FrameMgr.c **** }
242:FrameMgr.c **** break;
243:FrameMgr.c ****
244:FrameMgr.c **** case EV_DISABLE_TRACKING:
245:FrameMgr.c **** /* tracking needs to be turned off */
246:FrameMgr.c **** currentState = ST_FrameMgr_idle;
247:FrameMgr.c **** break;
248:FrameMgr.c **** }
249:FrameMgr.c **** }
250:FrameMgr.c ****
GAS LISTING /tmp/ccf43P2i.s page 7
 
 
251:FrameMgr.c **** /***********************************************************
252:FrameMgr.c **** Function Name: FrameMgr_acquireFrame
253:FrameMgr.c **** Function Description: This function is responsible for
254:FrameMgr.c **** beginning of the acquisition of a new frame of data
255:FrameMgr.c **** from the camera interface. The acquisition of this line
256:FrameMgr.c **** depends on the current state of the FrameMgr.
257:FrameMgr.c **** Inputs: none
258:FrameMgr.c **** Outputs: none
259:FrameMgr.c **** ***********************************************************/
260:FrameMgr.c **** void FrameMgr_acquireFrame(void)
261:FrameMgr.c **** {
262:FrameMgr.c **** if (currentState == ST_FrameMgr_TrackingFrame)
263:FrameMgr.c **** {
264:FrameMgr.c **** trackedLineCount = 0;
265:FrameMgr.c **** numPrevTrackedObjects = numCurrTrackedObjects;
266:FrameMgr.c **** numCurrTrackedObjects = 0;
267:FrameMgr.c ****
268:FrameMgr.c **** /* clear out the tracking table, and wait for the new frame
269:FrameMgr.c **** to start */
270:FrameMgr.c **** memset(trackedObjectTable,0x00,sizeof(trackedObjectTable));
271:FrameMgr.c **** //CamIntAsm_waitForNewTrackingFrame(currentLineBuffer,colorMap);
272:FrameMgr.c **** WAIT_FOR_VSYNC_HIGH();
273:FrameMgr.c **** CamIntAsm_acquireTrackingLine(currentLineBuffer,colorMap);
274:FrameMgr.c **** }
275:FrameMgr.c **** }
276:FrameMgr.c ****
277:FrameMgr.c **** /***********************************************************
278:FrameMgr.c **** Function Name: FrameMgr_acquireLine
279:FrameMgr.c **** Function Description: This function is responsible for
280:FrameMgr.c **** acquiring a line of data from the camera interface.
281:FrameMgr.c **** The acquisition of this line depends on the current
282:FrameMgr.c **** state of the FrameMgr.
283:FrameMgr.c **** Inputs: none
284:FrameMgr.c **** Outputs: none
285:FrameMgr.c **** ***********************************************************/
286:FrameMgr.c **** void FrameMgr_acquireLine(void)
287:FrameMgr.c **** {
288:FrameMgr.c **** unsigned char tmpLineCount;
289:FrameMgr.c ****
290:FrameMgr.c **** /* clearing out the buffers takes too long...we should
291:FrameMgr.c **** just overwrite the data here without a problem when
292:FrameMgr.c **** we start acquiring...at no point do we check for
293:FrameMgr.c **** a 0x00 value in the current or previous lineBuffers,
294:FrameMgr.c **** so it was a bit excessive :-) */
295:FrameMgr.c ****
296:FrameMgr.c **** /* check which state we are in and proceed as needed */
297:FrameMgr.c **** if (currentState == ST_FrameMgr_DumpingFrame)
298:FrameMgr.c **** {
299:FrameMgr.c **** tmpLineCount = lineCount*2;
300:FrameMgr.c ****
301:FrameMgr.c **** /* clearing out the line data in dump mode is ok, and actually
302:FrameMgr.c **** is needed, since it is possible for the first dump line in
303:FrameMgr.c **** a frame to come back with the last line captured of the
304:FrameMgr.c **** last capture session...*/
305:FrameMgr.c **** memset(currentLineBuffer,0x00,LENGTH_OF_LINE_BUFFER);
306:FrameMgr.c **** memset(previousLineBuffer,0x00,LENGTH_OF_LINE_BUFFER);
307:FrameMgr.c **** /* wait for another VSYNC so we know which frame to use
GAS LISTING /tmp/ccf43P2i.s page 8
 
 
308:FrameMgr.c **** to start looking for a line to receive */
309:FrameMgr.c **** WAIT_FOR_VSYNC_HIGH();
310:FrameMgr.c **** WAIT_FOR_VSYNC_LOW();
311:FrameMgr.c ****
312:FrameMgr.c **** /* look at lineCount to determine how many HREFs we should
313:FrameMgr.c **** wait before we start sampling */
314:FrameMgr.c **** while(tmpLineCount != 0)
315:FrameMgr.c **** {
316:FrameMgr.c **** WAIT_FOR_HREF_HIGH();
317:FrameMgr.c **** tmpLineCount--;
318:FrameMgr.c **** WAIT_FOR_HREF_LOW();
319:FrameMgr.c **** }
320:FrameMgr.c ****
321:FrameMgr.c **** /* we should now be ready to sample our line...*/
322:FrameMgr.c **** CamIntAsm_acquireDumpLine(currentLineBuffer,previousLineBuffer);
323:FrameMgr.c **** }
324:FrameMgr.c **** else if (currentState == ST_FrameMgr_TrackingFrame)
325:FrameMgr.c **** {
326:FrameMgr.c **** WAIT_FOR_HREF_LOW();
327:FrameMgr.c **** CamIntAsm_acquireTrackingLine(currentLineBuffer,colorMap);
328:FrameMgr.c **** }
329:FrameMgr.c **** }
330:FrameMgr.c ****
331:FrameMgr.c **** /***********************************************************
332:FrameMgr.c **** Function Name: FrameMgr_processLine
333:FrameMgr.c **** Function Description: This function is responsible for
334:FrameMgr.c **** parsing the received image line and performing either
335:FrameMgr.c **** connected region mapping (if in the Tracking state) or
336:FrameMgr.c **** sending out the raw sampled data (if in the Dumping
337:FrameMgr.c **** state).
338:FrameMgr.c **** Inputs: none
339:FrameMgr.c **** Outputs: none
340:FrameMgr.c **** ***********************************************************/
341:FrameMgr.c **** void FrameMgr_processLine(void)
342:FrameMgr.c **** {
343:FrameMgr.c **** unsigned char i;
344:FrameMgr.c **** volatile unsigned char dataToSend;
345:FrameMgr.c **** unsigned char *pTrackedObjectData = (unsigned char *)pCurrentTrackedObjectTable;
346:FrameMgr.c **** #ifdef DEBUG_TRACKED_LINE
347:FrameMgr.c **** unsigned char *pSendData;
348:FrameMgr.c **** unsigned char asciiBuffer[5];
349:FrameMgr.c **** unsigned char pixelCount = 0;
350:FrameMgr.c **** #endif
351:FrameMgr.c ****
352:FrameMgr.c **** if (currentState == ST_FrameMgr_DumpingFrame)
353:FrameMgr.c **** {
354:FrameMgr.c **** /* we want to sit in a tight loop and send the acquired data
355:FrameMgr.c **** sitting in current and previous line buffers out the serial
356:FrameMgr.c **** port...it is sent out the serial port immediately instead
357:FrameMgr.c **** of going into the UIMgr tx fifo because we can't do anything
358:FrameMgr.c **** until its sent out anyway...may as well just get it out now */
359:FrameMgr.c ****
360:FrameMgr.c **** /* currentLineBuffer is getting "g" previousLineBuffer is getting "b-r" */
361:FrameMgr.c **** UartInt_txByte(0x0B); /* send the header byte */
362:FrameMgr.c **** UartInt_txByte(lineCount); /* send the line count */
363:FrameMgr.c **** for (i=0; i<NUM_PIXELS_IN_A_DUMP_LINE; i+=2)
364:FrameMgr.c **** {
GAS LISTING /tmp/ccf43P2i.s page 9
 
 
365:FrameMgr.c **** /* when a dump line is sampled, the upper byte can potentially
366:FrameMgr.c **** have garbage in it...we don't have time to mask it off as we're
367:FrameMgr.c **** sampling, so it is done here before we send it out...we also
368:FrameMgr.c **** combine the samples together so we really are sending up a
369:FrameMgr.c **** sample for line N as well as line N+1 */
370:FrameMgr.c **** dataToSend = currentLineBuffer[i];
371:FrameMgr.c **** dataToSend &= 0x0F;
372:FrameMgr.c **** dataToSend <<= 4;
373:FrameMgr.c **** dataToSend |= (previousLineBuffer[i] & 0x0F);
374:FrameMgr.c ****
375:FrameMgr.c **** /* dataToSend should be packed now */
376:FrameMgr.c **** UartInt_txByte(dataToSend);
377:FrameMgr.c ****
378:FrameMgr.c **** /* flip the colors around since we are doing all G on Y and BR on UV */
379:FrameMgr.c **** dataToSend = previousLineBuffer[i+1];
380:FrameMgr.c **** dataToSend &= 0x0F;
381:FrameMgr.c **** dataToSend <<= 4;
382:FrameMgr.c **** dataToSend |= (currentLineBuffer[i+1] & 0x0F);
383:FrameMgr.c ****
384:FrameMgr.c **** /* dataToSend should be packed now */
385:FrameMgr.c **** UartInt_txByte(dataToSend);
386:FrameMgr.c **** }
387:FrameMgr.c **** UartInt_txByte(0x0F); /* send line end */
388:FrameMgr.c **** /* once all the data is sent, increment out line count by 2 since
389:FrameMgr.c **** we really get 2 lines worth of pixels on each pass */
390:FrameMgr.c **** /* Update...increment only by 1, but only send 72 double-lines */
391:FrameMgr.c **** lineCount++;
392:FrameMgr.c ****
393:FrameMgr.c **** /* check to see if we have retrieved all of the needed lines */
394:FrameMgr.c **** if (lineCount >= 72) /* half 144, since we send two lines at a time */
395:FrameMgr.c **** {
396:FrameMgr.c **** /* we're done, so send the dump complete?...nope, just change
397:FrameMgr.c **** states and we should be fine */
398:FrameMgr.c **** lineCount = 0;
399:FrameMgr.c **** currentState = ST_FrameMgr_idle;
400:FrameMgr.c ****
401:FrameMgr.c **** /* disable the PCLK counting overflow interrupt */
402:FrameMgr.c **** TIMSK &= DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK;
403:FrameMgr.c ****
404:FrameMgr.c **** CamConfig_setCamReg(0x11,0x00); /* reset the frame rate to normal*/
405:FrameMgr.c **** CamConfig_sendFifoCmds();
406:FrameMgr.c **** }
407:FrameMgr.c **** else
408:FrameMgr.c **** {
409:FrameMgr.c **** /* we have more lines to acquire in this frame, so keep on truckin...*/
410:FrameMgr.c **** PUBLISH_FAST_EVENT(FEV_PROCESS_LINE_COMPLETE);
411:FrameMgr.c **** }
412:FrameMgr.c **** }
413:FrameMgr.c **** else if (currentState == ST_FrameMgr_TrackingFrame)
414:FrameMgr.c **** {
415:FrameMgr.c **** #ifdef DEBUG_TRACKED_LINE
416:FrameMgr.c **** /* send the received line over serial...this should only send
417:FrameMgr.c **** until a pixelCount == 176 */
418:FrameMgr.c **** pSendData = currentLineBuffer;
419:FrameMgr.c **** itoa(trackedLineCount,asciiBuffer,10);
420:FrameMgr.c **** UIMgr_txBuffer(asciiBuffer,3);
421:FrameMgr.c **** UIMgr_txBuffer(" ",1);
GAS LISTING /tmp/ccf43P2i.s page 10
 
 
422:FrameMgr.c **** while(pixelCount < ACTUAL_NUM_PIXELS_IN_A_LINE)
423:FrameMgr.c **** {
424:FrameMgr.c **** memset(asciiBuffer,0x00,5);
425:FrameMgr.c **** itoa(*pSendData++,asciiBuffer,10); /* color is first byte */
426:FrameMgr.c **** UIMgr_txBuffer(asciiBuffer,3); /* 3 ascii bytes for data */
427:FrameMgr.c **** UIMgr_txBuffer(" ",1);
428:FrameMgr.c ****
429:FrameMgr.c **** pixelCount += *pSendData; /* run-length is second byte */
430:FrameMgr.c **** memset(asciiBuffer,0x00,5);
431:FrameMgr.c **** itoa(*pSendData++,asciiBuffer,10);
432:FrameMgr.c **** UIMgr_txBuffer(asciiBuffer,3);
433:FrameMgr.c **** UIMgr_txBuffer(" ",1);
434:FrameMgr.c **** }
435:FrameMgr.c **** UIMgr_txBuffer("\n\r",2);
436:FrameMgr.c ****
437:FrameMgr.c **** trackedLineCount++;
438:FrameMgr.c **** if (trackedLineCount == 144)
439:FrameMgr.c **** {
440:FrameMgr.c **** UIMgr_txBuffer(" FC \n\r",8);
441:FrameMgr.c **** trackedLineCount = 0;
442:FrameMgr.c **** PUBLISH_EVENT(EV_PROCESS_FRAME_COMPLETE);
443:FrameMgr.c **** }
444:FrameMgr.c **** else
445:FrameMgr.c **** {
446:FrameMgr.c **** PUBLISH_EVENT(EV_PROCESS_LINE_COMPLETE);
447:FrameMgr.c **** }
448:FrameMgr.c **** #else
449:FrameMgr.c **** /* determine if any of the RLE blocks overlap */
450:FrameMgr.c **** FrameMgr_findConnectedness();
451:FrameMgr.c ****
452:FrameMgr.c **** /* we also want to remove any objects that are less than
453:FrameMgr.c **** a minimum height...we already removed portions of the
454:FrameMgr.c **** run-length that are less than MIN_PIXEL_WIDTH in the
455:FrameMgr.c **** findConnectedness() routine...doing it here instead of
456:FrameMgr.c **** a function to speed things up...this may end up slowing down the
457:FrameMgr.c **** frame rate slightly, and can be removed if this isn't needed */
458:FrameMgr.c ****
459:FrameMgr.c **** /* run this routine once every 8 lines */
460:FrameMgr.c **** if ( (trackedLineCount & RUN_OBJECT_FILTER_MASK) == RUN_OBJECT_FILTER_MASK)
461:FrameMgr.c **** {
462:FrameMgr.c **** for (i=0; i<MAX_TRACKED_OBJECTS; i++)
463:FrameMgr.c **** {
464:FrameMgr.c **** if ( *(pTrackedObjectData + VALID_OBJECT_OFFSET) == TRUE)
465:FrameMgr.c **** {
466:FrameMgr.c **** /* check to see if the object is already in
467:FrameMgr.c **** our past...i.e., its last */
468:FrameMgr.c **** if ( (*(pTrackedObjectData + Y_LOWER_RIGHT_OFFSET) -
469:FrameMgr.c **** *(pTrackedObjectData + Y_UPPER_LEFT_OFFSET)) < MIN_OBJECT_TRACKING_HEIGHT
470:FrameMgr.c **** {
471:FrameMgr.c **** /* the object is less than the minimum height...see if it is adjacent
472:FrameMgr.c **** to the current line we just processed...if so, leave it here...otherwise,
473:FrameMgr.c **** it needs to be invalidated since its too small */
474:FrameMgr.c **** if ( trackedLineCount - *(pTrackedObjectData + Y_LOWER_RIGHT_OFFSET) > 2)
475:FrameMgr.c **** {
476:FrameMgr.c **** /* invalidate the object */
477:FrameMgr.c **** *(pTrackedObjectData + VALID_OBJECT_OFFSET) = FALSE;
478:FrameMgr.c **** numCurrTrackedObjects--;
GAS LISTING /tmp/ccf43P2i.s page 11
 
 
479:FrameMgr.c **** }
480:FrameMgr.c **** }
481:FrameMgr.c **** }
482:FrameMgr.c **** pTrackedObjectData += SIZE_OF_TRACKED_OBJECT;
483:FrameMgr.c **** }
484:FrameMgr.c **** }
485:FrameMgr.c ****
486:FrameMgr.c **** trackedLineCount++;
487:FrameMgr.c **** if (trackedLineCount == ACTUAL_NUM_LINES_IN_A_FRAME)
488:FrameMgr.c **** {
489:FrameMgr.c **** /* an entire frame of tracking data has been acquired, so
490:FrameMgr.c **** publish an event letting the system know this fact */
491:FrameMgr.c **** PUBLISH_EVENT(EV_ACQUIRE_FRAME_COMPLETE);
492:FrameMgr.c **** /* disable the PCLK counting overflow interrupt */
493:FrameMgr.c **** TIMSK &= DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK;
494:FrameMgr.c **** trackedLineCount = 0;
495:FrameMgr.c **** }
496:FrameMgr.c **** else
497:FrameMgr.c **** {
498:FrameMgr.c **** PUBLISH_FAST_EVENT(FEV_PROCESS_LINE_COMPLETE);
499:FrameMgr.c **** }
500:FrameMgr.c **** #endif
501:FrameMgr.c **** }
502:FrameMgr.c **** else
503:FrameMgr.c **** {
504:FrameMgr.c **** /* ...and here? */
505:FrameMgr.c **** }
506:FrameMgr.c **** }
507:FrameMgr.c ****
508:FrameMgr.c **** /***********************************************************
509:FrameMgr.c **** Function Name: FrameMgr_processFrame
510:FrameMgr.c **** Function Description: This function is responsible for
511:FrameMgr.c **** parsing the completed frame and performing all actions
512:FrameMgr.c **** needed at this level.
513:FrameMgr.c **** Inputs: none
514:FrameMgr.c **** Outputs: none
515:FrameMgr.c **** ***********************************************************/
516:FrameMgr.c **** void FrameMgr_processFrame(void)
517:FrameMgr.c **** {
93 .stabn 68,0,517,.LM0-FrameMgr_processFrame
94 .LM0:
95 /* prologue: frame size=0 */
96 0000 DF92 push r13
97 0002 EF92 push r14
98 0004 FF92 push r15
99 0006 0F93 push r16
100 0008 1F93 push r17
101 000a CF93 push r28
102 000c DF93 push r29
103 /* prologue end (size=7) */
518:FrameMgr.c **** unsigned char i,k,color;
519:FrameMgr.c **** #if DEBUG_FRAME_DATA
520:FrameMgr.c **** unsigned char asciiBuffer[5];
521:FrameMgr.c **** unsigned char j;
522:FrameMgr.c **** #endif
523:FrameMgr.c **** unsigned char *pTableData = (unsigned char *)pCurrentTrackedObjectTable;
104 .stabn 68,0,523,.LM1-FrameMgr_processFrame
GAS LISTING /tmp/ccf43P2i.s page 12
 
 
105 .LM1:
106 000e 2091 0000 lds r18,pCurrentTrackedObjectTable
107 0012 3091 0000 lds r19,(pCurrentTrackedObjectTable)+1
524:FrameMgr.c **** unsigned char tmpUpperLeftX,tmpUpperLeftY,tmpLowerRightX,tmpLowerRightY;
525:FrameMgr.c ****
526:FrameMgr.c **** #if DEBUG_FRAME_DATA
527:FrameMgr.c **** /* we want to send all of the currently tracked table out
528:FrameMgr.c **** the serial port for debugging */
529:FrameMgr.c **** for (i=0; i<numCurrTrackedObjects; i++)
530:FrameMgr.c **** {
531:FrameMgr.c **** UIMgr_txBuffer("----------\r\n",12);
532:FrameMgr.c **** for (j=0; j<SIZE_OF_TRACKED_OBJECT; j++)
533:FrameMgr.c **** {
534:FrameMgr.c **** memset(asciiBuffer,0x00,5);
535:FrameMgr.c **** itoa(*pTableData++,asciiBuffer,10);
536:FrameMgr.c **** UIMgr_txBuffer(asciiBuffer,3); /* 3 ascii bytes for data
537:FrameMgr.c **** + 1 space */
538:FrameMgr.c **** UIMgr_txBuffer("\r\n",2);
539:FrameMgr.c **** }
540:FrameMgr.c **** }
541:FrameMgr.c ****
542:FrameMgr.c **** /* finally, send a new line */
543:FrameMgr.c **** UIMgr_txBuffer("\r\n",2);
544:FrameMgr.c ****
545:FrameMgr.c **** memset(asciiBuffer,0x00,5);
546:FrameMgr.c **** itoa(numCurrTrackedObjects,asciiBuffer,10);
547:FrameMgr.c **** UIMgr_txBuffer(asciiBuffer,3);
548:FrameMgr.c **** UIMgr_txBuffer(" PFC\r\n",5);
549:FrameMgr.c ****
550:FrameMgr.c **** #else
551:FrameMgr.c **** /* we only send tracking packets if there are tracked objects */
552:FrameMgr.c ****
553:FrameMgr.c **** if (numCurrTrackedObjects > 0)
108 .stabn 68,0,553,.LM2-FrameMgr_processFrame
109 .LM2:
110 0016 8091 0000 lds r24,numCurrTrackedObjects
111 001a 8823 tst r24
112 001c 09F4 brne .+2
113 001e 3FC0 rjmp .L2
114 .stabn 68,0,523,.LM3-FrameMgr_processFrame
115 .LM3:
116 0020 E901 movw r28,r18
554:FrameMgr.c **** {
555:FrameMgr.c **** UIMgr_writeTxFifo(0x0A); /* header byte for a tracking packet */
117 .stabn 68,0,555,.LM4-FrameMgr_processFrame
118 .LM4:
119 0022 8AE0 ldi r24,lo8(10)
120 0024 00D0 rcall UIMgr_writeTxFifo
556:FrameMgr.c **** /* reset the pointer */
557:FrameMgr.c **** pTableData = (unsigned char *)pCurrentTrackedObjectTable;
558:FrameMgr.c ****
559:FrameMgr.c **** UIMgr_writeTxFifo(numCurrTrackedObjects); /* num of objects tracked */
121 .stabn 68,0,559,.LM5-FrameMgr_processFrame
122 .LM5:
123 0026 8091 0000 lds r24,numCurrTrackedObjects
124 002a 00D0 rcall UIMgr_writeTxFifo
125 002c DD24 clr r13
GAS LISTING /tmp/ccf43P2i.s page 13
 
 
126 .L4:
560:FrameMgr.c **** for (i=0; i<MAX_TRACKED_OBJECTS; i++)
561:FrameMgr.c **** {
562:FrameMgr.c **** /* we only want to process objects that have their objectValid flag
563:FrameMgr.c **** set to TRUE */
564:FrameMgr.c **** if ( *(pTableData + VALID_OBJECT_OFFSET) == TRUE)
127 .stabn 68,0,564,.LM6-FrameMgr_processFrame
128 .LM6:
129 002e 8F81 ldd r24,Y+7
130 0030 8130 cpi r24,lo8(1)
131 0032 69F5 brne .L5
565:FrameMgr.c **** {
566:FrameMgr.c **** /* the object is valid...convert the color from bit position to value...remember,
567:FrameMgr.c **** each bit in the "color" byte corresponds to a color */
568:FrameMgr.c **** k=0;
569:FrameMgr.c **** color = *(pTableData + COLOR_OFFSET);
132 .stabn 68,0,569,.LM7-FrameMgr_processFrame
133 .LM7:
134 0034 8881 ld r24,Y
570:FrameMgr.c **** if (color == 128) k=0;
135 .stabn 68,0,570,.LM8-FrameMgr_processFrame
136 .LM8:
137 0036 8038 cpi r24,lo8(-128)
138 0038 E1F0 breq .L7
571:FrameMgr.c **** else if (color == 64) k=1;
139 .stabn 68,0,571,.LM9-FrameMgr_processFrame
140 .LM9:
141 003a 8034 cpi r24,lo8(64)
142 003c 11F4 brne .L9
143 003e 81E0 ldi r24,lo8(1)
144 0040 19C0 rjmp .L11
145 .L9:
572:FrameMgr.c **** else if (color == 32) k=2;
146 .stabn 68,0,572,.LM10-FrameMgr_processFrame
147 .LM10:
148 0042 8032 cpi r24,lo8(32)
149 0044 11F4 brne .L12
150 0046 82E0 ldi r24,lo8(2)
151 0048 15C0 rjmp .L11
152 .L12:
573:FrameMgr.c **** else if (color == 16) k=3;
153 .stabn 68,0,573,.LM11-FrameMgr_processFrame
154 .LM11:
155 004a 8031 cpi r24,lo8(16)
156 004c 11F4 brne .L14
157 004e 83E0 ldi r24,lo8(3)
158 0050 11C0 rjmp .L11
159 .L14:
574:FrameMgr.c **** else if (color == 8) k=4;
160 .stabn 68,0,574,.LM12-FrameMgr_processFrame
161 .LM12:
162 0052 8830 cpi r24,lo8(8)
163 0054 11F4 brne .L16
164 0056 84E0 ldi r24,lo8(4)
165 0058 0DC0 rjmp .L11
166 .L16:
575:FrameMgr.c **** else if (color == 4) k=5;
GAS LISTING /tmp/ccf43P2i.s page 14
 
 
167 .stabn 68,0,575,.LM13-FrameMgr_processFrame
168 .LM13:
169 005a 8430 cpi r24,lo8(4)
170 005c 11F4 brne .L18
171 005e 85E0 ldi r24,lo8(5)
172 0060 09C0 rjmp .L11
173 .L18:
576:FrameMgr.c **** else if (color == 2) k=6;
174 .stabn 68,0,576,.LM14-FrameMgr_processFrame
175 .LM14:
176 0062 8230 cpi r24,lo8(2)
177 0064 11F4 brne .L20
178 0066 86E0 ldi r24,lo8(6)
179 0068 05C0 rjmp .L11
180 .L20:
577:FrameMgr.c **** else if (color == 1) k=7;
181 .stabn 68,0,577,.LM15-FrameMgr_processFrame
182 .LM15:
183 006a 8130 cpi r24,lo8(1)
184 006c 11F4 brne .L7
185 006e 87E0 ldi r24,lo8(7)
186 0070 01C0 rjmp .L11
187 .L7:
188 0072 80E0 ldi r24,lo8(0)
189 .L11:
578:FrameMgr.c ****
579:FrameMgr.c **** tmpUpperLeftX = *(pTableData + X_UPPER_LEFT_OFFSET); /* get the upper left X */
190 .stabn 68,0,579,.LM16-FrameMgr_processFrame
191 .LM16:
192 0074 1B81 ldd r17,Y+3
580:FrameMgr.c **** tmpUpperLeftY = *(pTableData + Y_UPPER_LEFT_OFFSET); /* get the upper left Y */
193 .stabn 68,0,580,.LM17-FrameMgr_processFrame
194 .LM17:
195 0076 0C81 ldd r16,Y+4
581:FrameMgr.c **** tmpLowerRightX = *(pTableData + X_LOWER_RIGHT_OFFSET); /* get the lower right X */
196 .stabn 68,0,581,.LM18-FrameMgr_processFrame
197 .LM18:
198 0078 FD80 ldd r15,Y+5
582:FrameMgr.c **** tmpLowerRightY = *(pTableData + Y_LOWER_RIGHT_OFFSET); /* get the lower right Y */
199 .stabn 68,0,582,.LM19-FrameMgr_processFrame
200 .LM19:
201 007a EE80 ldd r14,Y+6
583:FrameMgr.c ****
584:FrameMgr.c **** UIMgr_writeTxFifo(k); /* send the color first */
202 .stabn 68,0,584,.LM20-FrameMgr_processFrame
203 .LM20:
204 007c 00D0 rcall UIMgr_writeTxFifo
585:FrameMgr.c **** UIMgr_writeTxFifo(tmpUpperLeftX);
205 .stabn 68,0,585,.LM21-FrameMgr_processFrame
206 .LM21:
207 007e 812F mov r24,r17
208 0080 00D0 rcall UIMgr_writeTxFifo
586:FrameMgr.c **** UIMgr_writeTxFifo(tmpUpperLeftY);
209 .stabn 68,0,586,.LM22-FrameMgr_processFrame
210 .LM22:
211 0082 802F mov r24,r16
212 0084 00D0 rcall UIMgr_writeTxFifo
GAS LISTING /tmp/ccf43P2i.s page 15
 
 
587:FrameMgr.c **** UIMgr_writeTxFifo(tmpLowerRightX);
213 .stabn 68,0,587,.LM23-FrameMgr_processFrame
214 .LM23:
215 0086 8F2D mov r24,r15
216 0088 00D0 rcall UIMgr_writeTxFifo
588:FrameMgr.c **** UIMgr_writeTxFifo(tmpLowerRightY);
217 .stabn 68,0,588,.LM24-FrameMgr_processFrame
218 .LM24:
219 008a 8E2D mov r24,r14
220 008c 00D0 rcall UIMgr_writeTxFifo
221 .L5:
222 .stabn 68,0,560,.LM25-FrameMgr_processFrame
223 .LM25:
224 008e D394 inc r13
225 0090 88E0 ldi r24,lo8(8)
226 0092 D816 cp r13,r24
227 0094 11F0 breq .L23
589:FrameMgr.c **** }
590:FrameMgr.c ****
591:FrameMgr.c **** /* move our pointer up to the beginning of the next object */
592:FrameMgr.c **** pTableData += SIZE_OF_TRACKED_OBJECT;
228 .stabn 68,0,592,.LM26-FrameMgr_processFrame
229 .LM26:
230 0096 2896 adiw r28,8
231 0098 CACF rjmp .L4
232 .L23:
593:FrameMgr.c **** }
594:FrameMgr.c ****
595:FrameMgr.c **** /* all done...send the end of tracking packets char */
596:FrameMgr.c **** UIMgr_writeTxFifo(0xFF);
233 .stabn 68,0,596,.LM27-FrameMgr_processFrame
234 .LM27:
235 009a 8FEF ldi r24,lo8(-1)
236 009c 00D0 rcall UIMgr_writeTxFifo
237 .L2:
597:FrameMgr.c **** }
598:FrameMgr.c **** #endif
599:FrameMgr.c ****
600:FrameMgr.c **** /* the tracked object table will be cleared out right before we start
601:FrameMgr.c **** to wait for VSYNC to indicate a new frame...so it doesn't need to be
602:FrameMgr.c **** done now */
603:FrameMgr.c ****
604:FrameMgr.c **** /* schedule the next action to acquire a new frame */
605:FrameMgr.c **** PUBLISH_EVENT(EV_PROCESS_FRAME_COMPLETE);
238 .stabn 68,0,605,.LM28-FrameMgr_processFrame
239 .LM28:
240 009e 84E0 ldi r24,lo8(4)
241 00a0 00D0 rcall Exec_writeEventFifo
242 /* epilogue: frame size=0 */
243 00a2 DF91 pop r29
244 00a4 CF91 pop r28
245 00a6 1F91 pop r17
246 00a8 0F91 pop r16
247 00aa FF90 pop r15
248 00ac EF90 pop r14
249 00ae DF90 pop r13
250 00b0 0895 ret
GAS LISTING /tmp/ccf43P2i.s page 16
 
 
251 /* epilogue end (size=8) */
252 /* function FrameMgr_processFrame size 88 (73) */
253 .size FrameMgr_processFrame, .-FrameMgr_processFrame
254 .stabs "i:r(0,11)",64,0,518,13
255 .stabs "k:r(0,11)",64,0,518,24
256 .stabs "color:r(0,11)",64,0,518,24
257 .stabs "pTableData:r(0,22)=*(0,11)",64,0,523,28
258 .stabs "tmpUpperLeftX:r(0,11)",64,0,524,17
259 .stabs "tmpUpperLeftY:r(0,11)",64,0,524,16
260 .stabs "tmpLowerRightX:r(0,11)",64,0,524,15
261 .stabs "tmpLowerRightY:r(0,11)",64,0,524,14
262 .stabn 192,0,0,FrameMgr_processFrame-FrameMgr_processFrame
263 .stabn 224,0,0,.Lscope0-FrameMgr_processFrame
264 .Lscope0:
265 .stabs "",36,0,0,.Lscope0-FrameMgr_processFrame
266 .stabd 78,0,0
267 .stabs "FrameMgr_processLine:F(0,15)",36,0,342,FrameMgr_processLine
268 .global FrameMgr_processLine
269 .type FrameMgr_processLine, @function
270 FrameMgr_processLine:
271 .stabd 46,0,0
272 .stabn 68,0,342,.LM29-FrameMgr_processLine
273 .LM29:
274 /* prologue: frame size=1 */
275 00b2 2F92 push r2
276 00b4 3F92 push r3
277 00b6 4F92 push r4
278 00b8 5F92 push r5
279 00ba 6F92 push r6
280 00bc 7F92 push r7
281 00be 8F92 push r8
282 00c0 9F92 push r9
283 00c2 AF92 push r10
284 00c4 BF92 push r11
285 00c6 CF92 push r12
286 00c8 DF92 push r13
287 00ca EF92 push r14
288 00cc FF92 push r15
289 00ce 0F93 push r16
290 00d0 1F93 push r17
291 00d2 CF93 push r28
292 00d4 DF93 push r29
293 00d6 CDB7 in r28,__SP_L__
294 00d8 DEB7 in r29,__SP_H__
295 00da 2197 sbiw r28,1
296 00dc 0FB6 in __tmp_reg__,__SREG__
297 00de F894 cli
298 00e0 DEBF out __SP_H__,r29
299 00e2 0FBE out __SREG__,__tmp_reg__
300 00e4 CDBF out __SP_L__,r28
301 /* prologue end (size=26) */
302 .stabn 68,0,345,.LM30-FrameMgr_processLine
303 .LM30:
304 00e6 0091 0000 lds r16,pCurrentTrackedObjectTable
305 00ea 1091 0000 lds r17,(pCurrentTrackedObjectTable)+1
306 .stabn 68,0,352,.LM31-FrameMgr_processLine
307 .LM31:
GAS LISTING /tmp/ccf43P2i.s page 17
 
 
308 00ee 8091 0000 lds r24,currentState
309 00f2 8230 cpi r24,lo8(2)
310 00f4 09F0 breq .+2
311 00f6 6AC0 rjmp .L27
312 .stabn 68,0,361,.LM32-FrameMgr_processLine
313 .LM32:
314 00f8 8BE0 ldi r24,lo8(11)
315 00fa 00D0 rcall UartInt_txByte
316 .stabn 68,0,362,.LM33-FrameMgr_processLine
317 .LM33:
318 00fc 8091 0000 lds r24,lineCount
319 0100 00D0 rcall UartInt_txByte
320 0102 0F2E mov __tmp_reg__,r31
321 0104 F0E0 ldi r31,lo8(currentLineBuffer)
322 0106 CF2E mov r12,r31
323 0108 F0E0 ldi r31,hi8(currentLineBuffer)
324 010a DF2E mov r13,r31
325 010c F02D mov r31,__tmp_reg__
326 010e 00E0 ldi r16,lo8(0)
327 0110 10E0 ldi r17,hi8(0)
328 0112 0F2E mov __tmp_reg__,r31
329 0114 F0E0 ldi r31,lo8(previousLineBuffer)
330 0116 EF2E mov r14,r31
331 0118 F0E0 ldi r31,hi8(previousLineBuffer)
332 011a FF2E mov r15,r31
333 011c F02D mov r31,__tmp_reg__
334 .L29:
335 .stabn 68,0,370,.LM34-FrameMgr_processLine
336 .LM34:
337 011e F601 movw r30,r12
338 0120 8081 ld r24,Z
339 0122 8983 std Y+1,r24
340 .stabn 68,0,371,.LM35-FrameMgr_processLine
341 .LM35:
342 0124 8981 ldd r24,Y+1
343 0126 8F70 andi r24,lo8(15)
344 0128 8983 std Y+1,r24
345 .stabn 68,0,372,.LM36-FrameMgr_processLine
346 .LM36:
347 012a 8981 ldd r24,Y+1
348 012c 8295 swap r24
349 012e 807F andi r24,0xf0
350 0130 8983 std Y+1,r24
351 .stabn 68,0,373,.LM37-FrameMgr_processLine
352 .LM37:
353 0132 9981 ldd r25,Y+1
354 0134 F701 movw r30,r14
355 0136 8081 ld r24,Z
356 0138 8F70 andi r24,lo8(15)
357 013a 892B or r24,r25
358 013c 8983 std Y+1,r24
359 .stabn 68,0,376,.LM38-FrameMgr_processLine
360 .LM38:
361 013e 8981 ldd r24,Y+1
362 0140 00D0 rcall UartInt_txByte
363 .stabn 68,0,379,.LM39-FrameMgr_processLine
364 .LM39:
GAS LISTING /tmp/ccf43P2i.s page 18
 
 
365 0142 D801 movw r26,r16
366 0144 1196 adiw r26,1
367 0146 FD01 movw r30,r26
368 0148 E050 subi r30,lo8(-(previousLineBuffer))
369 014a F040 sbci r31,hi8(-(previousLineBuffer))
370 014c 8081 ld r24,Z
371 014e 8983 std Y+1,r24
372 .stabn 68,0,380,.LM40-FrameMgr_processLine
373 .LM40:
374 0150 8981 ldd r24,Y+1
375 0152 8F70 andi r24,lo8(15)
376 0154 8983 std Y+1,r24
377 .stabn 68,0,381,.LM41-FrameMgr_processLine
378 .LM41:
379 0156 8981 ldd r24,Y+1
380 0158 8295 swap r24
381 015a 807F andi r24,0xf0
382 015c 8983 std Y+1,r24
383 .stabn 68,0,382,.LM42-FrameMgr_processLine
384 .LM42:
385 015e 9981 ldd r25,Y+1
386 0160 A050 subi r26,lo8(-(currentLineBuffer))
387 0162 B040 sbci r27,hi8(-(currentLineBuffer))
388 0164 8C91 ld r24,X
389 0166 8F70 andi r24,lo8(15)
390 0168 892B or r24,r25
391 016a 8983 std Y+1,r24
392 .stabn 68,0,385,.LM43-FrameMgr_processLine
393 .LM43:
394 016c 8981 ldd r24,Y+1
395 016e 00D0 rcall UartInt_txByte
396 0170 82E0 ldi r24,lo8(2)
397 0172 90E0 ldi r25,hi8(2)
398 0174 C80E add r12,r24
399 0176 D91E adc r13,r25
400 0178 0E5F subi r16,lo8(-(2))
401 017a 1F4F sbci r17,hi8(-(2))
402 017c E80E add r14,r24
403 017e F91E adc r15,r25
404 .stabn 68,0,363,.LM44-FrameMgr_processLine
405 .LM44:
406 0180 003B cpi r16,176
407 0182 1105 cpc r17,__zero_reg__
408 0184 61F6 brne .L29
409 .stabn 68,0,387,.LM45-FrameMgr_processLine
410 .LM45:
411 0186 8FE0 ldi r24,lo8(15)
412 0188 00D0 rcall UartInt_txByte
413 .stabn 68,0,391,.LM46-FrameMgr_processLine
414 .LM46:
415 018a 8091 0000 lds r24,lineCount
416 018e 8F5F subi r24,lo8(-(1))
417 0190 8093 0000 sts lineCount,r24
418 .stabn 68,0,394,.LM47-FrameMgr_processLine
419 .LM47:
420 0194 8834 cpi r24,lo8(72)
421 0196 60F0 brlo .L31
GAS LISTING /tmp/ccf43P2i.s page 19
 
 
422 .stabn 68,0,398,.LM48-FrameMgr_processLine
423 .LM48:
424 0198 1092 0000 sts lineCount,__zero_reg__
425 .stabn 68,0,399,.LM49-FrameMgr_processLine
426 .LM49:
427 019c 1092 0000 sts currentState,__zero_reg__
428 .stabn 68,0,402,.LM50-FrameMgr_processLine
429 .LM50:
430 01a0 89B7 in r24,89-0x20
431 01a2 8B7F andi r24,lo8(-5)
432 01a4 89BF out 89-0x20,r24
433 .stabn 68,0,404,.LM51-FrameMgr_processLine
434 .LM51:
435 01a6 60E0 ldi r22,lo8(0)
436 01a8 81E1 ldi r24,lo8(17)
437 01aa 00D0 rcall CamConfig_setCamReg
438 .stabn 68,0,405,.LM52-FrameMgr_processLine
439 .LM52:
440 01ac 00D0 rcall CamConfig_sendFifoCmds
441 01ae C8C0 rjmp .L71
442 .L31:
443 .stabn 68,0,410,.LM53-FrameMgr_processLine
444 .LM53:
445 01b0 8091 0000 lds r24,fastEventBitmask
446 01b4 8260 ori r24,lo8(2)
447 01b6 8093 0000 sts fastEventBitmask,r24
448 01ba C2C0 rjmp .L71
449 .L72:
450 .stabn 68,0,491,.LM54-FrameMgr_processLine
451 .LM54:
452 01bc 80E2 ldi r24,lo8(32)
453 01be 00D0 rcall Exec_writeEventFifo
454 .stabn 68,0,493,.LM55-FrameMgr_processLine
455 .LM55:
456 01c0 89B7 in r24,89-0x20
457 01c2 8B7F andi r24,lo8(-5)
458 01c4 89BF out 89-0x20,r24
459 .stabn 68,0,494,.LM56-FrameMgr_processLine
460 .LM56:
461 01c6 1092 0000 sts trackedLineCount,__zero_reg__
462 01ca BAC0 rjmp .L71
463 .L27:
464 .stabn 68,0,413,.LM57-FrameMgr_processLine
465 .LM57:
466 01cc 8130 cpi r24,lo8(1)
467 01ce 09F0 breq .+2
468 01d0 B7C0 rjmp .L71
469 .LBB4:
470 .LBB5:
606:FrameMgr.c **** }
607:FrameMgr.c ****
608:FrameMgr.c **** /***********************************************************
609:FrameMgr.c **** Function Name: FrameMgr_findConnectedness
610:FrameMgr.c **** Function Description: This function is responsible for
611:FrameMgr.c **** finding the connectedness between two particular run-
612:FrameMgr.c **** length encoded lines of pixel data. It updates the
613:FrameMgr.c **** trackingTable as needed.
GAS LISTING /tmp/ccf43P2i.s page 20
 
 
614:FrameMgr.c **** Inputs: none
615:FrameMgr.c **** Outputs: none
616:FrameMgr.c **** ***********************************************************/
617:FrameMgr.c **** static void FrameMgr_findConnectedness(void)
618:FrameMgr.c **** {
619:FrameMgr.c **** trackedColor_t currColor;
620:FrameMgr.c **** unsigned char *pCurrLineColorInfo = currentLineBuffer;
621:FrameMgr.c **** unsigned char *pTrackedObjectData;
622:FrameMgr.c **** register unsigned char currPixelRunStart=0;
623:FrameMgr.c **** register unsigned char currPixelRunFinish=0;
624:FrameMgr.c **** register unsigned char lastLineXStart=0;
625:FrameMgr.c **** register unsigned char lastLineXFinish=0;
626:FrameMgr.c **** register unsigned char runLength=1;
627:FrameMgr.c **** unsigned char i;
628:FrameMgr.c **** bool_t colorConnected;
629:FrameMgr.c ****
630:FrameMgr.c **** do
631:FrameMgr.c **** {
632:FrameMgr.c **** /* grab both the current color and the number of pixels
633:FrameMgr.c **** in the run...remember, pixels start at 1, not 0! */
634:FrameMgr.c **** colorConnected = FALSE;
635:FrameMgr.c **** currColor = *pCurrLineColorInfo++;
636:FrameMgr.c **** currPixelRunStart += runLength;
637:FrameMgr.c **** runLength = *pCurrLineColorInfo++;
638:FrameMgr.c **** currPixelRunFinish += runLength;
639:FrameMgr.c ****
640:FrameMgr.c **** /* make sure that the run-length is at least as wide as
641:FrameMgr.c **** the minimum horizontal tracking width, and we care about the color */
642:FrameMgr.c ****
643:FrameMgr.c **** if ( (currColor != notTracked) && (runLength > MIN_OBJECT_TRACKING_WIDTH) )
644:FrameMgr.c **** {
645:FrameMgr.c **** /* this run contains a color we care about, so
646:FrameMgr.c **** either it will begin a new tracked object, or it
647:FrameMgr.c **** is connected to a currently tracked object...
648:FrameMgr.c **** compare it with each object in the tracking
649:FrameMgr.c **** table...we can't just look at the numTrackedObjects because
650:FrameMgr.c **** it is entirely possible that the first couple of objects could
651:FrameMgr.c **** be invalid...
652:FrameMgr.c ****
653:FrameMgr.c **** NOTE: Instead of accessing each element in the trackedObjectTable
654:FrameMgr.c **** through the 'i' index, and then accessing the fields in each structure,
655:FrameMgr.c **** a pointer to each entry is established each time through the loop, followed
656:FrameMgr.c **** by accessing the elements through specified offsets. GCC seems to be
657:FrameMgr.c **** able to optimize this code much better than simply accessing the elements
658:FrameMgr.c **** of each structure in the array the more normal way...*/
659:FrameMgr.c ****
660:FrameMgr.c **** pTrackedObjectData = (unsigned char *)pCurrentTrackedObjectTable;
661:FrameMgr.c **** for (i=0; i<MAX_TRACKED_OBJECTS; i++)
662:FrameMgr.c **** {
663:FrameMgr.c **** if ( (currColor == *(pTrackedObjectData + COLOR_OFFSET)) &&
664:FrameMgr.c **** (*(pTrackedObjectData + VALID_OBJECT_OFFSET) == TRUE) &&
665:FrameMgr.c **** (*(pTrackedObjectData + Y_LOWER_RIGHT_OFFSET) == trackedLineCount - 1) )
666:FrameMgr.c **** {
667:FrameMgr.c **** /* found a color match and the object is valid...check to see if there is
668:FrameMgr.c **** connectedness */
669:FrameMgr.c **** lastLineXStart = *(pTrackedObjectData + LAST_LINE_X_START_OFFSET);
670:FrameMgr.c **** lastLineXFinish = *(pTrackedObjectData + LAST_LINE_X_FINISH_OFFSET);
GAS LISTING /tmp/ccf43P2i.s page 21
 
 
671:FrameMgr.c ****
672:FrameMgr.c **** /* Check for the 5 following types of line connectedness:
673:FrameMgr.c **** ---------------------
674:FrameMgr.c **** | |
675:FrameMgr.c **** ---------------------
676:FrameMgr.c **** -------------------------
677:FrameMgr.c **** | |
678:FrameMgr.c **** ------------------------- */
679:FrameMgr.c **** if ( ( (currPixelRunStart >= lastLineXStart) &&
680:FrameMgr.c **** (currPixelRunStart <= lastLineXFinish) ) ||
681:FrameMgr.c ****
682:FrameMgr.c **** /* ---------------------
683:FrameMgr.c **** | |
684:FrameMgr.c **** ---------------------
685:FrameMgr.c **** -------------------
686:FrameMgr.c **** | |
687:FrameMgr.c **** -------------------
688:FrameMgr.c **** OR
689:FrameMgr.c **** ------------------------------
690:FrameMgr.c **** | |
691:FrameMgr.c **** ------------------------------
692:FrameMgr.c **** ---------
693:FrameMgr.c **** | |
694:FrameMgr.c **** --------- */
695:FrameMgr.c **** ( (currPixelRunFinish >= lastLineXStart) &&
696:FrameMgr.c **** (currPixelRunFinish <= lastLineXFinish) ) ||
697:FrameMgr.c ****
698:FrameMgr.c ****
699:FrameMgr.c **** /* -------------------------------
700:FrameMgr.c **** | |
701:FrameMgr.c **** -------------------------------
702:FrameMgr.c **** -------------------------------
703:FrameMgr.c **** | |
704:FrameMgr.c **** -------------------------------
705:FrameMgr.c **** OR
706:FrameMgr.c **** -------------
707:FrameMgr.c **** | |
708:FrameMgr.c **** -------------
709:FrameMgr.c **** -------------------------------
710:FrameMgr.c **** | |
711:FrameMgr.c **** ------------------------------- */
712:FrameMgr.c **** ( (currPixelRunStart <= lastLineXStart) &&
713:FrameMgr.c **** (currPixelRunFinish >= lastLineXFinish) ) )
714:FrameMgr.c **** {
715:FrameMgr.c **** /* THERE IS CONNECTEDNESS...update the lastLineXStart and lastLineXFinish
716:FrameMgr.c **** data pointed to by pTrackedObjectData */
717:FrameMgr.c **** *(pTrackedObjectData + LAST_LINE_X_START_OFFSET) = currPixelRunStart;
718:FrameMgr.c **** *(pTrackedObjectData + LAST_LINE_X_FINISH_OFFSET) = currPixelRunFinish;
719:FrameMgr.c ****
720:FrameMgr.c **** /* check if the bounding box needs to be updated */
721:FrameMgr.c **** if (*(pTrackedObjectData + X_UPPER_LEFT_OFFSET) > currPixelRunStart)
722:FrameMgr.c **** {
723:FrameMgr.c **** /* need to update the bounding box for the upper left point to
724:FrameMgr.c **** enclose this new left-most point...we never have to update the
725:FrameMgr.c **** upper left Y point, since each scan line we process moves from
726:FrameMgr.c **** top to bottom */
727:FrameMgr.c **** *(pTrackedObjectData + X_UPPER_LEFT_OFFSET) = currPixelRunStart;
GAS LISTING /tmp/ccf43P2i.s page 22
 
 
728:FrameMgr.c **** }
729:FrameMgr.c ****
730:FrameMgr.c **** if ( *(pTrackedObjectData + X_LOWER_RIGHT_OFFSET) < currPixelRunFinish)
731:FrameMgr.c **** {
732:FrameMgr.c **** /* need to update the bounding box for the lower right X point to
733:FrameMgr.c **** enclose this new right-most point */
734:FrameMgr.c **** *(pTrackedObjectData + X_LOWER_RIGHT_OFFSET) = currPixelRunFinish;
735:FrameMgr.c **** }
736:FrameMgr.c ****
737:FrameMgr.c **** /* the lower right 'y' point always gets updated when connectedness is found */
738:FrameMgr.c **** *(pTrackedObjectData + Y_LOWER_RIGHT_OFFSET) = trackedLineCount;
739:FrameMgr.c ****
740:FrameMgr.c **** /* set a flag indicating that that color run is part of another
741:FrameMgr.c **** object and thus doesn't need to be added as a new entry into the
742:FrameMgr.c **** tracking table */
743:FrameMgr.c **** colorConnected = TRUE;
744:FrameMgr.c **** break;
745:FrameMgr.c **** }
746:FrameMgr.c **** }
747:FrameMgr.c ****
748:FrameMgr.c **** /* go to the next object */
749:FrameMgr.c **** pTrackedObjectData += SIZE_OF_TRACKED_OBJECT;
750:FrameMgr.c **** }
751:FrameMgr.c ****
752:FrameMgr.c **** if (colorConnected == FALSE)
753:FrameMgr.c **** {
754:FrameMgr.c **** /* a new entry needs to be made to the tracking table, since we have
755:FrameMgr.c **** a run-length with a color, and it isn't connected to anything...but we
756:FrameMgr.c **** can only do this if there is space left in the trackedObject table */
757:FrameMgr.c **** if (numCurrTrackedObjects < MAX_TRACKED_OBJECTS)
758:FrameMgr.c **** {
759:FrameMgr.c **** /* space is available...add the object...but first we need to find an
760:FrameMgr.c **** invalid object in the object tracking table */
761:FrameMgr.c **** pTrackedObjectData = (unsigned char *)pCurrentTrackedObjectTable;
762:FrameMgr.c **** for (i=0; i<MAX_TRACKED_OBJECTS; i++)
763:FrameMgr.c **** {
764:FrameMgr.c **** if ( *(pTrackedObjectData + VALID_OBJECT_OFFSET) == FALSE) break;
765:FrameMgr.c ****
766:FrameMgr.c **** /* if we haven't broken above, then the object must have been valid...
767:FrameMgr.c **** go ahead and move the pointer to the next object to check it */
768:FrameMgr.c **** pTrackedObjectData += SIZE_OF_TRACKED_OBJECT;
769:FrameMgr.c **** }
770:FrameMgr.c ****
771:FrameMgr.c ****
772:FrameMgr.c **** /* now that we have a pointer to the tracked object to be updated, update all
773:FrameMgr.c **** the fields */
774:FrameMgr.c **** *(pTrackedObjectData + COLOR_OFFSET) = currColor; /* color */
775:FrameMgr.c **** *(pTrackedObjectData + LAST_LINE_X_START_OFFSET) = currPixelRunStart; /* lastLineXStart */
776:FrameMgr.c **** *(pTrackedObjectData + LAST_LINE_X_FINISH_OFFSET) = currPixelRunFinish; /* lastLineXFinish *
777:FrameMgr.c **** *(pTrackedObjectData + X_UPPER_LEFT_OFFSET) = currPixelRunStart; /* x_upperLeft */
778:FrameMgr.c **** *(pTrackedObjectData + Y_UPPER_LEFT_OFFSET) = trackedLineCount; /* y_upperLeft */
471 .stabn 68,0,778,.LM58-FrameMgr_processLine
472 .LM58:
473 01d2 F090 0000 lds r15,trackedLineCount
474 .stabn 68,0,663,.LM59-FrameMgr_processLine
475 .LM59:
476 01d6 CF2C mov r12,r15
GAS LISTING /tmp/ccf43P2i.s page 23
 
 
477 01d8 DD24 clr r13
478 01da 3601 movw r6,r12
479 01dc 0894 sec
480 01de 6108 sbc r6,__zero_reg__
481 01e0 7108 sbc r7,__zero_reg__
482 01e2 7091 0000 lds r23,numCurrTrackedObjects
483 01e6 0F2E mov __tmp_reg__,r31
484 01e8 F0E0 ldi r31,lo8(currentLineBuffer)
485 01ea 2F2E mov r2,r31
486 01ec F0E0 ldi r31,hi8(currentLineBuffer)
487 01ee 3F2E mov r3,r31
488 01f0 F02D mov r31,__tmp_reg__
489 01f2 50E0 ldi r21,lo8(0)
490 01f4 40E0 ldi r20,lo8(0)
491 01f6 61E0 ldi r22,lo8(1)
492 01f8 EF2C mov r14,r15
493 01fa E394 inc r14
494 .L35:
495 .stabn 68,0,635,.LM60-FrameMgr_processLine
496 .LM60:
497 01fc F101 movw r30,r2
498 01fe 3081 ld r19,Z
499 .stabn 68,0,636,.LM61-FrameMgr_processLine
500 .LM61:
501 0200 560F add r21,r22
502 .stabn 68,0,637,.LM62-FrameMgr_processLine
503 .LM62:
504 0202 6181 ldd r22,Z+1
505 0204 82E0 ldi r24,lo8(2)
506 0206 90E0 ldi r25,hi8(2)
507 0208 280E add r2,r24
508 020a 391E adc r3,r25
509 .stabn 68,0,638,.LM63-FrameMgr_processLine
510 .LM63:
511 020c 460F add r20,r22
512 .stabn 68,0,643,.LM64-FrameMgr_processLine
513 .LM64:
514 020e 3323 tst r19
515 0210 09F4 brne .+2
516 0212 5CC0 rjmp .L36
517 0214 6430 cpi r22,lo8(4)
518 0216 08F4 brsh .+2
519 0218 59C0 rjmp .L36
520 021a D801 movw r26,r16
521 021c 20E0 ldi r18,lo8(0)
522 .L39:
523 .stabn 68,0,663,.LM65-FrameMgr_processLine
524 .LM65:
525 021e 8C91 ld r24,X
526 0220 3817 cp r19,r24
527 0222 C9F5 brne .L40
528 0224 FD01 movw r30,r26
529 0226 8781 ldd r24,Z+7
530 0228 8130 cpi r24,lo8(1)
531 022a A9F5 brne .L40
532 022c 0F2E mov __tmp_reg__,r31
533 022e F6E0 ldi r31,lo8(6)
GAS LISTING /tmp/ccf43P2i.s page 24
 
 
534 0230 AF2E mov r10,r31
535 0232 BB24 clr r11
536 0234 F02D mov r31,__tmp_reg__
537 0236 AA0E add r10,r26
538 0238 BB1E adc r11,r27
539 023a 8681 ldd r24,Z+6
540 023c 9927 clr r25
541 023e 8615 cp r24,r6
542 0240 9705 cpc r25,r7
543 0242 49F5 brne .L40
544 0244 2D01 movw r4,r26
545 0246 0894 sec
546 0248 411C adc r4,__zero_reg__
547 024a 511C adc r5,__zero_reg__
548 .stabn 68,0,669,.LM66-FrameMgr_processLine
549 .LM66:
550 024c 8181 ldd r24,Z+1
551 024e 8824 clr r8
552 0250 9924 clr r9
553 0252 6894 set
554 0254 81F8 bld r8,1
555 0256 8A0E add r8,r26
556 0258 9B1E adc r9,r27
557 .stabn 68,0,670,.LM67-FrameMgr_processLine
558 .LM67:
559 025a 9281 ldd r25,Z+2
560 .stabn 68,0,679,.LM68-FrameMgr_processLine
561 .LM68:
562 025c 5817 cp r21,r24
563 025e 10F0 brlo .L44
564 0260 9517 cp r25,r21
565 0262 40F4 brsh .L46
566 .L44:
567 0264 4817 cp r20,r24
568 0266 10F0 brlo .L47
569 0268 9417 cp r25,r20
570 026a 20F4 brsh .L46
571 .L47:
572 026c 8517 cp r24,r21
573 026e 98F0 brlo .L40
574 0270 4917 cp r20,r25
575 0272 88F0 brlo .L40
576 .L46:
577 .stabn 68,0,717,.LM69-FrameMgr_processLine
578 .LM69:
579 0274 F201 movw r30,r4
580 0276 5083 st Z,r21
581 .stabn 68,0,718,.LM70-FrameMgr_processLine
582 .LM70:
583 0278 F401 movw r30,r8
584 027a 4083 st Z,r20
585 .stabn 68,0,721,.LM71-FrameMgr_processLine
586 .LM71:
587 027c FD01 movw r30,r26
588 027e 8381 ldd r24,Z+3
589 0280 5817 cp r21,r24
590 0282 08F4 brsh .L50
GAS LISTING /tmp/ccf43P2i.s page 25
 
 
591 .stabn 68,0,727,.LM72-FrameMgr_processLine
592 .LM72:
593 0284 5383 std Z+3,r21
594 .L50:
595 .stabn 68,0,730,.LM73-FrameMgr_processLine
596 .LM73:
597 0286 FD01 movw r30,r26
598 0288 8581 ldd r24,Z+5
599 028a 8417 cp r24,r20
600 028c 08F4 brsh .L52
601 .stabn 68,0,734,.LM74-FrameMgr_processLine
602 .LM74:
603 028e 4583 std Z+5,r20
604 .L52:
605 .stabn 68,0,738,.LM75-FrameMgr_processLine
606 .LM75:
607 0290 F501 movw r30,r10
608 0292 F082 st Z,r15
609 0294 1BC0 rjmp .L36
610 .L40:
611 .stabn 68,0,661,.LM76-FrameMgr_processLine
612 .LM76:
613 0296 2F5F subi r18,lo8(-(1))
614 0298 2830 cpi r18,lo8(8)
615 029a 09F4 brne .+2
616 029c 4DC0 rjmp .L54
617 .stabn 68,0,749,.LM77-FrameMgr_processLine
618 .LM77:
619 029e 1896 adiw r26,8
620 02a0 BECF rjmp .L39
621 .L56:
622 02a2 D801 movw r26,r16
623 02a4 90E0 ldi r25,lo8(0)
624 .L57:
625 .stabn 68,0,764,.LM78-FrameMgr_processLine
626 .LM78:
627 02a6 FD01 movw r30,r26
628 02a8 8781 ldd r24,Z+7
629 02aa 8823 tst r24
630 02ac 21F0 breq .L58
631 .stabn 68,0,768,.LM79-FrameMgr_processLine
632 .LM79:
633 02ae 1896 adiw r26,8
634 .stabn 68,0,762,.LM80-FrameMgr_processLine
635 .LM80:
636 02b0 9F5F subi r25,lo8(-(1))
637 02b2 9830 cpi r25,lo8(8)
638 02b4 C1F7 brne .L57
639 .L58:
640 .stabn 68,0,774,.LM81-FrameMgr_processLine
641 .LM81:
642 02b6 3C93 st X,r19
643 .stabn 68,0,775,.LM82-FrameMgr_processLine
644 .LM82:
645 02b8 FD01 movw r30,r26
646 02ba 5183 std Z+1,r21
647 .stabn 68,0,776,.LM83-FrameMgr_processLine
GAS LISTING /tmp/ccf43P2i.s page 26
 
 
648 .LM83:
649 02bc 4283 std Z+2,r20
650 .stabn 68,0,777,.LM84-FrameMgr_processLine
651 .LM84:
652 02be 5383 std Z+3,r21
653 .stabn 68,0,778,.LM85-FrameMgr_processLine
654 .LM85:
655 02c0 F482 std Z+4,r15
779:FrameMgr.c **** *(pTrackedObjectData + X_LOWER_RIGHT_OFFSET) = currPixelRunFinish; /* x_lowerRight */
656 .stabn 68,0,779,.LM86-FrameMgr_processLine
657 .LM86:
658 02c2 4583 std Z+5,r20
780:FrameMgr.c **** *(pTrackedObjectData + Y_LOWER_RIGHT_OFFSET) = trackedLineCount; /* y_lowerRight */
659 .stabn 68,0,780,.LM87-FrameMgr_processLine
660 .LM87:
661 02c4 F682 std Z+6,r15
781:FrameMgr.c **** *(pTrackedObjectData + VALID_OBJECT_OFFSET) = TRUE; /* o
662 .stabn 68,0,781,.LM88-FrameMgr_processLine
663 .LM88:
664 02c6 81E0 ldi r24,lo8(1)
665 02c8 8783 std Z+7,r24
782:FrameMgr.c ****
783:FrameMgr.c **** numCurrTrackedObjects++;
666 .stabn 68,0,783,.LM89-FrameMgr_processLine
667 .LM89:
668 02ca 7F5F subi r23,lo8(-(1))
669 .L36:
784:FrameMgr.c **** }
785:FrameMgr.c **** }
786:FrameMgr.c ****
787:FrameMgr.c **** /* move the pointer to the beginning of the next tracked object */
788:FrameMgr.c **** pTrackedObjectData += SIZE_OF_TRACKED_OBJECT;
789:FrameMgr.c **** }
790:FrameMgr.c **** } while(currPixelRunFinish < ACTUAL_NUM_PIXELS_IN_A_LINE);
670 .stabn 68,0,790,.LM90-FrameMgr_processLine
671 .LM90:
672 02cc 403B cpi r20,lo8(-80)
673 02ce 08F4 brsh .+2
674 02d0 95CF rjmp .L35
675 02d2 7093 0000 sts numCurrTrackedObjects,r23
676 .LBE5:
677 .LBE4:
678 .stabn 68,0,460,.LM91-FrameMgr_processLine
679 .LM91:
680 02d6 C601 movw r24,r12
681 02d8 8770 andi r24,lo8(7)
682 02da 9070 andi r25,hi8(7)
683 02dc 0797 sbiw r24,7
684 02de 01F5 brne .L61
685 02e0 D801 movw r26,r16
686 02e2 1796 adiw r26,7
687 02e4 40E0 ldi r20,lo8(0)
688 .L63:
689 .stabn 68,0,464,.LM92-FrameMgr_processLine
690 .LM92:
691 02e6 8C91 ld r24,X
692 02e8 8130 cpi r24,lo8(1)
GAS LISTING /tmp/ccf43P2i.s page 27
 
 
693 02ea A1F4 brne .L64
694 02ec FD01 movw r30,r26
695 02ee 3197 sbiw r30,1
696 .stabn 68,0,468,.LM93-FrameMgr_processLine
697 .LM93:
698 02f0 9081 ld r25,Z
699 02f2 FD01 movw r30,r26
700 02f4 3397 sbiw r30,3
701 02f6 8081 ld r24,Z
702 02f8 292F mov r18,r25
703 02fa 3327 clr r19
704 02fc F901 movw r30,r18
705 02fe E81B sub r30,r24
706 0300 F109 sbc r31,__zero_reg__
707 0302 3397 sbiw r30,3
708 0304 3CF4 brge .L64
709 .stabn 68,0,474,.LM94-FrameMgr_processLine
710 .LM94:
711 0306 C601 movw r24,r12
712 0308 821B sub r24,r18
713 030a 930B sbc r25,r19
714 030c 0397 sbiw r24,3
715 030e 14F0 brlt .L64
716 .stabn 68,0,477,.LM95-FrameMgr_processLine
717 .LM95:
718 0310 1C92 st X,__zero_reg__
719 .stabn 68,0,478,.LM96-FrameMgr_processLine
720 .LM96:
721 0312 7150 subi r23,lo8(-(-1))
722 .L64:
723 .stabn 68,0,462,.LM97-FrameMgr_processLine
724 .LM97:
725 0314 4F5F subi r20,lo8(-(1))
726 0316 1896 adiw r26,8
727 0318 4830 cpi r20,lo8(8)
728 031a 29F7 brne .L63
729 031c 7093 0000 sts numCurrTrackedObjects,r23
730 .L61:
731 .stabn 68,0,486,.LM98-FrameMgr_processLine
732 .LM98:
733 0320 E092 0000 sts trackedLineCount,r14
734 .stabn 68,0,487,.LM99-FrameMgr_processLine
735 .LM99:
736 0324 F0E9 ldi r31,lo8(-112)
737 0326 EF16 cp r14,r31
738 0328 09F4 brne .+2
739 032a 48CF rjmp .L72
740 .stabn 68,0,498,.LM100-FrameMgr_processLine
741 .LM100:
742 032c 8091 0000 lds r24,fastEventBitmask
743 0330 8260 ori r24,lo8(2)
744 0332 8093 0000 sts fastEventBitmask,r24
745 0336 04C0 rjmp .L71
746 .L54:
747 .LBB6:
748 .LBB7:
749 .stabn 68,0,757,.LM101-FrameMgr_processLine
GAS LISTING /tmp/ccf43P2i.s page 28
 
 
750 .LM101:
751 0338 7830 cpi r23,lo8(8)
752 033a 08F4 brsh .+2
753 033c B2CF rjmp .L56
754 033e C6CF rjmp .L36
755 .L71:
756 .LBE7:
757 .LBE6:
758 /* epilogue: frame size=1 */
759 0340 2196 adiw r28,1
760 0342 0FB6 in __tmp_reg__,__SREG__
761 0344 F894 cli
762 0346 DEBF out __SP_H__,r29
763 0348 0FBE out __SREG__,__tmp_reg__
764 034a CDBF out __SP_L__,r28
765 034c DF91 pop r29
766 034e CF91 pop r28
767 0350 1F91 pop r17
768 0352 0F91 pop r16
769 0354 FF90 pop r15
770 0356 EF90 pop r14
771 0358 DF90 pop r13
772 035a CF90 pop r12
773 035c BF90 pop r11
774 035e AF90 pop r10
775 0360 9F90 pop r9
776 0362 8F90 pop r8
777 0364 7F90 pop r7
778 0366 6F90 pop r6
779 0368 5F90 pop r5
780 036a 4F90 pop r4
781 036c 3F90 pop r3
782 036e 2F90 pop r2
783 0370 0895 ret
784 /* epilogue end (size=25) */
785 /* function FrameMgr_processLine size 355 (304) */
786 .size FrameMgr_processLine, .-FrameMgr_processLine
787 .stabs "i:r(0,11)",64,0,343,20
788 .stabs "dataToSend:(0,23)=B(0,11)",128,0,344,1
789 .stabs "pTrackedObjectData:r(0,22)",64,0,345,26
790 .stabn 192,0,0,FrameMgr_processLine-FrameMgr_processLine
791 .stabn 224,0,0,.Lscope1-FrameMgr_processLine
792 .Lscope1:
793 .stabs "",36,0,0,.Lscope1-FrameMgr_processLine
794 .stabd 78,0,0
795 .stabs "FrameMgr_init:F(0,15)",36,0,191,FrameMgr_init
796 .global FrameMgr_init
797 .type FrameMgr_init, @function
798 FrameMgr_init:
799 .stabd 46,0,0
800 .stabn 68,0,191,.LM102-FrameMgr_init
801 .LM102:
802 /* prologue: frame size=0 */
803 /* prologue end (size=0) */
804 .stabn 68,0,192,.LM103-FrameMgr_init
805 .LM103:
806 0372 80E4 ldi r24,lo8(64)
GAS LISTING /tmp/ccf43P2i.s page 29
 
 
807 0374 E0E0 ldi r30,lo8(trackedObjectTable)
808 0376 F0E0 ldi r31,hi8(trackedObjectTable)
809 0378 1192 st Z+,__zero_reg__
810 037a 8A95 dec r24
811 037c E9F7 brne .-6
812 /* epilogue: frame size=0 */
813 037e 0895 ret
814 /* epilogue end (size=1) */
815 /* function FrameMgr_init size 7 (6) */
816 .size FrameMgr_init, .-FrameMgr_init
817 .Lscope2:
818 .stabs "",36,0,0,.Lscope2-FrameMgr_init
819 .stabd 78,0,0
820 .stabs "FrameMgr_acquireLine:F(0,15)",36,0,287,FrameMgr_acquireLine
821 .global FrameMgr_acquireLine
822 .type FrameMgr_acquireLine, @function
823 FrameMgr_acquireLine:
824 .stabd 46,0,0
825 .stabn 68,0,287,.LM104-FrameMgr_acquireLine
826 .LM104:
827 /* prologue: frame size=0 */
828 /* prologue end (size=0) */
829 .stabn 68,0,297,.LM105-FrameMgr_acquireLine
830 .LM105:
831 0380 8091 0000 lds r24,currentState
832 0384 8230 cpi r24,lo8(2)
833 0386 49F5 brne .L83
834 .stabn 68,0,299,.LM106-FrameMgr_acquireLine
835 .LM106:
836 0388 8091 0000 lds r24,lineCount
837 038c 282F mov r18,r24
838 038e 220F lsl r18
839 .stabn 68,0,305,.LM107-FrameMgr_acquireLine
840 .LM107:
841 0390 80EB ldi r24,lo8(-80)
842 0392 E0E0 ldi r30,lo8(currentLineBuffer)
843 0394 F0E0 ldi r31,hi8(currentLineBuffer)
844 0396 982F mov r25,r24
845 0398 1192 st Z+,__zero_reg__
846 039a 9A95 dec r25
847 039c E9F7 brne .-6
848 .stabn 68,0,306,.LM108-FrameMgr_acquireLine
849 .LM108:
850 039e E0E0 ldi r30,lo8(previousLineBuffer)
851 03a0 F0E0 ldi r31,hi8(previousLineBuffer)
852 03a2 1192 st Z+,__zero_reg__
853 03a4 8A95 dec r24
854 03a6 E9F7 brne .-6
855 .L85:
856 .stabn 68,0,309,.LM109-FrameMgr_acquireLine
857 .LM109:
858 03a8 829B sbis 48-0x20,2
859 03aa FECF rjmp .L85
860 .L101:
861 .stabn 68,0,310,.LM110-FrameMgr_acquireLine
862 .LM110:
863 03ac 829B sbis 48-0x20,2
GAS LISTING /tmp/ccf43P2i.s page 30
 
 
864 03ae 07C0 rjmp .L110
865 03b0 FDCF rjmp .L101
866 .L88:
867 03b2 90E0 ldi r25,lo8(0)
868 .L114:
869 .stabn 68,0,316,.LM111-FrameMgr_acquireLine
870 .LM111:
871 03b4 849B sbis 48-0x20,4
872 03b6 FECF rjmp .L114
873 .L102:
874 .stabn 68,0,318,.LM112-FrameMgr_acquireLine
875 .LM112:
876 03b8 849B sbis 48-0x20,4
877 03ba 04C0 rjmp .L111
878 03bc FDCF rjmp .L102
879 .L110:
880 .stabn 68,0,314,.LM113-FrameMgr_acquireLine
881 .LM113:
882 03be 2223 tst r18
883 03c0 C1F7 brne .L88
884 03c2 05C0 rjmp .L92
885 .L111:
886 03c4 9150 subi r25,lo8(-(-1))
887 03c6 822F mov r24,r18
888 03c8 8195 neg r24
889 03ca 9817 cp r25,r24
890 03cc 99F7 brne .L114
891 .L92:
892 .stabn 68,0,322,.LM114-FrameMgr_acquireLine
893 .LM114:
894 03ce 60E0 ldi r22,lo8(previousLineBuffer)
895 03d0 70E0 ldi r23,hi8(previousLineBuffer)
896 03d2 80E0 ldi r24,lo8(currentLineBuffer)
897 03d4 90E0 ldi r25,hi8(currentLineBuffer)
898 03d6 00D0 rcall CamIntAsm_acquireDumpLine
899 03d8 0895 ret
900 .L83:
901 .stabn 68,0,324,.LM115-FrameMgr_acquireLine
902 .LM115:
903 03da 8130 cpi r24,lo8(1)
904 03dc 39F4 brne .L96
905 .L103:
906 .stabn 68,0,326,.LM116-FrameMgr_acquireLine
907 .LM116:
908 03de 8499 sbic 48-0x20,4
909 03e0 FECF rjmp .L103
910 .stabn 68,0,327,.LM117-FrameMgr_acquireLine
911 .LM117:
912 03e2 60E0 ldi r22,lo8(colorMap)
913 03e4 70E0 ldi r23,hi8(colorMap)
914 03e6 80E0 ldi r24,lo8(currentLineBuffer)
915 03e8 90E0 ldi r25,hi8(currentLineBuffer)
916 03ea 00D0 rcall CamIntAsm_acquireTrackingLine
917 .L96:
918 03ec 0895 ret
919 /* epilogue: frame size=0 */
920 /* epilogue: noreturn */
GAS LISTING /tmp/ccf43P2i.s page 31
 
 
921 /* epilogue end (size=0) */
922 /* function FrameMgr_acquireLine size 55 (55) */
923 .size FrameMgr_acquireLine, .-FrameMgr_acquireLine
924 .stabs "tmpLineCount:r(0,11)",64,0,288,18
925 .stabn 192,0,0,FrameMgr_acquireLine-FrameMgr_acquireLine
926 .stabn 224,0,0,.Lscope3-FrameMgr_acquireLine
927 .Lscope3:
928 .stabs "",36,0,0,.Lscope3-FrameMgr_acquireLine
929 .stabd 78,0,0
930 .stabs "FrameMgr_acquireFrame:F(0,15)",36,0,261,FrameMgr_acquireFrame
931 .global FrameMgr_acquireFrame
932 .type FrameMgr_acquireFrame, @function
933 FrameMgr_acquireFrame:
934 .stabd 46,0,0
935 .stabn 68,0,261,.LM118-FrameMgr_acquireFrame
936 .LM118:
937 /* prologue: frame size=0 */
938 /* prologue end (size=0) */
939 .stabn 68,0,262,.LM119-FrameMgr_acquireFrame
940 .LM119:
941 03ee 8091 0000 lds r24,currentState
942 03f2 8130 cpi r24,lo8(1)
943 03f4 A9F4 brne .L120
944 .stabn 68,0,264,.LM120-FrameMgr_acquireFrame
945 .LM120:
946 03f6 1092 0000 sts trackedLineCount,__zero_reg__
947 .stabn 68,0,265,.LM121-FrameMgr_acquireFrame
948 .LM121:
949 03fa 8091 0000 lds r24,numCurrTrackedObjects
950 03fe 8093 0000 sts numPrevTrackedObjects,r24
951 .stabn 68,0,266,.LM122-FrameMgr_acquireFrame
952 .LM122:
953 0402 1092 0000 sts numCurrTrackedObjects,__zero_reg__
954 .stabn 68,0,270,.LM123-FrameMgr_acquireFrame
955 .LM123:
956 0406 80E4 ldi r24,lo8(64)
957 0408 E0E0 ldi r30,lo8(trackedObjectTable)
958 040a F0E0 ldi r31,hi8(trackedObjectTable)
959 040c 1192 st Z+,__zero_reg__
960 040e 8A95 dec r24
961 0410 E9F7 brne .-6
962 .L118:
963 .stabn 68,0,272,.LM124-FrameMgr_acquireFrame
964 .LM124:
965 0412 829B sbis 48-0x20,2
966 0414 FECF rjmp .L118
967 .stabn 68,0,273,.LM125-FrameMgr_acquireFrame
968 .LM125:
969 0416 60E0 ldi r22,lo8(colorMap)
970 0418 70E0 ldi r23,hi8(colorMap)
971 041a 80E0 ldi r24,lo8(currentLineBuffer)
972 041c 90E0 ldi r25,hi8(currentLineBuffer)
973 041e 00D0 rcall CamIntAsm_acquireTrackingLine
974 .L120:
975 0420 0895 ret
976 /* epilogue: frame size=0 */
977 /* epilogue: noreturn */
GAS LISTING /tmp/ccf43P2i.s page 32
 
 
978 /* epilogue end (size=0) */
979 /* function FrameMgr_acquireFrame size 26 (26) */
980 .size FrameMgr_acquireFrame, .-FrameMgr_acquireFrame
981 .Lscope4:
982 .stabs "",36,0,0,.Lscope4-FrameMgr_acquireFrame
983 .stabd 78,0,0
984 .stabs "FrameMgr_dispatchEvent:F(0,15)",36,0,205,FrameMgr_dispatchEvent
985 .stabs "event:P(0,11)",64,0,204,24
986 .global FrameMgr_dispatchEvent
987 .type FrameMgr_dispatchEvent, @function
988 FrameMgr_dispatchEvent:
989 .stabd 46,0,0
990 .stabn 68,0,205,.LM126-FrameMgr_dispatchEvent
991 .LM126:
992 /* prologue: frame size=0 */
993 /* prologue end (size=0) */
994 .stabn 68,0,206,.LM127-FrameMgr_dispatchEvent
995 .LM127:
996 0422 8430 cpi r24,lo8(4)
997 0424 19F1 breq .L127
998 .stabn 68,0,206,.LM128-FrameMgr_dispatchEvent
999 .LM128:
1000 0426 8530 cpi r24,lo8(5)
1001 0428 28F4 brsh .L131
1002 042a 8130 cpi r24,lo8(1)
1003 042c 09F1 breq .L125
1004 042e 8230 cpi r24,lo8(2)
1005 0430 41F5 brne .L133
1006 0432 07C0 rjmp .L126
1007 .L131:
1008 0434 8038 cpi r24,lo8(-128)
1009 0436 99F0 breq .L129
1010 0438 8138 cpi r24,lo8(-127)
1011 043a 09F1 breq .L130
1012 043c 8032 cpi r24,lo8(32)
1013 043e 09F5 brne .L133
1014 0440 13C0 rjmp .L128
1015 .L126:
1016 .stabn 68,0,211,.LM129-FrameMgr_dispatchEvent
1017 .LM129:
1018 0442 61E0 ldi r22,lo8(1)
1019 0444 81E1 ldi r24,lo8(17)
1020 0446 00D0 rcall CamConfig_setCamReg
1021 .stabn 68,0,212,.LM130-FrameMgr_dispatchEvent
1022 .LM130:
1023 0448 00D0 rcall CamConfig_sendFifoCmds
1024 .stabn 68,0,213,.LM131-FrameMgr_dispatchEvent
1025 .LM131:
1026 044a 88EE ldi r24,lo8(1000)
1027 044c 93E0 ldi r25,hi8(1000)
1028 044e 00D0 rcall Utility_delay
1029 .stabn 68,0,214,.LM132-FrameMgr_dispatchEvent
1030 .LM132:
1031 0450 1092 0000 sts lineCount,__zero_reg__
1032 .stabn 68,0,215,.LM133-FrameMgr_dispatchEvent
1033 .LM133:
1034 0454 82E0 ldi r24,lo8(2)
GAS LISTING /tmp/ccf43P2i.s page 33
 
 
1035 0456 8093 0000 sts currentState,r24
1036 .stabn 68,0,217,.LM134-FrameMgr_dispatchEvent
1037 .LM134:
1038 045a 92DF rcall FrameMgr_acquireLine
1039 045c 0895 ret
1040 .L129:
1041 .stabn 68,0,221,.LM135-FrameMgr_dispatchEvent
1042 .LM135:
1043 045e 81E0 ldi r24,lo8(1)
1044 0460 8093 0000 sts currentState,r24
1045 .stabn 68,0,222,.LM136-FrameMgr_dispatchEvent
1046 .LM136:
1047 0464 C4DF rcall FrameMgr_acquireFrame
1048 0466 0895 ret
1049 .L128:
1050 .stabn 68,0,226,.LM137-FrameMgr_dispatchEvent
1051 .LM137:
1052 0468 CBDD rcall FrameMgr_processFrame
1053 046a 0895 ret
1054 .L127:
1055 .stabn 68,0,230,.LM138-FrameMgr_dispatchEvent
1056 .LM138:
1057 046c C0DF rcall FrameMgr_acquireFrame
1058 046e 0895 ret
1059 .L125:
1060 .stabn 68,0,234,.LM139-FrameMgr_dispatchEvent
1061 .LM139:
1062 0470 8091 0000 lds r24,currentState
1063 0474 8823 tst r24
1064 0476 29F0 breq .L133
1065 .stabn 68,0,240,.LM140-FrameMgr_dispatchEvent
1066 .LM140:
1067 0478 84E0 ldi r24,lo8(4)
1068 047a 00D0 rcall Exec_writeEventFifo
1069 047c 0895 ret
1070 .L130:
1071 .stabn 68,0,246,.LM141-FrameMgr_dispatchEvent
1072 .LM141:
1073 047e 1092 0000 sts currentState,__zero_reg__
1074 .L133:
1075 0482 0895 ret
1076 /* epilogue: frame size=0 */
1077 /* epilogue: noreturn */
1078 /* epilogue end (size=0) */
1079 /* function FrameMgr_dispatchEvent size 49 (49) */
1080 .size FrameMgr_dispatchEvent, .-FrameMgr_dispatchEvent
1081 .Lscope5:
1082 .stabs "",36,0,0,.Lscope5-FrameMgr_dispatchEvent
1083 .stabd 78,0,0
1084 .data
1085 .type pCurrentTrackedObjectTable, @object
1086 .size pCurrentTrackedObjectTable, 2
1087 pCurrentTrackedObjectTable:
1088 0000 0000 .word trackedObjectTable
1089 .lcomm numCurrTrackedObjects,1
1090 .lcomm currentState,1
1091 .lcomm lineCount,1
GAS LISTING /tmp/ccf43P2i.s page 34
 
 
1092 .lcomm trackedLineCount,1
1093 .lcomm numPrevTrackedObjects,1
1094 .lcomm trackedObjectTable,64
1095 .stabs "trackedObjectTable:S(0,24)=ar(0,25)=r(0,25);0;0177777;;0;7;(0,20)",40,0,162,trackedObjectT
1096 .stabs "pCurrentTrackedObjectTable:S(0,26)=*(0,20)",38,0,163,pCurrentTrackedObjectTable
1097 .stabs "lineCount:S(0,11)",38,0,164,lineCount
1098 .stabs "currentState:S(0,17)",38,0,165,currentState
1099 .stabs "numCurrTrackedObjects:S(0,11)",38,0,166,numCurrTrackedObjects
1100 .stabs "numPrevTrackedObjects:S(0,11)",38,0,167,numPrevTrackedObjects
1101 .stabs "trackedLineCount:S(0,11)",38,0,168,trackedLineCount
1102 .text
1103 .stabs "",100,0,0,.Letext0
1104 .Letext0:
1105 /* File "FrameMgr.c": code 580 = 0x0244 ( 513), prologues 33, epilogues 34 */
GAS LISTING /tmp/ccf43P2i.s page 35
 
 
DEFINED SYMBOLS
*ABS*:00000000 FrameMgr.c
/tmp/ccf43P2i.s:3 *ABS*:0000003f __SREG__
/tmp/ccf43P2i.s:4 *ABS*:0000003e __SP_H__
/tmp/ccf43P2i.s:5 *ABS*:0000003d __SP_L__
/tmp/ccf43P2i.s:6 *ABS*:00000000 __tmp_reg__
/tmp/ccf43P2i.s:7 *ABS*:00000001 __zero_reg__
/tmp/ccf43P2i.s:91 .text:00000000 FrameMgr_processFrame
/tmp/ccf43P2i.s:1087 .data:00000000 pCurrentTrackedObjectTable
.bss:00000000 numCurrTrackedObjects
/tmp/ccf43P2i.s:270 .text:000000b2 FrameMgr_processLine
/tmp/ccf43P2i.s:1089 .bss:00000001 currentState
/tmp/ccf43P2i.s:1090 .bss:00000002 lineCount
/tmp/ccf43P2i.s:1091 .bss:00000003 trackedLineCount
/tmp/ccf43P2i.s:798 .text:00000372 FrameMgr_init
/tmp/ccf43P2i.s:1093 .bss:00000005 trackedObjectTable
/tmp/ccf43P2i.s:823 .text:00000380 FrameMgr_acquireLine
/tmp/ccf43P2i.s:933 .text:000003ee FrameMgr_acquireFrame
/tmp/ccf43P2i.s:1092 .bss:00000004 numPrevTrackedObjects
/tmp/ccf43P2i.s:988 .text:00000422 FrameMgr_dispatchEvent
 
UNDEFINED SYMBOLS
__do_copy_data
__do_clear_bss
UIMgr_writeTxFifo
Exec_writeEventFifo
UartInt_txByte
currentLineBuffer
previousLineBuffer
CamConfig_setCamReg
CamConfig_sendFifoCmds
fastEventBitmask
CamIntAsm_acquireDumpLine
colorMap
CamIntAsm_acquireTrackingLine
Utility_delay
/programy/Atmel_C/AVRcam/I2CInterface.c
0,0 → 1,294
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: I2CInterface.c
Module Date: 4/10/2004
Module Auth: John Orlando
Description: This module is responsible for providing a
low-level interface to the I2C hardware resident on the
mega8 processor (also known as the Two-Wire Interface,
or TWI). The interface is needed to configure the
needed registers in the OV6620 camera. This interface
is interrupt-driven based on the events that should
occur upon successful writing of an I2C register.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
 
***********************************************************/
 
/* Includes */
#include <avr/io.h>
#include <avr/twi.h>
#include <avr/signal.h>
#include <avr/interrupt.h>
#include "CamConfig.h"
#include "CommonDefs.h"
 
/* Local Variables */
 
/* These variables are used as storage space for the current
I2C command being sent over the interface. They need to
be volatile since they are dealt with an the TWI ISR */
volatile static unsigned char twi_address;
volatile static unsigned char *twi_data;
volatile static unsigned char twi_ddr;
volatile static unsigned char twi_bytes;
volatile static unsigned char status;
volatile static unsigned char retry_cnt;
 
/* Local Structures and Typedefs */
 
/* Extern Variables */
 
/* Definitions */
/* Bit definitions for the tw_status register */
#define MAX_TWI_RETRIES 2
#define BUSY 7
 
/***********************************************************
Function Name: I2CInt_init
Function Description: This function is responsible
for setting up the registers needed for the TWI
interface
Inputs: none
Outputs: none
***********************************************************/
void I2CInt_init(void)
{
TWSR = 0;
/* init the speed of the I2C interface, running at
100 Kbps */
TWBR = (FOSC / I2C_SPEED - 16)/2;
}
 
/***********************************************************
Function Name: I2CInt_writeData
Function Description: This function is responsible for
initiating the process of writing a sequence of bytes
an I2C slave address. This function will try to write
the data three times before giving up.
Inputs: address: the address of the I2C slave device
data: a pointer to the data to be written
to the slave...for camera interfacing,
the data follows a <register #><data>
format
bytes: the number of bytes to write
Outputs: none
***********************************************************/
void I2CInt_writeData(unsigned char address, unsigned char *data, unsigned char bytes)
{
while(status & (1<<BUSY)); /* Bus is busy wait (or exit with error code) */
while(TWCR & (1<<TWSTO));
/* copy the needed data and state info to our local I2C command structure */
twi_address = address;
twi_data = data;
twi_bytes = bytes;
twi_ddr = TW_WRITE;
 
retry_cnt = 0;
/* Generate start condition, the remainder of the transfer is interrupt driven and
will be performed in the background */
TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN)|(1<<TWIE);
status |= (1<<BUSY);
}
 
/***********************************************************
Function Name: I2CInt_readData
Function Description: This funcion is responsible for
reading the specified number of bytes from a slave
device.
Inputs: address: the slave address to read from
data: a pointer to where the data will be stored
bytes: the number of bytes to read
Outputs: none
***********************************************************/
void I2CInt_readData(unsigned char address, unsigned char *data, unsigned char bytes)
{
/* Bus is busy wait (or exit with error code) */
while(status & (1<<BUSY));
 
twi_address = address;
twi_data = data;
twi_bytes = bytes;
twi_ddr = TW_READ;
 
retry_cnt = 0;
/* Generate start condition, the remainder of the transfer is interrupt driven and
will be performed in the background */
TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN)|(1<<TWIE);
status |= (1<<BUSY);
}
 
/***********************************************************
Function Name: I2CInt_isI2cBusy
Function Description: This funcion is responsible for
indicating if the I2C bus is currently busy to external
modules.
device.
Inputs: none
Outputs: bool_t - indicating if bus is busy
***********************************************************/
bool_t I2CInt_isI2cBusy(void)
{
bool_t retVal = FALSE;
if ( (status & (1<<BUSY)) != 0)
{
retVal = TRUE;
}
return(retVal);
}
 
/***********************************************************
Function Name: <interrupt handler for I2C>
Function Description: This function is responsible for
implementing the control logic needed to perform a
read or write operation with an I2C slave.
Inputs: none
Outputs: none
***********************************************************/
SIGNAL(SIG_2WIRE_SERIAL)
{
unsigned char TWI_status = TWSR & TW_STATUS_MASK; /* grab just the status bits */
/* the entire I2C handler is state-based...determine
what needs to be done based on TWI_status */
switch(TWI_status)
{
case TW_START: /* Start condition */
case TW_REP_START: /* Repeated start condition */
if(retry_cnt > MAX_TWI_RETRIES)
{
/* generate stop condition if we've reached our retry limit */
TWCR |= (1<<TWINT)|(1<<TWSTO);
status &= ~(1<<BUSY);
return;
}
/* indicate read or write */
TWDR = (twi_address<<1) + twi_ddr;
/* TWSTA must be cleared...also clears TWINT */
TWCR &= ~(1<<TWSTA);
break;
 
case TW_MT_SLA_ACK: /* Slave acknowledged address, */
retry_cnt = 0;
/* tx the data, and increment the data pointer */
TWDR = *twi_data;
twi_data++;
 
/* clear the int to continue */
TWCR |= (1<<TWINT);
break;
 
case TW_MT_SLA_NACK: /* Slave didn't acknowledge address, */
case TW_MR_SLA_NACK:
retry_cnt++;
 
/* retry...*/
TWCR |= (1<<TWINT)|(1<<TWSTA)|(1<<TWSTO);
break;
 
case TW_MT_DATA_ACK: /* Slave Acknowledged data, */
if(--twi_bytes > 0)
{
/* more data to send, so send it */
TWDR = *twi_data;
twi_data++;
TWCR |= (1<<TWINT);
}
else
{
/* generate the stop condition if needed */
TWCR |= (1<<TWSTO)|(1<<TWINT);
status &= ~(1<<BUSY);
}
break;
 
case TW_MT_DATA_NACK: /* Slave didn't acknowledge data */
/* send the stop condition */
TWCR |= (1<<TWINT)|(1<<TWSTO);
status &= ~(1<<BUSY);
break;
 
case TW_MR_SLA_ACK: /* Slave acknowledged address */
if(--twi_bytes > 0)
{
/* if there is more than one byte to read, acknowledge */
TWCR |= (1<<TWEA)|(1<<TWINT);
}
else
{
/* no acknowledge */
TWCR |= (1<<TWINT);
}
break;
 
case TW_MR_DATA_ACK: /* Master acknowledged data */
/* grab the received data */
*twi_data = TWDR;
twi_data++;
if(--twi_bytes > 0)
{
/* get the next data byte and ack */
TWCR |= (1<<TWEA)|(1<<TWINT);
}
else
{
/* clear out the enable acknowledge bit */
TWCR &= ~(1<<TWEA);
}
break;
 
case TW_MR_DATA_NACK: /* Master didn't acknowledge data -> end of read process */
/* read data, and generate the stop condition */
*twi_data = TWDR;
TWCR |= (1<<TWSTO)|(1<<TWINT);
status &= ~(1<<BUSY);
break;
}
}
 
 
 
 
 
 
 
 
 
/programy/Atmel_C/AVRcam/I2CInterface.d
0,0 → 1,0
I2CInterface.o I2CInterface.d : I2CInterface.c CamConfig.h I2CInterface.h CommonDefs.h
/programy/Atmel_C/AVRcam/I2CInterface.h
0,0 → 1,70
#ifndef I2CINTERFACE_H
#define I2CINTERFACE_H
 
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: I2CInterface.h
Module Date: 04/10/2004
Module Auth: John Orlando
Description: This module provides the external interface
to the I2C hardware available on the mega8. It also
contains defines and declarations for how the I2C
interface will be used in this system.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
***********************************************************/
#include "CommonDefs.h"
/* Structures and Typedefs */
typedef struct
{
unsigned char configReg;
unsigned char data;
} i2cCmd_t;
/* Defines */
/* The I2C interface will run at 100 KHz (the OV6620 can
support up to 400 KHz, but this hasn't been tested) */
#define I2C_SPEED 100000
 
 
/* External Function Prototypes */
extern void I2CInt_init(void);
extern void I2CInt_writeData(unsigned char address, unsigned char *data, unsigned char bytes);
extern void I2CInt_readData(unsigned char address, unsigned char *data, unsigned char bytes);
extern bool_t I2CInt_isI2cBusy(void);
 
 
 
#endif
 
/programy/Atmel_C/AVRcam/Main.c
0,0 → 1,95
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: Main.c
Module Date: 04/10/2004
Module Auth: John Orlando
Description: This module is responsible for providing
the entry point to the code through the "main" function.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
***********************************************************/
 
/* Includes */
#include <avr/io.h>
#include <stdlib.h>
#include <string.h>
#include "UIMgr.h"
#include "UartInterface.h"
#include "I2CInterface.h"
#include "CamInterface.h"
#include "DebugInterface.h"
#include "FrameMgr.h"
#include "CommonDefs.h"
#include "CamConfig.h"
#include "Executive.h"
#include "Utility.h"
 
/* Local Structures and Typedefs */
 
/* Extern Variables */
 
/* Definitions */
 
/***********************************************************
Function Name: main
Function Description: This function provides the entry
point into AVRcam application.
Inputs: none
Outputs: int
***********************************************************/
int main(void)
{
/* initialize all of the interface modules */
DebugInt_init();
UartInt_init();
I2CInt_init();
CamInt_init();
/* initialize the remaining modules that will process
data...interrupts need to be on for these */
ENABLE_INTS();
CamConfig_init();
UIMgr_init();
FrameMgr_init();
/* provide a short delay for the camera to stabilize before
we let the executive start up */
Utility_delay(1000);
/* the rest of the application will be under the
control of the Executive. */
Exec_run();
/* this should never be reached */
return(0);
}
 
/programy/Atmel_C/AVRcam/Main.d
0,0 → 1,3
Main.o Main.d : Main.c UIMgr.h UartInterface.h I2CInterface.h CommonDefs.h \
CamInterface.h DebugInterface.h FrameMgr.h CamConfig.h Executive.h \
Events.h Utility.h
/programy/Atmel_C/AVRcam/Main.lst
0,0 → 1,279
GAS LISTING /tmp/ccSepUfa.s page 1
 
 
1 .file "Main.c"
2 .arch atmega8
3 __SREG__ = 0x3f
4 __SP_H__ = 0x3e
5 __SP_L__ = 0x3d
6 __tmp_reg__ = 0
7 __zero_reg__ = 1
8 .global __do_copy_data
9 .global __do_clear_bss
10 .stabs "/home/kaklik/projects/roboti/istrobot/2007/ATmega8/AVRcam/",100,0,2,.Ltext0
11 .stabs "Main.c",100,0,2,.Ltext0
12 .text
13 .Ltext0:
14 .stabs "gcc2_compiled.",60,0,0,0
15 .stabs "int:t(0,1)=r(0,1);-32768;32767;",128,0,0,0
16 .stabs "char:t(0,2)=@s8;r(0,2);0;255;",128,0,0,0
17 .stabs "long int:t(0,3)=@s32;r(0,3);020000000000;017777777777;",128,0,0,0
18 .stabs "unsigned int:t(0,4)=r(0,4);0;0177777;",128,0,0,0
19 .stabs "long unsigned int:t(0,5)=@s32;r(0,5);0;037777777777;",128,0,0,0
20 .stabs "long long int:t(0,6)=@s64;r(0,6);01000000000000000000000;0777777777777777777777;",128,0,0,
21 .stabs "long long unsigned int:t(0,7)=@s64;r(0,7);0;01777777777777777777777;",128,0,0,0
22 .stabs "short int:t(0,8)=r(0,8);-32768;32767;",128,0,0,0
23 .stabs "short unsigned int:t(0,9)=r(0,9);0;0177777;",128,0,0,0
24 .stabs "signed char:t(0,10)=@s8;r(0,10);-128;127;",128,0,0,0
25 .stabs "unsigned char:t(0,11)=@s8;r(0,11);0;255;",128,0,0,0
26 .stabs "float:t(0,12)=r(0,1);4;0;",128,0,0,0
27 .stabs "double:t(0,13)=r(0,1);4;0;",128,0,0,0
28 .stabs "long double:t(0,14)=r(0,1);4;0;",128,0,0,0
29 .stabs "void:t(0,15)=(0,15)",128,0,0,0
30 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/io.h",130,0,0,0
31 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/sfr_defs.h",130,0,0,0
32 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/inttypes.h",130,0,0,0
33 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/stdint.h",130,0,0,0
34 .stabs "int8_t:t(4,1)=(0,10)",128,0,116,0
35 .stabs "uint8_t:t(4,2)=(0,11)",128,0,117,0
36 .stabs "int16_t:t(4,3)=(0,1)",128,0,118,0
37 .stabs "uint16_t:t(4,4)=(0,4)",128,0,119,0
38 .stabs "int32_t:t(4,5)=(0,3)",128,0,120,0
39 .stabs "uint32_t:t(4,6)=(0,5)",128,0,121,0
40 .stabs "int64_t:t(4,7)=(0,6)",128,0,122,0
41 .stabs "uint64_t:t(4,8)=(0,7)",128,0,123,0
42 .stabs "intptr_t:t(4,9)=(4,3)",128,0,135,0
43 .stabs "uintptr_t:t(4,10)=(4,4)",128,0,140,0
44 .stabs "int_least8_t:t(4,11)=(4,1)",128,0,152,0
45 .stabs "uint_least8_t:t(4,12)=(4,2)",128,0,157,0
46 .stabs "int_least16_t:t(4,13)=(4,3)",128,0,162,0
47 .stabs "uint_least16_t:t(4,14)=(4,4)",128,0,167,0
48 .stabs "int_least32_t:t(4,15)=(4,5)",128,0,172,0
49 .stabs "uint_least32_t:t(4,16)=(4,6)",128,0,177,0
50 .stabs "int_least64_t:t(4,17)=(4,7)",128,0,182,0
51 .stabs "uint_least64_t:t(4,18)=(4,8)",128,0,187,0
52 .stabs "int_fast8_t:t(4,19)=(4,1)",128,0,200,0
53 .stabs "uint_fast8_t:t(4,20)=(4,2)",128,0,205,0
54 .stabs "int_fast16_t:t(4,21)=(4,3)",128,0,210,0
55 .stabs "uint_fast16_t:t(4,22)=(4,4)",128,0,215,0
56 .stabs "int_fast32_t:t(4,23)=(4,5)",128,0,220,0
57 .stabs "uint_fast32_t:t(4,24)=(4,6)",128,0,225,0
GAS LISTING /tmp/ccSepUfa.s page 2
 
 
58 .stabs "int_fast64_t:t(4,25)=(4,7)",128,0,230,0
59 .stabs "uint_fast64_t:t(4,26)=(4,8)",128,0,235,0
60 .stabs "intmax_t:t(4,27)=(4,7)",128,0,249,0
61 .stabs "uintmax_t:t(4,28)=(4,8)",128,0,254,0
62 .stabn 162,0,0,0
63 .stabs "int_farptr_t:t(3,1)=(4,5)",128,0,76,0
64 .stabs "uint_farptr_t:t(3,2)=(4,6)",128,0,80,0
65 .stabn 162,0,0,0
66 .stabn 162,0,0,0
67 .stabn 162,0,0,0
68 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/stdlib.h",130,0,0,0
69 .stabs "/usr/lib/gcc/avr/4.1.0/include/stddef.h",130,0,0,0
70 .stabs "size_t:t(6,1)=(0,4)",128,0,214,0
71 .stabs "wchar_t:t(6,2)=(0,1)",128,0,326,0
72 .stabn 162,0,0,0
73 .stabs "div_t:t(5,1)=(5,2)=s4quot:(0,1),0,16;rem:(0,1),16,16;;",128,0,69,0
74 .stabs "ldiv_t:t(5,3)=(5,4)=s8quot:(0,3),0,32;rem:(0,3),32,32;;",128,0,75,0
75 .stabs "__compar_fn_t:t(5,5)=(5,6)=*(5,7)=f(0,1)",128,0,78,0
76 .stabn 162,0,0,0
77 .stabs "I2CInterface.h",130,0,0,0
78 .stabs "CommonDefs.h",130,0,0,0
79 .stabs "bool_t:t(8,1)=(0,11)",128,0,56,0
80 .stabn 162,0,0,0
81 .stabs "i2cCmd_t:t(7,1)=(7,2)=s2configReg:(0,11),0,8;data:(0,11),8,8;;",128,0,53,0
82 .stabn 162,0,0,0
83 .stabs "main:F(0,1)",36,0,70,main
84 .global main
85 .type main, @function
86 main:
87 .stabd 46,0,0
1:Main.c **** /*
2:Main.c **** Copyright (C) 2004 John Orlando
3:Main.c ****
4:Main.c **** AVRcam: a small real-time image processing engine.
5:Main.c ****
6:Main.c **** This program is free software; you can redistribute it and/or
7:Main.c **** modify it under the terms of the GNU General Public
8:Main.c **** License as published by the Free Software Foundation; either
9:Main.c **** version 2 of the License, or (at your option) any later version.
10:Main.c ****
11:Main.c **** This program is distributed in the hope that it will be useful,
12:Main.c **** but WITHOUT ANY WARRANTY; without even the implied warranty of
13:Main.c **** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14:Main.c **** General Public License for more details.
15:Main.c ****
16:Main.c **** You should have received a copy of the GNU General Public
17:Main.c **** License along with this program; if not, write to the Free Software
18:Main.c **** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19:Main.c ****
20:Main.c **** For more information on the AVRcam, please contact:
21:Main.c ****
22:Main.c **** john@jrobot.net
23:Main.c ****
24:Main.c **** or go to www.jrobot.net for more details regarding the system.
25:Main.c **** */
26:Main.c **** /***********************************************************
27:Main.c **** Module Name: Main.c
GAS LISTING /tmp/ccSepUfa.s page 3
 
 
28:Main.c **** Module Date: 04/10/2004
29:Main.c **** Module Auth: John Orlando
30:Main.c ****
31:Main.c **** Description: This module is responsible for providing
32:Main.c **** the entry point to the code through the "main" function.
33:Main.c ****
34:Main.c **** Revision History:
35:Main.c **** Date Rel Ver. Notes
36:Main.c **** 4/10/2004 0.1 Module created
37:Main.c **** 6/30/2004 1.0 Initial release for Circuit Cellar
38:Main.c **** contest.
39:Main.c **** ***********************************************************/
40:Main.c ****
41:Main.c **** /* Includes */
42:Main.c **** #include <avr/io.h>
43:Main.c **** #include <stdlib.h>
44:Main.c **** #include <string.h>
45:Main.c **** #include "UIMgr.h"
46:Main.c **** #include "UartInterface.h"
47:Main.c **** #include "I2CInterface.h"
48:Main.c **** #include "CamInterface.h"
49:Main.c **** #include "DebugInterface.h"
50:Main.c **** #include "FrameMgr.h"
51:Main.c **** #include "CommonDefs.h"
52:Main.c **** #include "CamConfig.h"
53:Main.c **** #include "Executive.h"
54:Main.c **** #include "Utility.h"
55:Main.c ****
56:Main.c **** /* Local Structures and Typedefs */
57:Main.c ****
58:Main.c **** /* Extern Variables */
59:Main.c ****
60:Main.c **** /* Definitions */
61:Main.c ****
62:Main.c **** /***********************************************************
63:Main.c **** Function Name: main
64:Main.c **** Function Description: This function provides the entry
65:Main.c **** point into AVRcam application.
66:Main.c **** Inputs: none
67:Main.c **** Outputs: int
68:Main.c **** ***********************************************************/
69:Main.c **** int main(void)
70:Main.c **** {
88 .stabn 68,0,70,.LM0-main
89 .LM0:
90 /* prologue: frame size=0 */
91 0000 C0E0 ldi r28,lo8(__stack - 0)
92 0002 D0E0 ldi r29,hi8(__stack - 0)
93 0004 DEBF out __SP_H__,r29
94 0006 CDBF out __SP_L__,r28
95 /* prologue end (size=4) */
71:Main.c **** /* initialize all of the interface modules */
72:Main.c **** DebugInt_init();
96 .stabn 68,0,72,.LM1-main
97 .LM1:
98 0008 00D0 rcall DebugInt_init
73:Main.c **** UartInt_init();
GAS LISTING /tmp/ccSepUfa.s page 4
 
 
99 .stabn 68,0,73,.LM2-main
100 .LM2:
101 000a 00D0 rcall UartInt_init
74:Main.c **** I2CInt_init();
102 .stabn 68,0,74,.LM3-main
103 .LM3:
104 000c 00D0 rcall I2CInt_init
75:Main.c **** CamInt_init();
105 .stabn 68,0,75,.LM4-main
106 .LM4:
107 000e 00D0 rcall CamInt_init
76:Main.c ****
77:Main.c **** /* initialize the remaining modules that will process
78:Main.c **** data...interrupts need to be on for these */
79:Main.c **** ENABLE_INTS();
108 .stabn 68,0,79,.LM5-main
109 .LM5:
110 /* #APP */
111 0010 7894 sei
80:Main.c **** CamConfig_init();
112 .stabn 68,0,80,.LM6-main
113 .LM6:
114 /* #NOAPP */
115 0012 00D0 rcall CamConfig_init
81:Main.c **** UIMgr_init();
116 .stabn 68,0,81,.LM7-main
117 .LM7:
118 0014 00D0 rcall UIMgr_init
82:Main.c **** FrameMgr_init();
119 .stabn 68,0,82,.LM8-main
120 .LM8:
121 0016 00D0 rcall FrameMgr_init
83:Main.c ****
84:Main.c **** /* provide a short delay for the camera to stabilize before
85:Main.c **** we let the executive start up */
86:Main.c **** Utility_delay(1000);
122 .stabn 68,0,86,.LM9-main
123 .LM9:
124 0018 88EE ldi r24,lo8(1000)
125 001a 93E0 ldi r25,hi8(1000)
126 001c 00D0 rcall Utility_delay
87:Main.c ****
88:Main.c **** /* the rest of the application will be under the
89:Main.c **** control of the Executive. */
90:Main.c **** Exec_run();
127 .stabn 68,0,90,.LM10-main
128 .LM10:
129 001e 00D0 rcall Exec_run
91:Main.c ****
92:Main.c **** /* this should never be reached */
93:Main.c **** return(0);
94:Main.c **** }
130 .stabn 68,0,94,.LM11-main
131 .LM11:
132 0020 80E0 ldi r24,lo8(0)
133 0022 90E0 ldi r25,hi8(0)
134 /* epilogue: frame size=0 */
GAS LISTING /tmp/ccSepUfa.s page 5
 
 
135 0024 00C0 rjmp exit
136 /* epilogue end (size=1) */
137 /* function main size 20 (15) */
138 .size main, .-main
139 .Lscope0:
140 .stabs "",36,0,0,.Lscope0-main
141 .stabd 78,0,0
142 .stabs "",100,0,0,.Letext0
143 .Letext0:
144 /* File "Main.c": code 20 = 0x0014 ( 15), prologues 4, epilogues 1 */
GAS LISTING /tmp/ccSepUfa.s page 6
 
 
DEFINED SYMBOLS
*ABS*:00000000 Main.c
/tmp/ccSepUfa.s:3 *ABS*:0000003f __SREG__
/tmp/ccSepUfa.s:4 *ABS*:0000003e __SP_H__
/tmp/ccSepUfa.s:5 *ABS*:0000003d __SP_L__
/tmp/ccSepUfa.s:6 *ABS*:00000000 __tmp_reg__
/tmp/ccSepUfa.s:7 *ABS*:00000001 __zero_reg__
/tmp/ccSepUfa.s:86 .text:00000000 main
 
UNDEFINED SYMBOLS
__do_copy_data
__do_clear_bss
__stack
DebugInt_init
UartInt_init
I2CInt_init
CamInt_init
CamConfig_init
UIMgr_init
FrameMgr_init
Utility_delay
Exec_run
exit
/programy/Atmel_C/AVRcam/README.txt
0,0 → 1,62
AVRcam Release 1.4
1/16/2005
 
Whats New in v1.4:
-Greatly improved the issue where the AVRcam would potentially
lock up in particular situations (especially after lots of frame
dumps). This was due to a combination of bugs, which have all been fixed:
-turned off interrupts in certain critical sections that were missed
previously
-only allow PCLK to be piped into timer1 when needed (i.e., when dumping
a line or tracking a frame).
-allowed the main executive to check both the fast event bitmask as well
as the normal event queue on each pass of the main executive
 
I'll be curious to hear if this has completely fixed the issue (I haven't
seen it happen after ~500 frame dumps, but the real test is when
others try it :-). Also note: an input voltage below 6 volts will
cause the system to work sometimes and lock up others. The input voltage
regulator really wants to see a 6V minimum. I had drained
8 AA NiMH batteries down to where they were only providing ~4.8 V at the
input. The system worked for a little while, and then started locking
up. I immediately changed batteries and everything was fine.
 
-Improved how the colorMap gets written to EEPROM. Now, before
each byte in the colorMap is written to EEPROM, a check of the
current value in EEPROM is made to see if the old value matches
the new value. If so, the write is skipped. Also, after a value
is written, it is read back to ensure that it is correct, and
will re-write up to three times if needed.
 
-Moved the UART rx ISR to the UartInterface.c file, instead of having
it in its own UartInterfaceAsm.S file. The ISR is in C now.
 
-Added a revision history to each source file so that people can
see the changes on a per-version basis.
 
 
---Misc Info about AVRcam---
 
* The AVRcam source files were built using the WinAVR distribution
(version 3.3.1 of GCC). I haven't tested other versions of GCC,
but they should compile without too much difficulty. The makefile
used to build the source is included.
 
* Currently, the AVRcam only works at a baud rate of 115.2 kbps. I
am in the process of working on autobaud routines that will set the
baud rate automatically at start up. I'm pretty sure the system
should be able to track 8 objects all the way down to a baud rate
of 38.4 kbps. Check back to www.jrobot.net for more info about the
AVRcam.
 
* Different portions of the code are #ifdef'ed in or out to show
the various debugging that can be turned on in the system. The
debugging mechanisms are typically for dumping additional information
out to a serial terminal for viewing, and are not intended to work
with the AVRcamVIEW PC application. The code, as released, doesn't
have any debugging features turned on.
 
* For more info about the AVRcam, check out http://www.jrobot.net
 
John Orlando
January 16, 2005
/programy/Atmel_C/AVRcam/UIMgr.c
0,0 → 1,664
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: UIMgr.c
Module Date: 04/10/2004
Module Auth: John Orlando
Description: This module is responsible for providing
the processing to manage the user interface of the
system. This user interface is provided via the UART.
This module handles the incoming serial commands, and
performs the needed functionality. It is then
responsible for generating any needed response to
the external entity.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
11/15/2004 1.2 Updated version string to 1.2.
1/16/2005 1.4 Added code to write the colorMap
to EEPROM one byte at a time,
ensuring that the EEPROM is only
written when the data is different
than the current value (thus saving
EEPROM writes). Updated version
string to 1.4.
***********************************************************/
 
/* Includes */
#include <avr/io.h>
#include <stdlib.h>
#include <string.h>
#include <avr/eeprom.h>
#include "CommonDefs.h"
#include "UIMgr.h"
#include "UartInterface.h"
#include "CamConfig.h"
#include "Utility.h"
#include "Executive.h"
#include "CamInterface.h"
 
/* Local Structures and Typedefs */
 
typedef enum
{
getVersionCmd,
pingCmd,
setCameraRegsCmd,
dumpFrameCmd,
enableTrackingCmd,
disableTrackingCmd,
setColorMapCmd,
resetCameraCmd,
noCmd,
invalidCmd
} UIMgr_Cmd_t;
 
typedef enum
{
setRed,
setGreen,
setBlue
} setColorState_t;
 
/* Local Variables */
static unsigned char charCount = 0;
static unsigned char charIndex = 0;
static unsigned char asciiTokenBuffer[MAX_TOKEN_LENGTH+1]; /* +1 to ensure NULL at end */
static unsigned char tokenCount = 0;
static unsigned char tokenBuffer[MAX_TOKEN_COUNT];
static UIMgr_Cmd_t receivedCmd = noCmd;
static unsigned char AVRcamVersion[] = "AVRcam v1.4\r";
 
/* Local Function Declaration */
static unsigned char UIMgr_readRxFifo(void);
static unsigned char UIMgr_readTxFifo(void);
static unsigned char UIMgr_readRxFifo(void);
static void UIMgr_sendNck(void);
static void UIMgr_sendAck(void);
static void UIMgr_convertTokenToCmd(void);
static void UIMgr_convertTokenToValue(void);
static void UIMgr_executeCmd(void);
 
/* Extern Variables */
unsigned char UIMgr_rxFifo[UI_MGR_RX_FIFO_SIZE];
unsigned char UIMgr_rxFifoHead=0;
unsigned char UIMgr_rxFifoTail=0;
 
unsigned char UIMgr_txFifo[UI_MGR_TX_FIFO_SIZE];
unsigned char UIMgr_txFifoHead=0;
unsigned char UIMgr_txFifoTail=0;
 
/* Definitions */
#define IS_DATA_IN_TX_FIFO() (!(UIMgr_txFifoHead == UIMgr_txFifoTail))
#define IS_DATA_IN_RX_FIFO() (!(UIMgr_rxFifoHead == UIMgr_rxFifoTail))
 
/* MAX_EEPROM_WRITE_ATTEMPTS limits the number of writes that can be
done to a particular EEPROM cell, so that it can't possible just
write to the same cell over and over */
#define MAX_EEPROM_WRITE_ATTEMPTS 3
 
/***********************************************************
Function Name: UIMgr_init
Function Description: This function is responsible for
initializing the UIMgr module. It sets up the fifo
used to hold incoming data, etc.
Inputs: none
Outputs: none
***********************************************************/
void UIMgr_init(void)
{
memset(asciiTokenBuffer,0x00,MAX_TOKEN_LENGTH+1);
memset(tokenBuffer,0x00,MAX_TOKEN_COUNT);
memset(UIMgr_txFifo,0x00,UI_MGR_TX_FIFO_SIZE);
memset(UIMgr_rxFifo,0x00,UI_MGR_RX_FIFO_SIZE);
}
 
/***********************************************************
Function Name: UIMgr_dispatchEvent
Function Description: This function is responsible for
processing events that pertain to the UIMgr.
Inputs: event - the generated event
Outputs: none
***********************************************************/
void UIMgr_dispatchEvent(unsigned char event)
{
switch(event)
{
case EV_ACQUIRE_LINE_COMPLETE:
UIMgr_transmitPendingData();
break;
case EV_SERIAL_DATA_RECEIVED:
UIMgr_processReceivedData();
break;
case EV_SERIAL_DATA_PENDING_TX:
UIMgr_flushTxBuffer();
break;
}
}
/***********************************************************
Function Name: UIMgr_transmitPendingData
Function Description: This function is responsible for
transmitting a single byte of data if data is waiting
to be sent. Otherwise, if nothing is waiting, the
function just returns.
Inputs: none
Outputs: none
***********************************************************/
void UIMgr_transmitPendingData(void)
{
if (IS_DATA_IN_TX_FIFO() == TRUE)
{
/* data is waiting...send a single byte */
UartInt_txByte( UIMgr_readTxFifo() );
}
}
/***********************************************************
Function Name: UIMgr_processReceivedData
Function Description: This function is responsible for
parsing any serial data waiting in the rx fifo
Inputs: none
Outputs: none
***********************************************************/
void UIMgr_processReceivedData(void)
{
unsigned char tmpData = 0;
 
/* still need to add a mechanism to handle token counts
that are excessive!!! FIX ME!!! */
while(IS_DATA_IN_RX_FIFO() == TRUE)
{
tmpData = UIMgr_readRxFifo();
if (tmpData == '\r')
{
/* we have reached a token separator */
if (tokenCount == 0)
{
/* convert the command */
UIMgr_convertTokenToCmd();
}
else
{
/* convert a value */
UIMgr_convertTokenToValue();
tokenCount++;
}
/* either way, it is time to try to process the received
token list since we have reached the end of the cmd. */
Utility_delay(100);
if (receivedCmd == invalidCmd ||
receivedCmd == noCmd )
{
UIMgr_sendNck();
PUBLISH_EVENT(EV_SERIAL_DATA_PENDING_TX);
}
else
{
UIMgr_sendAck();
/* publish the serial data pending event, so it
will push the ACK out before we execute the cmd */
PUBLISH_EVENT(EV_SERIAL_DATA_PENDING_TX);
UIMgr_executeCmd();
}
/* reset any necessary data */
tokenCount = 0;
memset(tokenBuffer,0x00,MAX_TOKEN_COUNT);
}
else if (tmpData == ' ') /* space char */
{
/* the end of a token has been reached */
if (tokenCount == 0)
{
UIMgr_convertTokenToCmd();
tokenCount++; /* check this...why is this being incremented here??? This
means we have received a token, with tokenCount == 0, which means it is a
command...why is this contributing to tokenCount?
This might cause the set color map command to include too much data, since
it sets the color map based on tokenCount...CHECK*/
}
else
{
/* check to see if this token is going to push
us over the limit...if so, abort the transaction */
if (tokenCount+1 >= MAX_TOKEN_COUNT)
{
/* we received too many tokens, and
need to NCK this request, since its too
large...reset everything...*/
charCount=0;
charIndex=0;
tokenCount=0;
receivedCmd = invalidCmd;
}
else
{
/* tokenCount is still in range...*/
UIMgr_convertTokenToValue();
tokenCount++;
}
}
}
else if ( (tmpData >= 'A' && tmpData <= 'Z') ||
(tmpData >= '0' && tmpData <= '9') )
{
/* a valid range of token was received */
asciiTokenBuffer[charIndex] = tmpData;
charCount++;
charIndex++;
if (charCount > MAX_TOKEN_LENGTH)
{
/* we have received a token that cannot be handled...
set the received cmd to an invalid cmd, and wait
for the \r to process it */
receivedCmd = invalidCmd;
charIndex = 0; /* ...so we won't overwrite memory */
}
}
else
{
/* an invalid character was received */
receivedCmd = invalidCmd;
}
} /* end while */
asm volatile("clt"::); /* clear out the T flag in case it wasn't
cleared already */
}
 
/***********************************************************
Function Name: UIMgr_executeCmd
Function Description: This function is responsible for
executing whatever cmd is stored in the receivedCmd
object.
Inputs: none
Outputs: none
***********************************************************/
static void UIMgr_executeCmd(void)
{
unsigned char i,eepromData, num_writes=0;
unsigned char *pData;
unsigned char eeprom_write_succeeded = FALSE;
#if DEBUG_COLOR_MAP
unsigned char asciiBuffer[5];
#endif
 
if (receivedCmd == pingCmd)
{
}
else if (receivedCmd == getVersionCmd)
{
pData = AVRcamVersion;
while(*pData != 0)
{
UIMgr_writeTxFifo(*pData++);
}
}
else if (receivedCmd == resetCameraCmd)
{
CamInt_resetCam();
}
else if (receivedCmd == dumpFrameCmd)
{
/* publish the event that will indicate that
a request has come to dump a frame...this will
be received by the FrameMgr, which will begin
dumping the frame...a short delay is needed
here to keep the Java demo app happy (sometimes
it wouldn't be able to receive the serial data
as quickly as AVRcam can provide it). */
Utility_delay(100);
PUBLISH_EVENT(EV_DUMP_FRAME);
}
else if (receivedCmd == setCameraRegsCmd)
{
/* we need to gather the tokens and
build config cmds to be sent to the camera */
for (i=1; i<tokenCount; i+=2) /* starts at 1 since first token
is the CR cmd */
{
CamConfig_setCamReg(tokenBuffer[i],tokenBuffer[i+1]);
}
CamConfig_sendFifoCmds();
}
else if (receivedCmd == enableTrackingCmd)
{
/* publish the event...again with a short delay */
Utility_delay(100);
PUBLISH_EVENT(EV_ENABLE_TRACKING);
}
else if (receivedCmd == disableTrackingCmd)
{
PUBLISH_EVENT(EV_DISABLE_TRACKING);
}
else if (receivedCmd == setColorMapCmd)
{
/* copy the received tokens into the color map */
for (i=0; i<tokenCount; i++)
{
colorMap[i] = tokenBuffer[i+1];
/* write each colorMap byte to EEPROM, but only those
that changed...this will help reduce wear on the EEPROM */
eepromData = eeprom_read_byte( (unsigned char*)(i+1));
if (eepromData != colorMap[i])
{
/* need to actually perform the write because the
data in eeprom is different than the current colorMap */
eeprom_write_succeeded = FALSE;
while(eeprom_write_succeeded == FALSE && num_writes < MAX_EEPROM_WRITE_ATTEMPTS)
{
eeprom_write_byte((unsigned char*)(i+1),colorMap[i]);
num_writes++;
eepromData = eeprom_read_byte( (unsigned char*)(i+1));
if (eepromData == colorMap[i])
{
eeprom_write_succeeded = TRUE;
}
}
num_writes = 0;
}
}
 
#if DEBUG_COLOR_MAP
/* for debugging...send out the entire color map */
UIMgr_txBuffer("\r\n",2);
for (i=0; i<NUM_ELEMENTS_IN_COLOR_MAP; i++)
{
memset(asciiBuffer,0x00,5);
itoa(colorMap[i],asciiBuffer,10);
UIMgr_txBuffer(asciiBuffer,3);
UIMgr_txBuffer(" ",1);
if (i==15 || i == 31)
{
/* break up the output */
UIMgr_txBuffer("\r\n",2);
}
}
#endif
}
}
 
/***********************************************************
Function Name: UIMgr_convertTokenToValue
Function Description: This function is responsible for
converting a received token to a hex value It will
access the asciiTokenBuffer directly, and store the
result in the appropriate token buffer.
Inputs: none
Outputs: none
***********************************************************/
static void UIMgr_convertTokenToValue(void)
{
unsigned int newValue;
newValue = atoi(asciiTokenBuffer);
if (newValue > 255)
{
/* the value is too large */
receivedCmd = invalidCmd;
tokenBuffer[tokenCount] = 0xFF; /* to indicate an error */
}
else
{
/* copy the value into the tokenBuffer */
tokenBuffer[tokenCount] = newValue;
}
memset(asciiTokenBuffer,0x00,MAX_TOKEN_LENGTH);
charIndex = 0;
charCount = 0;
}
/***********************************************************
Function Name: UIMgr_convertTokenToCmd
Function Description: This function is responsible for
parsing a received 2-character command. It will
access the asciiTokenBuffer directly.
Inputs: none
Outputs: none
***********************************************************/
static void UIMgr_convertTokenToCmd(void)
{
if ( (asciiTokenBuffer[0] == 'P') &&
(asciiTokenBuffer[1] == 'G') )
{
/* we got a "ping" command...but we still need to see
if we are going to get the \r */
receivedCmd = pingCmd;
}
else if ( (asciiTokenBuffer[0] == 'G') &&
(asciiTokenBuffer[1] == 'V') )
{
/* we got the "get version" command */
receivedCmd = getVersionCmd;
}
else if ( (asciiTokenBuffer[0] == 'D') &&
(asciiTokenBuffer[1] == 'F') )
{
/* we should go into frame dump mode */
receivedCmd = dumpFrameCmd;
}
else if ( (asciiTokenBuffer[0] == 'C') &&
(asciiTokenBuffer[1] == 'R') )
{
/* the user wants to set registers in the OV6620 */
receivedCmd = setCameraRegsCmd;
}
else if ( (asciiTokenBuffer[0] == 'E') &&
(asciiTokenBuffer[1] == 'T') )
{
/* the user wants to enable tracking */
receivedCmd = enableTrackingCmd;
}
else if ( (asciiTokenBuffer[0] == 'S') &&
(asciiTokenBuffer[1] == 'M') )
{
/* the user wants to set the color map */
receivedCmd = setColorMapCmd;
}
else if ( (asciiTokenBuffer[0] == 'D') &&
(asciiTokenBuffer[1] == 'T') )
{
receivedCmd = disableTrackingCmd;
}
else if ( (asciiTokenBuffer[0] == 'R') &&
(asciiTokenBuffer[1] == 'S') )
{
receivedCmd = resetCameraCmd;
}
else
{
/* don't recognize the cmd */
receivedCmd = invalidCmd;
}
memset(asciiTokenBuffer,0x00,MAX_TOKEN_LENGTH);
charIndex = 0;
charCount = 0;
}
/***********************************************************
Function Name: UIMgr_sendAck
Function Description: This function is responsible for
queuing up an ACK to be sent to the user.
Inputs: none
Outputs: none
***********************************************************/
static void UIMgr_sendAck(void)
{
UIMgr_writeTxFifo('A');
UIMgr_writeTxFifo('C');
UIMgr_writeTxFifo('K');
UIMgr_writeTxFifo('\r');
}
 
/***********************************************************
Function Name: UIMgr_sendNck
Function Description: This function is responsible for
queueing up an NCK to be sent to the user.
Inputs: none
Outputs: none
***********************************************************/
static void UIMgr_sendNck(void)
{
UIMgr_writeTxFifo('N');
UIMgr_writeTxFifo('C');
UIMgr_writeTxFifo('K');
UIMgr_writeTxFifo('\r');
}
 
 
/***********************************************************
Function Name: UIMgr_writeBufferToTxFifo
Function Description: This function is responsible for
placing "length" bytes into the tx FIFO.
Inputs: pData - a pointer to the data to send
length - the number of bytes to send
Outputs: none
***********************************************************/
void UIMgr_writeBufferToTxFifo(unsigned char *pData, unsigned char length)
{
unsigned char tmpHead;
if (length == 0)
{
return;
}
DISABLE_INTS();
while(length-- != 0)
{
UIMgr_txFifo[UIMgr_txFifoHead] = *pData++;
/* now move the head up */
tmpHead = (UIMgr_txFifoHead + 1) & (UI_MGR_TX_FIFO_MASK);
UIMgr_txFifoHead = tmpHead;
}
ENABLE_INTS();
}
 
/***********************************************************
Function Name: UIMgr_txBuffer
Function Description: This function is responsible for
sending 'length' bytes out using the UartInterface
module.
Inputs: pData - a pointer to the data to send
length - the number of bytes to send
Outputs: none
***********************************************************/
void UIMgr_txBuffer(unsigned char *pData, unsigned char length)
{
while(length-- != 0)
{
UartInt_txByte(*pData++);
}
}
 
/***********************************************************
Function Name: UIMgr_flushTxBuffer
Function Description: This function is responsible for
sending all data currently in the serial tx buffer
to the user.
Inputs: none
Outputs: none
***********************************************************/
void UIMgr_flushTxBuffer(void)
{
while(IS_DATA_IN_TX_FIFO() == TRUE)
{
UartInt_txByte(UIMgr_readTxFifo() );
}
}
 
/***********************************************************
Function Name: UIMgr_readRxFifo
Function Description: This function is responsible for
reading a single byte of data from the rx fifo, and
updating the appropriate pointers.
Inputs: none
Outputs: unsigned char-the data read
***********************************************************/
static unsigned char UIMgr_readRxFifo(void)
{
unsigned char dataByte, tmpTail;
/* just return the current tail from the rx fifo */
DISABLE_INTS();
dataByte = UIMgr_rxFifo[UIMgr_rxFifoTail];
tmpTail = (UIMgr_rxFifoTail+1) & (UI_MGR_RX_FIFO_MASK);
UIMgr_rxFifoTail = tmpTail;
ENABLE_INTS();
return(dataByte);
}
 
/***********************************************************
Function Name: UIMgr_readTxFifo
Function Description: This function is responsible for
reading a single byte of data from the tx fifo, and
updating the appropriate pointers.
Inputs: none
Outputs: unsigned char-the data read
***********************************************************/
static unsigned char UIMgr_readTxFifo(void)
{
unsigned char dataByte, tmpTail;
/* just return the current tail from the tx fifo */
DISABLE_INTS();
dataByte = UIMgr_txFifo[UIMgr_txFifoTail];
tmpTail = (UIMgr_txFifoTail+1) & (UI_MGR_TX_FIFO_MASK);
UIMgr_txFifoTail = tmpTail;
ENABLE_INTS();
return(dataByte);
}
 
/***********************************************************
Function Name: UIMgr_writeTxFifo
Function Description: This function is responsible for
writing a single byte to the TxFifo and
updating the appropriate pointers.
Inputs: data - the byte to write to the Fifo
Outputs: none
***********************************************************/
void UIMgr_writeTxFifo(unsigned char data)
{
unsigned char tmpHead;
 
DISABLE_INTS();
UIMgr_txFifo[UIMgr_txFifoHead] = data;
 
/* now move the head up */
tmpHead = (UIMgr_txFifoHead + 1) & (UI_MGR_TX_FIFO_MASK);
UIMgr_txFifoHead = tmpHead;
ENABLE_INTS();
}
 
/programy/Atmel_C/AVRcam/UIMgr.d
0,0 → 1,2
UIMgr.o UIMgr.d : UIMgr.c CommonDefs.h UIMgr.h UartInterface.h CamConfig.h \
I2CInterface.h Utility.h Executive.h Events.h CamInterface.h
/programy/Atmel_C/AVRcam/UIMgr.h
0,0 → 1,74
#ifndef UIMGR_H
#define UIMGR_H
 
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: UIMgr.h
Module Date: 04/10/2004
Module Auth: John Orlando
Description: This file provides the external interface
to the UI Mgr.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
***********************************************************/
 
 
/* Defines */
#define UI_MGR_RX_FIFO_SIZE 32
#define UI_MGR_RX_FIFO_MASK UI_MGR_RX_FIFO_SIZE-1
 
#define UI_MGR_TX_FIFO_SIZE 64
#define UI_MGR_TX_FIFO_MASK UI_MGR_TX_FIFO_SIZE-1
 
#define LENGTH_OF_UI_CMD 2
#define UI_MGR_MAX_CMD_LENGTH 32
#define MAX_TOKEN_LENGTH 3 /* needs to hold 0 - 255 in ASCII format */
#define MAX_TOKEN_COUNT 64 /* for setting the color maps */
 
 
/* External Variable Reference */
extern unsigned char UIMgr_rxFifo[];
extern unsigned char UIMgr_rxFifoHead;
extern unsigned char UIMgr_rxFifoTail;
 
/* External Function Declaration */
extern void UIMgr_init(void);
extern void UIMgr_writeBufferToTxFifo(unsigned char *pData, unsigned char length);
extern void UIMgr_txBuffer(unsigned char *pData, unsigned char length);
extern void UIMgr_processReceivedData(void);
extern void UIMgr_transmitPendingData(void);
extern void UIMgr_dispatchEvent(unsigned char event);
extern void UIMgr_flushTxBuffer(void);
extern void UIMgr_writeTxFifo(unsigned char data);
#endif
 
/programy/Atmel_C/AVRcam/UIMgr.lst
0,0 → 1,2363
GAS LISTING /tmp/cc2L16GD.s page 1
 
 
1 .file "UIMgr.c"
2 .arch atmega8
3 __SREG__ = 0x3f
4 __SP_H__ = 0x3e
5 __SP_L__ = 0x3d
6 __tmp_reg__ = 0
7 __zero_reg__ = 1
8 .global __do_copy_data
9 .global __do_clear_bss
10 .stabs "/home/kaklik/projects/roboti/istrobot/2007/ATmega8/AVRcam/",100,0,2,.Ltext0
11 .stabs "UIMgr.c",100,0,2,.Ltext0
12 .text
13 .Ltext0:
14 .stabs "gcc2_compiled.",60,0,0,0
15 .stabs "int:t(0,1)=r(0,1);-32768;32767;",128,0,0,0
16 .stabs "char:t(0,2)=@s8;r(0,2);0;255;",128,0,0,0
17 .stabs "long int:t(0,3)=@s32;r(0,3);020000000000;017777777777;",128,0,0,0
18 .stabs "unsigned int:t(0,4)=r(0,4);0;0177777;",128,0,0,0
19 .stabs "long unsigned int:t(0,5)=@s32;r(0,5);0;037777777777;",128,0,0,0
20 .stabs "long long int:t(0,6)=@s64;r(0,6);01000000000000000000000;0777777777777777777777;",128,0,0,
21 .stabs "long long unsigned int:t(0,7)=@s64;r(0,7);0;01777777777777777777777;",128,0,0,0
22 .stabs "short int:t(0,8)=r(0,8);-32768;32767;",128,0,0,0
23 .stabs "short unsigned int:t(0,9)=r(0,9);0;0177777;",128,0,0,0
24 .stabs "signed char:t(0,10)=@s8;r(0,10);-128;127;",128,0,0,0
25 .stabs "unsigned char:t(0,11)=@s8;r(0,11);0;255;",128,0,0,0
26 .stabs "float:t(0,12)=r(0,1);4;0;",128,0,0,0
27 .stabs "double:t(0,13)=r(0,1);4;0;",128,0,0,0
28 .stabs "long double:t(0,14)=r(0,1);4;0;",128,0,0,0
29 .stabs "void:t(0,15)=(0,15)",128,0,0,0
30 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/io.h",130,0,0,0
31 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/sfr_defs.h",130,0,0,0
32 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/inttypes.h",130,0,0,0
33 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/stdint.h",130,0,0,0
34 .stabs "int8_t:t(4,1)=(0,10)",128,0,116,0
35 .stabs "uint8_t:t(4,2)=(0,11)",128,0,117,0
36 .stabs "int16_t:t(4,3)=(0,1)",128,0,118,0
37 .stabs "uint16_t:t(4,4)=(0,4)",128,0,119,0
38 .stabs "int32_t:t(4,5)=(0,3)",128,0,120,0
39 .stabs "uint32_t:t(4,6)=(0,5)",128,0,121,0
40 .stabs "int64_t:t(4,7)=(0,6)",128,0,122,0
41 .stabs "uint64_t:t(4,8)=(0,7)",128,0,123,0
42 .stabs "intptr_t:t(4,9)=(4,3)",128,0,135,0
43 .stabs "uintptr_t:t(4,10)=(4,4)",128,0,140,0
44 .stabs "int_least8_t:t(4,11)=(4,1)",128,0,152,0
45 .stabs "uint_least8_t:t(4,12)=(4,2)",128,0,157,0
46 .stabs "int_least16_t:t(4,13)=(4,3)",128,0,162,0
47 .stabs "uint_least16_t:t(4,14)=(4,4)",128,0,167,0
48 .stabs "int_least32_t:t(4,15)=(4,5)",128,0,172,0
49 .stabs "uint_least32_t:t(4,16)=(4,6)",128,0,177,0
50 .stabs "int_least64_t:t(4,17)=(4,7)",128,0,182,0
51 .stabs "uint_least64_t:t(4,18)=(4,8)",128,0,187,0
52 .stabs "int_fast8_t:t(4,19)=(4,1)",128,0,200,0
53 .stabs "uint_fast8_t:t(4,20)=(4,2)",128,0,205,0
54 .stabs "int_fast16_t:t(4,21)=(4,3)",128,0,210,0
55 .stabs "uint_fast16_t:t(4,22)=(4,4)",128,0,215,0
56 .stabs "int_fast32_t:t(4,23)=(4,5)",128,0,220,0
57 .stabs "uint_fast32_t:t(4,24)=(4,6)",128,0,225,0
GAS LISTING /tmp/cc2L16GD.s page 2
 
 
58 .stabs "int_fast64_t:t(4,25)=(4,7)",128,0,230,0
59 .stabs "uint_fast64_t:t(4,26)=(4,8)",128,0,235,0
60 .stabs "intmax_t:t(4,27)=(4,7)",128,0,249,0
61 .stabs "uintmax_t:t(4,28)=(4,8)",128,0,254,0
62 .stabn 162,0,0,0
63 .stabs "int_farptr_t:t(3,1)=(4,5)",128,0,76,0
64 .stabs "uint_farptr_t:t(3,2)=(4,6)",128,0,80,0
65 .stabn 162,0,0,0
66 .stabn 162,0,0,0
67 .stabn 162,0,0,0
68 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/stdlib.h",130,0,0,0
69 .stabs "/usr/lib/gcc/avr/4.1.0/include/stddef.h",130,0,0,0
70 .stabs "size_t:t(6,1)=(0,4)",128,0,214,0
71 .stabs "wchar_t:t(6,2)=(0,1)",128,0,326,0
72 .stabn 162,0,0,0
73 .stabs "div_t:t(5,1)=(5,2)=s4quot:(0,1),0,16;rem:(0,1),16,16;;",128,0,69,0
74 .stabs "ldiv_t:t(5,3)=(5,4)=s8quot:(0,3),0,32;rem:(0,3),32,32;;",128,0,75,0
75 .stabs "__compar_fn_t:t(5,5)=(5,6)=*(5,7)=f(0,1)",128,0,78,0
76 .stabn 162,0,0,0
77 .stabs "CommonDefs.h",130,0,0,0
78 .stabs "bool_t:t(7,1)=(0,11)",128,0,56,0
79 .stabn 162,0,0,0
80 .stabs "CamConfig.h",130,0,0,0
81 .stabs "I2CInterface.h",130,0,0,0
82 .stabs "i2cCmd_t:t(9,1)=(9,2)=s2configReg:(0,11),0,8;data:(0,11),8,8;;",128,0,53,0
83 .stabn 162,0,0,0
84 .stabn 162,0,0,0
85 .stabs " :T(0,16)=@s8;egetVersionCmd:0,pingCmd:1,setCameraRegsCmd:2,dumpFrameCmd:3,enableTrackingC
86 .stabs "UIMgr_Cmd_t:t(0,17)=(0,16)",128,0,81,0
87 .stabs " :T(0,18)=@s8;esetRed:0,setGreen:1,setBlue:2,;",128,0,0,0
88 .stabs "setColorState_t:t(0,19)=(0,18)",128,0,88,0
89 .stabs "UIMgr_writeBufferToTxFifo:F(0,15)",36,0,547,UIMgr_writeBufferToTxFifo
90 .stabs "pData:P(0,20)=*(0,11)",64,0,546,26
91 .stabs "length:P(0,11)",64,0,546,24
92 .global UIMgr_writeBufferToTxFifo
93 .type UIMgr_writeBufferToTxFifo, @function
94 UIMgr_writeBufferToTxFifo:
95 .stabd 46,0,0
1:UIMgr.c **** /*
2:UIMgr.c **** Copyright (C) 2004 John Orlando
3:UIMgr.c ****
4:UIMgr.c **** AVRcam: a small real-time image processing engine.
5:UIMgr.c ****
6:UIMgr.c **** This program is free software; you can redistribute it and/or
7:UIMgr.c **** modify it under the terms of the GNU General Public
8:UIMgr.c **** License as published by the Free Software Foundation; either
9:UIMgr.c **** version 2 of the License, or (at your option) any later version.
10:UIMgr.c ****
11:UIMgr.c **** This program is distributed in the hope that it will be useful,
12:UIMgr.c **** but WITHOUT ANY WARRANTY; without even the implied warranty of
13:UIMgr.c **** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14:UIMgr.c **** General Public License for more details.
15:UIMgr.c ****
16:UIMgr.c **** You should have received a copy of the GNU General Public
17:UIMgr.c **** License along with this program; if not, write to the Free Software
18:UIMgr.c **** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19:UIMgr.c ****
GAS LISTING /tmp/cc2L16GD.s page 3
 
 
20:UIMgr.c **** For more information on the AVRcam, please contact:
21:UIMgr.c ****
22:UIMgr.c **** john@jrobot.net
23:UIMgr.c ****
24:UIMgr.c **** or go to www.jrobot.net for more details regarding the system.
25:UIMgr.c **** */
26:UIMgr.c **** /***********************************************************
27:UIMgr.c **** Module Name: UIMgr.c
28:UIMgr.c **** Module Date: 04/10/2004
29:UIMgr.c **** Module Auth: John Orlando
30:UIMgr.c ****
31:UIMgr.c **** Description: This module is responsible for providing
32:UIMgr.c **** the processing to manage the user interface of the
33:UIMgr.c **** system. This user interface is provided via the UART.
34:UIMgr.c **** This module handles the incoming serial commands, and
35:UIMgr.c **** performs the needed functionality. It is then
36:UIMgr.c **** responsible for generating any needed response to
37:UIMgr.c **** the external entity.
38:UIMgr.c ****
39:UIMgr.c **** Revision History:
40:UIMgr.c **** Date Rel Ver. Notes
41:UIMgr.c **** 4/10/2004 0.1 Module created
42:UIMgr.c **** 6/30/2004 1.0 Initial release for Circuit Cellar
43:UIMgr.c **** contest.
44:UIMgr.c **** 11/15/2004 1.2 Updated version string to 1.2.
45:UIMgr.c **** 1/16/2005 1.4 Added code to write the colorMap
46:UIMgr.c **** to EEPROM one byte at a time,
47:UIMgr.c **** ensuring that the EEPROM is only
48:UIMgr.c **** written when the data is different
49:UIMgr.c **** than the current value (thus saving
50:UIMgr.c **** EEPROM writes). Updated version
51:UIMgr.c **** string to 1.4.
52:UIMgr.c **** ***********************************************************/
53:UIMgr.c ****
54:UIMgr.c **** /* Includes */
55:UIMgr.c **** #include <avr/io.h>
56:UIMgr.c **** #include <stdlib.h>
57:UIMgr.c **** #include <string.h>
58:UIMgr.c **** #include <avr/eeprom.h>
59:UIMgr.c **** #include "CommonDefs.h"
60:UIMgr.c **** #include "UIMgr.h"
61:UIMgr.c **** #include "UartInterface.h"
62:UIMgr.c **** #include "CamConfig.h"
63:UIMgr.c **** #include "Utility.h"
64:UIMgr.c **** #include "Executive.h"
65:UIMgr.c **** #include "CamInterface.h"
66:UIMgr.c ****
67:UIMgr.c **** /* Local Structures and Typedefs */
68:UIMgr.c ****
69:UIMgr.c **** typedef enum
70:UIMgr.c **** {
71:UIMgr.c **** getVersionCmd,
72:UIMgr.c **** pingCmd,
73:UIMgr.c **** setCameraRegsCmd,
74:UIMgr.c **** dumpFrameCmd,
75:UIMgr.c **** enableTrackingCmd,
76:UIMgr.c **** disableTrackingCmd,
GAS LISTING /tmp/cc2L16GD.s page 4
 
 
77:UIMgr.c **** setColorMapCmd,
78:UIMgr.c **** resetCameraCmd,
79:UIMgr.c **** noCmd,
80:UIMgr.c **** invalidCmd
81:UIMgr.c **** } UIMgr_Cmd_t;
82:UIMgr.c ****
83:UIMgr.c **** typedef enum
84:UIMgr.c **** {
85:UIMgr.c **** setRed,
86:UIMgr.c **** setGreen,
87:UIMgr.c **** setBlue
88:UIMgr.c **** } setColorState_t;
89:UIMgr.c ****
90:UIMgr.c ****
91:UIMgr.c **** /* Local Variables */
92:UIMgr.c **** static unsigned char charCount = 0;
93:UIMgr.c **** static unsigned char charIndex = 0;
94:UIMgr.c **** static unsigned char asciiTokenBuffer[MAX_TOKEN_LENGTH+1]; /* +1 to ensure NULL at end */
95:UIMgr.c **** static unsigned char tokenCount = 0;
96:UIMgr.c **** static unsigned char tokenBuffer[MAX_TOKEN_COUNT];
97:UIMgr.c **** static UIMgr_Cmd_t receivedCmd = noCmd;
98:UIMgr.c **** static unsigned char AVRcamVersion[] = "AVRcam v1.4\r";
99:UIMgr.c ****
100:UIMgr.c **** /* Local Function Declaration */
101:UIMgr.c **** static unsigned char UIMgr_readRxFifo(void);
102:UIMgr.c **** static unsigned char UIMgr_readTxFifo(void);
103:UIMgr.c **** static unsigned char UIMgr_readRxFifo(void);
104:UIMgr.c **** static void UIMgr_sendNck(void);
105:UIMgr.c **** static void UIMgr_sendAck(void);
106:UIMgr.c **** static void UIMgr_convertTokenToCmd(void);
107:UIMgr.c **** static void UIMgr_convertTokenToValue(void);
108:UIMgr.c **** static void UIMgr_executeCmd(void);
109:UIMgr.c ****
110:UIMgr.c **** /* Extern Variables */
111:UIMgr.c **** unsigned char UIMgr_rxFifo[UI_MGR_RX_FIFO_SIZE];
112:UIMgr.c **** unsigned char UIMgr_rxFifoHead=0;
113:UIMgr.c **** unsigned char UIMgr_rxFifoTail=0;
114:UIMgr.c ****
115:UIMgr.c **** unsigned char UIMgr_txFifo[UI_MGR_TX_FIFO_SIZE];
116:UIMgr.c **** unsigned char UIMgr_txFifoHead=0;
117:UIMgr.c **** unsigned char UIMgr_txFifoTail=0;
118:UIMgr.c ****
119:UIMgr.c **** /* Definitions */
120:UIMgr.c **** #define IS_DATA_IN_TX_FIFO() (!(UIMgr_txFifoHead == UIMgr_txFifoTail))
121:UIMgr.c **** #define IS_DATA_IN_RX_FIFO() (!(UIMgr_rxFifoHead == UIMgr_rxFifoTail))
122:UIMgr.c ****
123:UIMgr.c **** /* MAX_EEPROM_WRITE_ATTEMPTS limits the number of writes that can be
124:UIMgr.c **** done to a particular EEPROM cell, so that it can't possible just
125:UIMgr.c **** write to the same cell over and over */
126:UIMgr.c **** #define MAX_EEPROM_WRITE_ATTEMPTS 3
127:UIMgr.c ****
128:UIMgr.c **** /***********************************************************
129:UIMgr.c **** Function Name: UIMgr_init
130:UIMgr.c **** Function Description: This function is responsible for
131:UIMgr.c **** initializing the UIMgr module. It sets up the fifo
132:UIMgr.c **** used to hold incoming data, etc.
133:UIMgr.c **** Inputs: none
GAS LISTING /tmp/cc2L16GD.s page 5
 
 
134:UIMgr.c **** Outputs: none
135:UIMgr.c **** ***********************************************************/
136:UIMgr.c **** void UIMgr_init(void)
137:UIMgr.c **** {
138:UIMgr.c **** memset(asciiTokenBuffer,0x00,MAX_TOKEN_LENGTH+1);
139:UIMgr.c **** memset(tokenBuffer,0x00,MAX_TOKEN_COUNT);
140:UIMgr.c **** memset(UIMgr_txFifo,0x00,UI_MGR_TX_FIFO_SIZE);
141:UIMgr.c **** memset(UIMgr_rxFifo,0x00,UI_MGR_RX_FIFO_SIZE);
142:UIMgr.c **** }
143:UIMgr.c ****
144:UIMgr.c **** /***********************************************************
145:UIMgr.c **** Function Name: UIMgr_dispatchEvent
146:UIMgr.c **** Function Description: This function is responsible for
147:UIMgr.c **** processing events that pertain to the UIMgr.
148:UIMgr.c **** Inputs: event - the generated event
149:UIMgr.c **** Outputs: none
150:UIMgr.c **** ***********************************************************/
151:UIMgr.c **** void UIMgr_dispatchEvent(unsigned char event)
152:UIMgr.c **** {
153:UIMgr.c **** switch(event)
154:UIMgr.c **** {
155:UIMgr.c **** case EV_ACQUIRE_LINE_COMPLETE:
156:UIMgr.c **** UIMgr_transmitPendingData();
157:UIMgr.c **** break;
158:UIMgr.c ****
159:UIMgr.c **** case EV_SERIAL_DATA_RECEIVED:
160:UIMgr.c **** UIMgr_processReceivedData();
161:UIMgr.c **** break;
162:UIMgr.c ****
163:UIMgr.c **** case EV_SERIAL_DATA_PENDING_TX:
164:UIMgr.c **** UIMgr_flushTxBuffer();
165:UIMgr.c **** break;
166:UIMgr.c **** }
167:UIMgr.c **** }
168:UIMgr.c **** /***********************************************************
169:UIMgr.c **** Function Name: UIMgr_transmitPendingData
170:UIMgr.c **** Function Description: This function is responsible for
171:UIMgr.c **** transmitting a single byte of data if data is waiting
172:UIMgr.c **** to be sent. Otherwise, if nothing is waiting, the
173:UIMgr.c **** function just returns.
174:UIMgr.c **** Inputs: none
175:UIMgr.c **** Outputs: none
176:UIMgr.c **** ***********************************************************/
177:UIMgr.c **** void UIMgr_transmitPendingData(void)
178:UIMgr.c **** {
179:UIMgr.c **** if (IS_DATA_IN_TX_FIFO() == TRUE)
180:UIMgr.c **** {
181:UIMgr.c **** /* data is waiting...send a single byte */
182:UIMgr.c **** UartInt_txByte( UIMgr_readTxFifo() );
183:UIMgr.c **** }
184:UIMgr.c **** }
185:UIMgr.c **** /***********************************************************
186:UIMgr.c **** Function Name: UIMgr_processReceivedData
187:UIMgr.c **** Function Description: This function is responsible for
188:UIMgr.c **** parsing any serial data waiting in the rx fifo
189:UIMgr.c **** Inputs: none
190:UIMgr.c **** Outputs: none
GAS LISTING /tmp/cc2L16GD.s page 6
 
 
191:UIMgr.c **** ***********************************************************/
192:UIMgr.c **** void UIMgr_processReceivedData(void)
193:UIMgr.c **** {
194:UIMgr.c **** unsigned char tmpData = 0;
195:UIMgr.c ****
196:UIMgr.c **** /* still need to add a mechanism to handle token counts
197:UIMgr.c **** that are excessive!!! FIX ME!!! */
198:UIMgr.c ****
199:UIMgr.c **** while(IS_DATA_IN_RX_FIFO() == TRUE)
200:UIMgr.c **** {
201:UIMgr.c **** tmpData = UIMgr_readRxFifo();
202:UIMgr.c **** if (tmpData == '\r')
203:UIMgr.c **** {
204:UIMgr.c **** /* we have reached a token separator */
205:UIMgr.c **** if (tokenCount == 0)
206:UIMgr.c **** {
207:UIMgr.c **** /* convert the command */
208:UIMgr.c **** UIMgr_convertTokenToCmd();
209:UIMgr.c **** }
210:UIMgr.c **** else
211:UIMgr.c **** {
212:UIMgr.c **** /* convert a value */
213:UIMgr.c **** UIMgr_convertTokenToValue();
214:UIMgr.c **** tokenCount++;
215:UIMgr.c **** }
216:UIMgr.c **** /* either way, it is time to try to process the received
217:UIMgr.c **** token list since we have reached the end of the cmd. */
218:UIMgr.c **** Utility_delay(100);
219:UIMgr.c **** if (receivedCmd == invalidCmd ||
220:UIMgr.c **** receivedCmd == noCmd )
221:UIMgr.c **** {
222:UIMgr.c **** UIMgr_sendNck();
223:UIMgr.c **** PUBLISH_EVENT(EV_SERIAL_DATA_PENDING_TX);
224:UIMgr.c **** }
225:UIMgr.c **** else
226:UIMgr.c **** {
227:UIMgr.c **** UIMgr_sendAck();
228:UIMgr.c **** /* publish the serial data pending event, so it
229:UIMgr.c **** will push the ACK out before we execute the cmd */
230:UIMgr.c **** PUBLISH_EVENT(EV_SERIAL_DATA_PENDING_TX);
231:UIMgr.c **** UIMgr_executeCmd();
232:UIMgr.c **** }
233:UIMgr.c ****
234:UIMgr.c **** /* reset any necessary data */
235:UIMgr.c **** tokenCount = 0;
236:UIMgr.c **** memset(tokenBuffer,0x00,MAX_TOKEN_COUNT);
237:UIMgr.c **** }
238:UIMgr.c **** else if (tmpData == ' ') /* space char */
239:UIMgr.c **** {
240:UIMgr.c **** /* the end of a token has been reached */
241:UIMgr.c **** if (tokenCount == 0)
242:UIMgr.c **** {
243:UIMgr.c **** UIMgr_convertTokenToCmd();
244:UIMgr.c **** tokenCount++; /* check this...why is this being incremented here??? This
245:UIMgr.c **** means we have received a token, with tokenCount == 0, which means it is a
246:UIMgr.c **** command...why is this contributing to tokenCount?
247:UIMgr.c **** This might cause the set color map command to include too much data, since
GAS LISTING /tmp/cc2L16GD.s page 7
 
 
248:UIMgr.c **** it sets the color map based on tokenCount...CHECK*/
249:UIMgr.c **** }
250:UIMgr.c **** else
251:UIMgr.c **** {
252:UIMgr.c **** /* check to see if this token is going to push
253:UIMgr.c **** us over the limit...if so, abort the transaction */
254:UIMgr.c **** if (tokenCount+1 >= MAX_TOKEN_COUNT)
255:UIMgr.c **** {
256:UIMgr.c **** /* we received too many tokens, and
257:UIMgr.c **** need to NCK this request, since its too
258:UIMgr.c **** large...reset everything...*/
259:UIMgr.c **** charCount=0;
260:UIMgr.c **** charIndex=0;
261:UIMgr.c **** tokenCount=0;
262:UIMgr.c **** receivedCmd = invalidCmd;
263:UIMgr.c **** }
264:UIMgr.c **** else
265:UIMgr.c **** {
266:UIMgr.c **** /* tokenCount is still in range...*/
267:UIMgr.c **** UIMgr_convertTokenToValue();
268:UIMgr.c **** tokenCount++;
269:UIMgr.c **** }
270:UIMgr.c **** }
271:UIMgr.c **** }
272:UIMgr.c **** else if ( (tmpData >= 'A' && tmpData <= 'Z') ||
273:UIMgr.c **** (tmpData >= '0' && tmpData <= '9') )
274:UIMgr.c **** {
275:UIMgr.c **** /* a valid range of token was received */
276:UIMgr.c **** asciiTokenBuffer[charIndex] = tmpData;
277:UIMgr.c **** charCount++;
278:UIMgr.c **** charIndex++;
279:UIMgr.c **** if (charCount > MAX_TOKEN_LENGTH)
280:UIMgr.c **** {
281:UIMgr.c **** /* we have received a token that cannot be handled...
282:UIMgr.c **** set the received cmd to an invalid cmd, and wait
283:UIMgr.c **** for the \r to process it */
284:UIMgr.c **** receivedCmd = invalidCmd;
285:UIMgr.c **** charIndex = 0; /* ...so we won't overwrite memory */
286:UIMgr.c **** }
287:UIMgr.c **** }
288:UIMgr.c **** else
289:UIMgr.c **** {
290:UIMgr.c **** /* an invalid character was received */
291:UIMgr.c **** receivedCmd = invalidCmd;
292:UIMgr.c **** }
293:UIMgr.c **** } /* end while */
294:UIMgr.c ****
295:UIMgr.c **** asm volatile("clt"::); /* clear out the T flag in case it wasn't
296:UIMgr.c **** cleared already */
297:UIMgr.c **** }
298:UIMgr.c ****
299:UIMgr.c **** /***********************************************************
300:UIMgr.c **** Function Name: UIMgr_executeCmd
301:UIMgr.c **** Function Description: This function is responsible for
302:UIMgr.c **** executing whatever cmd is stored in the receivedCmd
303:UIMgr.c **** object.
304:UIMgr.c **** Inputs: none
GAS LISTING /tmp/cc2L16GD.s page 8
 
 
305:UIMgr.c **** Outputs: none
306:UIMgr.c **** ***********************************************************/
307:UIMgr.c **** static void UIMgr_executeCmd(void)
308:UIMgr.c **** {
309:UIMgr.c **** unsigned char i,eepromData, num_writes=0;
310:UIMgr.c **** unsigned char *pData;
311:UIMgr.c **** unsigned char eeprom_write_succeeded = FALSE;
312:UIMgr.c **** #if DEBUG_COLOR_MAP
313:UIMgr.c **** unsigned char asciiBuffer[5];
314:UIMgr.c **** #endif
315:UIMgr.c ****
316:UIMgr.c **** if (receivedCmd == pingCmd)
317:UIMgr.c **** {
318:UIMgr.c **** }
319:UIMgr.c **** else if (receivedCmd == getVersionCmd)
320:UIMgr.c **** {
321:UIMgr.c **** pData = AVRcamVersion;
322:UIMgr.c **** while(*pData != 0)
323:UIMgr.c **** {
324:UIMgr.c **** UIMgr_writeTxFifo(*pData++);
325:UIMgr.c **** }
326:UIMgr.c **** }
327:UIMgr.c **** else if (receivedCmd == resetCameraCmd)
328:UIMgr.c **** {
329:UIMgr.c **** CamInt_resetCam();
330:UIMgr.c **** }
331:UIMgr.c **** else if (receivedCmd == dumpFrameCmd)
332:UIMgr.c **** {
333:UIMgr.c **** /* publish the event that will indicate that
334:UIMgr.c **** a request has come to dump a frame...this will
335:UIMgr.c **** be received by the FrameMgr, which will begin
336:UIMgr.c **** dumping the frame...a short delay is needed
337:UIMgr.c **** here to keep the Java demo app happy (sometimes
338:UIMgr.c **** it wouldn't be able to receive the serial data
339:UIMgr.c **** as quickly as AVRcam can provide it). */
340:UIMgr.c **** Utility_delay(100);
341:UIMgr.c **** PUBLISH_EVENT(EV_DUMP_FRAME);
342:UIMgr.c **** }
343:UIMgr.c **** else if (receivedCmd == setCameraRegsCmd)
344:UIMgr.c **** {
345:UIMgr.c **** /* we need to gather the tokens and
346:UIMgr.c **** build config cmds to be sent to the camera */
347:UIMgr.c **** for (i=1; i<tokenCount; i+=2) /* starts at 1 since first token
348:UIMgr.c **** is the CR cmd */
349:UIMgr.c **** {
350:UIMgr.c **** CamConfig_setCamReg(tokenBuffer[i],tokenBuffer[i+1]);
351:UIMgr.c **** }
352:UIMgr.c **** CamConfig_sendFifoCmds();
353:UIMgr.c **** }
354:UIMgr.c **** else if (receivedCmd == enableTrackingCmd)
355:UIMgr.c **** {
356:UIMgr.c **** /* publish the event...again with a short delay */
357:UIMgr.c **** Utility_delay(100);
358:UIMgr.c **** PUBLISH_EVENT(EV_ENABLE_TRACKING);
359:UIMgr.c **** }
360:UIMgr.c **** else if (receivedCmd == disableTrackingCmd)
361:UIMgr.c **** {
GAS LISTING /tmp/cc2L16GD.s page 9
 
 
362:UIMgr.c **** PUBLISH_EVENT(EV_DISABLE_TRACKING);
363:UIMgr.c **** }
364:UIMgr.c **** else if (receivedCmd == setColorMapCmd)
365:UIMgr.c **** {
366:UIMgr.c **** /* copy the received tokens into the color map */
367:UIMgr.c **** for (i=0; i<tokenCount; i++)
368:UIMgr.c **** {
369:UIMgr.c **** colorMap[i] = tokenBuffer[i+1];
370:UIMgr.c ****
371:UIMgr.c **** /* write each colorMap byte to EEPROM, but only those
372:UIMgr.c **** that changed...this will help reduce wear on the EEPROM */
373:UIMgr.c **** eepromData = eeprom_read_byte( (unsigned char*)(i+1));
374:UIMgr.c **** if (eepromData != colorMap[i])
375:UIMgr.c **** {
376:UIMgr.c **** /* need to actually perform the write because the
377:UIMgr.c **** data in eeprom is different than the current colorMap */
378:UIMgr.c **** eeprom_write_succeeded = FALSE;
379:UIMgr.c **** while(eeprom_write_succeeded == FALSE && num_writes < MAX_EEPROM_WRITE_ATTEMPTS)
380:UIMgr.c **** {
381:UIMgr.c **** eeprom_write_byte((unsigned char*)(i+1),colorMap[i]);
382:UIMgr.c **** num_writes++;
383:UIMgr.c **** eepromData = eeprom_read_byte( (unsigned char*)(i+1));
384:UIMgr.c **** if (eepromData == colorMap[i])
385:UIMgr.c **** {
386:UIMgr.c **** eeprom_write_succeeded = TRUE;
387:UIMgr.c **** }
388:UIMgr.c **** }
389:UIMgr.c **** num_writes = 0;
390:UIMgr.c **** }
391:UIMgr.c **** }
392:UIMgr.c ****
393:UIMgr.c **** #if DEBUG_COLOR_MAP
394:UIMgr.c **** /* for debugging...send out the entire color map */
395:UIMgr.c **** UIMgr_txBuffer("\r\n",2);
396:UIMgr.c **** for (i=0; i<NUM_ELEMENTS_IN_COLOR_MAP; i++)
397:UIMgr.c **** {
398:UIMgr.c **** memset(asciiBuffer,0x00,5);
399:UIMgr.c **** itoa(colorMap[i],asciiBuffer,10);
400:UIMgr.c **** UIMgr_txBuffer(asciiBuffer,3);
401:UIMgr.c **** UIMgr_txBuffer(" ",1);
402:UIMgr.c **** if (i==15 || i == 31)
403:UIMgr.c **** {
404:UIMgr.c **** /* break up the output */
405:UIMgr.c **** UIMgr_txBuffer("\r\n",2);
406:UIMgr.c **** }
407:UIMgr.c **** }
408:UIMgr.c **** #endif
409:UIMgr.c **** }
410:UIMgr.c **** }
411:UIMgr.c ****
412:UIMgr.c **** /***********************************************************
413:UIMgr.c **** Function Name: UIMgr_convertTokenToValue
414:UIMgr.c **** Function Description: This function is responsible for
415:UIMgr.c **** converting a received token to a hex value It will
416:UIMgr.c **** access the asciiTokenBuffer directly, and store the
417:UIMgr.c **** result in the appropriate token buffer.
418:UIMgr.c **** Inputs: none
GAS LISTING /tmp/cc2L16GD.s page 10
 
 
419:UIMgr.c **** Outputs: none
420:UIMgr.c **** ***********************************************************/
421:UIMgr.c **** static void UIMgr_convertTokenToValue(void)
422:UIMgr.c **** {
423:UIMgr.c **** unsigned int newValue;
424:UIMgr.c ****
425:UIMgr.c **** newValue = atoi(asciiTokenBuffer);
426:UIMgr.c **** if (newValue > 255)
427:UIMgr.c **** {
428:UIMgr.c **** /* the value is too large */
429:UIMgr.c **** receivedCmd = invalidCmd;
430:UIMgr.c **** tokenBuffer[tokenCount] = 0xFF; /* to indicate an error */
431:UIMgr.c **** }
432:UIMgr.c **** else
433:UIMgr.c **** {
434:UIMgr.c **** /* copy the value into the tokenBuffer */
435:UIMgr.c **** tokenBuffer[tokenCount] = newValue;
436:UIMgr.c **** }
437:UIMgr.c **** memset(asciiTokenBuffer,0x00,MAX_TOKEN_LENGTH);
438:UIMgr.c **** charIndex = 0;
439:UIMgr.c **** charCount = 0;
440:UIMgr.c **** }
441:UIMgr.c **** /***********************************************************
442:UIMgr.c **** Function Name: UIMgr_convertTokenToCmd
443:UIMgr.c **** Function Description: This function is responsible for
444:UIMgr.c **** parsing a received 2-character command. It will
445:UIMgr.c **** access the asciiTokenBuffer directly.
446:UIMgr.c **** Inputs: none
447:UIMgr.c **** Outputs: none
448:UIMgr.c **** ***********************************************************/
449:UIMgr.c **** static void UIMgr_convertTokenToCmd(void)
450:UIMgr.c **** {
451:UIMgr.c **** if ( (asciiTokenBuffer[0] == 'P') &&
452:UIMgr.c **** (asciiTokenBuffer[1] == 'G') )
453:UIMgr.c **** {
454:UIMgr.c **** /* we got a "ping" command...but we still need to see
455:UIMgr.c **** if we are going to get the \r */
456:UIMgr.c **** receivedCmd = pingCmd;
457:UIMgr.c **** }
458:UIMgr.c **** else if ( (asciiTokenBuffer[0] == 'G') &&
459:UIMgr.c **** (asciiTokenBuffer[1] == 'V') )
460:UIMgr.c **** {
461:UIMgr.c **** /* we got the "get version" command */
462:UIMgr.c **** receivedCmd = getVersionCmd;
463:UIMgr.c **** }
464:UIMgr.c **** else if ( (asciiTokenBuffer[0] == 'D') &&
465:UIMgr.c **** (asciiTokenBuffer[1] == 'F') )
466:UIMgr.c **** {
467:UIMgr.c **** /* we should go into frame dump mode */
468:UIMgr.c **** receivedCmd = dumpFrameCmd;
469:UIMgr.c **** }
470:UIMgr.c **** else if ( (asciiTokenBuffer[0] == 'C') &&
471:UIMgr.c **** (asciiTokenBuffer[1] == 'R') )
472:UIMgr.c **** {
473:UIMgr.c **** /* the user wants to set registers in the OV6620 */
474:UIMgr.c **** receivedCmd = setCameraRegsCmd;
475:UIMgr.c **** }
GAS LISTING /tmp/cc2L16GD.s page 11
 
 
476:UIMgr.c **** else if ( (asciiTokenBuffer[0] == 'E') &&
477:UIMgr.c **** (asciiTokenBuffer[1] == 'T') )
478:UIMgr.c **** {
479:UIMgr.c **** /* the user wants to enable tracking */
480:UIMgr.c **** receivedCmd = enableTrackingCmd;
481:UIMgr.c **** }
482:UIMgr.c **** else if ( (asciiTokenBuffer[0] == 'S') &&
483:UIMgr.c **** (asciiTokenBuffer[1] == 'M') )
484:UIMgr.c **** {
485:UIMgr.c **** /* the user wants to set the color map */
486:UIMgr.c **** receivedCmd = setColorMapCmd;
487:UIMgr.c **** }
488:UIMgr.c **** else if ( (asciiTokenBuffer[0] == 'D') &&
489:UIMgr.c **** (asciiTokenBuffer[1] == 'T') )
490:UIMgr.c **** {
491:UIMgr.c **** receivedCmd = disableTrackingCmd;
492:UIMgr.c **** }
493:UIMgr.c **** else if ( (asciiTokenBuffer[0] == 'R') &&
494:UIMgr.c **** (asciiTokenBuffer[1] == 'S') )
495:UIMgr.c **** {
496:UIMgr.c **** receivedCmd = resetCameraCmd;
497:UIMgr.c **** }
498:UIMgr.c **** else
499:UIMgr.c **** {
500:UIMgr.c **** /* don't recognize the cmd */
501:UIMgr.c **** receivedCmd = invalidCmd;
502:UIMgr.c **** }
503:UIMgr.c **** memset(asciiTokenBuffer,0x00,MAX_TOKEN_LENGTH);
504:UIMgr.c **** charIndex = 0;
505:UIMgr.c **** charCount = 0;
506:UIMgr.c **** }
507:UIMgr.c **** /***********************************************************
508:UIMgr.c **** Function Name: UIMgr_sendAck
509:UIMgr.c **** Function Description: This function is responsible for
510:UIMgr.c **** queuing up an ACK to be sent to the user.
511:UIMgr.c **** Inputs: none
512:UIMgr.c **** Outputs: none
513:UIMgr.c **** ***********************************************************/
514:UIMgr.c **** static void UIMgr_sendAck(void)
515:UIMgr.c **** {
516:UIMgr.c **** UIMgr_writeTxFifo('A');
517:UIMgr.c **** UIMgr_writeTxFifo('C');
518:UIMgr.c **** UIMgr_writeTxFifo('K');
519:UIMgr.c **** UIMgr_writeTxFifo('\r');
520:UIMgr.c **** }
521:UIMgr.c ****
522:UIMgr.c **** /***********************************************************
523:UIMgr.c **** Function Name: UIMgr_sendNck
524:UIMgr.c **** Function Description: This function is responsible for
525:UIMgr.c **** queueing up an NCK to be sent to the user.
526:UIMgr.c **** Inputs: none
527:UIMgr.c **** Outputs: none
528:UIMgr.c **** ***********************************************************/
529:UIMgr.c **** static void UIMgr_sendNck(void)
530:UIMgr.c **** {
531:UIMgr.c **** UIMgr_writeTxFifo('N');
532:UIMgr.c **** UIMgr_writeTxFifo('C');
GAS LISTING /tmp/cc2L16GD.s page 12
 
 
533:UIMgr.c **** UIMgr_writeTxFifo('K');
534:UIMgr.c **** UIMgr_writeTxFifo('\r');
535:UIMgr.c **** }
536:UIMgr.c ****
537:UIMgr.c ****
538:UIMgr.c **** /***********************************************************
539:UIMgr.c **** Function Name: UIMgr_writeBufferToTxFifo
540:UIMgr.c **** Function Description: This function is responsible for
541:UIMgr.c **** placing "length" bytes into the tx FIFO.
542:UIMgr.c **** Inputs: pData - a pointer to the data to send
543:UIMgr.c **** length - the number of bytes to send
544:UIMgr.c **** Outputs: none
545:UIMgr.c **** ***********************************************************/
546:UIMgr.c **** void UIMgr_writeBufferToTxFifo(unsigned char *pData, unsigned char length)
547:UIMgr.c **** {
96 .stabn 68,0,547,.LM0-UIMgr_writeBufferToTxFifo
97 .LM0:
98 /* prologue: frame size=0 */
99 /* prologue end (size=0) */
100 0000 DC01 movw r26,r24
101 0002 862F mov r24,r22
548:UIMgr.c **** unsigned char tmpHead;
549:UIMgr.c **** if (length == 0)
102 .stabn 68,0,549,.LM1-UIMgr_writeBufferToTxFifo
103 .LM1:
104 0004 6623 tst r22
105 0006 C9F0 breq .L7
550:UIMgr.c **** {
551:UIMgr.c **** return;
552:UIMgr.c **** }
553:UIMgr.c ****
554:UIMgr.c **** DISABLE_INTS();
106 .stabn 68,0,554,.LM2-UIMgr_writeBufferToTxFifo
107 .LM2:
108 /* #APP */
109 0008 F894 cli
555:UIMgr.c **** while(length-- != 0)
110 .stabn 68,0,555,.LM3-UIMgr_writeBufferToTxFifo
111 .LM3:
112 /* #NOAPP */
113 000a 6150 subi r22,lo8(-(-1))
114 000c 6F3F cpi r22,lo8(-1)
115 000e A1F0 breq .L4
116 0010 262F mov r18,r22
117 0012 40E0 ldi r20,lo8(UIMgr_txFifo)
118 0014 50E0 ldi r21,hi8(UIMgr_txFifo)
119 0016 861B sub r24,r22
120 0018 682F mov r22,r24
121 001a 6250 subi r22,lo8(-(-2))
122 .L6:
556:UIMgr.c **** {
557:UIMgr.c **** UIMgr_txFifo[UIMgr_txFifoHead] = *pData++;
123 .stabn 68,0,557,.LM4-UIMgr_writeBufferToTxFifo
124 .LM4:
125 001c 8091 0000 lds r24,UIMgr_txFifoHead
126 0020 FA01 movw r30,r20
127 0022 E80F add r30,r24
GAS LISTING /tmp/cc2L16GD.s page 13
 
 
128 0024 F11D adc r31,__zero_reg__
129 0026 9D91 ld r25,X+
130 0028 9083 st Z,r25
558:UIMgr.c ****
559:UIMgr.c **** /* now move the head up */
560:UIMgr.c **** tmpHead = (UIMgr_txFifoHead + 1) & (UI_MGR_TX_FIFO_MASK);
561:UIMgr.c **** UIMgr_txFifoHead = tmpHead;
131 .stabn 68,0,561,.LM5-UIMgr_writeBufferToTxFifo
132 .LM5:
133 002a 8F5F subi r24,lo8(-(1))
134 002c 8F73 andi r24,lo8(63)
135 002e 8093 0000 sts UIMgr_txFifoHead,r24
136 .stabn 68,0,555,.LM6-UIMgr_writeBufferToTxFifo
137 .LM6:
138 0032 2150 subi r18,lo8(-(-1))
139 0034 6217 cp r22,r18
140 0036 91F7 brne .L6
141 .L4:
562:UIMgr.c **** }
563:UIMgr.c **** ENABLE_INTS();
142 .stabn 68,0,563,.LM7-UIMgr_writeBufferToTxFifo
143 .LM7:
144 /* #APP */
145 0038 7894 sei
146 /* #NOAPP */
147 .L7:
148 003a 0895 ret
149 /* epilogue: frame size=0 */
150 /* epilogue: noreturn */
151 /* epilogue end (size=0) */
152 /* function UIMgr_writeBufferToTxFifo size 32 (32) */
153 .size UIMgr_writeBufferToTxFifo, .-UIMgr_writeBufferToTxFifo
154 .Lscope0:
155 .stabs "",36,0,0,.Lscope0-UIMgr_writeBufferToTxFifo
156 .stabd 78,0,0
157 .stabs "UIMgr_readTxFifo:f(0,11)",36,0,630,UIMgr_readTxFifo
158 .type UIMgr_readTxFifo, @function
159 UIMgr_readTxFifo:
160 .stabd 46,0,0
564:UIMgr.c **** }
565:UIMgr.c ****
566:UIMgr.c **** /***********************************************************
567:UIMgr.c **** Function Name: UIMgr_txBuffer
568:UIMgr.c **** Function Description: This function is responsible for
569:UIMgr.c **** sending 'length' bytes out using the UartInterface
570:UIMgr.c **** module.
571:UIMgr.c **** Inputs: pData - a pointer to the data to send
572:UIMgr.c **** length - the number of bytes to send
573:UIMgr.c **** Outputs: none
574:UIMgr.c **** ***********************************************************/
575:UIMgr.c **** void UIMgr_txBuffer(unsigned char *pData, unsigned char length)
576:UIMgr.c **** {
577:UIMgr.c **** while(length-- != 0)
578:UIMgr.c **** {
579:UIMgr.c **** UartInt_txByte(*pData++);
580:UIMgr.c **** }
581:UIMgr.c **** }
GAS LISTING /tmp/cc2L16GD.s page 14
 
 
582:UIMgr.c ****
583:UIMgr.c **** /***********************************************************
584:UIMgr.c **** Function Name: UIMgr_flushTxBuffer
585:UIMgr.c **** Function Description: This function is responsible for
586:UIMgr.c **** sending all data currently in the serial tx buffer
587:UIMgr.c **** to the user.
588:UIMgr.c **** Inputs: none
589:UIMgr.c **** Outputs: none
590:UIMgr.c **** ***********************************************************/
591:UIMgr.c **** void UIMgr_flushTxBuffer(void)
592:UIMgr.c **** {
593:UIMgr.c **** while(IS_DATA_IN_TX_FIFO() == TRUE)
594:UIMgr.c **** {
595:UIMgr.c **** UartInt_txByte(UIMgr_readTxFifo() );
596:UIMgr.c **** }
597:UIMgr.c **** }
598:UIMgr.c ****
599:UIMgr.c **** /***********************************************************
600:UIMgr.c **** Function Name: UIMgr_readRxFifo
601:UIMgr.c **** Function Description: This function is responsible for
602:UIMgr.c **** reading a single byte of data from the rx fifo, and
603:UIMgr.c **** updating the appropriate pointers.
604:UIMgr.c **** Inputs: none
605:UIMgr.c **** Outputs: unsigned char-the data read
606:UIMgr.c **** ***********************************************************/
607:UIMgr.c **** static unsigned char UIMgr_readRxFifo(void)
608:UIMgr.c **** {
609:UIMgr.c **** unsigned char dataByte, tmpTail;
610:UIMgr.c ****
611:UIMgr.c **** /* just return the current tail from the rx fifo */
612:UIMgr.c **** DISABLE_INTS();
613:UIMgr.c **** dataByte = UIMgr_rxFifo[UIMgr_rxFifoTail];
614:UIMgr.c **** tmpTail = (UIMgr_rxFifoTail+1) & (UI_MGR_RX_FIFO_MASK);
615:UIMgr.c **** UIMgr_rxFifoTail = tmpTail;
616:UIMgr.c **** ENABLE_INTS();
617:UIMgr.c ****
618:UIMgr.c **** return(dataByte);
619:UIMgr.c **** }
620:UIMgr.c ****
621:UIMgr.c **** /***********************************************************
622:UIMgr.c **** Function Name: UIMgr_readTxFifo
623:UIMgr.c **** Function Description: This function is responsible for
624:UIMgr.c **** reading a single byte of data from the tx fifo, and
625:UIMgr.c **** updating the appropriate pointers.
626:UIMgr.c **** Inputs: none
627:UIMgr.c **** Outputs: unsigned char-the data read
628:UIMgr.c **** ***********************************************************/
629:UIMgr.c **** static unsigned char UIMgr_readTxFifo(void)
630:UIMgr.c **** {
161 .stabn 68,0,630,.LM8-UIMgr_readTxFifo
162 .LM8:
163 /* prologue: frame size=0 */
164 /* prologue end (size=0) */
631:UIMgr.c **** unsigned char dataByte, tmpTail;
632:UIMgr.c ****
633:UIMgr.c **** /* just return the current tail from the tx fifo */
634:UIMgr.c **** DISABLE_INTS();
GAS LISTING /tmp/cc2L16GD.s page 15
 
 
165 .stabn 68,0,634,.LM9-UIMgr_readTxFifo
166 .LM9:
167 /* #APP */
168 003c F894 cli
635:UIMgr.c **** dataByte = UIMgr_txFifo[UIMgr_txFifoTail];
169 .stabn 68,0,635,.LM10-UIMgr_readTxFifo
170 .LM10:
171 /* #NOAPP */
172 003e 9091 0000 lds r25,UIMgr_txFifoTail
173 0042 E0E0 ldi r30,lo8(UIMgr_txFifo)
174 0044 F0E0 ldi r31,hi8(UIMgr_txFifo)
175 0046 E90F add r30,r25
176 0048 F11D adc r31,__zero_reg__
177 004a 8081 ld r24,Z
636:UIMgr.c **** tmpTail = (UIMgr_txFifoTail+1) & (UI_MGR_TX_FIFO_MASK);
637:UIMgr.c **** UIMgr_txFifoTail = tmpTail;
178 .stabn 68,0,637,.LM11-UIMgr_readTxFifo
179 .LM11:
180 004c 9F5F subi r25,lo8(-(1))
181 004e 9F73 andi r25,lo8(63)
182 0050 9093 0000 sts UIMgr_txFifoTail,r25
638:UIMgr.c **** ENABLE_INTS();
183 .stabn 68,0,638,.LM12-UIMgr_readTxFifo
184 .LM12:
185 /* #APP */
186 0054 7894 sei
639:UIMgr.c ****
640:UIMgr.c **** return(dataByte);
641:UIMgr.c **** }
187 .stabn 68,0,641,.LM13-UIMgr_readTxFifo
188 .LM13:
189 /* #NOAPP */
190 0056 9927 clr r25
191 /* epilogue: frame size=0 */
192 0058 0895 ret
193 /* epilogue end (size=1) */
194 /* function UIMgr_readTxFifo size 17 (16) */
195 .size UIMgr_readTxFifo, .-UIMgr_readTxFifo
196 .stabs "dataByte:r(0,11)",64,0,631,24
197 .stabn 192,0,0,UIMgr_readTxFifo-UIMgr_readTxFifo
198 .stabn 224,0,0,.Lscope1-UIMgr_readTxFifo
199 .Lscope1:
200 .stabs "",36,0,0,.Lscope1-UIMgr_readTxFifo
201 .stabd 78,0,0
202 .stabs "UIMgr_writeTxFifo:F(0,15)",36,0,652,UIMgr_writeTxFifo
203 .stabs "data:P(0,11)",64,0,651,24
204 .global UIMgr_writeTxFifo
205 .type UIMgr_writeTxFifo, @function
206 UIMgr_writeTxFifo:
207 .stabd 46,0,0
642:UIMgr.c ****
643:UIMgr.c **** /***********************************************************
644:UIMgr.c **** Function Name: UIMgr_writeTxFifo
645:UIMgr.c **** Function Description: This function is responsible for
646:UIMgr.c **** writing a single byte to the TxFifo and
647:UIMgr.c **** updating the appropriate pointers.
648:UIMgr.c **** Inputs: data - the byte to write to the Fifo
GAS LISTING /tmp/cc2L16GD.s page 16
 
 
649:UIMgr.c **** Outputs: none
650:UIMgr.c **** ***********************************************************/
651:UIMgr.c **** void UIMgr_writeTxFifo(unsigned char data)
652:UIMgr.c **** {
208 .stabn 68,0,652,.LM14-UIMgr_writeTxFifo
209 .LM14:
210 /* prologue: frame size=0 */
211 /* prologue end (size=0) */
653:UIMgr.c **** unsigned char tmpHead;
654:UIMgr.c ****
655:UIMgr.c **** DISABLE_INTS();
212 .stabn 68,0,655,.LM15-UIMgr_writeTxFifo
213 .LM15:
214 /* #APP */
215 005a F894 cli
656:UIMgr.c **** UIMgr_txFifo[UIMgr_txFifoHead] = data;
216 .stabn 68,0,656,.LM16-UIMgr_writeTxFifo
217 .LM16:
218 /* #NOAPP */
219 005c 9091 0000 lds r25,UIMgr_txFifoHead
220 0060 E0E0 ldi r30,lo8(UIMgr_txFifo)
221 0062 F0E0 ldi r31,hi8(UIMgr_txFifo)
222 0064 E90F add r30,r25
223 0066 F11D adc r31,__zero_reg__
224 0068 8083 st Z,r24
657:UIMgr.c ****
658:UIMgr.c **** /* now move the head up */
659:UIMgr.c **** tmpHead = (UIMgr_txFifoHead + 1) & (UI_MGR_TX_FIFO_MASK);
660:UIMgr.c **** UIMgr_txFifoHead = tmpHead;
225 .stabn 68,0,660,.LM17-UIMgr_writeTxFifo
226 .LM17:
227 006a 9F5F subi r25,lo8(-(1))
228 006c 9F73 andi r25,lo8(63)
229 006e 9093 0000 sts UIMgr_txFifoHead,r25
661:UIMgr.c **** ENABLE_INTS();
230 .stabn 68,0,661,.LM18-UIMgr_writeTxFifo
231 .LM18:
232 /* #APP */
233 0072 7894 sei
234 /* #NOAPP */
235 /* epilogue: frame size=0 */
236 0074 0895 ret
237 /* epilogue end (size=1) */
238 /* function UIMgr_writeTxFifo size 16 (15) */
239 .size UIMgr_writeTxFifo, .-UIMgr_writeTxFifo
240 .Lscope2:
241 .stabs "",36,0,0,.Lscope2-UIMgr_writeTxFifo
242 .stabd 78,0,0
243 .stabs "UIMgr_flushTxBuffer:F(0,15)",36,0,592,UIMgr_flushTxBuffer
244 .global UIMgr_flushTxBuffer
245 .type UIMgr_flushTxBuffer, @function
246 UIMgr_flushTxBuffer:
247 .stabd 46,0,0
248 .stabn 68,0,592,.LM19-UIMgr_flushTxBuffer
249 .LM19:
250 /* prologue: frame size=0 */
251 /* prologue end (size=0) */
GAS LISTING /tmp/cc2L16GD.s page 17
 
 
252 .stabn 68,0,593,.LM20-UIMgr_flushTxBuffer
253 .LM20:
254 0076 9091 0000 lds r25,UIMgr_txFifoHead
255 007a 8091 0000 lds r24,UIMgr_txFifoTail
256 007e 9817 cp r25,r24
257 0080 41F0 breq .L16
258 .L17:
259 .stabn 68,0,595,.LM21-UIMgr_flushTxBuffer
260 .LM21:
261 0082 DCDF rcall UIMgr_readTxFifo
262 0084 00D0 rcall UartInt_txByte
263 .stabn 68,0,593,.LM22-UIMgr_flushTxBuffer
264 .LM22:
265 0086 9091 0000 lds r25,UIMgr_txFifoHead
266 008a 8091 0000 lds r24,UIMgr_txFifoTail
267 008e 9817 cp r25,r24
268 0090 C1F7 brne .L17
269 .L16:
270 0092 0895 ret
271 /* epilogue: frame size=0 */
272 /* epilogue: noreturn */
273 /* epilogue end (size=0) */
274 /* function UIMgr_flushTxBuffer size 15 (15) */
275 .size UIMgr_flushTxBuffer, .-UIMgr_flushTxBuffer
276 .Lscope3:
277 .stabs "",36,0,0,.Lscope3-UIMgr_flushTxBuffer
278 .stabd 78,0,0
279 .stabs "UIMgr_txBuffer:F(0,15)",36,0,576,UIMgr_txBuffer
280 .stabs "pData:P(0,20)",64,0,575,28
281 .stabs "length:P(0,11)",64,0,575,24
282 .global UIMgr_txBuffer
283 .type UIMgr_txBuffer, @function
284 UIMgr_txBuffer:
285 .stabd 46,0,0
286 .stabn 68,0,576,.LM23-UIMgr_txBuffer
287 .LM23:
288 /* prologue: frame size=0 */
289 0094 0F93 push r16
290 0096 1F93 push r17
291 0098 CF93 push r28
292 009a DF93 push r29
293 /* prologue end (size=4) */
294 009c EC01 movw r28,r24
295 009e 862F mov r24,r22
296 .stabn 68,0,577,.LM24-UIMgr_txBuffer
297 .LM24:
298 00a0 6150 subi r22,lo8(-(-1))
299 00a2 6F3F cpi r22,lo8(-1)
300 00a4 49F0 breq .L23
301 .stabn 68,0,577,.LM25-UIMgr_txBuffer
302 .LM25:
303 00a6 162F mov r17,r22
304 00a8 861B sub r24,r22
305 00aa 082F mov r16,r24
306 00ac 0250 subi r16,lo8(-(-2))
307 .L22:
308 .stabn 68,0,579,.LM26-UIMgr_txBuffer
GAS LISTING /tmp/cc2L16GD.s page 18
 
 
309 .LM26:
310 00ae 8991 ld r24,Y+
311 00b0 00D0 rcall UartInt_txByte
312 .stabn 68,0,577,.LM27-UIMgr_txBuffer
313 .LM27:
314 00b2 1150 subi r17,lo8(-(-1))
315 00b4 0117 cp r16,r17
316 00b6 D9F7 brne .L22
317 .L23:
318 /* epilogue: frame size=0 */
319 00b8 DF91 pop r29
320 00ba CF91 pop r28
321 00bc 1F91 pop r17
322 00be 0F91 pop r16
323 00c0 0895 ret
324 /* epilogue end (size=5) */
325 /* function UIMgr_txBuffer size 23 (14) */
326 .size UIMgr_txBuffer, .-UIMgr_txBuffer
327 .Lscope4:
328 .stabs "",36,0,0,.Lscope4-UIMgr_txBuffer
329 .stabd 78,0,0
330 .stabs "UIMgr_transmitPendingData:F(0,15)",36,0,178,UIMgr_transmitPendingData
331 .global UIMgr_transmitPendingData
332 .type UIMgr_transmitPendingData, @function
333 UIMgr_transmitPendingData:
334 .stabd 46,0,0
335 .stabn 68,0,178,.LM28-UIMgr_transmitPendingData
336 .LM28:
337 /* prologue: frame size=0 */
338 /* prologue end (size=0) */
339 .stabn 68,0,179,.LM29-UIMgr_transmitPendingData
340 .LM29:
341 00c2 9091 0000 lds r25,UIMgr_txFifoHead
342 00c6 8091 0000 lds r24,UIMgr_txFifoTail
343 00ca 9817 cp r25,r24
344 00cc 11F0 breq .L28
345 .stabn 68,0,182,.LM30-UIMgr_transmitPendingData
346 .LM30:
347 00ce B6DF rcall UIMgr_readTxFifo
348 00d0 00D0 rcall UartInt_txByte
349 .L28:
350 00d2 0895 ret
351 /* epilogue: frame size=0 */
352 /* epilogue: noreturn */
353 /* epilogue end (size=0) */
354 /* function UIMgr_transmitPendingData size 9 (9) */
355 .size UIMgr_transmitPendingData, .-UIMgr_transmitPendingData
356 .Lscope5:
357 .stabs "",36,0,0,.Lscope5-UIMgr_transmitPendingData
358 .stabd 78,0,0
359 .stabs "UIMgr_convertTokenToCmd:f(0,15)",36,0,450,UIMgr_convertTokenToCmd
360 .type UIMgr_convertTokenToCmd, @function
361 UIMgr_convertTokenToCmd:
362 .stabd 46,0,0
363 .stabn 68,0,450,.LM31-UIMgr_convertTokenToCmd
364 .LM31:
365 /* prologue: frame size=0 */
GAS LISTING /tmp/cc2L16GD.s page 19
 
 
366 /* prologue end (size=0) */
367 .stabn 68,0,451,.LM32-UIMgr_convertTokenToCmd
368 .LM32:
369 00d4 9091 0000 lds r25,asciiTokenBuffer
370 00d8 9035 cpi r25,lo8(80)
371 00da 41F4 brne .L30
372 .stabn 68,0,451,.LM33-UIMgr_convertTokenToCmd
373 .LM33:
374 00dc 8091 0000 lds r24,asciiTokenBuffer+1
375 00e0 8734 cpi r24,lo8(71)
376 00e2 09F5 brne .L32
377 .stabn 68,0,456,.LM34-UIMgr_convertTokenToCmd
378 .LM34:
379 00e4 81E0 ldi r24,lo8(1)
380 00e6 8093 0000 sts receivedCmd,r24
381 00ea 48C0 rjmp .L34
382 .L30:
383 .stabn 68,0,458,.LM35-UIMgr_convertTokenToCmd
384 .LM35:
385 00ec 9734 cpi r25,lo8(71)
386 00ee 39F4 brne .L35
387 00f0 8091 0000 lds r24,asciiTokenBuffer+1
388 00f4 8635 cpi r24,lo8(86)
389 00f6 09F5 brne .L37
390 .stabn 68,0,462,.LM36-UIMgr_convertTokenToCmd
391 .LM36:
392 00f8 1092 0000 sts receivedCmd,__zero_reg__
393 00fc 3FC0 rjmp .L34
394 .L35:
395 .stabn 68,0,464,.LM37-UIMgr_convertTokenToCmd
396 .LM37:
397 00fe 9434 cpi r25,lo8(68)
398 0100 41F4 brne .L39
399 0102 8091 0000 lds r24,asciiTokenBuffer+1
400 0106 8634 cpi r24,lo8(70)
401 0108 11F5 brne .L41
402 .stabn 68,0,468,.LM38-UIMgr_convertTokenToCmd
403 .LM38:
404 010a 83E0 ldi r24,lo8(3)
405 010c 8093 0000 sts receivedCmd,r24
406 0110 35C0 rjmp .L34
407 .L39:
408 .stabn 68,0,470,.LM39-UIMgr_convertTokenToCmd
409 .LM39:
410 0112 9334 cpi r25,lo8(67)
411 0114 41F4 brne .L32
412 0116 8091 0000 lds r24,asciiTokenBuffer+1
413 011a 8235 cpi r24,lo8(82)
414 011c 11F5 brne .L44
415 .stabn 68,0,474,.LM40-UIMgr_convertTokenToCmd
416 .LM40:
417 011e 82E0 ldi r24,lo8(2)
418 0120 8093 0000 sts receivedCmd,r24
419 0124 2BC0 rjmp .L34
420 .L32:
421 .stabn 68,0,476,.LM41-UIMgr_convertTokenToCmd
422 .LM41:
GAS LISTING /tmp/cc2L16GD.s page 20
 
 
423 0126 9534 cpi r25,lo8(69)
424 0128 41F4 brne .L37
425 012a 8091 0000 lds r24,asciiTokenBuffer+1
426 012e 8435 cpi r24,lo8(84)
427 0130 11F5 brne .L47
428 .stabn 68,0,480,.LM42-UIMgr_convertTokenToCmd
429 .LM42:
430 0132 84E0 ldi r24,lo8(4)
431 0134 8093 0000 sts receivedCmd,r24
432 0138 21C0 rjmp .L34
433 .L37:
434 .stabn 68,0,482,.LM43-UIMgr_convertTokenToCmd
435 .LM43:
436 013a 9335 cpi r25,lo8(83)
437 013c 41F4 brne .L41
438 013e 8091 0000 lds r24,asciiTokenBuffer+1
439 0142 8D34 cpi r24,lo8(77)
440 0144 C1F4 brne .L47
441 .stabn 68,0,486,.LM44-UIMgr_convertTokenToCmd
442 .LM44:
443 0146 86E0 ldi r24,lo8(6)
444 0148 8093 0000 sts receivedCmd,r24
445 014c 17C0 rjmp .L34
446 .L41:
447 .stabn 68,0,488,.LM45-UIMgr_convertTokenToCmd
448 .LM45:
449 014e 9434 cpi r25,lo8(68)
450 0150 41F4 brne .L44
451 0152 8091 0000 lds r24,asciiTokenBuffer+1
452 0156 8435 cpi r24,lo8(84)
453 0158 71F4 brne .L47
454 .stabn 68,0,491,.LM46-UIMgr_convertTokenToCmd
455 .LM46:
456 015a 85E0 ldi r24,lo8(5)
457 015c 8093 0000 sts receivedCmd,r24
458 0160 0DC0 rjmp .L34
459 .L44:
460 .stabn 68,0,493,.LM47-UIMgr_convertTokenToCmd
461 .LM47:
462 0162 9235 cpi r25,lo8(82)
463 0164 41F4 brne .L47
464 0166 8091 0000 lds r24,asciiTokenBuffer+1
465 016a 8335 cpi r24,lo8(83)
466 016c 21F4 brne .L47
467 .stabn 68,0,496,.LM48-UIMgr_convertTokenToCmd
468 .LM48:
469 016e 87E0 ldi r24,lo8(7)
470 0170 8093 0000 sts receivedCmd,r24
471 0174 03C0 rjmp .L34
472 .L47:
473 .stabn 68,0,501,.LM49-UIMgr_convertTokenToCmd
474 .LM49:
475 0176 89E0 ldi r24,lo8(9)
476 0178 8093 0000 sts receivedCmd,r24
477 .L34:
478 .stabn 68,0,503,.LM50-UIMgr_convertTokenToCmd
479 .LM50:
GAS LISTING /tmp/cc2L16GD.s page 21
 
 
480 017c 83E0 ldi r24,lo8(3)
481 017e E0E0 ldi r30,lo8(asciiTokenBuffer)
482 0180 F0E0 ldi r31,hi8(asciiTokenBuffer)
483 0182 1192 st Z+,__zero_reg__
484 0184 8A95 dec r24
485 0186 E9F7 brne .-6
486 .stabn 68,0,504,.LM51-UIMgr_convertTokenToCmd
487 .LM51:
488 0188 1092 0000 sts charIndex,__zero_reg__
489 .stabn 68,0,505,.LM52-UIMgr_convertTokenToCmd
490 .LM52:
491 018c 1092 0000 sts charCount,__zero_reg__
492 /* epilogue: frame size=0 */
493 0190 0895 ret
494 /* epilogue end (size=1) */
495 /* function UIMgr_convertTokenToCmd size 95 (94) */
496 .size UIMgr_convertTokenToCmd, .-UIMgr_convertTokenToCmd
497 .Lscope6:
498 .stabs "",36,0,0,.Lscope6-UIMgr_convertTokenToCmd
499 .stabd 78,0,0
500 .stabs "UIMgr_init:F(0,15)",36,0,137,UIMgr_init
501 .global UIMgr_init
502 .type UIMgr_init, @function
503 UIMgr_init:
504 .stabd 46,0,0
505 .stabn 68,0,137,.LM53-UIMgr_init
506 .LM53:
507 /* prologue: frame size=0 */
508 /* prologue end (size=0) */
509 .stabn 68,0,138,.LM54-UIMgr_init
510 .LM54:
511 0192 1092 0000 sts asciiTokenBuffer,__zero_reg__
512 0196 1092 0000 sts (asciiTokenBuffer)+1,__zero_reg__
513 019a 1092 0000 sts (asciiTokenBuffer)+2,__zero_reg__
514 019e 1092 0000 sts (asciiTokenBuffer)+3,__zero_reg__
515 .stabn 68,0,139,.LM55-UIMgr_init
516 .LM55:
517 01a2 80E4 ldi r24,lo8(64)
518 01a4 E0E0 ldi r30,lo8(tokenBuffer)
519 01a6 F0E0 ldi r31,hi8(tokenBuffer)
520 01a8 982F mov r25,r24
521 01aa 1192 st Z+,__zero_reg__
522 01ac 9A95 dec r25
523 01ae E9F7 brne .-6
524 .stabn 68,0,140,.LM56-UIMgr_init
525 .LM56:
526 01b0 E0E0 ldi r30,lo8(UIMgr_txFifo)
527 01b2 F0E0 ldi r31,hi8(UIMgr_txFifo)
528 01b4 1192 st Z+,__zero_reg__
529 01b6 8A95 dec r24
530 01b8 E9F7 brne .-6
531 .stabn 68,0,141,.LM57-UIMgr_init
532 .LM57:
533 01ba 80E2 ldi r24,lo8(32)
534 01bc E0E0 ldi r30,lo8(UIMgr_rxFifo)
535 01be F0E0 ldi r31,hi8(UIMgr_rxFifo)
536 01c0 1192 st Z+,__zero_reg__
GAS LISTING /tmp/cc2L16GD.s page 22
 
 
537 01c2 8A95 dec r24
538 01c4 E9F7 brne .-6
539 /* epilogue: frame size=0 */
540 01c6 0895 ret
541 /* epilogue end (size=1) */
542 /* function UIMgr_init size 27 (26) */
543 .size UIMgr_init, .-UIMgr_init
544 .Lscope7:
545 .stabs "",36,0,0,.Lscope7-UIMgr_init
546 .stabd 78,0,0
547 .stabs "UIMgr_convertTokenToValue:f(0,15)",36,0,422,UIMgr_convertTokenToValue
548 .type UIMgr_convertTokenToValue, @function
549 UIMgr_convertTokenToValue:
550 .stabd 46,0,0
551 .stabn 68,0,422,.LM58-UIMgr_convertTokenToValue
552 .LM58:
553 /* prologue: frame size=0 */
554 /* prologue end (size=0) */
555 .stabn 68,0,425,.LM59-UIMgr_convertTokenToValue
556 .LM59:
557 01c8 80E0 ldi r24,lo8(asciiTokenBuffer)
558 01ca 90E0 ldi r25,hi8(asciiTokenBuffer)
559 01cc 00D0 rcall atoi
560 01ce 9C01 movw r18,r24
561 .stabn 68,0,426,.LM60-UIMgr_convertTokenToValue
562 .LM60:
563 01d0 8F3F cpi r24,255
564 01d2 9105 cpc r25,__zero_reg__
565 01d4 69F0 breq .L59
566 01d6 60F0 brlo .L59
567 .stabn 68,0,429,.LM61-UIMgr_convertTokenToValue
568 .LM61:
569 01d8 89E0 ldi r24,lo8(9)
570 01da 8093 0000 sts receivedCmd,r24
571 .stabn 68,0,430,.LM62-UIMgr_convertTokenToValue
572 .LM62:
573 01de 8091 0000 lds r24,tokenCount
574 01e2 E0E0 ldi r30,lo8(tokenBuffer)
575 01e4 F0E0 ldi r31,hi8(tokenBuffer)
576 01e6 E80F add r30,r24
577 01e8 F11D adc r31,__zero_reg__
578 01ea 8FEF ldi r24,lo8(-1)
579 01ec 8083 st Z,r24
580 01ee 07C0 rjmp .L61
581 .L59:
582 .stabn 68,0,435,.LM63-UIMgr_convertTokenToValue
583 .LM63:
584 01f0 8091 0000 lds r24,tokenCount
585 01f4 E0E0 ldi r30,lo8(tokenBuffer)
586 01f6 F0E0 ldi r31,hi8(tokenBuffer)
587 01f8 E80F add r30,r24
588 01fa F11D adc r31,__zero_reg__
589 01fc 2083 st Z,r18
590 .L61:
591 .stabn 68,0,437,.LM64-UIMgr_convertTokenToValue
592 .LM64:
593 01fe 83E0 ldi r24,lo8(3)
GAS LISTING /tmp/cc2L16GD.s page 23
 
 
594 0200 E0E0 ldi r30,lo8(asciiTokenBuffer)
595 0202 F0E0 ldi r31,hi8(asciiTokenBuffer)
596 0204 1192 st Z+,__zero_reg__
597 0206 8A95 dec r24
598 0208 E9F7 brne .-6
599 .stabn 68,0,438,.LM65-UIMgr_convertTokenToValue
600 .LM65:
601 020a 1092 0000 sts charIndex,__zero_reg__
602 .stabn 68,0,439,.LM66-UIMgr_convertTokenToValue
603 .LM66:
604 020e 1092 0000 sts charCount,__zero_reg__
605 /* epilogue: frame size=0 */
606 0212 0895 ret
607 /* epilogue end (size=1) */
608 /* function UIMgr_convertTokenToValue size 38 (37) */
609 .size UIMgr_convertTokenToValue, .-UIMgr_convertTokenToValue
610 .stabs "newValue:r(0,4)",64,0,423,18
611 .stabn 192,0,0,UIMgr_convertTokenToValue-UIMgr_convertTokenToValue
612 .stabn 224,0,0,.Lscope8-UIMgr_convertTokenToValue
613 .Lscope8:
614 .stabs "",36,0,0,.Lscope8-UIMgr_convertTokenToValue
615 .stabd 78,0,0
616 .stabs "UIMgr_processReceivedData:F(0,15)",36,0,193,UIMgr_processReceivedData
617 .global UIMgr_processReceivedData
618 .type UIMgr_processReceivedData, @function
619 UIMgr_processReceivedData:
620 .stabd 46,0,0
621 .stabn 68,0,193,.LM67-UIMgr_processReceivedData
622 .LM67:
623 /* prologue: frame size=0 */
624 0214 FF92 push r15
625 0216 0F93 push r16
626 0218 1F93 push r17
627 021a CF93 push r28
628 021c DF93 push r29
629 /* prologue end (size=5) */
630 021e 0F2E mov __tmp_reg__,r31
631 0220 F9E0 ldi r31,lo8(9)
632 0222 FF2E mov r15,r31
633 0224 F02D mov r31,__tmp_reg__
634 0226 FFC0 rjmp .L119
635 .L65:
636 .LBB22:
637 .LBB23:
638 .stabn 68,0,612,.LM68-UIMgr_processReceivedData
639 .LM68:
640 /* #APP */
641 0228 F894 cli
642 .stabn 68,0,613,.LM69-UIMgr_processReceivedData
643 .LM69:
644 /* #NOAPP */
645 022a E22F mov r30,r18
646 022c FF27 clr r31
647 022e E050 subi r30,lo8(-(UIMgr_rxFifo))
648 0230 F040 sbci r31,hi8(-(UIMgr_rxFifo))
649 0232 9081 ld r25,Z
650 .stabn 68,0,615,.LM70-UIMgr_processReceivedData
GAS LISTING /tmp/cc2L16GD.s page 24
 
 
651 .LM70:
652 0234 822F mov r24,r18
653 0236 8F5F subi r24,lo8(-(1))
654 0238 8F71 andi r24,lo8(31)
655 023a 8093 0000 sts UIMgr_rxFifoTail,r24
656 .stabn 68,0,616,.LM71-UIMgr_processReceivedData
657 .LM71:
658 /* #APP */
659 023e 7894 sei
660 /* #NOAPP */
661 .LBE23:
662 .LBE22:
663 .stabn 68,0,202,.LM72-UIMgr_processReceivedData
664 .LM72:
665 0240 9D30 cpi r25,lo8(13)
666 0242 09F0 breq .+2
667 0244 B1C0 rjmp .L66
668 .stabn 68,0,205,.LM73-UIMgr_processReceivedData
669 .LM73:
670 0246 8091 0000 lds r24,tokenCount
671 024a 8823 tst r24
672 024c 11F4 brne .L68
673 .stabn 68,0,208,.LM74-UIMgr_processReceivedData
674 .LM74:
675 024e 42DF rcall UIMgr_convertTokenToCmd
676 0250 06C0 rjmp .L70
677 .L68:
678 .stabn 68,0,213,.LM75-UIMgr_processReceivedData
679 .LM75:
680 0252 BADF rcall UIMgr_convertTokenToValue
681 .stabn 68,0,214,.LM76-UIMgr_processReceivedData
682 .LM76:
683 0254 8091 0000 lds r24,tokenCount
684 0258 8F5F subi r24,lo8(-(1))
685 025a 8093 0000 sts tokenCount,r24
686 .L70:
687 .stabn 68,0,218,.LM77-UIMgr_processReceivedData
688 .LM77:
689 025e 84E6 ldi r24,lo8(100)
690 0260 90E0 ldi r25,hi8(100)
691 0262 00D0 rcall Utility_delay
692 .stabn 68,0,219,.LM78-UIMgr_processReceivedData
693 .LM78:
694 0264 8091 0000 lds r24,receivedCmd
695 0268 8850 subi r24,lo8(-(-8))
696 026a 8230 cpi r24,lo8(2)
697 026c 58F4 brsh .L71
698 .LBB24:
699 .LBB25:
700 .stabn 68,0,531,.LM79-UIMgr_processReceivedData
701 .LM79:
702 026e 8EE4 ldi r24,lo8(78)
703 0270 F4DE rcall UIMgr_writeTxFifo
704 .stabn 68,0,532,.LM80-UIMgr_processReceivedData
705 .LM80:
706 0272 83E4 ldi r24,lo8(67)
707 0274 F2DE rcall UIMgr_writeTxFifo
GAS LISTING /tmp/cc2L16GD.s page 25
 
 
708 .stabn 68,0,533,.LM81-UIMgr_processReceivedData
709 .LM81:
710 0276 8BE4 ldi r24,lo8(75)
711 0278 F0DE rcall UIMgr_writeTxFifo
712 .stabn 68,0,534,.LM82-UIMgr_processReceivedData
713 .LM82:
714 027a 8DE0 ldi r24,lo8(13)
715 027c EEDE rcall UIMgr_writeTxFifo
716 .LBE25:
717 .LBE24:
718 .stabn 68,0,223,.LM83-UIMgr_processReceivedData
719 .LM83:
720 027e 80E9 ldi r24,lo8(-112)
721 0280 00D0 rcall Exec_writeEventFifo
722 0282 89C0 rjmp .L73
723 .L71:
724 .LBB26:
725 .LBB27:
726 .stabn 68,0,516,.LM84-UIMgr_processReceivedData
727 .LM84:
728 0284 81E4 ldi r24,lo8(65)
729 0286 E9DE rcall UIMgr_writeTxFifo
730 .stabn 68,0,517,.LM85-UIMgr_processReceivedData
731 .LM85:
732 0288 83E4 ldi r24,lo8(67)
733 028a E7DE rcall UIMgr_writeTxFifo
734 .stabn 68,0,518,.LM86-UIMgr_processReceivedData
735 .LM86:
736 028c 8BE4 ldi r24,lo8(75)
737 028e E5DE rcall UIMgr_writeTxFifo
738 .stabn 68,0,519,.LM87-UIMgr_processReceivedData
739 .LM87:
740 0290 8DE0 ldi r24,lo8(13)
741 0292 E3DE rcall UIMgr_writeTxFifo
742 .LBE27:
743 .LBE26:
744 .stabn 68,0,230,.LM88-UIMgr_processReceivedData
745 .LM88:
746 0294 80E9 ldi r24,lo8(-112)
747 0296 00D0 rcall Exec_writeEventFifo
748 .LBB28:
749 .LBB29:
750 .stabn 68,0,316,.LM89-UIMgr_processReceivedData
751 .LM89:
752 0298 8091 0000 lds r24,receivedCmd
753 029c 8130 cpi r24,lo8(1)
754 029e 09F4 brne .+2
755 02a0 7AC0 rjmp .L73
756 .stabn 68,0,319,.LM90-UIMgr_processReceivedData
757 .LM90:
758 02a2 8823 tst r24
759 02a4 71F4 brne .L75
760 .stabn 68,0,322,.LM91-UIMgr_processReceivedData
761 .LM91:
762 02a6 8091 0000 lds r24,AVRcamVersion
763 02aa 8823 tst r24
764 02ac 09F4 brne .+2
GAS LISTING /tmp/cc2L16GD.s page 26
 
 
765 02ae 73C0 rjmp .L73
766 02b0 C0E0 ldi r28,lo8(AVRcamVersion)
767 02b2 D0E0 ldi r29,hi8(AVRcamVersion)
768 .L78:
769 .stabn 68,0,324,.LM92-UIMgr_processReceivedData
770 .LM92:
771 02b4 2196 adiw r28,1
772 02b6 D1DE rcall UIMgr_writeTxFifo
773 .stabn 68,0,322,.LM93-UIMgr_processReceivedData
774 .LM93:
775 02b8 8881 ld r24,Y
776 02ba 8823 tst r24
777 02bc 09F4 brne .+2
778 02be 6BC0 rjmp .L73
779 02c0 F9CF rjmp .L78
780 .L75:
781 .stabn 68,0,327,.LM94-UIMgr_processReceivedData
782 .LM94:
783 02c2 8730 cpi r24,lo8(7)
784 02c4 11F4 brne .L79
785 .stabn 68,0,329,.LM95-UIMgr_processReceivedData
786 .LM95:
787 02c6 00D0 rcall CamInt_resetCam
788 02c8 66C0 rjmp .L73
789 .L79:
790 .stabn 68,0,331,.LM96-UIMgr_processReceivedData
791 .LM96:
792 02ca 8330 cpi r24,lo8(3)
793 02cc 31F4 brne .L81
794 .stabn 68,0,340,.LM97-UIMgr_processReceivedData
795 .LM97:
796 02ce 84E6 ldi r24,lo8(100)
797 02d0 90E0 ldi r25,hi8(100)
798 02d2 00D0 rcall Utility_delay
799 .stabn 68,0,341,.LM98-UIMgr_processReceivedData
800 .LM98:
801 02d4 82E0 ldi r24,lo8(2)
802 02d6 00D0 rcall Exec_writeEventFifo
803 02d8 5EC0 rjmp .L73
804 .L81:
805 .stabn 68,0,343,.LM99-UIMgr_processReceivedData
806 .LM99:
807 02da 8230 cpi r24,lo8(2)
808 02dc 99F4 brne .L83
809 .stabn 68,0,347,.LM100-UIMgr_processReceivedData
810 .LM100:
811 02de 8091 0000 lds r24,tokenCount
812 02e2 8230 cpi r24,lo8(2)
813 02e4 68F0 brlo .L85
814 02e6 11E0 ldi r17,lo8(1)
815 .L87:
816 .stabn 68,0,350,.LM101-UIMgr_processReceivedData
817 .LM101:
818 02e8 E12F mov r30,r17
819 02ea FF27 clr r31
820 02ec E050 subi r30,lo8(-(tokenBuffer))
821 02ee F040 sbci r31,hi8(-(tokenBuffer))
GAS LISTING /tmp/cc2L16GD.s page 27
 
 
822 02f0 6181 ldd r22,Z+1
823 02f2 8081 ld r24,Z
824 02f4 00D0 rcall CamConfig_setCamReg
825 .stabn 68,0,347,.LM102-UIMgr_processReceivedData
826 .LM102:
827 02f6 1E5F subi r17,lo8(-(2))
828 02f8 8091 0000 lds r24,tokenCount
829 02fc 1817 cp r17,r24
830 02fe A0F3 brlo .L87
831 .L85:
832 .stabn 68,0,352,.LM103-UIMgr_processReceivedData
833 .LM103:
834 0300 00D0 rcall CamConfig_sendFifoCmds
835 0302 49C0 rjmp .L73
836 .L83:
837 .stabn 68,0,354,.LM104-UIMgr_processReceivedData
838 .LM104:
839 0304 8430 cpi r24,lo8(4)
840 0306 31F4 brne .L88
841 .stabn 68,0,357,.LM105-UIMgr_processReceivedData
842 .LM105:
843 0308 84E6 ldi r24,lo8(100)
844 030a 90E0 ldi r25,hi8(100)
845 030c 00D0 rcall Utility_delay
846 .stabn 68,0,358,.LM106-UIMgr_processReceivedData
847 .LM106:
848 030e 80E8 ldi r24,lo8(-128)
849 0310 00D0 rcall Exec_writeEventFifo
850 0312 41C0 rjmp .L73
851 .L88:
852 .stabn 68,0,360,.LM107-UIMgr_processReceivedData
853 .LM107:
854 0314 8530 cpi r24,lo8(5)
855 0316 19F4 brne .L90
856 .stabn 68,0,362,.LM108-UIMgr_processReceivedData
857 .LM108:
858 0318 81E8 ldi r24,lo8(-127)
859 031a 00D0 rcall Exec_writeEventFifo
860 031c 3CC0 rjmp .L73
861 .L90:
862 .stabn 68,0,364,.LM109-UIMgr_processReceivedData
863 .LM109:
864 031e 8630 cpi r24,lo8(6)
865 0320 09F0 breq .+2
866 0322 39C0 rjmp .L73
867 .stabn 68,0,367,.LM110-UIMgr_processReceivedData
868 .LM110:
869 0324 8091 0000 lds r24,tokenCount
870 0328 8823 tst r24
871 032a 09F4 brne .+2
872 032c 34C0 rjmp .L73
873 032e 40E0 ldi r20,lo8(0)
874 0330 00E0 ldi r16,lo8(tokenBuffer)
875 0332 10E0 ldi r17,hi8(tokenBuffer)
876 0334 60E0 ldi r22,lo8(colorMap)
877 0336 70E0 ldi r23,hi8(colorMap)
878 .L94:
GAS LISTING /tmp/cc2L16GD.s page 28
 
 
879 .stabn 68,0,369,.LM111-UIMgr_processReceivedData
880 .LM111:
881 0338 842F mov r24,r20
882 033a 9927 clr r25
883 033c 9C01 movw r18,r24
884 033e 2F5F subi r18,lo8(-(1))
885 0340 3F4F sbci r19,hi8(-(1))
886 0342 F901 movw r30,r18
887 0344 E00F add r30,r16
888 0346 F11F adc r31,r17
889 0348 E081 ld r30,Z
890 034a EC01 movw r28,r24
891 034c C60F add r28,r22
892 034e D71F adc r29,r23
893 0350 E883 st Y,r30
894 .LBB30:
895 .LBB31:
896 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h",132,0,0,.Ltext1
897 .Ltext1:
1:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /* Copyright (c) 2002, 2003, 2004 Marek Michalkiewicz
2:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Copyright (c) 2005, 2006 Bjoern Haase
3:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** All rights reserved.
4:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
5:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Redistribution and use in source and binary forms, with or without
6:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** modification, are permitted provided that the following conditions are met:
7:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
8:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** * Redistributions of source code must retain the above copyright
9:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** notice, this list of conditions and the following disclaimer.
10:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
11:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** * Redistributions in binary form must reproduce the above copyright
12:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** notice, this list of conditions and the following disclaimer in
13:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** the documentation and/or other materials provided with the
14:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** distribution.
15:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
16:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** * Neither the name of the copyright holders nor the names of
17:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** contributors may be used to endorse or promote products derived
18:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** from this software without specific prior written permission.
19:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
20:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** POSSIBILITY OF SUCH DAMAGE. */
31:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
32:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /* $Id: eeprom.h,v 1.17.2.1 2006/02/26 21:51:04 aesok Exp $ */
33:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
34:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /*
35:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom.h
36:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
37:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Contributors:
38:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Created by Marek Michalkiewicz <marekm@linux.org.pl>
GAS LISTING /tmp/cc2L16GD.s page 29
 
 
39:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_write_word and eeprom_write_block added by Artur Lipowski
40:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** <LAL@pro.onet.pl>
41:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Complete rewrite using the original interface by Bjoern Haase
42:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** <bjoern.haase@de.bosch.com>.
43:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** */
44:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
45:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #ifndef _EEPROM_H_
46:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define _EEPROM_H_ 1
47:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
48:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define __need_size_t
49:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #include <stddef.h>
50:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #include <inttypes.h>
51:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
52:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
53:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #ifdef __AVR_MEGA__
54:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define XCALL "call"
55:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #else
56:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define XCALL "rcall"
57:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #endif
58:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
59:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #include <avr/io.h>
60:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #ifndef __EEPROM_REG_LOCATIONS__
61:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \def __EEPROM_REG_LOCATIONS__
62:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \ingroup avr_eeprom
63:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** In order to be able to work without a requiring a multilib
64:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** approach for dealing with controllers having the EEPROM registers
65:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** at different positions in memory space, the eeprom functions evaluate
66:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** __EEPROM_REG_LOCATIONS__: It is assumed to be defined by
67:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** the device io header and contains 6 uppercase hex digits encoding the
68:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** addresses of EECR,EEDR and EEAR.
69:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** First two letters: EECR address.
70:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Second two letters: EEDR address.
71:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Last two letters: EEAR address.
72:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** The default 1C1D1E corresponds to the
73:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** register location that is valid for most controllers. The value
74:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** of this define symbol is used for appending it to the base name of the
75:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** assembler functions. */
76:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define __EEPROM_REG_LOCATIONS__ 1C1D1E
77:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #endif
78:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define _STR2(EXP) _STR1(EXP)
79:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define _STR1(EXP) #EXP
80:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define _REG_LOCATION_SUFFIX _STR2(__EEPROM_REG_LOCATIONS__)
81:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
82:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #ifndef CR_TAB
83:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define CR_TAB "\n\t"
84:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #endif
85:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
86:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
87:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \defgroup avr_eeprom <avr/eeprom.h>: EEPROM handling
88:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \code #include <avr/eeprom.h> \endcode
89:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
90:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** This header file declares the interface to some simple library
91:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** routines suitable for handling the data EEPROM contained in the
92:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** AVR microcontrollers. The implementation uses a simple polled
93:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** mode interface. Applications that require interrupt-controlled
94:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** EEPROM access to ensure that no time will be wasted in spinloops
95:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** will have to deploy their own implementation.
GAS LISTING /tmp/cc2L16GD.s page 30
 
 
96:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
97:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \note All of the read/write functions first make sure the EEPROM
98:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** is ready to be accessed. Since this may cause long delays if a
99:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** write operation is still pending, time-critical applications
100:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** should first poll the EEPROM e. g. using eeprom_is_ready() before
101:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** attempting any actual I/O.
102:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
103:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \note This header file declares inline functions that call the
104:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** assembler subroutines directly. This prevents that the compiler
105:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** generates push/pops for the call-clobbered registers. This way
106:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** also a specific calling convention could be used for the eeprom
107:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** routines e.g. by passing values in __tmp_reg__, eeprom addresses in
108:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** X and memory addresses in Z registers. Method is optimized for code
109:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** size.
110:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
111:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \note Presently supported are two locations of the EEPROM register
112:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** set: 0x1F,0x20,0x21 and 0x1C,0x1D,0x1E
113:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** (see ::__EEPROM_REG_LOCATIONS__).
114:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
115:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \note As these functions modify IO registers, they are known to be
116:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** non-reentrant. If any of these functions are used from both,
117:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** standard and interrupt context, the applications must ensure
118:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** proper protection (e.g. by disabling interrupts before accessing
119:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** them).
120:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
121:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** */
122:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
123:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
124:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /* forward declarations of the inline functions so that doxygen does
125:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** not get confused by the attribute expression. */
126:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
127:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** static inline uint8_t __attribute__ ((always_inline))
128:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_read_byte (const uint8_t *addr);
129:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
130:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** static inline uint16_t __attribute__ ((always_inline))
131:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_read_word (const uint16_t *addr);
132:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
133:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** static inline void __attribute__ ((always_inline))
134:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_read_block (void *pointer_ram,
135:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** const void *pointer_eeprom,
136:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** size_t size);
137:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
138:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** static inline void __attribute__ ((always_inline))
139:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_write_byte (uint8_t *addr,uint8_t value);
140:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
141:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** static inline void __attribute__ ((always_inline))
142:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_write_word (uint16_t *addr,uint16_t value);
143:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
144:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** static inline void __attribute__ ((always_inline))
145:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_write_block (const void *pointer_ram,
146:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** void *pointer_eeprom,
147:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** size_t size);
148:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
149:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \name avr-libc declarations */
150:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
151:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /*@{*/
152:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
GAS LISTING /tmp/cc2L16GD.s page 31
 
 
153:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \def EEMEM
154:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \ingroup avr_eeprom
155:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Attribute expression causing a variable to be allocated within the .eeprom
156:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** section. */
157:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define EEMEM __attribute__((section(".eeprom")))
158:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
159:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \def eeprom_is_ready
160:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \ingroup avr_eeprom
161:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \returns 1 if EEPROM is ready for a new read/write operation, 0 if not. */
162:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
163:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #if defined(__DOXYGEN__)
164:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** # define eeprom_is_ready()
165:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #elif defined(EEWE)
166:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** # define eeprom_is_ready() bit_is_clear(EECR, EEWE)
167:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #elif defined(EEPE)
168:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** # define eeprom_is_ready() bit_is_clear(EECR, EEPE)
169:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #elif defined(DEECR) && defined(EEL)
170:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** # define eeprom_is_ready() bit_is_clear(DEECR, EEL)
171:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #else
172:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** # error "No write enable bit known for this device's EEPROM."
173:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #endif
174:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
175:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \def eeprom_busy_wait
176:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \ingroup avr_eeprom
177:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
178:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Loops until the eeprom is no longer busy.
179:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
180:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \returns Nothing. */
181:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
182:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** #define eeprom_busy_wait() do {} while (!eeprom_is_ready())
183:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
184:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
185:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \ingroup avr_eeprom
186:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Read one byte from EEPROM address \c addr. */
187:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
188:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** uint8_t
189:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_read_byte (const uint8_t *addr)
190:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
191:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** uint8_t result;
192:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** asm volatile
898 .stabn 68,0,192,.LM112-UIMgr_processReceivedData
899 .LM112:
900 0352 D901 movw r26,r18
901 /* #APP */
902 0354 00D0 rcall __eeprom_read_byte_1C1D1E
903 0356 802D mov r24,__tmp_reg__
904 /* #NOAPP */
905 .LBE31:
906 .LBE30:
907 .stabs "UIMgr.c",132,0,0,.Ltext2
908 .Ltext2:
909 .stabn 68,0,374,.LM113-UIMgr_processReceivedData
910 .LM113:
911 0358 E817 cp r30,r24
912 035a C1F0 breq .L95
913 .LBB32:
914 .LBB33:
GAS LISTING /tmp/cc2L16GD.s page 32
 
 
915 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h",132,0,0,.Ltext3
916 .Ltext3:
193:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** ( XCALL " __eeprom_read_byte_" _REG_LOCATION_SUFFIX CR_TAB
194:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "mov %1,__tmp_reg__"
195:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "+x" (addr),
196:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "=r" (result)
197:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : );
198:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** return result;
199:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** }
200:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
201:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \ingroup avr_eeprom
202:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Read one 16-bit word (little endian) from EEPROM address \c addr. */
203:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** uint16_t
204:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_read_word (const uint16_t *addr)
205:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
206:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** uint16_t result;
207:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
208:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** asm (
209:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** XCALL " __eeprom_read_word_" _REG_LOCATION_SUFFIX CR_TAB
210:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "+x" (addr),
211:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "=z" (result)
212:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : );
213:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** return result;
214:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** }
215:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
216:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \ingroup avr_eeprom
217:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Read a block of \c n bytes from EEPROM address \c pointer_eeprom to
218:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** \c pointer_ram. For constant n <= 256 bytes a library function is used.
219:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** For block sizes unknown at compile time or block sizes > 256 an inline
220:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** loop is expanded. */
221:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
222:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** void
223:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_read_block (void *pointer_ram,
224:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** const void *pointer_eeprom,
225:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** size_t n)
226:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
227:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** if (!__builtin_constant_p (n)
228:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** || n > 256)
229:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
230:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /* make sure size is a 16 bit variable. */
231:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** uint16_t size = n;
232:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
233:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** asm volatile (
234:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** ".%=_start:" CR_TAB
235:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "sbiw %2,1" CR_TAB
236:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "brlt .%=_finished" CR_TAB
237:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** XCALL " __eeprom_read_byte_" _REG_LOCATION_SUFFIX CR_TAB
238:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "st z+,__tmp_reg__" CR_TAB
239:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "rjmp .%=_start" CR_TAB
240:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** ".%=_finished:"
241:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "=x" (pointer_eeprom),
242:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "=z" (pointer_ram),
243:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "+w" (size)
244:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "x" (pointer_eeprom),
245:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "z" (pointer_ram)
246:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "memory");
247:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** }
GAS LISTING /tmp/cc2L16GD.s page 33
 
 
248:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** else
249:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
250:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** if (n != 0)
251:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
252:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** if (n == 256)
253:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
254:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** asm volatile (
255:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** XCALL " __eeprom_read_block_" _REG_LOCATION_SUFFIX
256:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "+x" (pointer_eeprom),
257:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "=z" (pointer_ram)
258:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "z" (pointer_ram)
259:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "memory");
260:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** }
261:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** else
262:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
263:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /* Needed in order to truncate to 8 bit. */
264:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** uint8_t len;
265:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** len = (uint8_t) n;
266:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
267:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** asm volatile (
268:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "mov __zero_reg__,%2" CR_TAB
269:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** XCALL " __eeprom_read_block_" _REG_LOCATION_SUFFIX
270:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "+x" (pointer_eeprom),
271:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "=z" (pointer_ram)
272:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "r" (len),
273:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** "z" (pointer_ram)
274:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** : "memory");
275:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** }
276:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** }
277:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** }
278:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** }
279:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
280:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** /** \ingroup avr_eeprom
281:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** Write a byte \c value to EEPROM address \c addr. */
282:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h ****
283:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** void
284:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** eeprom_write_byte (uint8_t *addr,uint8_t value)
285:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** {
286:/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h **** asm volatile (
917 .stabn 68,0,286,.LM114-UIMgr_processReceivedData
918 .LM114:
919 035c D901 movw r26,r18
920 /* #APP */
921 035e 0E2E mov __tmp_reg__,r30
922 0360 00D0 rcall __eeprom_write_byte_1C1D1E
923 /* #NOAPP */
924 .LBE33:
925 .LBE32:
926 .LBB34:
927 .LBB35:
928 .stabn 68,0,192,.LM115-UIMgr_processReceivedData
929 .LM115:
930 0362 D901 movw r26,r18
931 /* #APP */
932 0364 00D0 rcall __eeprom_read_byte_1C1D1E
933 0366 802D mov r24,__tmp_reg__
934 /* #NOAPP */
GAS LISTING /tmp/cc2L16GD.s page 34
 
 
935 .LBE35:
936 .LBE34:
937 .stabs "UIMgr.c",132,0,0,.Ltext4
938 .Ltext4:
939 .stabn 68,0,384,.LM116-UIMgr_processReceivedData
940 .LM116:
941 0368 9881 ld r25,Y
942 036a 9817 cp r25,r24
943 036c 79F0 breq .L95
944 .LBB36:
945 .LBB37:
946 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h",132,0,0,.Ltext5
947 .Ltext5:
948 .stabn 68,0,286,.LM117-UIMgr_processReceivedData
949 .LM117:
950 036e D901 movw r26,r18
951 /* #APP */
952 0370 092E mov __tmp_reg__,r25
953 0372 00D0 rcall __eeprom_write_byte_1C1D1E
954 /* #NOAPP */
955 .LBE37:
956 .LBE36:
957 .LBB38:
958 .LBB39:
959 .stabn 68,0,192,.LM118-UIMgr_processReceivedData
960 .LM118:
961 0374 D901 movw r26,r18
962 /* #APP */
963 0376 00D0 rcall __eeprom_read_byte_1C1D1E
964 0378 802D mov r24,__tmp_reg__
965 /* #NOAPP */
966 .LBE39:
967 .LBE38:
968 .stabs "UIMgr.c",132,0,0,.Ltext6
969 .Ltext6:
970 .stabn 68,0,384,.LM119-UIMgr_processReceivedData
971 .LM119:
972 037a 9881 ld r25,Y
973 037c 9817 cp r25,r24
974 037e 31F0 breq .L95
975 .LBB40:
976 .LBB41:
977 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/eeprom.h",132,0,0,.Ltext7
978 .Ltext7:
979 .stabn 68,0,286,.LM120-UIMgr_processReceivedData
980 .LM120:
981 0380 D901 movw r26,r18
982 /* #APP */
983 0382 092E mov __tmp_reg__,r25
984 0384 00D0 rcall __eeprom_write_byte_1C1D1E
985 /* #NOAPP */
986 .LBE41:
987 .LBE40:
988 .LBB42:
989 .LBB43:
990 .stabn 68,0,192,.LM121-UIMgr_processReceivedData
991 .LM121:
GAS LISTING /tmp/cc2L16GD.s page 35
 
 
992 0386 D901 movw r26,r18
993 /* #APP */
994 0388 00D0 rcall __eeprom_read_byte_1C1D1E
995 038a 802D mov r24,__tmp_reg__
996 /* #NOAPP */
997 .L95:
998 .LBE43:
999 .LBE42:
1000 .stabs "UIMgr.c",132,0,0,.Ltext8
1001 .Ltext8:
1002 .stabn 68,0,367,.LM122-UIMgr_processReceivedData
1003 .LM122:
1004 038c 4F5F subi r20,lo8(-(1))
1005 038e 8091 0000 lds r24,tokenCount
1006 0392 4817 cp r20,r24
1007 0394 88F2 brlo .L94
1008 .L73:
1009 .LBE29:
1010 .LBE28:
1011 .stabn 68,0,235,.LM123-UIMgr_processReceivedData
1012 .LM123:
1013 0396 1092 0000 sts tokenCount,__zero_reg__
1014 .stabn 68,0,236,.LM124-UIMgr_processReceivedData
1015 .LM124:
1016 039a 80E4 ldi r24,lo8(64)
1017 039c E0E0 ldi r30,lo8(tokenBuffer)
1018 039e F0E0 ldi r31,hi8(tokenBuffer)
1019 03a0 1192 st Z+,__zero_reg__
1020 03a2 8A95 dec r24
1021 03a4 E9F7 brne .-6
1022 03a6 3FC0 rjmp .L119
1023 .L66:
1024 .stabn 68,0,238,.LM125-UIMgr_processReceivedData
1025 .LM125:
1026 03a8 9032 cpi r25,lo8(32)
1027 03aa F1F4 brne .L99
1028 .stabn 68,0,241,.LM126-UIMgr_processReceivedData
1029 .LM126:
1030 03ac 8091 0000 lds r24,tokenCount
1031 03b0 8823 tst r24
1032 03b2 39F4 brne .L101
1033 .stabn 68,0,243,.LM127-UIMgr_processReceivedData
1034 .LM127:
1035 03b4 8FDE rcall UIMgr_convertTokenToCmd
1036 .stabn 68,0,244,.LM128-UIMgr_processReceivedData
1037 .LM128:
1038 03b6 8091 0000 lds r24,tokenCount
1039 03ba 8F5F subi r24,lo8(-(1))
1040 03bc 8093 0000 sts tokenCount,r24
1041 03c0 32C0 rjmp .L119
1042 .L101:
1043 .stabn 68,0,254,.LM129-UIMgr_processReceivedData
1044 .LM129:
1045 03c2 9927 clr r25
1046 03c4 CF97 sbiw r24,63
1047 03c6 4CF0 brlt .L103
1048 .stabn 68,0,259,.LM130-UIMgr_processReceivedData
GAS LISTING /tmp/cc2L16GD.s page 36
 
 
1049 .LM130:
1050 03c8 1092 0000 sts charCount,__zero_reg__
1051 .stabn 68,0,260,.LM131-UIMgr_processReceivedData
1052 .LM131:
1053 03cc 1092 0000 sts charIndex,__zero_reg__
1054 .stabn 68,0,261,.LM132-UIMgr_processReceivedData
1055 .LM132:
1056 03d0 1092 0000 sts tokenCount,__zero_reg__
1057 .stabn 68,0,262,.LM133-UIMgr_processReceivedData
1058 .LM133:
1059 03d4 F092 0000 sts receivedCmd,r15
1060 03d8 26C0 rjmp .L119
1061 .L103:
1062 .stabn 68,0,267,.LM134-UIMgr_processReceivedData
1063 .LM134:
1064 03da F6DE rcall UIMgr_convertTokenToValue
1065 .stabn 68,0,268,.LM135-UIMgr_processReceivedData
1066 .LM135:
1067 03dc 8091 0000 lds r24,tokenCount
1068 03e0 8F5F subi r24,lo8(-(1))
1069 03e2 8093 0000 sts tokenCount,r24
1070 03e6 1FC0 rjmp .L119
1071 .L99:
1072 .stabn 68,0,272,.LM136-UIMgr_processReceivedData
1073 .LM136:
1074 03e8 892F mov r24,r25
1075 03ea 8154 subi r24,lo8(-(-65))
1076 03ec 8A31 cpi r24,lo8(26)
1077 03ee 18F0 brlo .L105
1078 03f0 8F5E subi r24,lo8(-(17))
1079 03f2 8A30 cpi r24,lo8(10)
1080 03f4 B0F4 brsh .L107
1081 .L105:
1082 .stabn 68,0,276,.LM137-UIMgr_processReceivedData
1083 .LM137:
1084 03f6 8091 0000 lds r24,charIndex
1085 03fa E82F mov r30,r24
1086 03fc FF27 clr r31
1087 03fe E050 subi r30,lo8(-(asciiTokenBuffer))
1088 0400 F040 sbci r31,hi8(-(asciiTokenBuffer))
1089 0402 9083 st Z,r25
1090 .stabn 68,0,277,.LM138-UIMgr_processReceivedData
1091 .LM138:
1092 0404 9091 0000 lds r25,charCount
1093 0408 9F5F subi r25,lo8(-(1))
1094 040a 9093 0000 sts charCount,r25
1095 .stabn 68,0,278,.LM139-UIMgr_processReceivedData
1096 .LM139:
1097 040e 8F5F subi r24,lo8(-(1))
1098 0410 8093 0000 sts charIndex,r24
1099 .stabn 68,0,279,.LM140-UIMgr_processReceivedData
1100 .LM140:
1101 0414 9430 cpi r25,lo8(4)
1102 0416 38F0 brlo .L119
1103 .stabn 68,0,284,.LM141-UIMgr_processReceivedData
1104 .LM141:
1105 0418 F092 0000 sts receivedCmd,r15
GAS LISTING /tmp/cc2L16GD.s page 37
 
 
1106 .stabn 68,0,285,.LM142-UIMgr_processReceivedData
1107 .LM142:
1108 041c 1092 0000 sts charIndex,__zero_reg__
1109 0420 02C0 rjmp .L119
1110 .L107:
1111 .stabn 68,0,291,.LM143-UIMgr_processReceivedData
1112 .LM143:
1113 0422 F092 0000 sts receivedCmd,r15
1114 .L119:
1115 .stabn 68,0,199,.LM144-UIMgr_processReceivedData
1116 .LM144:
1117 0426 2091 0000 lds r18,UIMgr_rxFifoTail
1118 042a 8091 0000 lds r24,UIMgr_rxFifoHead
1119 042e 8217 cp r24,r18
1120 0430 09F0 breq .+2
1121 0432 FACE rjmp .L65
1122 .stabn 68,0,295,.LM145-UIMgr_processReceivedData
1123 .LM145:
1124 /* #APP */
1125 0434 E894 clt
1126 /* #NOAPP */
1127 /* epilogue: frame size=0 */
1128 0436 DF91 pop r29
1129 0438 CF91 pop r28
1130 043a 1F91 pop r17
1131 043c 0F91 pop r16
1132 043e FF90 pop r15
1133 0440 0895 ret
1134 /* epilogue end (size=6) */
1135 /* function UIMgr_processReceivedData size 297 (286) */
1136 .size UIMgr_processReceivedData, .-UIMgr_processReceivedData
1137 .stabs "tmpData:r(0,11)",64,0,194,25
1138 .stabn 192,0,0,UIMgr_processReceivedData-UIMgr_processReceivedData
1139 .stabs "dataByte:r(0,11)",64,0,609,25
1140 .stabn 192,0,0,.LBB23-UIMgr_processReceivedData
1141 .stabn 224,0,0,.LBE23-UIMgr_processReceivedData
1142 .stabn 224,0,0,.Lscope9-UIMgr_processReceivedData
1143 .Lscope9:
1144 .stabs "",36,0,0,.Lscope9-UIMgr_processReceivedData
1145 .stabd 78,0,0
1146 .stabs "UIMgr_dispatchEvent:F(0,15)",36,0,152,UIMgr_dispatchEvent
1147 .stabs "event:P(0,11)",64,0,151,24
1148 .global UIMgr_dispatchEvent
1149 .type UIMgr_dispatchEvent, @function
1150 UIMgr_dispatchEvent:
1151 .stabd 46,0,0
1152 .stabn 68,0,152,.LM146-UIMgr_dispatchEvent
1153 .LM146:
1154 /* prologue: frame size=0 */
1155 /* prologue end (size=0) */
1156 .stabn 68,0,153,.LM147-UIMgr_dispatchEvent
1157 .LM147:
1158 0442 8031 cpi r24,lo8(16)
1159 0444 29F0 breq .L123
1160 .stabn 68,0,153,.LM148-UIMgr_dispatchEvent
1161 .LM148:
1162 0446 8039 cpi r24,lo8(-112)
GAS LISTING /tmp/cc2L16GD.s page 38
 
 
1163 0448 39F0 breq .L124
1164 044a 8130 cpi r24,lo8(1)
1165 044c 31F4 brne .L125
1166 044e 02C0 rjmp .L122
1167 .L123:
1168 .stabn 68,0,156,.LM149-UIMgr_dispatchEvent
1169 .LM149:
1170 0450 38DE rcall UIMgr_transmitPendingData
1171 0452 0895 ret
1172 .L122:
1173 .stabn 68,0,160,.LM150-UIMgr_dispatchEvent
1174 .LM150:
1175 0454 DFDE rcall UIMgr_processReceivedData
1176 0456 0895 ret
1177 .L124:
1178 .stabn 68,0,164,.LM151-UIMgr_dispatchEvent
1179 .LM151:
1180 0458 0EDE rcall UIMgr_flushTxBuffer
1181 .L125:
1182 045a 0895 ret
1183 /* epilogue: frame size=0 */
1184 /* epilogue: noreturn */
1185 /* epilogue end (size=0) */
1186 /* function UIMgr_dispatchEvent size 13 (13) */
1187 .size UIMgr_dispatchEvent, .-UIMgr_dispatchEvent
1188 .Lscope10:
1189 .stabs "",36,0,0,.Lscope10-UIMgr_dispatchEvent
1190 .stabd 78,0,0
1191 .global UIMgr_rxFifoHead
1192 .global UIMgr_rxFifoHead
1193 .section .bss
1194 .type UIMgr_rxFifoHead, @object
1195 .size UIMgr_rxFifoHead, 1
1196 UIMgr_rxFifoHead:
1197 0000 00 .skip 1,0
1198 .global UIMgr_rxFifoTail
1199 .global UIMgr_rxFifoTail
1200 .type UIMgr_rxFifoTail, @object
1201 .size UIMgr_rxFifoTail, 1
1202 UIMgr_rxFifoTail:
1203 0001 00 .skip 1,0
1204 .global UIMgr_txFifoHead
1205 .global UIMgr_txFifoHead
1206 .type UIMgr_txFifoHead, @object
1207 .size UIMgr_txFifoHead, 1
1208 UIMgr_txFifoHead:
1209 0002 00 .skip 1,0
1210 .global UIMgr_txFifoTail
1211 .global UIMgr_txFifoTail
1212 .type UIMgr_txFifoTail, @object
1213 .size UIMgr_txFifoTail, 1
1214 UIMgr_txFifoTail:
1215 0003 00 .skip 1,0
1216 .lcomm tokenCount,1
1217 .data
1218 .type receivedCmd, @object
1219 .size receivedCmd, 1
GAS LISTING /tmp/cc2L16GD.s page 39
 
 
1220 receivedCmd:
1221 0000 08 .byte 8
1222 .lcomm charCount,1
1223 .lcomm charIndex,1
1224 .type AVRcamVersion, @object
1225 .size AVRcamVersion, 13
1226 AVRcamVersion:
1227 0001 4156 5263 .string "AVRcam v1.4\r"
1227 616D 2076
1227 312E 340D
1227 00
1228 .lcomm asciiTokenBuffer,4
1229 .lcomm tokenBuffer,64
1230 .comm UIMgr_rxFifo,32,1
1231 .comm UIMgr_txFifo,64,1
1232 .stabs "charCount:S(0,11)",38,0,92,charCount
1233 .stabs "charIndex:S(0,11)",38,0,93,charIndex
1234 .stabs "asciiTokenBuffer:S(0,21)=ar(0,22)=r(0,22);0;0177777;;0;3;(0,11)",40,0,94,asciiTokenBuffer
1235 .stabs "tokenCount:S(0,11)",38,0,95,tokenCount
1236 .stabs "tokenBuffer:S(0,23)=ar(0,22);0;63;(0,11)",40,0,96,tokenBuffer
1237 .stabs "receivedCmd:S(0,17)",38,0,97,receivedCmd
1238 .stabs "AVRcamVersion:S(0,24)=ar(0,22);0;12;(0,11)",38,0,98,AVRcamVersion
1239 .stabs "UIMgr_rxFifo:G(0,25)=ar(0,22);0;31;(0,11)",32,0,111,0
1240 .stabs "UIMgr_rxFifoHead:G(0,11)",32,0,112,0
1241 .stabs "UIMgr_rxFifoTail:G(0,11)",32,0,113,0
1242 .stabs "UIMgr_txFifo:G(0,23)",32,0,115,0
1243 .stabs "UIMgr_txFifoHead:G(0,11)",32,0,116,0
1244 .stabs "UIMgr_txFifoTail:G(0,11)",32,0,117,0
1245 .text
1246 .stabs "",100,0,0,.Letext0
1247 .Letext0:
1248 /* File "UIMgr.c": code 582 = 0x0246 ( 557), prologues 9, epilogues 16 */
GAS LISTING /tmp/cc2L16GD.s page 40
 
 
DEFINED SYMBOLS
*ABS*:00000000 UIMgr.c
/tmp/cc2L16GD.s:3 *ABS*:0000003f __SREG__
/tmp/cc2L16GD.s:4 *ABS*:0000003e __SP_H__
/tmp/cc2L16GD.s:5 *ABS*:0000003d __SP_L__
/tmp/cc2L16GD.s:6 *ABS*:00000000 __tmp_reg__
/tmp/cc2L16GD.s:7 *ABS*:00000001 __zero_reg__
/tmp/cc2L16GD.s:94 .text:00000000 UIMgr_writeBufferToTxFifo
*COM*:00000040 UIMgr_txFifo
/tmp/cc2L16GD.s:1208 .bss:00000002 UIMgr_txFifoHead
/tmp/cc2L16GD.s:159 .text:0000003c UIMgr_readTxFifo
/tmp/cc2L16GD.s:1214 .bss:00000003 UIMgr_txFifoTail
/tmp/cc2L16GD.s:206 .text:0000005a UIMgr_writeTxFifo
/tmp/cc2L16GD.s:246 .text:00000076 UIMgr_flushTxBuffer
/tmp/cc2L16GD.s:284 .text:00000094 UIMgr_txBuffer
/tmp/cc2L16GD.s:333 .text:000000c2 UIMgr_transmitPendingData
/tmp/cc2L16GD.s:361 .text:000000d4 UIMgr_convertTokenToCmd
/tmp/cc2L16GD.s:1223 .bss:00000007 asciiTokenBuffer
/tmp/cc2L16GD.s:1220 .data:00000000 receivedCmd
/tmp/cc2L16GD.s:1222 .bss:00000006 charIndex
/tmp/cc2L16GD.s:1216 .bss:00000005 charCount
/tmp/cc2L16GD.s:503 .text:00000192 UIMgr_init
/tmp/cc2L16GD.s:1228 .bss:0000000b tokenBuffer
*COM*:00000020 UIMgr_rxFifo
/tmp/cc2L16GD.s:549 .text:000001c8 UIMgr_convertTokenToValue
.bss:00000004 tokenCount
/tmp/cc2L16GD.s:619 .text:00000214 UIMgr_processReceivedData
/tmp/cc2L16GD.s:1202 .bss:00000001 UIMgr_rxFifoTail
/tmp/cc2L16GD.s:1226 .data:00000001 AVRcamVersion
/tmp/cc2L16GD.s:1196 .bss:00000000 UIMgr_rxFifoHead
/tmp/cc2L16GD.s:1150 .text:00000442 UIMgr_dispatchEvent
 
UNDEFINED SYMBOLS
__do_copy_data
__do_clear_bss
UartInt_txByte
atoi
Utility_delay
Exec_writeEventFifo
CamInt_resetCam
CamConfig_setCamReg
CamConfig_sendFifoCmds
colorMap
__eeprom_read_byte_1C1D1E
__eeprom_write_byte_1C1D1E
/programy/Atmel_C/AVRcam/UartInterface.c
0,0 → 1,157
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: UartInterface.c
Module Date: 04/10/2004
Module Auth: John Orlando
Description: This module is responsible for providing an
interface to the UART hardware available on the mega8.
This interface is an interrupt-driven interface.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
11/15/2004 1.2 Updated UART baud rate regs so that
it runs at 115.2 kbps when the input
crystal is at 17.7 MHz (which is the
speed of the OV6620's crystal).
1/16/2005 1.4 Moved the serial received ISR to
this file, instead of having it
in its own UartInterfaceAsm.S file
written in assembly.
***********************************************************/
 
/* Includes */
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include "CommonDefs.h"
#include "UartInterface.h"
#include "UIMgr.h"
#include "Executive.h"
 
/* Local Variables */
 
/* Local Structures and Typedefs */
 
/* Extern Variables */
 
/* Definitions */
 
/***********************************************************
Function Name: UartInt_init
Function Description: This function is responsible for
initializing the UART interface on the mega8. This
interface is set to communicate at 115.2 Kbps, with an
8N1 protocol.
Inputs: none
Outputs: none
***********************************************************/
void UartInt_init(void)
{
/* set up the baud rate registers so the UART will operate
at 115.2 Kbps */
UBRRH = 0x00;
 
#ifdef NO_CRYSTAL
UBRRL = 18; /* 18 for double clocking at 115.2 kbps */
#else
UBRRL = 0x08; /* for 16 MHz crystal at 115.2 kbps */
#endif
/* enable the tx and rx capabilities of the UART...as well
as the receive complete interrupt */
UCSRB = (1<<RXCIE)|(1<<RXEN)|(1<<TXEN);
/* set up the control registers so the UART works at 8N1 */
UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0);
#ifdef NO_CRYSTAL
/* set the baud rate to use the double-speed */
UCSRA = (1<<U2X);
#endif
}
 
/***********************************************************
Function Name: UartInt_txByte
Function Description: This function is responsible for
transmitting a single byte on the uart.
Inputs: txByte - the byte to send
Outputs: none
NOTES: When the TX UDRE (data register empty) is set, there
is puposefully no interrupt...thus, to send a string of
data out, the calling routine needs to hold up the entire
application while this takes place (or just send one
byte at a time at strtegically timed intervals, like
the stats data is sent out :-)
***********************************************************/
void UartInt_txByte(unsigned char txByte)
{
/* Wait for empty transmit buffer */
while ( !( UCSRA & (1<<UDRE)) );
/* Put data into buffer, sends the data */
UDR = txByte;
}
 
/***********************************************************
Function Name: SIG_UART_RECV ISR
Function Description: This function is responsible for
handling the interrupt caused when a data byte is
received by the UART.
Inputs: none
Outputs: none
NOTES: This function was originally written in assembly,
but moved over to C when the setting of the "T" bit at
the end of the routine was no longer necessary (this
theoretically allowed the AVRcam to respond to serial
bytes in the middle of tracking or dumping a frame.
But it wasn't really needed, and understanding the C
is easier :-)
***********************************************************/
SIGNAL(SIG_UART_RECV)
{
unsigned char tmpHead;
/* read the data byte, put it in the serial queue, and
post the event */
UIMgr_rxFifo[UIMgr_rxFifoHead] = UDR;
 
/* now move the head up */
tmpHead = (UIMgr_rxFifoHead + 1) & (UI_MGR_RX_FIFO_MASK);
UIMgr_rxFifoHead = tmpHead;
/* write the serial received event to the event fifo */
Exec_eventFifo[Exec_eventFifoHead] = EV_SERIAL_DATA_RECEIVED;
 
/* now move the head up */
tmpHead = (Exec_eventFifoHead + 1) & (EXEC_EVENT_FIFO_MASK);
Exec_eventFifoHead = tmpHead;
}
 
/programy/Atmel_C/AVRcam/UartInterface.d
0,0 → 1,2
UartInterface.o UartInterface.d : UartInterface.c CommonDefs.h UartInterface.h UIMgr.h \
Executive.h Events.h
/programy/Atmel_C/AVRcam/UartInterface.h
0,0 → 1,52
#ifndef UARTINTERFACE_H
#define UARTINTERFACE_H
 
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: UartInterface.h
Module Date: 04/10/2004
Module Auth: John Orlando
Description: This modules provides the external interface
to the UartInterface module.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
***********************************************************/
/* extern variables */
extern unsigned char serialReceivedFlag;
 
/* External Function Prototypes */
extern void UartInt_init(void);
extern void UartInt_txByte(unsigned char txByte);
#endif
 
/programy/Atmel_C/AVRcam/UartInterface.lst
0,0 → 1,394
GAS LISTING /tmp/ccGIWzET.s page 1
 
 
1 .file "UartInterface.c"
2 .arch atmega8
3 __SREG__ = 0x3f
4 __SP_H__ = 0x3e
5 __SP_L__ = 0x3d
6 __tmp_reg__ = 0
7 __zero_reg__ = 1
8 .global __do_copy_data
9 .global __do_clear_bss
10 .stabs "/home/kaklik/projects/roboti/istrobot/2007/ATmega8/AVRcam/",100,0,2,.Ltext0
11 .stabs "UartInterface.c",100,0,2,.Ltext0
12 .text
13 .Ltext0:
14 .stabs "gcc2_compiled.",60,0,0,0
15 .stabs "int:t(0,1)=r(0,1);-32768;32767;",128,0,0,0
16 .stabs "char:t(0,2)=@s8;r(0,2);0;255;",128,0,0,0
17 .stabs "long int:t(0,3)=@s32;r(0,3);020000000000;017777777777;",128,0,0,0
18 .stabs "unsigned int:t(0,4)=r(0,4);0;0177777;",128,0,0,0
19 .stabs "long unsigned int:t(0,5)=@s32;r(0,5);0;037777777777;",128,0,0,0
20 .stabs "long long int:t(0,6)=@s64;r(0,6);01000000000000000000000;0777777777777777777777;",128,0,0,
21 .stabs "long long unsigned int:t(0,7)=@s64;r(0,7);0;01777777777777777777777;",128,0,0,0
22 .stabs "short int:t(0,8)=r(0,8);-32768;32767;",128,0,0,0
23 .stabs "short unsigned int:t(0,9)=r(0,9);0;0177777;",128,0,0,0
24 .stabs "signed char:t(0,10)=@s8;r(0,10);-128;127;",128,0,0,0
25 .stabs "unsigned char:t(0,11)=@s8;r(0,11);0;255;",128,0,0,0
26 .stabs "float:t(0,12)=r(0,1);4;0;",128,0,0,0
27 .stabs "double:t(0,13)=r(0,1);4;0;",128,0,0,0
28 .stabs "long double:t(0,14)=r(0,1);4;0;",128,0,0,0
29 .stabs "void:t(0,15)=(0,15)",128,0,0,0
30 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/io.h",130,0,0,0
31 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/avr/sfr_defs.h",130,0,0,0
32 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/inttypes.h",130,0,0,0
33 .stabs "/usr/lib/gcc/avr/4.1.0/../../../../avr/include/stdint.h",130,0,0,0
34 .stabs "int8_t:t(4,1)=(0,10)",128,0,116,0
35 .stabs "uint8_t:t(4,2)=(0,11)",128,0,117,0
36 .stabs "int16_t:t(4,3)=(0,1)",128,0,118,0
37 .stabs "uint16_t:t(4,4)=(0,4)",128,0,119,0
38 .stabs "int32_t:t(4,5)=(0,3)",128,0,120,0
39 .stabs "uint32_t:t(4,6)=(0,5)",128,0,121,0
40 .stabs "int64_t:t(4,7)=(0,6)",128,0,122,0
41 .stabs "uint64_t:t(4,8)=(0,7)",128,0,123,0
42 .stabs "intptr_t:t(4,9)=(4,3)",128,0,135,0
43 .stabs "uintptr_t:t(4,10)=(4,4)",128,0,140,0
44 .stabs "int_least8_t:t(4,11)=(4,1)",128,0,152,0
45 .stabs "uint_least8_t:t(4,12)=(4,2)",128,0,157,0
46 .stabs "int_least16_t:t(4,13)=(4,3)",128,0,162,0
47 .stabs "uint_least16_t:t(4,14)=(4,4)",128,0,167,0
48 .stabs "int_least32_t:t(4,15)=(4,5)",128,0,172,0
49 .stabs "uint_least32_t:t(4,16)=(4,6)",128,0,177,0
50 .stabs "int_least64_t:t(4,17)=(4,7)",128,0,182,0
51 .stabs "uint_least64_t:t(4,18)=(4,8)",128,0,187,0
52 .stabs "int_fast8_t:t(4,19)=(4,1)",128,0,200,0
53 .stabs "uint_fast8_t:t(4,20)=(4,2)",128,0,205,0
54 .stabs "int_fast16_t:t(4,21)=(4,3)",128,0,210,0
55 .stabs "uint_fast16_t:t(4,22)=(4,4)",128,0,215,0
56 .stabs "int_fast32_t:t(4,23)=(4,5)",128,0,220,0
57 .stabs "uint_fast32_t:t(4,24)=(4,6)",128,0,225,0
GAS LISTING /tmp/ccGIWzET.s page 2
 
 
58 .stabs "int_fast64_t:t(4,25)=(4,7)",128,0,230,0
59 .stabs "uint_fast64_t:t(4,26)=(4,8)",128,0,235,0
60 .stabs "intmax_t:t(4,27)=(4,7)",128,0,249,0
61 .stabs "uintmax_t:t(4,28)=(4,8)",128,0,254,0
62 .stabn 162,0,0,0
63 .stabs "int_farptr_t:t(3,1)=(4,5)",128,0,76,0
64 .stabs "uint_farptr_t:t(3,2)=(4,6)",128,0,80,0
65 .stabn 162,0,0,0
66 .stabn 162,0,0,0
67 .stabn 162,0,0,0
68 .stabs "CommonDefs.h",130,0,0,0
69 .stabs "bool_t:t(5,1)=(0,11)",128,0,56,0
70 .stabn 162,0,0,0
71 .stabs "UartInt_init:F(0,15)",36,0,77,UartInt_init
72 .global UartInt_init
73 .type UartInt_init, @function
74 UartInt_init:
75 .stabd 46,0,0
1:UartInterface.c **** /*
2:UartInterface.c **** Copyright (C) 2004 John Orlando
3:UartInterface.c ****
4:UartInterface.c **** AVRcam: a small real-time image processing engine.
5:UartInterface.c ****
6:UartInterface.c **** This program is free software; you can redistribute it and/or
7:UartInterface.c **** modify it under the terms of the GNU General Public
8:UartInterface.c **** License as published by the Free Software Foundation; either
9:UartInterface.c **** version 2 of the License, or (at your option) any later version.
10:UartInterface.c ****
11:UartInterface.c **** This program is distributed in the hope that it will be useful,
12:UartInterface.c **** but WITHOUT ANY WARRANTY; without even the implied warranty of
13:UartInterface.c **** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14:UartInterface.c **** General Public License for more details.
15:UartInterface.c ****
16:UartInterface.c **** You should have received a copy of the GNU General Public
17:UartInterface.c **** License along with this program; if not, write to the Free Software
18:UartInterface.c **** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19:UartInterface.c ****
20:UartInterface.c **** For more information on the AVRcam, please contact:
21:UartInterface.c ****
22:UartInterface.c **** john@jrobot.net
23:UartInterface.c ****
24:UartInterface.c **** or go to www.jrobot.net for more details regarding the system.
25:UartInterface.c **** */
26:UartInterface.c **** /***********************************************************
27:UartInterface.c **** Module Name: UartInterface.c
28:UartInterface.c **** Module Date: 04/10/2004
29:UartInterface.c **** Module Auth: John Orlando
30:UartInterface.c ****
31:UartInterface.c **** Description: This module is responsible for providing an
32:UartInterface.c **** interface to the UART hardware available on the mega8.
33:UartInterface.c **** This interface is an interrupt-driven interface.
34:UartInterface.c ****
35:UartInterface.c **** Revision History:
36:UartInterface.c **** Date Rel Ver. Notes
37:UartInterface.c **** 4/10/2004 0.1 Module created
38:UartInterface.c **** 6/30/2004 1.0 Initial release for Circuit Cellar
39:UartInterface.c **** contest.
GAS LISTING /tmp/ccGIWzET.s page 3
 
 
40:UartInterface.c **** 11/15/2004 1.2 Updated UART baud rate regs so that
41:UartInterface.c **** it runs at 115.2 kbps when the input
42:UartInterface.c **** crystal is at 17.7 MHz (which is the
43:UartInterface.c **** speed of the OV6620's crystal).
44:UartInterface.c **** 1/16/2005 1.4 Moved the serial received ISR to
45:UartInterface.c **** this file, instead of having it
46:UartInterface.c **** in its own UartInterfaceAsm.S file
47:UartInterface.c **** written in assembly.
48:UartInterface.c **** ***********************************************************/
49:UartInterface.c ****
50:UartInterface.c **** /* Includes */
51:UartInterface.c **** #include <avr/io.h>
52:UartInterface.c **** #include <avr/interrupt.h>
53:UartInterface.c **** #include <avr/signal.h>
54:UartInterface.c **** #include "CommonDefs.h"
55:UartInterface.c **** #include "UartInterface.h"
56:UartInterface.c **** #include "UIMgr.h"
57:UartInterface.c **** #include "Executive.h"
58:UartInterface.c ****
59:UartInterface.c **** /* Local Variables */
60:UartInterface.c ****
61:UartInterface.c **** /* Local Structures and Typedefs */
62:UartInterface.c ****
63:UartInterface.c **** /* Extern Variables */
64:UartInterface.c ****
65:UartInterface.c **** /* Definitions */
66:UartInterface.c ****
67:UartInterface.c **** /***********************************************************
68:UartInterface.c **** Function Name: UartInt_init
69:UartInterface.c **** Function Description: This function is responsible for
70:UartInterface.c **** initializing the UART interface on the mega8. This
71:UartInterface.c **** interface is set to communicate at 115.2 Kbps, with an
72:UartInterface.c **** 8N1 protocol.
73:UartInterface.c **** Inputs: none
74:UartInterface.c **** Outputs: none
75:UartInterface.c **** ***********************************************************/
76:UartInterface.c **** void UartInt_init(void)
77:UartInterface.c **** {
76 .stabn 68,0,77,.LM0-UartInt_init
77 .LM0:
78 /* prologue: frame size=0 */
79 /* prologue end (size=0) */
78:UartInterface.c **** /* set up the baud rate registers so the UART will operate
79:UartInterface.c **** at 115.2 Kbps */
80:UartInterface.c **** UBRRH = 0x00;
80 .stabn 68,0,80,.LM1-UartInt_init
81 .LM1:
82 0000 10BC out 64-0x20,__zero_reg__
81:UartInterface.c ****
82:UartInterface.c **** #ifdef NO_CRYSTAL
83:UartInterface.c **** UBRRL = 18; /* 18 for double clocking at 115.2 kbps */
83 .stabn 68,0,83,.LM2-UartInt_init
84 .LM2:
85 0002 82E1 ldi r24,lo8(18)
86 0004 89B9 out 41-0x20,r24
84:UartInterface.c **** #else
85:UartInterface.c **** UBRRL = 0x08; /* for 16 MHz crystal at 115.2 kbps */
GAS LISTING /tmp/ccGIWzET.s page 4
 
 
86:UartInterface.c **** #endif
87:UartInterface.c ****
88:UartInterface.c **** /* enable the tx and rx capabilities of the UART...as well
89:UartInterface.c **** as the receive complete interrupt */
90:UartInterface.c **** UCSRB = (1<<RXCIE)|(1<<RXEN)|(1<<TXEN);
87 .stabn 68,0,90,.LM3-UartInt_init
88 .LM3:
89 0006 88E9 ldi r24,lo8(-104)
90 0008 8AB9 out 42-0x20,r24
91:UartInterface.c ****
92:UartInterface.c **** /* set up the control registers so the UART works at 8N1 */
93:UartInterface.c **** UCSRC = (1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0);
91 .stabn 68,0,93,.LM4-UartInt_init
92 .LM4:
93 000a 86E8 ldi r24,lo8(-122)
94 000c 80BD out 64-0x20,r24
94:UartInterface.c ****
95:UartInterface.c **** #ifdef NO_CRYSTAL
96:UartInterface.c **** /* set the baud rate to use the double-speed */
97:UartInterface.c **** UCSRA = (1<<U2X);
95 .stabn 68,0,97,.LM5-UartInt_init
96 .LM5:
97 000e 82E0 ldi r24,lo8(2)
98 0010 8BB9 out 43-0x20,r24
99 /* epilogue: frame size=0 */
100 0012 0895 ret
101 /* epilogue end (size=1) */
102 /* function UartInt_init size 10 (9) */
103 .size UartInt_init, .-UartInt_init
104 .Lscope0:
105 .stabs "",36,0,0,.Lscope0-UartInt_init
106 .stabd 78,0,0
107 .stabs "UartInt_txByte:F(0,15)",36,0,116,UartInt_txByte
108 .stabs "txByte:P(0,11)",64,0,115,24
109 .global UartInt_txByte
110 .type UartInt_txByte, @function
111 UartInt_txByte:
112 .stabd 46,0,0
98:UartInterface.c **** #endif
99:UartInterface.c ****
100:UartInterface.c **** }
101:UartInterface.c ****
102:UartInterface.c **** /***********************************************************
103:UartInterface.c **** Function Name: UartInt_txByte
104:UartInterface.c **** Function Description: This function is responsible for
105:UartInterface.c **** transmitting a single byte on the uart.
106:UartInterface.c **** Inputs: txByte - the byte to send
107:UartInterface.c **** Outputs: none
108:UartInterface.c **** NOTES: When the TX UDRE (data register empty) is set, there
109:UartInterface.c **** is puposefully no interrupt...thus, to send a string of
110:UartInterface.c **** data out, the calling routine needs to hold up the entire
111:UartInterface.c **** application while this takes place (or just send one
112:UartInterface.c **** byte at a time at strtegically timed intervals, like
113:UartInterface.c **** the stats data is sent out :-)
114:UartInterface.c **** ***********************************************************/
115:UartInterface.c **** void UartInt_txByte(unsigned char txByte)
116:UartInterface.c **** {
GAS LISTING /tmp/ccGIWzET.s page 5
 
 
113 .stabn 68,0,116,.LM6-UartInt_txByte
114 .LM6:
115 /* prologue: frame size=0 */
116 /* prologue end (size=0) */
117 .L5:
117:UartInterface.c **** /* Wait for empty transmit buffer */
118:UartInterface.c **** while ( !( UCSRA & (1<<UDRE)) );
118 .stabn 68,0,118,.LM7-UartInt_txByte
119 .LM7:
120 0014 5D9B sbis 43-0x20,5
121 0016 FECF rjmp .L5
119:UartInterface.c **** /* Put data into buffer, sends the data */
120:UartInterface.c **** UDR = txByte;
122 .stabn 68,0,120,.LM8-UartInt_txByte
123 .LM8:
124 0018 8CB9 out 44-0x20,r24
125 /* epilogue: frame size=0 */
126 001a 0895 ret
127 /* epilogue end (size=1) */
128 /* function UartInt_txByte size 4 (3) */
129 .size UartInt_txByte, .-UartInt_txByte
130 .Lscope1:
131 .stabs "",36,0,0,.Lscope1-UartInt_txByte
132 .stabd 78,0,0
133 .stabs "__vector_11:F(0,15)",36,0,139,__vector_11
134 .global __vector_11
135 .type __vector_11, @function
136 __vector_11:
137 .stabd 46,0,0
121:UartInterface.c **** }
122:UartInterface.c ****
123:UartInterface.c **** /***********************************************************
124:UartInterface.c **** Function Name: SIG_UART_RECV ISR
125:UartInterface.c **** Function Description: This function is responsible for
126:UartInterface.c **** handling the interrupt caused when a data byte is
127:UartInterface.c **** received by the UART.
128:UartInterface.c **** Inputs: none
129:UartInterface.c **** Outputs: none
130:UartInterface.c **** NOTES: This function was originally written in assembly,
131:UartInterface.c **** but moved over to C when the setting of the "T" bit at
132:UartInterface.c **** the end of the routine was no longer necessary (this
133:UartInterface.c **** theoretically allowed the AVRcam to respond to serial
134:UartInterface.c **** bytes in the middle of tracking or dumping a frame.
135:UartInterface.c **** But it wasn't really needed, and understanding the C
136:UartInterface.c **** is easier :-)
137:UartInterface.c **** ***********************************************************/
138:UartInterface.c **** SIGNAL(SIG_UART_RECV)
139:UartInterface.c **** {
138 .stabn 68,0,139,.LM9-__vector_11
139 .LM9:
140 /* prologue: frame size=0 */
141 001c 1F92 push __zero_reg__
142 001e 0F92 push __tmp_reg__
143 0020 0FB6 in __tmp_reg__,__SREG__
144 0022 0F92 push __tmp_reg__
145 0024 1124 clr __zero_reg__
146 0026 8F93 push r24
GAS LISTING /tmp/ccGIWzET.s page 6
 
 
147 0028 9F93 push r25
148 002a EF93 push r30
149 002c FF93 push r31
150 /* prologue end (size=9) */
140:UartInterface.c **** unsigned char tmpHead;
141:UartInterface.c **** /* read the data byte, put it in the serial queue, and
142:UartInterface.c **** post the event */
143:UartInterface.c ****
144:UartInterface.c **** UIMgr_rxFifo[UIMgr_rxFifoHead] = UDR;
151 .stabn 68,0,144,.LM10-__vector_11
152 .LM10:
153 002e 8091 0000 lds r24,UIMgr_rxFifoHead
154 0032 9CB1 in r25,44-0x20
155 0034 E0E0 ldi r30,lo8(UIMgr_rxFifo)
156 0036 F0E0 ldi r31,hi8(UIMgr_rxFifo)
157 0038 E80F add r30,r24
158 003a F11D adc r31,__zero_reg__
159 003c 9083 st Z,r25
145:UartInterface.c ****
146:UartInterface.c **** /* now move the head up */
147:UartInterface.c **** tmpHead = (UIMgr_rxFifoHead + 1) & (UI_MGR_RX_FIFO_MASK);
148:UartInterface.c **** UIMgr_rxFifoHead = tmpHead;
160 .stabn 68,0,148,.LM11-__vector_11
161 .LM11:
162 003e 8F5F subi r24,lo8(-(1))
163 0040 8F71 andi r24,lo8(31)
164 0042 8093 0000 sts UIMgr_rxFifoHead,r24
149:UartInterface.c ****
150:UartInterface.c **** /* write the serial received event to the event fifo */
151:UartInterface.c **** Exec_eventFifo[Exec_eventFifoHead] = EV_SERIAL_DATA_RECEIVED;
165 .stabn 68,0,151,.LM12-__vector_11
166 .LM12:
167 0046 8091 0000 lds r24,Exec_eventFifoHead
168 004a E0E0 ldi r30,lo8(Exec_eventFifo)
169 004c F0E0 ldi r31,hi8(Exec_eventFifo)
170 004e E80F add r30,r24
171 0050 F11D adc r31,__zero_reg__
172 0052 91E0 ldi r25,lo8(1)
173 0054 9083 st Z,r25
152:UartInterface.c ****
153:UartInterface.c **** /* now move the head up */
154:UartInterface.c **** tmpHead = (Exec_eventFifoHead + 1) & (EXEC_EVENT_FIFO_MASK);
155:UartInterface.c **** Exec_eventFifoHead = tmpHead;
174 .stabn 68,0,155,.LM13-__vector_11
175 .LM13:
176 0056 8F5F subi r24,lo8(-(1))
177 0058 8770 andi r24,lo8(7)
178 005a 8093 0000 sts Exec_eventFifoHead,r24
179 /* epilogue: frame size=0 */
180 005e FF91 pop r31
181 0060 EF91 pop r30
182 0062 9F91 pop r25
183 0064 8F91 pop r24
184 0066 0F90 pop __tmp_reg__
185 0068 0FBE out __SREG__,__tmp_reg__
186 006a 0F90 pop __tmp_reg__
187 006c 1F90 pop __zero_reg__
GAS LISTING /tmp/ccGIWzET.s page 7
 
 
188 006e 1895 reti
189 /* epilogue end (size=9) */
190 /* function __vector_11 size 42 (24) */
191 .size __vector_11, .-__vector_11
192 .Lscope2:
193 .stabs "",36,0,0,.Lscope2-__vector_11
194 .stabd 78,0,0
195 .stabs "",100,0,0,.Letext0
196 .Letext0:
197 /* File "UartInterface.c": code 56 = 0x0038 ( 36), prologues 9, epilogues 11 */
GAS LISTING /tmp/ccGIWzET.s page 8
 
 
DEFINED SYMBOLS
*ABS*:00000000 UartInterface.c
/tmp/ccGIWzET.s:3 *ABS*:0000003f __SREG__
/tmp/ccGIWzET.s:4 *ABS*:0000003e __SP_H__
/tmp/ccGIWzET.s:5 *ABS*:0000003d __SP_L__
/tmp/ccGIWzET.s:6 *ABS*:00000000 __tmp_reg__
/tmp/ccGIWzET.s:7 *ABS*:00000001 __zero_reg__
/tmp/ccGIWzET.s:74 .text:00000000 UartInt_init
/tmp/ccGIWzET.s:111 .text:00000014 UartInt_txByte
/tmp/ccGIWzET.s:136 .text:0000001c __vector_11
 
UNDEFINED SYMBOLS
__do_copy_data
__do_clear_bss
UIMgr_rxFifoHead
UIMgr_rxFifo
Exec_eventFifoHead
Exec_eventFifo
/programy/Atmel_C/AVRcam/Utility.c
0,0 → 1,78
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: Utility.c
Module Date: 04/13/2004
Module Auth: John Orlando
Description: This module provides a basic set of
general purpose utilities that can be used by any
module needing them.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
***********************************************************/
 
/* Includes */
#include "CommonDefs.h"
 
/* Local Variables */
 
/* Local Structures and Typedefs */
 
/* Extern Variables */
 
/* Definitions */
 
/***********************************************************
Function Name: Utility_delay
Function Description: This function provides a busy-wait
delay for a specified number of milliseconds.
Inputs: numMs - the number of milliseconds to delay
Outputs: none
NOTES: The delay_loop_1 and delay_loop_2 functions found
in avr/delay.h provide accurate 3 and 4 cycle delay loops
if needed...this isn't really a millisecond, so DON'T
depend on it for exact timing...
***********************************************************/
void Utility_delay(unsigned short numMs)
{
volatile unsigned short i=0,j=0;
#ifndef SIMULATION
for (i=0; i<numMs; i++)
{
for (j=0; j<1000; j++)
{
asm volatile("nop"::);
}
}
#endif
}
 
 
/programy/Atmel_C/AVRcam/Utility.d
0,0 → 1,0
Utility.o Utility.d : Utility.c CommonDefs.h
/programy/Atmel_C/AVRcam/Utility.h
0,0 → 1,48
#ifndef UTILITY_H
#define UTILITY_H
 
/*
Copyright (C) 2004 John Orlando
AVRcam: a small real-time image processing engine.
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcam, please contact:
 
john@jrobot.net
 
or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
Module Name: Utility.h
Module Date: 04/13/2004
Module Auth: John Orlando
Description: This file provides the external interface
to the Utility module.
Revision History:
Date Rel Ver. Notes
4/10/2004 0.1 Module created
6/30/2004 1.0 Initial release for Circuit Cellar
contest.
***********************************************************/
/* Extern Functions */
extern void Utility_delay(unsigned short numMs);
#endif
 
/programy/Atmel_C/AVRcam/makefile
0,0 → 1,362
# WinAVR Sample makefile written by Eric B. Weddington, Jörg Wunsch, et al.
# Released to the Public Domain
# Please read the make user manual!
#
# Retrofitted for the AVRcam project by John Orlando 6/30/2004
#
#
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
#
# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
# 4.07 or greater).
#
# make program = Download the hex file to the device, using avrdude. Please
# customize the avrdude settings below first!
#
# make filename.s = Just compile filename.c into the assembler code only
#
# To rebuild project do "make clean" then "make all".
#
# Revision History:
# Date Rel Ver. Notes
# 4/10/2004 0.1 Module created
# 6/30/2004 1.0 Initial release for Circuit Cellar
# contest.
# 1/15/2005 1.4 Removed the UartInterfaceAsm file from
# file list, since the routine in that
# file was added to UartInterface.c.
 
 
# MCU name
MCU = atmega8
 
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
 
# Target file name (without extension).
TARGET = AVRcam
 
# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
# (Note 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = 1
 
 
# List C source files here. (C dependencies are automatically generated.)
#SRC = $(TARGET).c
 
# If there is more than one source file, append them above, or adjust and
# uncomment the following:
# NOTE: The order of the files here is important...CamInterface.c MUST be
# the first file, due to the declaration of an array that needs to be
# located at the very beginning of the .noinit section in on-board RAM.
SRC = CamInterface.c Main.c Executive.c FrameMgr.c UIMgr.c UartInterface.c I2CInterface.c CamConfig.c Utility.c DebugInterface.c
 
 
# List Assembler source files here.
# Make them always end in a capital .S. Files ending in a lowercase .s
# will not be considered source files but generated files (assembler
# output from the compiler), and will be deleted upon "make clean"!
# Even though the DOS/Win* filesystem matches both .s and .S the same,
# it will preserve the spelling of the filenames, and gcc itself does
# care about how the name is spelled on its command-line.
ASRC = CamInterfaceAsm.S
 
 
 
# Optional compiler flags.
# -g: generate debugging information (for GDB, or for COFF conversion)
# -O*: optimization level
# -f...: tuning, see gcc manual and avr-libc documentation
# -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create assembler listing
CFLAGS = -g -O$(OPT) \
-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \
-Wall -Wstrict-prototypes \
-Wa,-ahlms=$(<:.c=.lst)
 
 
 
# Optional assembler flags.
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create listing
# -gstabs: have the assembler create line number information; note that
# for use in COFF files, additional information about filenames
# and function names needs to be present in the assembler source
# files -- see avr-libc docs [FIXME: not yet described there]
ASFLAGS = -Wa,-ahlms=$(<:.S=.lst),-gstabs
 
 
 
# Optional linker flags.
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref,--section-start=.noinit=0x800300
#LDFLAGS = -Wl,-Map=$(TARGET).map,--cref,--section-start=.john=0x800200
 
 
 
# Additional libraries
#
# Minimalistic printf version
#LDFLAGS += -Wl,-u,vfprintf -lprintf_min
#
# Floating point printf version (requires -lm below)
#LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
#
# -lm = math library
LDFLAGS += -lm
 
 
 
 
# Programming support using avrdude. Settings and variables.
 
# Programming hardware: avrisp stk500 avr910 pavr stk200 pony-stk200
# dt006 bascom alf
# Type: avrdude -c ?
# to get a full listing.
#
AVRDUDE_PROGRAMMER = dapa
 
 
#AVRDUDE_PORT = com1 # programmer connected to serial device
AVRDUDE_PORT = /dev/parport0 # programmer connected to parallel port
 
AVRDUDE_ERASE = -e
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
 
 
# Uncomment the following if you want avrdude's erase cycle counter.
# Note that this counter needs to be initialized first using -Yn,
# see avrdude manual.
#AVRDUDE_ERASE += -y
#
# Uncomment the following if you do /not/ wish a verification to be
# performed after programming the device.
#AVRDUDE_FLAGS += -V
#
# Increase verbosity level. Please use this when submitting bug
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
# to submit bug reports.
#AVRDUDE_FLAGS += -v -v
 
 
 
 
# ---------------------------------------------------------------------------
 
# Define directories, if needed.
DIRAVR = c:/winavr
DIRAVRBIN = $(DIRAVR)/bin
DIRAVRUTILS = $(DIRAVR)/utils/bin
DIRINC = .
DIRLIB = $(DIRAVR)/avr/lib
 
 
# Define programs and commands.
SHELL = sh
 
CC = avr-gcc
 
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
 
 
# Programming support using avrdude.
AVRDUDE = avrdude
 
 
REMOVE = rm -f
COPY = cp
 
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
ELFSIZE = $(SIZE) -A $(TARGET).elf
 
FINISH = echo Errors: none
BEGIN = echo -------- begin --------
END = echo -------- end --------
 
 
 
 
# Define all object files.
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
 
# Define all listing files.
LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
 
# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
 
 
 
# Default target.
all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \
$(TARGET).lss coff sizeafter finished end
 
 
# Eye candy.
# AVR Studio 3.x does not check make's exit code but relies on
# the following magic strings to be generated by the compile job.
begin:
@$(BEGIN)
 
finished:
@$(FINISH)
 
end:
@$(END)
 
 
# Display size of file.
sizebefore:
@if [ -f $(TARGET).elf ]; then echo Size before:; $(ELFSIZE);fi
 
sizeafter:
@if [ -f $(TARGET).elf ]; then echo Size after:; $(ELFSIZE);fi
 
 
 
# Display compiler version information.
gccversion :
$(CC) --version
 
 
 
 
# Convert ELF to COFF for use in debugging / simulating in
# AVR Studio or VMLAB.
COFFCONVERT=$(OBJCOPY) --debugging \
--change-section-address .data-0x800000 \
--change-section-address .bss-0x800000 \
--change-section-address .noinit-0x800000 \
--change-section-address .eeprom-0x810000
 
 
coff: $(TARGET).elf
$(COFFCONVERT) -O coff-avr $< $(TARGET).cof
 
 
extcoff: $(TARGET).elf
$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
 
 
 
 
# Program the device. The magic trickery below examines the .eep hex
# file whether the size is > 0, and if so, reprograms the EEPROM as
# well. Just delete these lines if you don't want this feature (like
# on the ATmegas with the EESAVE fuse bit set).
program: $(TARGET).hex $(TARGET).eep
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_ERASE)
$(AVRDUDE) $(AVRDUDE_FLAGS) -i $(TARGET).hex
@$(SIZE) --target=$(FORMAT) $(TARGET).eep | while read line; \
do \
set -- $$line; \
if [ "x$$1" != "x0" ] ; then continue; fi; \
if [ "$$2" -ne 0 ] ; then \
echo $(AVRDUDE) $(AVRDUDE_FLAGS) -m eeprom -i $(TARGET).eep; \
$(AVRDUDE) $(AVRDUDE_FLAGS) -m eeprom -i $(TARGET).eep; \
break; \
fi; \
done
 
 
# Create final output files (.hex, .eep) from ELF output file.
%.hex: %.elf
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
 
%.eep: %.elf
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@
 
# Create extended listing file from ELF output file.
%.lss: %.elf
$(OBJDUMP) -h -S $< > $@
 
 
 
# Link: create ELF output file from object files.
.SECONDARY : $(TARGET).elf
.PRECIOUS : $(OBJ)
%.elf: $(OBJ)
$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
 
 
# Compile: create object files from C source files.
%.o : %.c
$(CC) -c $(ALL_CFLAGS) $< -o $@
 
 
# Compile: create assembler files from C source files.
%.s : %.c
$(CC) -S $(ALL_CFLAGS) $< -o $@
 
 
# Assemble: create object files from assembler source files.
%.o : %.S
$(CC) -c $(ALL_ASFLAGS) $< -o $@
 
 
 
 
 
 
# Target: clean project.
clean: begin clean_list finished end
 
clean_list :
$(REMOVE) $(TARGET).hex
$(REMOVE) $(TARGET).eep
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).cof
$(REMOVE) $(TARGET).elf
$(REMOVE) $(TARGET).map
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).a90
$(REMOVE) $(TARGET).sym
$(REMOVE) $(TARGET).lnk
$(REMOVE) $(TARGET).lss
$(REMOVE) $(OBJ)
$(REMOVE) $(LST)
$(REMOVE) $(SRC:.c=.s)
$(REMOVE) $(SRC:.c=.d)
 
 
# Automatically generate C source code dependencies.
# (Code originally taken from the GNU make user manual and modified
# (See README.txt Credits).)
#
# Note that this will work with sh (bash) and sed that is shipped with WinAVR
# (see the SHELL variable defined above).
# This may not work with other shells or other seds.
#
%.d: %.c
set -e; $(CC) -MM $(ALL_CFLAGS) $< \
| sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \
[ -s $@ ] || rm -f $@
 
 
# Remove the '-' if you want to see the dependency files generated.
-include $(SRC:.c=.d)
 
 
 
# Listing of phony targets.
.PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \
clean clean_list program