Index: /firmware/MSR/MSR.aps
===================================================================
--- /firmware/MSR/MSR.aps	(revision 10588)
+++ /firmware/MSR/MSR.aps	(revision 10588)
@@ -0,0 +1,1 @@
+<AVRStudio><MANAGEMENT><ProjectName>MSR</ProjectName><Created>23-Mar-2011 20:49:59</Created><LastEdit>29-Mar-2011 11:16:28</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>23-Mar-2011 20:49:59</Created><Version>4</Version><Build>4, 18, 0, 685</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>default\MSR.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>C:\Documents and Settings\daqct3\Desktop\MSR_29.03.11_10h\MSR\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR Simulator</CURRENT_TARGET><CURRENT_PART>ATmega32.xml</CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><modules><module><map private="c:\avrdev\gcc\build-avr\gcc\" public=""/><map private="c:\avrdev\gcc\gcc-4.3.3\gcc\" public=""/><map private="c:\avrdev\gcc\gcc-4.3.3\gcc\config\" public=""/></module></modules><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>src\MSR.c</SOURCEFILE><SOURCEFILE>src\usart.c</SOURCEFILE><SOURCEFILE>src\application.c</SOURCEFILE><SOURCEFILE>src\spi_master.c</SOURCEFILE><SOURCEFILE>src\ad7719_adc.c</SOURCEFILE><SOURCEFILE>src\atmega_adc.c</SOURCEFILE><SOURCEFILE>src\num_conversion.c</SOURCEFILE><HEADERFILE>src\ad7719_adc.h</HEADERFILE><HEADERFILE>src\application.h</HEADERFILE><HEADERFILE>src\atmega_adc.h</HEADERFILE><HEADERFILE>src\macros.h</HEADERFILE><HEADERFILE>src\num_conversion.h</HEADERFILE><HEADERFILE>src\spi_master.h</HEADERFILE><HEADERFILE>src\typedefs.h</HEADERFILE><HEADERFILE>src\usart.h</HEADERFILE><OTHERFILE>default\MSR.lss</OTHERFILE><OTHERFILE>default\MSR.map</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>NO</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE></EXTERNALMAKEFILE><PART>atmega32</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>MSR.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>D:\WinAVR-20100110\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>D:\WinAVR-20100110\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="1" orderaddress="1" ordergroup="1"/></IOView><Files><File00000><FileId>00000</FileId><FileName>src\MSR.c</FileName><Status>1</Status></File00000></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>
Index: /firmware/MSR/default/MSR.hex
===================================================================
--- /firmware/MSR/default/MSR.hex	(revision 10588)
+++ /firmware/MSR/default/MSR.hex	(revision 10588)
@@ -0,0 +1,804 @@
+:100000000C942A000C9447000C9447000C94470071
+:100010000C9449000C9447000C9447000C94470042
+:100020000C9447000C9447000C9447000C94470034
+:100030000C9447000C9447000C9447000C94470024
+:100040000C9447000C9447000C9447000C94470014
+:100050000C94470011241FBECFE5D8E0DEBFCDBF12
+:1000600016E0A0E6B0E0EAE1FCE202C005900D92E5
+:10007000AC36B107D9F717E0ACE6B6E001C01D9287
+:10008000AA38B107E1F70E948B040C940B160C946C
+:1000900000001F920F920FB60F9211248F939F931F
+:1000A000AF93BF938091700690917106A0917206F4
+:1000B000B09173060196A11DB11D809370069093B7
+:1000C0007106A0937206B0937306BF91AF919F9192
+:1000D0008F910F900FBE0F901F901895582F482F9B
+:1000E0004F5F682F6F5E342F3F70E32FE695E695E4
+:1000F000E695F0E0E856F94F808190E0232F2770D5
+:1001000002C0959587952A95E2F780FD04C04F5F60
+:10011000461749F7352F832F0895582F482F4F5FE3
+:10012000682F6F5E342F3F70E32FE695E695E695D6
+:10013000F0E0E550F94F808190E0232F277002C056
+:10014000959587952A95E2F780FD04C04F5F461785
+:1001500049F7352F832F089595B38F70907F892BA2
+:1001600085BB08959BB38F70907F892B8BBB0895BF
+:1001700081E080938006909198068091950698176B
+:1001800031F49091990680919606981711F010928B
+:10019000800680918006089581E080937A06909190
+:1001A000FB0680914207981731F49091FC068091EC
+:1001B0004307981711F010927A0680917A060895F5
+:1001C00080E690E00E948206089584E492E00E9416
+:1001D000820685E792E00E94820687E992E00E940B
+:1001E000820681EC92E00E9482060895882321F025
+:1001F0008FEE92E00E9482068091FC060E94D60655
+:1002000080E20E9475068091FB060E94D60680E27D
+:100210000E9475068AE00E947506809143070E943D
+:10022000D60680E20E947506809142070E94D6069B
+:100230000895882321F08EE093E00E948206809149
+:1002400099060E94D60680E20E9475068091980663
+:100250000E94D60680E20E9475068AE00E9475061A
+:10026000809196060E94D60680E20E9475068091D3
+:1002700095060E94D60680E20E94750608950F93A7
+:100280001F931092FA0680E20E9475068BED96E0AD
+:100290000E9482068AE00E94750690916C0699235E
+:1002A00009F4A6C18091DB06823609F437C1833692
+:1002B000A0F4873409F441C1883440F4843421F136
+:1002C000853401F1813209F093C181C1883409F488
+:1002D00095C1803509F08CC149C1873609F434C114
+:1002E000883630F4843681F0853609F081C10AC041
+:1002F000803709F430C1833709F442C1883609F0E8
+:1003000077C17CC101E001C000E08091DC0682374A
+:1003100031F0863721F0883611F0803739F4933088
+:1003200040F01091DD0610531A3020F00E94E500D5
+:100330005FC110E0943058F09091DE0690539A30EF
+:1003400048F48AE0189F102D1124190F03C0933030
+:1003500008F44EC182E693E00E948206002319F061
+:1003600083E793E002C087E793E00E9482068091D2
+:10037000DC06803709F498C0813720F4883609F00C
+:10038000CAC068C0823721F0863709F0C4C031C0C6
+:10039000E12FE695E695E695212F30E0002381F0E8
+:1003A000F0E0E550F94F2770307081E090E002C036
+:1003B000880F991F2A95E2F72081282B208316C0E9
+:1003C000F0E02770307081E090E002C0880F991F44
+:1003D0002A95E2F78095DF01A550B94F2C9128238B
+:1003E0002C93EE5BF84F2081822380838CE793E08F
+:1003F00088C0E12FE695E695E695212F30E00023B1
+:1004000081F0F0E0E856F94F2770307081E090E01D
+:1004100002C0880F991F2A95E2F72081282B20839C
+:1004200016C0F0E02770307081E090E002C0880FC5
+:10043000991F2A95E2F78095DF01A856B94F2C91B4
+:1004400028232C93EB56F94F20818223808381E966
+:1004500093E057C0212F30E0002379F023703070F3
+:1004600081E090E002C0880F991F2A95E2F7209161
+:100470009906282B2093990614C02370307081E0D0
+:1004800090E002C0880F991F2A95E2F7809520918D
+:10049000990628232093990620919606822380931B
+:1004A000960683EA93E02DC0212F30E0002389F0E7
+:1004B000237030702C5F3F4F81E090E002C0880FC6
+:1004C000991F2A95E2F720919906282B20939906E7
+:1004D00016C0237030702C5F3F4F81E090E002C067
+:1004E000880F991F2A95E2F7809520919906282375
+:1004F000209399062091960682238093960686EB98
+:1005000093E00E948206812F62E00E94E5068AE065
+:100510000E9475066DC089EC93E068C088E094E0A5
+:100520000E94820681E0809397068091DC068033EA
+:1005300009F061C01092970657C0109211051092F1
+:1005400042071092430754C010921305109295066B
+:10055000109296064DC081E0809381068091DC0662
+:10056000803309F045C01092810642C081E080933B
+:100570007B068091DC068033D9F510927B0638C06B
+:1005800081E00E9419018AE00E94750681E00E94C4
+:10059000F6008AE00E9475068DE194E00E948206D2
+:1005A0006091700670917106809172069091730649
+:1005B0000E94111320E030E04AE754E40E945311F6
+:1005C00041E027E00E94B30683E294E00FC08AE294
+:1005D00094E00E94820681E0809382068091DC068E
+:1005E000803349F41092820684E194E00E948206EE
+:1005F000EBEDF6E006C089E194E0F8CF80E690E00C
+:10060000F5CF119286E0EB3FF807D9F71F910F91D4
+:100610000895BF92CF92DF92EF92FF920F931F93B4
+:10062000CF93DF93B62E8823C1F087E394E00E9436
+:10063000820610E086E794E00E948206812F62E045
+:100640000E94E50689E794E00E9482061F5F103150
+:1006500089F78DE794E00E9482068CE70E94750678
+:100660008BE9C82E86E0D82EC0E0D0E0CE0186957A
+:1006700086958695E82FF0E0E550F94F808190E06F
+:100680009E012770307002C0959587952A95E2F7F4
+:1006900080FF54C060910D0570910E0580910F058B
+:1006A0009091100520E030E040E854E40E94591099
+:1006B0007B018C01F60160817181828193810E94AE
+:1006C00011139B01AC01C801B7010E94591020E031
+:1006D00030E040E053E30E9459107B018C0120E0A0
+:1006E00030E04AE754E40E942F1288231CF480E291
+:1006F0000E947506C801B70120E030E048EC52E4E2
+:100700000E942F1288231CF480E20E947506C80103
+:10071000B70120E030E040E251E40E942F1288232C
+:100720001CF480E20E947506C801B70141E025E093
+:100730000E94B3068CE70E94750604C080E894E02E
+:100740000E948206219684E090E0C80ED91EC03136
+:10075000D10509F08BCFBB2019F08AE00E94750605
+:10076000DF91CF911F910F91FF90EF90DF90CF908D
+:10077000BF900895FF920F931F93CF93DF93F62EB0
+:10078000882309F478C088E894E00E94820610E08B
+:1007900086EB94E00E948206812F61E00E94E506CC
+:1007A00089E794E00E9482061F5F183089F78AEB80
+:1007B00094E00E94820680E061E00E94E50689E7FD
+:1007C00094E00E9482068AEB94E00E94820681E017
+:1007D00061E00E94E50689E794E00E9482068AEBC8
+:1007E00094E00E94820682E061E00E94E50689E7CB
+:1007F00094E00E9482068AEB94E00E94820683E0E5
+:1008000061E00E94E50689E794E00E9482068EEB93
+:1008100094E00E94820680E061E00E94E50689E79C
+:1008200094E00E9482068EEB94E00E94820681E0B2
+:1008300061E00E94E50689E794E00E9482068EEB63
+:1008400094E00E94820682E061E00E94E50689E76A
+:1008500094E00E9482068EEB94E00E94820683E080
+:1008600061E00E94E50689E794E00E9482068DE738
+:1008700094E00E94820602E017E0C0E0D0E08CE73E
+:100880000E947506CE01869586958695E82FF0E044
+:10089000E856F94F808190E09E012770307002C0C9
+:1008A000959587952A95E2F780FF1DC0F801608134
+:1008B00071818281938122E0660F771F881F991FC3
+:1008C0002A95D1F76E5F7F4F8F4F9F4F2091120572
+:1008D00030E040E050E00E94B215CA01B90146E0A4
+:1008E0000E94C20604C082EC94E00E948206219617
+:1008F0000C5F1F4FC031D10511F68CE70E947506C1
+:10090000FF2019F08AE00E947506DF91CF911F91B8
+:100910000F91FF900895CF92DF92EF92FF920F9385
+:100920001F93CF93DF930E94EA060E9469060E94FC
+:1009300051070E94CE080E944B0988E085BD85B50D
+:10094000836085BD8CE783BD89B7806889BF789453
+:10095000C2989FEF109242071092FC069093FB06FC
+:10096000109243071092950683E380939906909323
+:1009700098061092960684E195E00E94820680E631
+:1009800090E00E94820681E00E9419018AE00E94A4
+:10099000750681E00E94F6008AE00E9475068DE1EE
+:1009A00094E00E94820660917006709171068091B9
+:1009B0007206909173060E94111320E030E04AE71E
+:1009C00054E40E94531141E027E00E94B30683E201
+:1009D00094E00E94820611E000E181E0E82EF12C13
+:1009E000B0E2CB2EBEE4DB2E0E94B800882379F162
+:1009F00080918106882309F189EC94E00E948206A7
+:100A000060917006709171068091720690917306E4
+:100A10000E94111320E030E04AE754E40E94531191
+:100A200041E024E00E94B30680E061E00E94BA0346
+:100A300010929506109296060AC08091130588239D
+:100A400031F41093130581E061E00E94BA030E9423
+:100A5000CC00882379F180917B06882309F18CEC06
+:100A600094E00E94820660917006709171068091F8
+:100A70007206909173060E94111320E030E04AE75D
+:100A800054E40E94531141E024E00E94B30680E048
+:100A900061E00E94090310924207109243070AC0C6
+:100AA00080911105882331F41093110581E061E0F4
+:100AB0000E94090380919706882319F08BB3802741
+:100AC0008BBB90916D06992381F05D9B0EC0809148
+:100AD000FD068CB9EDEFF6E08181819347E0E230CD
+:100AE000F407D1F7915090936D065F9B1CC09CB1A9
+:100AF00090939A0680916C06803278F4E82FF0E0AB
+:100B0000E552F94F90838F5F80936C0681509A3045
+:100B100051F480936C06108204C08FEC94E00E9424
+:100B2000820610936F065B9B07C088EF94E00E94DB
+:100B300082068CB180939A0680916F06882369F0B3
+:100B40000E943F0110926F06EBEDF6E0119256E025
+:100B5000EB3FF507D9F710926C06349B60C080918B
+:100B60008006882309F05BC084B195B1D92FC0E01D
+:100B7000AE01480F511D50937F0640937E06609151
+:100B80007C068091120530917D06681771F5E32F80
+:100B9000E695E695E695F0E0EB56F94F832F8770E2
+:100BA000A70102C0440F551F8A95E2F72081242B2C
+:100BB0002083832F0E946E0080937D06E82FF0E053
+:100BC000EE0FFF1FEE0FFF1FEE5FF84F1082118236
+:100BD0001282138295B38F70907F982B95BB1092E1
+:100BE0007C06C6010197F1F71AC0E32FF0E0EE0F83
+:100BF000FF1FEE0FFF1FEE5FF84FCA01A0E0B0E04D
+:100C00002081318142815381820F931FA41FB51F20
+:100C100080839183A283B3836F5F60937C06829904
+:100C2000E3CE80917A06882309F0DECE0E94780810
+:100C30006093760670937706809378069093790692
+:100C400020917406309182062230B9F5E091750644
+:100C5000F0E0EE0FFF1FEE0FFF1FE556F94F608328
+:100C600071838283938310927406332341F00E9430
+:100C7000B8068AE00E9475068AE00E947506809197
+:100C80007506E82FE695E695E695F0E0EE5BF84F01
+:100C9000282F2770A70102C0440F551F2A95E2F79D
+:100CA0009081942B90830E948D00809375069BB356
+:100CB0008F70907F982B9BBB97CE2F5F20937406ED
+:100CC000332309F491CE0E94B8068AE00E9475068B
+:100CD0008BCE10BC83E389B91BB81AB8549A889894
+:100CE000539A899A86E880BD08955D9BFECF8CB9A2
+:100CF00008955D9BFECF8DE08CB95D9BFECF8AE0B1
+:100D00008CB90895FC0104C05D9BFECF31968CB96F
+:100D100080818823C9F70895FC0104C05D9BFECF44
+:100D200031968CB980818823C9F70895FC0104C0ED
+:100D30005D9BFECF31968CB980818823C9F75D9B7E
+:100D4000FECF8DE08CB95D9BFECF8AE08CB9089513
+:100D50000E9482065D9BFECF8DE08CB95D9BFECF2D
+:100D60008AE08CB908950E941B0A0E9482060895A9
+:100D70000E94B4090E94820608950E94120B0E94EC
+:100D8000820608950E942F0C0E94820608950E94F8
+:100D90008E090E94820608950E944B0D0E948206D1
+:100DA00008950E94AE0D0E94820608950E94720965
+:100DB0000E94820608950E945C090E94820608959E
+:100DC0000E940A0E0E94820608950E94480E0E9408
+:100DD0008206089584B78093440714BE8898899A40
+:100DE000D598D698D498D598D698D798D49AD79895
+:100DF0008AB38F608ABB84B38F6084BBBB9ABC9A72
+:100E0000C39AC49ABD9ABF9ABE98C59AC79A8A983F
+:100E1000B99AB89808952FB78D5FF894A89591B5B1
+:100E2000986191BD81BD2FBF08951DB8809159076C
+:100E300080FF02C06D9A01C06D988DB18091460708
+:100E400080FF02C06B9A01C06B988DB180915707EB
+:100E500080FF02C06A9A01C06A988DB180915807DC
+:100E6000833091F0843028F4813051F0823050F496
+:100E700010C0853089F0853048F0863051F407C0C5
+:100E8000699A0AC0699A03C0689A06C0689A709AFB
+:100E900004C08DB183608DB970988DB180658DB9B6
+:100EA0000895109258071092590781E080934607E1
+:100EB000809357070E9415070895873008F086E051
+:100EC000809358070E9415070895811181E080934F
+:100ED00059070E9415070895811181E08093460704
+:100EE0000E9415070895811181E0809357070E94A1
+:100EF000150708956C9B6C9A8FB9779BFECF8FB1C5
+:100F00000895AF92BF92CF92DF92EF92FF920F932C
+:100F10001F93CF93DF93C82ED62EEE24FF24862F67
+:100F200090E023E8A22E26E0B22EA80EB91EEC0116
+:100F3000C05BDA4F01E010E07BC0F50180818823BF
+:100F4000C1F0DD2059F428B38881A80102C0440F04
+:100F5000551F8A95E2F7242B28BB26C022B388812F
+:100F6000F80102C0EE0FFF1F8A95E2F72E2B22BB7D
+:100F70001BC0DD2069F428B38881A80102C0440F9A
+:100F8000551F8A95E2F7CA018095822388BB0CC061
+:100F900022B38881F80102C0EE0FFF1F8A95E2F7A5
+:100FA000CF018095822382BBF701E95BF84F8081F6
+:100FB0000E947A07F701E65AF84F8083F501808195
+:100FC0008823E1F0DD2069F428B38881A80102C0FC
+:100FD000440F551F8A95E2F7CA018095822388BB8A
+:100FE00024C022B38881F80102C0EE0FFF1F8A954A
+:100FF000E2F7CF018095822382BB17C0DD2059F430
+:1010000028B38881A80102C0440F551F8A95E2F7D2
+:10101000242B28BB0AC022B38881F80102C0EE0F3E
+:10102000FF1F8A95E2F72E2B22BB0894E11CF11CCE
+:10103000EC1408F482CFDF91CF911F910F91FF90B4
+:10104000EF90DF90CF90BF90AF900895FF920F93F5
+:101050001F93CF93DF93F82E042F442379F488B3A2
+:101060009091500521E030E002C0220F331F9A9585
+:10107000E2F7822788BBEB0110E014C022B3E42F13
+:10108000F0E0E05BFA4F308181E090E002C0880F31
+:10109000991F3A95E2F7282722BBEDCF89910E944C
+:1010A0007A071F5F1F15D0F3002369F488B390916E
+:1010B000500521E030E002C0220F331F9A95E2F77D
+:1010C000822788BB0FC022B3E02FF0E0E05BFA4F2D
+:1010D000308181E090E002C0880F991F3A95E2F7D5
+:1010E000282722BBDF91CF911F910F91FF90089588
+:1010F000EF92FF920F931F93C49885E40E947A07A2
+:10110000C49A85E88A95F1F7C49880E00E947A072E
+:10111000E82EFF2400E010E0102F0F2DFE2CEE240F
+:1011200080E00E947A0790E0A0E0B0E0E82AF92A87
+:101130000A2B1B2B102F0F2DFE2CEE2480E00E947B
+:101140007A07C49A282F30E040E050E02E293F294A
+:10115000402B512BB901CA011F910F91FF90EF90C5
+:101160000895C49881E00E947A07C49AC49881E0E7
+:101170000E947A07C49A08951F93182FC49881E09B
+:101180000E947A07C49AC498112311F082E001C02A
+:1011900083E00E947A07C49A1F9108951F93C19813
+:1011A000C19AC49884E40E947A07C49A15E8812FF2
+:1011B0008A95F1F7C49880E00E947A07C49A812F3B
+:1011C0008A95F1F7C49887E00E947A07C49A812F24
+:1011D0008A95F1F7C49883E00E947A07C49A812F18
+:1011E0008A95F1F7C49880E00E947A07C49A812F0B
+:1011F0008A95F1F7C49884E00E947A07C49A812FF7
+:101200008A95F1F7C49882E50E947A07C49A812FE3
+:101210008A95F1F7C49883E00E947A07C49A812FD7
+:101220008A95F1F7C49881E30E947A07C49A812FC6
+:101230008A95F1F7C49882E00E947A07C49A812FB8
+:101240008A95F1F7C4988EE80E947A07C49A812F94
+:101250008A95F1F7C49881E00E947A07C49A812F99
+:101260008A95F1F7C49883E00E947A07C49A812F87
+:101270008A95F1F7C49884E40E947A07C49A812F72
+:101280008A95F1F7C49880E00E947A07C49A1A956B
+:10129000F1F71F91089586B1866086B93098359A26
+:1012A00080B78F7180BF379A3E983F983D9887B13D
+:1012B000876087B9369A0895982F92959F70A2E516
+:1012C000B5E0FD01E90FF11D908190936A078F70E1
+:1012D000A80FB11D8C9180936B0710926C078AE662
+:1012E00097E00895EAE6F7E027E0482F50E060E352
+:1012F00031E3CA01022E02C0959587950A94E2F760
+:10130000DF01119680FF02C0308301C06083FD01C0
+:10131000215078F71C928AE697E00895292F2295AC
+:101320002F70A2E5B5E0FD01E20FF11D20812093B1
+:101330006A079F70FD01E90FF11D908190936B0783
+:10134000982F92959F70FD01E90FF11D9081909368
+:101350006C078F70A80FB11D8C9180936D07109250
+:101360006E078AE697E00895292F22952F70A2E54F
+:10137000B5E0FD01E20FF11D208120936A079F7007
+:10138000FD01E90FF11D908190936B07982F9295C5
+:101390009F70FD01E90FF11D908190936C078F7094
+:1013A000FD01E80FF11D808180936D07872F8295E5
+:1013B0008F70FD01E80FF11D808180936E077F70B3
+:1013C000FD01E70FF11D808180936F07862F8295C5
+:1013D0008F70FD01E80FF11D8081809370076F70A1
+:1013E000A60FB11D8C9180937107109272078AE647
+:1013F00097E00895CF93DF93EC01FC01019000206A
+:10140000E9F73197E81BAAE7B7E080E202C08D93C5
+:101410006150E617E0F3CD018E0F911DFC0102C073
+:1014200089918D93AE17BF07D9F71C928AE797E091
+:10143000DF91CF9108952F923F924F925F926F92DA
+:101440007F928F929F92AF92BF92CF92DF92EF9254
+:10145000FF920F931F93DF93CF930F92CDB7DEB719
+:101460003B014C012983242E85E0841710F435E0DC
+:10147000232EC401B30120E030E040E050E00E94A0
+:101480002F1287FD05C02AE6422E27E0522E0BC000
+:101490008DE280936A0797FA909497F890949BE670
+:1014A000492E97E0592EC401B3010E94830E5B01BF
+:1014B0006C01611571058105910521F480E3D2016C
+:1014C0008D932D0186017501332423C0C801B70116
+:1014D0002AE030E040E050E00E94B215E32DF0E059
+:1014E000EB57F94F6083E61AF10801091109E1147D
+:1014F000F1040105110561F0C801B7012AE030E0EF
+:1015000040E050E00E94B215C901DA017C018D0172
+:101510003394E114F10401051105C1F6C601B501CA
+:101520000E9411139B01AC01C401B3010E94FB0F87
+:101530007B018C018DE8A82E86E0B82E6501822CF7
+:1015400099243501680C791C22C0C801B70120E03C
+:1015500030E040E251E40E9459107B018C010E946E
+:10156000830EF6016083662379F070E0882777FDAB
+:101570008095982F0E945F129B01AC01C801B701B2
+:101580000E94FB0F7B018C010894C11CD11CC61466
+:10159000D704D9F6932D9150A92FBB27A7FDB0955D
+:1015A000AB57B94F07C08C91805DF2018083290150
+:1015B0009150119792012F5F3F4F97FFF4CF8EE22A
+:1015C000D2018C93F20105C0D5018D915D01805D42
+:1015D00080833196AC14BD04B9F7280D391DF9018B
+:1015E0001082F981FF2319F42AE637E006C08AE663
+:1015F00097E069810E94FA099C01C9010F90CF917F
+:10160000DF911F910F91FF90EF90DF90CF90BF90EF
+:10161000AF909F908F907F906F905F904F903F9092
+:101620002F900895BF92CF92DF92EF92FF920F9387
+:101630001F93CF93DF938B019C01B42E97FF0DC0B6
+:101640008DE280936A07CC24DD247601C01AD10A8A
+:10165000E20AF30ACBE6D7E004C06B017C01CAE6DC
+:10166000D7E080E0C8168AECD8068AE9E8068BE362
+:10167000F80658F0C701B60120E03AEC4AE95BE30E
+:101680000E94B215205D299309C080E0C81681EE42
+:10169000D80685EFE80685E0F80688F0C701B601B0
+:1016A00020E03AEC4AE95BE30E94B21520E031EE1B
+:1016B00045EF55E00E94B215205D299309C080E8EE
+:1016C000C81686E9D80688E9E80680E0F80688F0BA
+:1016D000C701B60120E031EE45EF55E00E94B2159A
+:1016E00020E836E948E950E00E94B215205D2993D0
+:1016F00009C080E4C81682E4D8068FE0E80680E0DE
+:10170000F80688F0C701B60120E836E948E950E05C
+:101710000E94B21520E432E44FE050E00E94B2157E
+:10172000205D299309C080EAC81686E8D80681E0C2
+:10173000E80680E0F80688F0C701B60120E432E44C
+:101740004FE050E00E94B21520EA36E841E050E058
+:101750000E94B215205D299309C080E1C81687E276
+:10176000D80680E0E80680E0F80688F0C701B601F8
+:1017700020EA36E841E050E00E94B21520E137E26D
+:1017800040E050E00E94B215205D299309C088EE28
+:10179000C81683E0D80680E0E80680E0F80688F006
+:1017A000C701B60120E137E240E050E00E94B215E7
+:1017B00028EE33E040E050E00E94B215205D29930E
+:1017C00006C084E6C816D104E104F10488F0C7011C
+:1017D000B60128EE33E040E050E00E94B21524E666
+:1017E00030E040E050E00E94B215205D299306C031
+:1017F0008AE0C816D104E104F10480F0C701B60103
+:1018000024E630E040E050E00E94B2152AE030E0EB
+:1018100040E050E00E94B215205D2993C701B60157
+:101820002AE030E040E050E00E94B215605D68833D
+:101830001982BB2019F42AE637E006C08AE697E051
+:101840006B2D0E94FA099C01C901DF91CF911F9174
+:101850000F91FF90EF90DF90CF90BF900895DF92AF
+:10186000EF92FF920F931F93CF93DF937B018C0135
+:10187000D42E80E0E8168AECF8068AE908078BE3A4
+:10188000180770F0C801B70120E03AEC4AE95BE3C1
+:101890000E94B215205D20936A07CBE6D7E00BC00B
+:1018A00080E0E81681EEF80685EF080785E0180766
+:1018B00098F0CAE6D7E0C801B70120E03AEC4AE95F
+:1018C0005BE30E94B21520E031EE45EF55E00E9447
+:1018D000B215205D29930BC080E8E81686E9F8066A
+:1018E00088E9080780E0180798F0CAE6D7E0C80141
+:1018F000B70120E031EE45EF55E00E94B21520E837
+:1019000036E948E950E00E94B215205D29930BC0EA
+:1019100080E4E81682E4F8068FE0080780E0180704
+:1019200098F0CAE6D7E0C801B70120E836E948E9EF
+:1019300050E00E94B21520E432E44FE050E00E94F3
+:10194000B215205D29930BC080EAE81686E8F806F8
+:1019500081E0080780E0180798F0CAE6D7E0C801E0
+:10196000B70120E432E44FE050E00E94B21520EAD3
+:1019700036E841E050E00E94B215205D29930BC08B
+:1019800080E1E81687E2F80680E0080780E01807A3
+:1019900098F0CAE6D7E0C801B70120EA36E841E08E
+:1019A00050E00E94B21520E137E240E050E00E9492
+:1019B000B215205D29930BC088EEE81683E0F80687
+:1019C00080E0080780E0180798F0CAE6D7E0C80171
+:1019D000B70120E137E240E050E00E94B21528EE66
+:1019E00033E040E050E00E94B215205D299308C02A
+:1019F00084E6E816F1040105110598F0CAE6D7E07F
+:101A0000C801B70128EE33E040E050E00E94B21573
+:101A100024E630E040E050E00E94B215205D2993BA
+:101A20000BC08AE0E816F1040105110518F4CAE6B6
+:101A3000D7E012C0CAE6D7E0C801B70124E630E01B
+:101A400040E050E00E94B2152AE030E040E050E073
+:101A50000E94B215205D2993C801B7012AE030E049
+:101A600040E050E00E94B215605D68831982DD207D
+:101A700019F42AE637E006C08AE697E06D2D0E9449
+:101A8000FA099C01C901DF91CF911F910F91FF903D
+:101A9000EF90DF900895CF93DF939C01462F97FF3F
+:101AA0000AC08DE280936A07EE27FF27E21BF30B43
+:101AB000CBE6D7E003C0FC01CAE6D7E087E2E0311D
+:101AC000F80740F0CF0160E177E20E948B15605D7E
+:101AD000699304C083E0E83EF80760F0CF0160E15D
+:101AE00077E20E948B1568EE73E00E948B15605DB3
+:101AF000699303C0E436F10560F0CF0168EE73E04E
+:101B00000E948B1564E670E00E948B15605D6993FE
+:101B100003C0EA30F10558F0CF0164E670E00E949E
+:101B20008B156AE070E00E948B15605D6993CF01B0
+:101B30006AE070E00E948B15805D888319824423DF
+:101B400019F42AE637E006C08AE697E0642F0E947F
+:101B5000FA099C01C901DF91CF9108959C01462F9C
+:101B600087E22031380758F0C90160E177E20E942E
+:101B70008B15605D60936A07EBE6F7E006C083E0D3
+:101B8000283E380770F0EAE6F7E0C90160E177E245
+:101B90000E948B1568EE73E00E948B15605D619367
+:101BA00005C02436310570F0EAE6F7E0C90168EEB9
+:101BB00073E00E948B1564E670E00E948B15605DF7
+:101BC000619308C02A30310518F4EAE6F7E00DC049
+:101BD000EAE6F7E0C90164E670E00E948B156AE06E
+:101BE00070E00E948B15605D6193C9016AE070E04E
+:101BF0000E948B15805D80831182442319F42AE6AC
+:101C000037E006C08AE697E0642F0E94FA099C013B
+:101C1000C9010895982F362F87FF08C08DE2809361
+:101C20006A07292F2195EBE6F7E003C0282FEAE6A3
+:101C3000F7E0243668F0822F90E068EE73E00E94AF
+:101C40009F1564E670E00E949F15605D619302C07D
+:101C50002A3050F0822F64E60E947F15892F6AE0B7
+:101C60000E947F15805D8193822F6AE00E947F151C
+:101C7000905D90831182332319F42AE637E006C081
+:101C80008AE697E0632F0E94FA099C01C901089532
+:101C90001F93482F162F843678F090E068EE73E09B
+:101CA0000E949F1564E670E00E949F15605D60933E
+:101CB0006A072BE637E007C08A3018F4EAE6F7E057
+:101CC0000DC02AE637E0842F64E60E947F15892F35
+:101CD0006AE00E947F15805DF9018193842F6AE09C
+:101CE0000E947F15905D90831182112319F42AE6DA
+:101CF00037E006C08AE697E0612F0E94FA099C014E
+:101D0000C9011F910895EF92FF920F931F937B01DA
+:101D10008C0120E030E040E05FE40E94FF11882366
+:101D20008CF0C801B70120E030E040E05FE40E94A1
+:101D3000FB0F0E94BD129B01AC012050304040407F
+:101D4000504806C0C801B7010E94BD129B01AC01FA
+:101D5000B901CA011F910F91FF90EF900895A0E083
+:101D6000B0E0E5EBFEE00C94D415DC012B01FA01A8
+:101D70009C91923008F439C1EB018881823008F4DB
+:101D800033C1943069F4843009F02FC111969C91CD
+:101D900011978981981709F428C1A3E6B5E025C1F8
+:101DA000843009F421C18230A9F4923009F01DC1B8
+:101DB0009A01AD0188E0EA010990AE01E9010992BA
+:101DC0009E018150C1F7E201898111969C9189237E
+:101DD000818308C1923009F407C112962D903C907E
+:101DE0001397EB018A819B811496AD90BD90CD90A5
+:101DF000DC901797EC80FD800E811F819101281BDC
+:101E0000390BB90137FF04C066277727621B730BB4
+:101E1000603271050CF061C0121613066CF53701C3
+:101E20004801062E04C096948794779467940A9488
+:101E3000D2F721E030E040E050E004C0220F331F31
+:101E4000441F551F6A95D2F7215030404040504002
+:101E50002E213F21402351232115310541055105F4
+:101E600021F021E030E040E050E079018A01E628ED
+:101E7000F728082919293CC0232BD1F1260E371E3B
+:101E800035014601062E04C0969487947794679492
+:101E90000A94D2F721E030E040E050E004C0220F85
+:101EA000331F441F551F6A95D2F7215030404040E0
+:101EB00050402A213B214C215D212115310541054E
+:101EC000510521F021E030E040E050E059016A0185
+:101ED000A628B728C828D9280BC0821593052CF04E
+:101EE0001C01AA24BB24650103C0EE24FF24870142
+:101EF00011969C91D20111968C91981709F445C0C6
+:101F0000992339F0A80197012A193B094C095D0969
+:101F100006C0A60195012E193F09400B510B57FD34
+:101F200008C01182338222822483358346835783FB
+:101F30001DC081E081833382228288279927DC01BA
+:101F4000821B930BA40BB50B84839583A683B78365
+:101F50000DC0220F331F441F551F24833583468332
+:101F60005783828193810197938382832481358172
+:101F700046815781DA01C9010197A109B1098F5F33
+:101F80009F4FAF4FBF4328F30BC091833382228210
+:101F9000EA0CFB1C0C1D1D1DE482F58206831783D1
+:101FA00083E08083248135814681578157FF1AC0A1
+:101FB000C901AA2797FDA095BA2F81709070A070D3
+:101FC000B0705695479537952795822B932BA42B68
+:101FD000B52B84839583A683B783828193810196F1
+:101FE00093838283DF0101C0D201CD01CDB7DEB77B
+:101FF000E2E10C94F015A0E2B0E0E1E0F0E10C9435
+:10200000E01569837A838B839C832D833E834F8382
+:102010005887E9E0EE2EF12CEC0EFD1ECE01019664
+:10202000B7010E94AE148E010F5E1F4FCE010596C0
+:10203000B8010E94AE148A8991E089278A8BC70172
+:10204000B801AE01475E5F4F0E94AF0E0E94D913E8
+:10205000A096E6E00C94FC15A0E2B0E0E2E3F0E12B
+:102060000C94E01569837A838B839C832D833E8354
+:102070004F835887F9E0EF2EF12CEC0EFD1ECE01B8
+:102080000196B7010E94AE148E010F5E1F4FCE0164
+:102090000596B8010E94AE14C701B801AE01475EB3
+:1020A0005F4F0E94AF0E0E94D913A096E6E00C94F9
+:1020B000FC15A0E2B0E0EFE5F0E10C94D4156983E3
+:1020C0007A838B839C832D833E834F835887CE01F5
+:1020D0000196BE01675F7F4F0E94AE14CE01059648
+:1020E000BE016F5E7F4F0E94AE149985923088F0DA
+:1020F00089898230C8F0943019F4823051F404C0D8
+:10210000843029F4923081F483E695E0C6C09230A1
+:1021100049F420E09A858A89981321E02A87CE0124
+:102120000996BBC0823049F420E09A858A899813C9
+:1021300021E02A8BCE014196B0C02D843E844F848D
+:1021400058886D887E888F88988CEE24FF248701BC
+:10215000AA24BB24650140E050E060E070E0E0E0CC
+:10216000F0E0C10181709070892BE9F0E60CF71C5A
+:10217000081D191D9A01AB012A0D3B1D4C1D5D1D4B
+:1021800080E090E0A0E0B0E0E614F704080519054F
+:1021900020F481E090E0A0E0B0E0BA01A901480F8E
+:1021A000591F6A1F7B1FAA0CBB1CCC1CDD1C97FE91
+:1021B00008C081E090E0A0E0B0E0A82AB92ACA2ACD
+:1021C000DB2A3196E032F10549F0660C771C881C59
+:1021D000991C5694479437942794C3CFFA85EA897B
+:1021E0002B893C898B859C85280F391F2E5F3F4F9B
+:1021F00017C0CA0181709070892B61F01695079500
+:10220000F794E79480E090E0A0E0B0E8E82AF92AAB
+:102210000A2B1B2B76956795579547952F5F3F4F58
+:1022200077FDE7CF0CC0440F551F661F771F17FDC2
+:102230004160EE0CFF1C001F111F21503040403048
+:1022400090E0590790E0690790E4790760F32B8FDD
+:102250003C8FDB01CA018F779070A070B070803422
+:102260009105A105B10561F447FD0AC0E114F1042F
+:102270000105110529F0405C5F4F6F4F7F4F40789B
+:102280001A8EFE1711F081E08A8F4D8F5E8F6F8F4F
+:1022900078A383E0898FCE0149960E94D913A09636
+:1022A000E2E10C94F015A8E1B0E0E9E5F1E10C946D
+:1022B000DC1569837A838B839C832D833E834F83D4
+:1022C0005887B9E0EB2EF12CEC0EFD1ECE010196E5
+:1022D000B7010E94AE148E010F5E1F4FCE0105960E
+:1022E000B8010E94AE142985223008F47EC03989D5
+:1022F000323010F4B8017CC08A859A8989278A8790
+:10230000243011F0223031F4231709F06EC063E657
+:1023100075E06EC0343039F41D861E861F86188A1B
+:102320001C861B8604C0323021F484E08987B70103
+:102330005FC02B853C858B899C89281B390B3C878A
+:102340002B87ED84FE840F851889AD88BE88CF88E1
+:10235000D88CEA14FB040C051D0540F4EE0CFF1CA0
+:10236000001F111F215030403C872B8720E030E0B8
+:1023700040E050E080E090E0A0E0B0E460E070E099
+:10238000EA14FB040C051D0540F0282B392B4A2BC1
+:102390005B2BEA18FB080C091D09B695A7959795C4
+:1023A0008795EE0CFF1C001F111F6F5F7F4F6F3171
+:1023B000710531F7DA01C9018F779070A070B070A4
+:1023C00080349105A105B10561F427FD0AC0E1142F
+:1023D000F1040105110529F0205C3F4F4F4F5F4F7D
+:1023E00020782D873E874F87588BBE01675F7F4FD0
+:1023F000CB010E94D9136896EAE00C94F815A8E185
+:10240000B0E0E5E0F2E10C94E01569837A838B8318
+:102410009C832D833E834F83588789E0E82EF12CDF
+:10242000EC0EFD1ECE010196B7010E94AE148E0186
+:102430000F5E1F4FCE010596B8010E94AE1489852C
+:10244000823040F08989823028F0C701B8010E94AB
+:10245000261501C08FEF6896E6E00C94FC15A8E104
+:10246000B0E0E5E3F2E10C94E01569837A838B83B5
+:102470009C832D833E834F83588789E0E82EF12C7F
+:10248000EC0EFD1ECE010196B7010E94AE148E0126
+:102490000F5E1F4FCE010596B8010E94AE148985CC
+:1024A000823040F08989823028F0C701B8010E944B
+:1024B000261501C081E06896E6E00C94FC15A8E0C2
+:1024C000B0E0E5E6F2E10C94DD159B01AC0183E0A0
+:1024D0008983DA01C9018827B7FD83959927AA273F
+:1024E000BB27B82E211531054105510519F482E0AD
+:1024F00089833AC08823A9F0203080E0380780E043
+:10250000480780E8580729F460E070E080E09FEC1D
+:1025100030C0EE24FF248701E21AF30A040B150BE6
+:1025200002C079018A018EE1C82ED12CDC82CB82D7
+:10253000ED82FE820F831887C801B7010E948A13BB
+:1025400001971816190684F4082E04C0EE0CFF1C1F
+:10255000001F111F0A94D2F7ED82FE820F831887A5
+:10256000C81AD90ADC82CB82BA82CE0101960E94B7
+:10257000D9132896E9E00C94F915ACE0B0E0E3EC4F
+:10258000F2E10C94E41569837A838B839C83CE01FA
+:102590000196BE016B5F7F4F0E94AE148D81823029
+:1025A00061F1823050F1843021F48E81882351F121
+:1025B0002EC02F81388537FD20C06E812F31310527
+:1025C0001CF06623F9F023C08EE190E0821B930B90
+:1025D00029853A854B855C8504C056954795379586
+:1025E00027958A95D2F76623B1F05095409530959E
+:1025F00021953F4F4F4F5F4F0EC020E030E040E04D
+:1026000050E009C02FEF3FEF4FEF5FE704C020E03D
+:1026100030E040E050E8B901CA012C96E2E00C94A9
+:102620000016A8E0B0E0E7E1F3E10C94DC157B01D3
+:102630008C01611571058105910519F482E089838A
+:1026400060C083E089838EE1C82ED12CDC82CB82EE
+:10265000ED82FE820F831887C801B7010E948A139A
+:10266000FC013197F7FF3BC0222733272E1B3F0B7E
+:1026700057016801022E04C0D694C794B794A7945A
+:102680000A94D2F740E050E060E070E081E090E032
+:10269000A0E0B0E004C0880F991FAA1FBB1F2A95B5
+:1026A000D2F70197A109B1098E219F21A023B1235F
+:1026B0000097A105B10521F041E050E060E070E035
+:1026C0004A295B296C297D294D835E836F83788736
+:1026D0008EE190E08E1B9F0B9C838B8312C0309702
+:1026E00081F00E2E04C0EE0CFF1C001F111F0A9477
+:1026F000D2F7ED82FE820F831887CE1ADF0ADC82C2
+:10270000CB821A82CE0101960E94D9132896EAE064
+:102710000C94F815EF92FF920F931F937B018C019D
+:1027200080E0E81680E0F80681E0080780E01807FE
+:1027300088F48FEFE816F1040105110531F028F057
+:1027400088E090E0A0E0B0E017C080E090E0A0E07A
+:10275000B0E012C080E0E81680E0F80680E00807EC
+:1027600081E0180728F088E190E0A0E0B0E004C024
+:1027700080E190E0A0E0B0E020E230E040E050E016
+:10278000281B390B4A0B5B0B04C016950795F79471
+:10279000E7948A95D2F7F701E559FA4F8081281B13
+:1027A000310941095109C9011F910F91FF90EF9023
+:1027B0000895DF92EF92FF920F931F93FC01E48044
+:1027C000F58006811781D1808081823048F480E0D5
+:1027D00090E0A0E1B0E0E82AF92A0A2B1B2BA5C063
+:1027E000843009F49FC0823021F4EE24FF24870155
+:1027F00005C0E114F1040105110519F4E0E0F0E071
+:1028000096C0628173819FEF623879070CF05BC0DC
+:1028100022E83FEF261B370B2A3131052CF020E050
+:1028200030E040E050E02AC0B801A701022E04C009
+:1028300076956795579547950A94D2F781E090E091
+:10284000A0E0B0E004C0880F991FAA1FBB1F2A9503
+:10285000D2F70197A109B1098E219F21A023B123AD
+:102860000097A105B10521F081E090E0A0E0B0E083
+:102870009A01AB01282B392B4A2B5B2BDA01C901BA
+:102880008F779070A070B07080349105A105B1056C
+:1028900039F427FF09C0205C3F4F4F4F5F4F04C002
+:1028A000215C3F4F4F4F5F4FE0E0F0E02030A0E071
+:1028B0003A07A0E04A07A0E45A0710F0E1E0F0E090
+:1028C00079018A0127C06038710564F5FB01E15880
+:1028D000FF4FD801C7018F779070A070B07080341F
+:1028E0009105A105B10539F4E7FE0DC080E490E043
+:1028F000A0E0B0E004C08FE390E0A0E0B0E0E80E1C
+:10290000F91E0A1F1B1F17FF05C016950795F794A0
+:10291000E794319687E016950795F794E7948A95A2
+:10292000D1F705C0EE24FF248701EFEFF0E06E2F12
+:10293000679566276795902F9F77D794DD24D79466
+:102940008E2F8695492F462B582F5D29B701CA0136
+:102950001F910F91FF90EF90DF900895FC01DB0134
+:10296000408151812281622F6F7770E0221F2227E0
+:10297000221F9381892F880F822B282F30E0991FE7
+:102980009927991F11969C93119721153105A9F547
+:10299000411551056105710511F482E037C082E8E7
+:1029A0009FEF13969C938E9312979A01AB0167E069
+:1029B000220F331F441F551F6A95D1F783E08C9374
+:1029C0000DC0220F331F441F551F12968D919C91ED
+:1029D0001397019713969C938E931297203080E063
+:1029E000380780E0480780E4580758F314962D9381
+:1029F0003D934D935C93179708952F3F310579F4DC
+:102A0000411551056105710519F484E08C93089511
+:102A100064FF03C081E08C9312C01C9210C02F573A
+:102A2000304013963C932E93129783E08C9387E06B
+:102A3000440F551F661F771F8A95D1F7706414964F
+:102A40004D935D936D937C93179708951F93DC01CD
+:102A5000FB019C91923008F447C08081823008F4D9
+:102A600043C0943051F411961C91843099F58181C2
+:102A7000682F70E0611B71093FC0843021F09230F3
+:102A800031F48230B9F18181882389F12DC011960A
+:102A90001C9111978230F1F081811817D9F41296A8
+:102AA0002D913C911397828193818217930794F023
+:102AB00028173907BCF014968D919D910D90BC910B
+:102AC000A02D2481358146815781281739074A076F
+:102AD0005B0718F4112341F00AC082179307A4077B
+:102AE000B50740F4112319F061E070E005C06FEF05
+:102AF0007FEF02C060E070E0CB011F910895991B49
+:102B000079E004C0991F961708F0961B881F7A95E4
+:102B1000C9F780950895AA1BBB1B51E107C0AA1FE6
+:102B2000BB1FA617B70710F0A61BB70B881F991F6E
+:102B30005A95A9F780959095BC01CD01089597FB12
+:102B4000092E07260AD077FD04D0E5DF06D0002045
+:102B50001AF4709561957F4F0895F6F790958195D9
+:102B60009F4F0895A1E21A2EAA1BBB1BFD010DC0A9
+:102B7000AA1FBB1FEE1FFF1FA217B307E407F5072D
+:102B800020F0A21BB30BE40BF50B661F771F881F09
+:102B9000991F1A9469F760957095809590959B019F
+:102BA000AC01BD01CF0108952F923F924F925F92E9
+:102BB0006F927F928F929F92AF92BF92CF92DF924D
+:102BC000EF92FF920F931F93CF93DF93CDB7DEB7B2
+:102BD000CA1BDB0B0FB6F894DEBF0FBECDBF099446
+:102BE0002A88398848885F846E847D848C849B849D
+:102BF000AA84B984C884DF80EE80FD800C811B81AB
+:102C0000AA81B981CE0FD11D0FB6F894DEBF0FBED9
+:0A2C1000CDBFED010895F894FFCF49
+:102C1A004C697374206F66204D535220636F6D6D3B
+:102C2A00616E64733A0A32392E30332E32303131C2
+:102C3A000A45206F7220652020202020202D2D207B
+:102C4A002020656E61626C65206368616E6E656CDA
+:102C5A003A207479706520653F20666F722064653A
+:102C6A007461696C65642068656C700A44206F72CF
+:102C7A0020642020202020202D2D202064697361CB
+:102C8A00626C65206368616E6E656C3A2074797057
+:102C9A006520643F20666F722064657461696C65A3
+:102CAA00642068656C700A6230206F72206231207D
+:102CBA002020202D2D202073776974636820686591
+:102CCA006172746265617420504134206F6E206FA6
+:102CDA0072206F66660A47202020202020202020AC
+:102CEA0020202D2D20202767657420414437373155
+:102CFA003927202020202020202D3E206D65617359
+:102D0A0075726520726573697374616E6365732089
+:102D1A00616761696E0A6720202020202020202018
+:102D2A0020202D2D2020276765742041546D65676A
+:102D3A006120616463272020202D3E206D65617328
+:102D4A0075726520766F6C74616765732020202028
+:102D5A00616761696E0A50202020202020202020EF
+:102D6A0020202D2D20206765742026207072696E20
+:102D7A00742041443737313920696E66696E697447
+:102D8A006C79200A7020202020202020202020205A
+:102D9A002D2D20206765742026207072696E74209C
+:102DAA0041546D6567612061646320696E66696E6E
+:102DBA0069746C79200A732020202020202020208A
+:102DCA0020202D2D20207072696E74207374617416
+:102DDA0075730A48206F7220682020202020202D39
+:102DEA002D20207072696E7420746869732068657A
+:102DFA006C700A000A6572726F723A20696E7661A7
+:102E0A006C69642027656E61626C6527206F722089
+:102E1A002764697361626C652773746174656D6593
+:102E2A006E742E0A0075736167653A205B457C658E
+:102E3A007C447C645D5B727C767C687C705D5B3014
+:102E4A002E2E31355D0A00652E672E3A20204576F2
+:102E5A003120202D2D3E20656E61626C6520766FD3
+:102E6A006C74616765206368616E6E656C20310AF7
+:102E7A0000652E672E3A202064723020202D2D3EC8
+:102E8A002064697361626C65207265736973746129
+:102E9A006E6365206368616E6E656C20300A00613E
+:102EAA006437373139206368616E6E656C733A2016
+:102EBA00313520646F776E746F20303A0A0061648E
+:102ECA0063206368616E6E656C7320313520646FB0
+:102EDA00776E746F20303A0A20692E652E206C6551
+:102EEA0066742069732070726573737572652061E8
+:102EFA006E642068756D6964697479202E2E2E209F
+:102F0A00726967687420697320766F6C746167658B
+:102F1A000A000A20492077696C6C20737769746308
+:102F2A006820006F6E20006F66662000207265734D
+:102F3A00697374616E6365206368616E6E656C2087
+:102F4A000020766F6C74616765206368616E6E65D8
+:102F5A006C20002068756D69646974792063686102
+:102F6A006E6E656C200020707265737375726520D1
+:102F7A006368616E6E656C20000A2044414D4E21E3
+:102F8A0020746869732073686F756C64206E657647
+:102F9A0065722068617070656E2D20656E61626C65
+:102FAA00652F64697361626C6520737769746368FD
+:102FBA002D63617365210A000A686561727462652E
+:102FCA00617420006F66660A006F6E0A0074696D8C
+:102FDA00653A00207365632E0A000A6465627567A4
+:102FEA00206D6F646520000A2072657369737461CD
+:102FFA006E6365284F686D290A20286E6F74653ADA
+:10300A00206F6E6C7920656E61626C6564206368FE
+:10301A00616E6E656C7320617265207072696E7480
+:10302A006564293A0A007C5200202020007C0A00AC
+:10303A002020202020207C00566F6C746167652850
+:10304A006D56292C202048756D6964697479286D3C
+:10305A0056292020262020507265737375726528C0
+:10306A006D56293A0A007C2056007C2048007C20B4
+:10307A00500020202020202000567C00527C007224
+:10308A0065636569766520627566666572206F7626
+:10309A006572666C6F77202E2E2E207061727369AE
+:1030AA006E67206E6F770A0050432073656E6469FD
+:1030BA006E6720746F2066617374210A005839C8DC
+:1030CA004001FA0177656C636F6D6520746F3A0A87
+:1030DA00204D535220636F6D6D616E6420696E746A
+:1030EA0065726661636520312E30200A2062756937
+:1030FA006C643A2032392E30332E323031300A00A5
+:10310A000304303132333435363738394142434497
+:10311A004546000000000000000000000102020312
+:10312A000303030404040404040404050505050553
+:10313A000505050505050505050505060606060630
+:10314A000606060606060606060606060606060615
+:10315A000606060606060606060606070707070700
+:10316A0007070707070707070707070707070707E5
+:10317A0007070707070707070707070707070707D5
+:10318A0007070707070707070707070707070707C5
+:10319A0007070707070707070707070808080808B0
+:1031AA000808080808080808080808080808080895
+:1031BA000808080808080808080808080808080885
+:1031CA000808080808080808080808080808080875
+:1031DA000808080808080808080808080808080865
+:1031EA000808080808080808080808080808080855
+:1031FA000808080808080808080808080808080845
+:10320A000808080808080808080808080808080834
+:0C321A0008080808080808080808080050
+:00000001FF
Index: /firmware/MSR/msr.aws
===================================================================
--- /firmware/MSR/msr.aws	(revision 10588)
+++ /firmware/MSR/msr.aws	(revision 10588)
@@ -0,0 +1,1 @@
+<AVRWorkspace><IOSettings><CurrentRegisters/></IOSettings><part name="ATMEGA32"/><Files><File00000 Name="C:\Documents and Settings\daqct3\Desktop\MSR_29.03.11_10h\MSR\src\MSR.c" Position="179 96 1378 492" LineCol="396 0"/></Files></AVRWorkspace>
Index: /firmware/MSR/src/MSR.c
===================================================================
--- /firmware/MSR/src/MSR.c	(revision 10588)
+++ /firmware/MSR/src/MSR.c	(revision 10588)
@@ -0,0 +1,711 @@
+//-----------------------------------------------------------------------------
+#include "typedefs.h"
+#include "application.h"
+#include "spi_master.h"
+#include "ad7719_adc.h"
+#include "atmega_adc.h"    
+#include "usart.h"
+#include "macros.h"
+//#include "interpol.h"
+//#include "w5100_spi_interface.h"
+#include <avr/interrupt.h>
+#include <avr/wdt.h>
+#include <stdlib.h>
+//-----------------------------------------------------------------------------
+// definition of some functions:
+// these function are implemented in this file, this is not doog coding style.
+// sooner or later, they will be moved into more apropriate files.
+U08	increase_adc (U08 channel);
+U08	increase_ad7719 (U08 channel);
+void Set_V_Muxer (U08 channel);
+void Set_T_Muxer(U08 channel);
+void parse(); 
+void check_if_measured_all() ;
+void print_ad7719_nicely(bool with_header, bool with_LF) ;
+void print_adc_nicely(bool with_header, bool with_LF) ;
+
+void print_invalid_enable_statement();
+void print_help() ;  // is not printin help at the moment .... eats up too much RAM
+void print_adc_enable_status(bool with_headline);
+void print_ad7719_enable_status(bool with_headline) ;
+
+bool check_if_adc_measurement_done();
+bool check_if_ad7719_measurement_done();
+
+
+// end of function definition:
+//-----------------------------------------------------------------------------
+
+// Reference resistance
+	float r_reference = 6.257;
+
+// MAIN WORKFLOW GLOBAL VARIABLES
+	bool verbose;
+	bool heartbeat_enable;
+
+// USART global variables
+	U08 usart_rx_buffer[USART_RX_BUFFER_SIZE];
+	U08 usart_tx_buffer[USART_TX_BUFFER_SIZE];
+	U08 usart_received_chars;
+	U08 usart_rx_buffer_index = 0;
+	U08 usart_tx_buffer_index = 0;
+  	U08 usart_last_char; 					// last received char
+
+// USART FLAGS
+	bool usart_tx_buffer_overflow = false;	// true if usart_tx_buffer was full.
+	bool usart_rx_ready = false;			// EOL was received, parser needs to be called
+	
+// TIMER global variable
+	volatile U32 local_ms = 0;
+
+// AD7719 global variables
+	#define TEMP_CHANNELS 16
+	#define CHANNEL_BITMAP 2
+	#define AD7719_READINGS_UNTIL_SETTLED 3 // bei3:480ms
+	U32 ad7719_values[TEMP_CHANNELS];
+	U08 ad7719_enables[CHANNEL_BITMAP];
+	U08 ad7719_channels_ready[CHANNEL_BITMAP];
+	U08 ad7719_readings_since_last_muxing = 0;
+	U08 ad7719_current_channel = 0;
+	U32 ad7719_current_reading = 0;
+	bool ad7719_measured_all = false;
+	bool ad7719_values_printed = true;
+	bool ad7719_print_endless = false;
+	
+// ATMEGA ADC global variables
+	#define V_CHANNELS 16
+	#define V_BITMAP 2
+	#define ADC_READINGS_UNTIL_SETTLED 1
+	U08 adc_readings_until_mean=250;
+	U32 adc_values[V_CHANNELS]; // stores measured voltage in steps of 16mV
+	U08 adc_enables[V_BITMAP];
+	U08 adc_channels_ready[V_BITMAP];
+	U08 adc_readings_since_last_muxing = 0;
+	U08 adc_current_channel = 0;
+	U16 adc_current_reading = 0;
+	bool adc_measured_all = false;
+	bool adc_values_printed = true;
+	bool adc_print_endless = false;
+
+	bool debug_mode = false;
+	
+	//U32 hb_counter = 0;
+
+//-----------------------------------------------------------------------------
+//   M A I N    ---   M A I N    ---   M A I N    ---   M A I N    ---  M A I N    
+//-----------------------------------------------------------------------------
+int main(void)
+{
+	app_init();		  // Setup: Watchdog and I/Os
+	usart_init();		// Initialize serial interface   
+	spi_init(); 		// Initialize SPI interface as master
+	ad7719_init(); 		// Initialize AD7719 ADC as SPI slave 
+	atmega_adc_init();
+
+// TIMER2 is used as local clock:
+// configure timer 2
+	TCCR2 = (1<<WGM21); // CTC Modus
+	TCCR2 |= (1<<CS21) | (1<<CS20); // Prescaler 64 --> counts up every 8us
+	OCR2 = 125-1; 					// --> output compare interrupt occurs every 125 x 8us = 1ms
+	// Compare Interrupt erlauben
+	TIMSK |= (1<<OCIE2);
+
+  //  Enable interrupts
+  sei();              
+
+  PORTB &= ~(1<<PB2);
+  
+for ( U08 i=0; i<CHANNEL_BITMAP; ++i ) {
+	ad7719_enables[1]=0x00;
+	ad7719_enables[0]=0xFF;
+
+//	ad7719_enables[i]=0x00;
+	ad7719_channels_ready[i]=0;
+	}
+
+for ( U08 i=0; i<V_BITMAP; ++i ) {
+	adc_enables[1]=0x33;
+	adc_enables[0]=0xFF;
+//	adc_enables[i]=0x00;
+	adc_channels_ready[i]=0;
+}
+
+
+	static U08 welcome[]="welcome to:\n MSR command interface 1.0 \n build: 29.03.2010\n";
+	usart_write_str(welcome);
+	print_help();
+	print_adc_enable_status(true);
+	usart_write_char('\n');
+	print_ad7719_enable_status(true);
+	usart_write_char('\n');
+	usart_write_str((pU08)"time:");
+	usart_write_float((float)local_ms/1000 , 1,7);
+	usart_write_str((pU08)" sec.\n");
+
+//MAIN LOOP
+while (1)
+{
+	if (check_if_adc_measurement_done()) {
+		if(adc_print_endless){
+			usart_write_str((pU08)"V|");
+			usart_write_float((float)local_ms/1000 , 1,4);
+			print_adc_nicely(false,true);
+			for ( U08 i=0; i<V_BITMAP; ++i ) {
+				adc_channels_ready[i]=0;
+			}
+		} else 
+		if ( !adc_values_printed) {
+			adc_values_printed = true;
+			print_adc_nicely(true,true);
+		}
+	} 
+
+	if (check_if_ad7719_measurement_done()) {
+		if(ad7719_print_endless){
+			usart_write_str((pU08)"R|");
+			usart_write_float((float)local_ms/1000 , 1,4);
+			print_ad7719_nicely(false,true);
+			for ( U08 i=0; i<CHANNEL_BITMAP; ++i ) {
+				ad7719_channels_ready[i]=0;
+			}
+		} else 
+		if ( !ad7719_values_printed) {
+			ad7719_values_printed = true;
+			print_ad7719_nicely(true,true);
+		}
+	} 
+
+//----------------------------------------------------------------------------
+
+	if (heartbeat_enable) {
+		PORTA ^= (1<<PA4); // toggle PA4 --> heartbeat
+	
+		// warte 100.000 heartbeats und schreibe die Zeit raus
+		//hb_counter++;
+		//if (hb_counter == 100000){
+		//	hb_counter = 0;
+		//	usart_write_float((float)local_ms/1000 , 1,7);
+		//	usart_write_str((pU08)" sec.\n");
+		//}
+	}
+		
+//----------------------------------------------------------------------------
+	//IF we need to send away one byte, and ready to send
+
+	if ( (usart_tx_buffer_index > 0) && (UCSRA & (1<<UDRE)) ) { 
+		UDR = usart_tx_buffer[0];
+		// THis is shit
+		for (U08 i=0 ; i < USART_TX_BUFFER_SIZE; ++i) {
+			usart_tx_buffer[i] = usart_tx_buffer[i+1];
+		}
+		usart_tx_buffer_index--;
+	}
+//----------------------------------------------------------------------------
+
+	//IF we just received one byte
+	if ( UCSRA & (1<<RXC) )
+	{
+		usart_last_char = UDR;  // read the byte from ATmega internal buffer
+								// what are we going to do with this byte?
+		if (usart_rx_buffer_index < USART_RX_BUFFER_SIZE ) // if space in the buffer ... we store it.
+		{
+			usart_rx_buffer[usart_rx_buffer_index] = usart_last_char;
+			usart_rx_buffer_index++;
+			if (usart_last_char == '\n'){ // if EOL was received
+				usart_rx_buffer_index--;
+				usart_rx_buffer[usart_rx_buffer_index] = 0;
+				usart_rx_ready = true;
+			}
+		} else {													// if no space in buffer ... we try to parse()
+			usart_write_str((pU08)"receive buffer overflow ... parsing now\n");
+			usart_rx_ready = true;
+		}
+	} 
+
+//----------------------------------------------------------------------------
+
+	//IF USART DOR bit is set, PC is sending data to fast!!!
+	if ( UCSRA & (1<<DOR) ){
+		usart_write_str((pU08)"PC sending to fast!\n");
+		usart_last_char = UDR;
+		// flush TX_buffer and write warning message in
+		// maybe even switch off every measurement. ?
+	}
+//----------------------------------------------------------------------------
+
+	//IF TX_BUFFER was overrun.	
+	if (usart_tx_buffer_overflow) {
+		// flash TX_buffer and write warning message in
+		// maybe even switch off every measurement. ?
+		//
+		// this should only happen, in verbose mode and with low baudrates.
+	}
+//----------------------------------------------------------------------------
+	
+	//IF one command was received. 
+	//	-It is not allowed to send more than one command between two '\n'
+	if (usart_rx_ready){ 
+		parse();
+		usart_rx_ready = false;
+		for ( U08 i =0 ; i < USART_RX_BUFFER_SIZE; i++){
+			usart_rx_buffer[i]=0;
+		}
+		usart_rx_buffer_index = 0;
+		
+	}
+//----------------------------------------------------------------------------
+
+	//IF ATmega internal ADC did finish a conversion --every 200us
+	if ( (ADCSRA & (1<<ADIF)) && !adc_measured_all) {
+		adc_current_reading = (U16)ADCL;
+		adc_current_reading += (U16)ADCH<<8;
+		if (adc_readings_since_last_muxing == ADC_READINGS_UNTIL_SETTLED+adc_readings_until_mean-1) {
+			adc_channels_ready[adc_current_channel/8] |= (1<<(adc_current_channel%8));
+			adc_current_channel = increase_adc (adc_current_channel);
+			adc_values[adc_current_channel] = 0;
+			Set_V_Muxer(adc_current_channel);
+			adc_readings_since_last_muxing = 0;
+			_delay_ms(10);
+		}
+		else if (adc_readings_since_last_muxing >= ADC_READINGS_UNTIL_SETTLED-1) {
+			adc_values[adc_current_channel] += adc_current_reading;
+			++adc_readings_since_last_muxing;
+		}
+		else  {
+			++adc_readings_since_last_muxing;
+		}
+
+	}
+//----------------------------------------------------------------------------
+
+	//IF AD7719 ADC just finished a conversion -- every 60ms
+	
+	if (AD7719_IS_READY() && !ad7719_measured_all) {
+	
+
+			ad7719_current_reading = read_adc(); // --takes at 4MHz SCLK speed about 6us
+		// AD7719 is only read out if settled. saves time.	
+		if (ad7719_readings_since_last_muxing == AD7719_READINGS_UNTIL_SETTLED-1) {
+			ad7719_values[ad7719_current_channel] = ad7719_current_reading;
+			ad7719_readings_since_last_muxing=0;
+			if (debug_mode) {
+				usart_write_U32_hex(ad7719_current_reading);
+				usart_write_char('\n');
+				usart_write_char('\n');
+			}
+			// now prepare the data to be send away via USART.
+			
+			// note that this channel is ready, now and 
+			// proceed to the next enabled channel.
+			ad7719_channels_ready[ad7719_current_channel/8] |= (1<<(ad7719_current_channel%8));
+			ad7719_current_channel = increase_ad7719 (ad7719_current_channel);
+			Set_T_Muxer(ad7719_current_channel);
+		} else { // the AD7719 did not settle yet, we discard the reading
+			++ad7719_readings_since_last_muxing;
+			if (debug_mode) {
+				usart_write_U32_hex(ad7719_current_reading);
+				usart_write_char('\n'); 
+			}
+
+			// current reading is not used for anything else
+		}
+	}
+
+
+} // end of MAIN LOOP
+
+} // end of main function
+//-----------------------------------------------------------------------------
+//    E N D     E N D     E N D     E N D     E N D     E N D     E N D     
+//-----------------------------------------------------------------------------
+
+
+ISR (TIMER2_COMP_vect)
+{
+ ++local_ms;
+}
+
+U08	increase_adc (U08 channel){
+U08 effective_channel;
+	for ( U08 increase = 1 ; increase <= V_CHANNELS; increase++)
+	{
+		effective_channel = (channel + increase) % (V_CHANNELS);
+		if (adc_enables[effective_channel/8] & (1<<effective_channel%8))
+			return effective_channel;
+	}
+	return channel;
+} // end if increase_adc;
+
+U08	increase_ad7719 (U08 channel){
+U08 effective_channel;
+	for ( U08 increase = 1 ; increase <= TEMP_CHANNELS; increase++)
+	{
+		effective_channel = (channel + increase) % (TEMP_CHANNELS);
+		if (ad7719_enables[effective_channel/8] & (1<<effective_channel%8))
+			return effective_channel;
+	}
+	return channel;
+} // end if increase_adc;
+
+// Sets voltage Muxer to current channel
+void Set_V_Muxer (U08 channel){
+	PORTC = (PORTC & 0xF0) | (0x0F & channel); 
+}
+
+void Set_T_Muxer(U08 channel) {
+	PORTA = (PORTA & 0xF0) | (0x0F & channel); // Here the muxer is switched.
+}
+
+bool check_if_adc_measurement_done(){
+	adc_measured_all = true;
+	for ( U08 i=0; i<V_BITMAP; ++i ) {
+		if ((adc_enables[i] ^ adc_channels_ready[i]) != 0x00) {
+			adc_measured_all = false;
+			break;
+		}
+	}
+	return adc_measured_all;
+}
+
+bool check_if_ad7719_measurement_done(){
+	ad7719_measured_all = true;
+	for ( U08 i=0; i<CHANNEL_BITMAP; ++i ) {
+		if ((ad7719_enables[i] ^ ad7719_channels_ready[i]) != 0x00) {
+			ad7719_measured_all = false;
+			break;
+		}
+	}
+	return ad7719_measured_all;
+}
+
+void print_ad7719_nicely(bool with_header, bool with_LF) {
+	float value_in_ohms;
+	if (with_header) {
+
+		usart_write_str((pU08)"\n resistance(Ohm)\n (note: only enabled channels are printed):\n");
+
+		// Überschrift alles in einer Zeile, hoffentlich sieht das gut aus.
+		for (U08 i=0; i< TEMP_CHANNELS;++i) {
+			usart_write_str((pU08)"|R");						// 1 letter -- R
+			usart_write_U08(i, 2);							// 2 letters  -- the channel number 
+			usart_write_str((pU08)"   ");  				// 5 spaces
+		}
+		usart_write_str((pU08)"|\n");
+	}
+		
+	// Jetzt die Werte, auch alle in einer Zeile
+	usart_write_char('|');
+	for (U08 i=0; i< TEMP_CHANNELS;++i) {
+		
+		if (ad7719_enables[i/8] & (1<<i%8))
+		{
+			value_in_ohms = (r_reference * 1024 * ad7719_values[i]) / ((U32)1 << 25);
+			if (value_in_ohms < 1000.0)
+				usart_write_char(' ');
+			if (value_in_ohms < 100.0)
+				usart_write_char(' ');
+			if (value_in_ohms < 10.0)
+				usart_write_char(' ');
+			usart_write_float(value_in_ohms, 1, 5);  	// 6 letters .. 1002.4 ohm .. this is 6 letter .. the dot . is also a letter
+			usart_write_char('|');				// 2 spaces	
+		} else {
+			usart_write_str((pU08)"      |");			// or 8 spaces	
+		}
+	}
+	if (with_LF)
+		usart_write_char('\n');
+}
+
+void print_adc_nicely(bool with_header, bool with_LF) {
+
+	if (with_header) {
+		usart_write_str((pU08)"Voltage(mV),  Humidity(mV)  &  Pressure(mV):\n");
+
+		for (U08 i=0; i < 8; ++i) {
+			usart_write_str((pU08)"| V");
+			usart_write_U08(i, 1); //data
+			usart_write_str((pU08)"   ");
+		}
+
+		for (U08 i=0; i < 4; ++i) {
+			usart_write_str((pU08)"| H");
+			usart_write_U08(i, 1); //data
+			usart_write_str((pU08)"   ");
+		}
+		for (U08 i=0; i < 4; ++i) {
+			usart_write_str((pU08)"| P");
+			usart_write_U08(i, 1); //data
+			usart_write_str((pU08)"   ");
+		}
+		usart_write_str((pU08)"|\n");
+	}
+
+	// Jetzt die gemessenen Werte und zwar nur die Spannungen
+	for (U08 i=0; i < 16; ++i) {
+		usart_write_char('|');
+		if (adc_enables[i/8] & (1<<i%8))
+			usart_write_U32( ( ( adc_values[i] * 4 + 2 ) / adc_readings_until_mean ) , 6 );
+		else
+			usart_write_str((pU08)"      "); 
+	}
+	usart_write_char('|');
+
+	if (with_LF)
+		usart_write_char('\n');
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////// P A R S E R /////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////////////////////////
+// this method parses the data, 
+// which came in via USART
+// later it might as well parse the data from ethernet.
+void parse() {
+
+U08 input_number = 0;
+bool enable = false;
+// look at first byte
+// I hope, I can manage to use one byte commands
+	usart_rx_buffer[USART_RX_BUFFER_SIZE-1] = 0;
+	usart_write_char(' ');
+	usart_write_str(usart_rx_buffer);
+	usart_write_char('\n');
+	//usart_write_str((pU08)"\n received number of bytes:");
+	//usart_write_U08(usart_rx_buffer_index,3);
+
+	if (usart_rx_buffer_index >0) {
+		switch (usart_rx_buffer[0]) {
+			case 'E': 		// user wants to enable/disable something
+			case 'e':
+				enable = true;
+			case 'D':
+			case 'd':
+			
+				if (usart_rx_buffer_index>=1) {  // let's see what.
+					if ( 	usart_rx_buffer[1] != 'r'  &&
+							usart_rx_buffer[1] != 'v'  &&
+							usart_rx_buffer[1] != 'h'  &&
+							usart_rx_buffer[1] != 'p' )
+						{
+							print_invalid_enable_statement();
+							break;
+						}
+				}
+				
+				input_number = 0;
+				if (usart_rx_buffer_index >2) {  // lets check the first digit
+					if ( usart_rx_buffer[2] >= '0' && usart_rx_buffer[2] <= '9' ) {
+						input_number = usart_rx_buffer[2] - '0';
+					} else {
+						print_invalid_enable_statement();
+						break;
+					}
+				}
+				if (usart_rx_buffer_index >3) {  // lets check the 2nd digit
+					if ( usart_rx_buffer[3] >= '0' && usart_rx_buffer[3] <= '9' ) {
+						input_number = 10*input_number + usart_rx_buffer[3] - '0';
+					} else {
+						// okay as well ... if the second digit is missing .. 
+						// we might have trailing spaces
+						// that's okay .. we just accept the first number.
+					}
+				}
+				if (usart_rx_buffer_index>2) {
+					usart_write_str((pU08)"\n I will switch ");
+					if (enable) 
+						usart_write_str((pU08)"on ");
+					else
+						usart_write_str((pU08)"off ");
+					
+					// now we know, what the user wanted ... and we need to do it.
+					switch (usart_rx_buffer[1]) {
+						case 'r':
+							if (enable)
+								ad7719_enables[input_number/8] |= (1<<(input_number%8));
+							else {
+								ad7719_enables[input_number/8] &= ~(1<<(input_number%8));
+								ad7719_channels_ready[input_number/8] &= ~(1<<(input_number%8));
+								}
+							usart_write_str((pU08)" resistance channel ");
+							usart_write_U08(input_number,2);
+							usart_write_char('\n');
+							break;
+						case 'v':
+							if (enable)
+								adc_enables[input_number/8] |= (1<<(input_number%8));
+							else {
+								adc_enables[input_number/8] &= ~(1<<(input_number%8));
+								adc_channels_ready[input_number/8] &= ~(1<<(input_number%8));
+								}
+							usart_write_str((pU08)" voltage channel ");
+							usart_write_U08(input_number,2);
+							usart_write_char('\n');
+							break;
+							
+						case 'h':
+							if (enable)
+								adc_enables[1] |= (1<<(input_number%4));
+							else {
+								adc_enables[1] &= ~(1<<(input_number%4));
+								adc_channels_ready[1] &= ~(1<<(input_number%4));
+								}
+							usart_write_str((pU08)" humidity channel ");
+							usart_write_U08(input_number,2);
+							usart_write_char('\n');
+							break;
+						case 'p':
+							if (enable)
+								adc_enables[1] |= (1<<((input_number%4) + 4));
+							else {
+								adc_enables[1] &= ~(1<<((input_number%4) + 4));
+								adc_channels_ready[1] &= ~(1<<((input_number%4) + 4));
+								}
+							usart_write_str((pU08)" pressure channel ");
+							usart_write_U08(input_number,2);
+							usart_write_char('\n');
+							break;
+						default:
+							usart_write_str((pU08)"\n DAMN! this should never happen"
+							"- enable/disable switch-case!\n");
+							break;
+					}
+					
+					
+					
+				}// end of if usart_rx_buffer_index>2  --> this should not be necessary at all
+				break;
+				
+			case 'b':
+				usart_write_str((pU08)"\nheartbeat ");
+				heartbeat_enable = true;
+				if (usart_rx_buffer[1] == '0'){
+					heartbeat_enable = false;
+					usart_write_str((pU08)"off\n");
+				} else {
+					usart_write_str((pU08)"on\n");
+				}
+				break;
+			case 'G': 			// GET the Temperature channels, which are enabled
+				ad7719_values_printed = false;
+				for ( U08 i=0; i<CHANNEL_BITMAP; ++i ) {
+					ad7719_channels_ready[i]=0;
+				}
+				break;
+			case 'g':			// GET the voltage/current/humidity channels, which are enabled
+				adc_values_printed = false;
+				for ( U08 i=0; i<V_BITMAP; ++i ) {
+					adc_channels_ready[i]=0;
+				}
+				break;
+
+			case 'p':
+					adc_print_endless = true;
+				if (usart_rx_buffer[1] == '0')
+					adc_print_endless = false;
+				break;		
+
+			case 'P':
+					ad7719_print_endless = true;
+				if (usart_rx_buffer[1] == '0')
+					ad7719_print_endless = false;
+				break;		
+				
+
+			case 's':			
+				print_adc_enable_status(true);
+				usart_write_char('\n');
+
+				print_ad7719_enable_status(true);
+				usart_write_char('\n');
+			
+				usart_write_str((pU08)"time:");
+				usart_write_float((float)local_ms/1000 , 1,7);
+				usart_write_str((pU08)" sec.\n");
+				break;	
+
+			case '!':
+				usart_write_str((pU08)"\ndebug mode ");
+				debug_mode = true;
+				if (usart_rx_buffer[1] == '0'){
+					debug_mode = false;
+					usart_write_str((pU08)"off\n");
+				} else {
+					usart_write_str((pU08)"on\n");
+				}
+				break;		
+				
+			case 'h':
+			case 'H':
+				print_help();
+				break;
+		}
+	} else
+	{
+		// zero bytes received
+	}
+	
+	
+	for (U08 i=0; i<USART_RX_BUFFER_SIZE; ++i)
+		usart_rx_buffer[i] = 0;
+}
+
+
+void print_invalid_enable_statement(){
+usart_write_str((pU08)"\nerror: invalid 'enable' or 'disable'statement.\n");
+usart_write_str((pU08)"usage: [E|e|D|d][r|v|h|p][0..15]\n");
+usart_write_str((pU08)"e.g.:  Ev1  --> enable voltage channel 1\n");
+usart_write_str((pU08)"e.g.:  dr0  --> disable resistance channel 0\n");
+}
+
+void print_help() {
+
+usart_write_str((pU08)
+"List of MSR commands:\n29.03.2011\n" 
+"E or e      --   enable channel: type e? for detailed help\n" 
+"D or d      --  disable channel: type d? for detailed help\n" 
+"b0 or b1    --  switch heartbeat PA4 on or off\n" 
+"G           --  'get AD7719'       -> measure resistances again\n" 
+"g           --  'get ATmega adc'   -> measure voltages    again\n" 
+"P           --  get & print AD7719 infinitly \n" 
+"p           --  get & print ATmega adc infinitly \n" 
+"s           --  print status\n" 
+"H or h      --  print this help\n" 
+);
+
+}
+
+void print_adc_enable_status(bool with_headline) {
+
+	if (with_headline) {
+		usart_write_str((pU08)"adc channels 15 downto 0:\n i.e. left is pressure and humidity ... right is voltage\n");
+	}
+	usart_write_U08_bin(adc_enables[1]);	
+	usart_write_char(' ');
+	usart_write_U08_bin(adc_enables[0]);	
+	usart_write_char(' ');
+	
+	usart_write_char('\n');
+	usart_write_U08_bin(adc_channels_ready[1]);
+	usart_write_char(' ');
+	usart_write_U08_bin(adc_channels_ready[0]);
+	usart_write_char(' ');
+}
+
+void print_ad7719_enable_status(bool with_headline) {
+
+	if (with_headline) {
+		usart_write_str((pU08)"ad7719 channels: 15 downto 0:\n");
+	}
+	usart_write_U08_bin(ad7719_enables[1]);
+	usart_write_char(' ');
+	usart_write_U08_bin(ad7719_enables[0]);
+	usart_write_char(' ');
+
+	usart_write_char('\n');
+	usart_write_U08_bin(ad7719_channels_ready[1]);
+	usart_write_char(' ');
+	usart_write_U08_bin(ad7719_channels_ready[0]);
+	
+}
+
Index: /firmware/MSR/src/UARTBUF/MAIN.C
===================================================================
--- /firmware/MSR/src/UARTBUF/MAIN.C	(revision 10588)
+++ /firmware/MSR/src/UARTBUF/MAIN.C	(revision 10588)
@@ -0,0 +1,49 @@
+/************************************************************************/
+/*                                                                      */
+/*                      UART test program                               */
+/*                                                                      */
+/*              Author: Peter Dannegger                                 */
+/*                                                                      */
+/************************************************************************/
+#include "main.h"
+#include "uart0.h"
+
+
+void delay_1ms( u16 i )
+{
+  do{
+    _delay_ms( 1 );
+  }while( --i );
+}
+
+
+int main( void )
+{
+  init_uart0( (u16)(XTAL / BAUD / 16 - 0.5) );
+  sei();
+  delay_1ms( 300 );
+  uputs0("Hallo Peter\n\r");
+  uputs0("UART buffer test\n\r");
+
+  for(;;){
+    if( !ukbhit0()){
+      continue;
+    }
+    delay_1ms( 10000 );        			// wait 10s
+						// to see rx buffer overflow
+    do{
+      uputchar0( ugetchar0());			// send without waiting
+      if( !utx0_ready() ){
+	if( !ukbhit0()){
+	  break;
+	}
+	uputchar0( '.' );			// to see tx buffer size
+	do{
+	  uputchar0( ugetchar0());		// send with busy waiting
+	}while( ukbhit0());
+      }
+    }while( ukbhit0());
+    uputchar0( '\n' );
+    uputchar0( '\r' );
+  }
+}
Index: /firmware/MSR/src/UARTBUF/MAIN.H
===================================================================
--- /firmware/MSR/src/UARTBUF/MAIN.H	(revision 10588)
+++ /firmware/MSR/src/UARTBUF/MAIN.H	(revision 10588)
@@ -0,0 +1,17 @@
+#ifndef _main_h_
+#define _main_h_
+#include <avr/interrupt.h>
+#include <avr/io.h>
+#include "mydefs.h"
+
+
+#define XTAL		14.756e6
+
+#define BAUD		9600
+
+
+#define	F_CPU	XTAL
+#include <util/delay.h>
+
+
+#endif
Index: /firmware/MSR/src/UARTBUF/MYDEFS.H
===================================================================
--- /firmware/MSR/src/UARTBUF/MYDEFS.H	(revision 10588)
+++ /firmware/MSR/src/UARTBUF/MYDEFS.H	(revision 10588)
@@ -0,0 +1,61 @@
+/************************************************************************/
+/*                                                                      */
+/*                      Several helpful definitions                     */
+/*                                                                      */
+/*              Author: Peter Dannegger                                 */
+/*                                                                      */
+/************************************************************************/
+#ifndef _mydefs_h_
+#define _mydefs_h_
+
+
+//			Easier type writing:
+
+typedef unsigned char  u8;
+typedef   signed char  s8;
+typedef unsigned short u16;
+typedef   signed short s16;
+typedef unsigned long  u32;
+typedef   signed long  s32;
+
+
+// 			Access bits like variables:
+
+struct bits {
+  u8 b0:1;
+  u8 b1:1;
+  u8 b2:1;
+  u8 b3:1;
+  u8 b4:1;
+  u8 b5:1;
+  u8 b6:1;
+  u8 b7:1;
+} __attribute__((__packed__));
+
+#define SBIT_(port,pin) ((*(volatile struct bits*)&port).b##pin)
+#define	SBIT(x,y)	SBIT_(x,y)
+
+
+//			Optimization improvements
+
+// always inline function x:
+
+#define AIL(x)   static x __attribute__ ((always_inline)); static x
+
+
+// never inline function x:
+
+#define NIL(x)   x __attribute__ ((noinline)); x
+
+
+// volatile access (reject unwanted removing access):
+
+#define vu8(x)  (*(volatile u8*)&(x))
+#define vs8(x)  (*(volatile s8*)&(x))
+#define vu16(x) (*(volatile u16*)&(x))
+#define vs16(x) (*(volatile s16*)&(x))
+#define vu32(x) (*(volatile u32*)&(x))
+#define vs32(x) (*(volatile s32*)&(x))
+
+
+#endif
Index: /firmware/MSR/src/UARTBUF/UART0.C
===================================================================
--- /firmware/MSR/src/UARTBUF/UART0.C	(revision 10588)
+++ /firmware/MSR/src/UARTBUF/UART0.C	(revision 10588)
@@ -0,0 +1,109 @@
+/************************************************************************/
+/*                                                                      */
+/*                      Interrupt driven buffered UART                  */
+/*                                                                      */
+/*              Author: Peter Dannegger                                 */
+/*                                                                      */
+/************************************************************************/
+#include "main.h"
+#include "uart0.h"
+
+
+static u8 rx_buff[RX0_SIZE];
+static u8 rx_in;
+static u8 rx_out;
+static u8 tx_buff[TX0_SIZE];
+static u8 tx_in;
+static u8 tx_out;
+
+
+#define ROLLOVER( x, max )	x = ++x >= max ? 0 : x
+					// count up and wrap around
+
+void init_uart0( u16 bauddivider )
+{
+  UBRR0H = bauddivider >> 8;
+  UBRR0L = bauddivider;			// set baud rate
+  UCSR0A = 0;				// no U2X, MPCM
+  UCSR0C = 1<<UCSZ01^1<<UCSZ00		// 8 Bit
+#ifdef URSEL0
+	   ^1<<URSEL0			// if UCSR0C shared with UBRR0H
+#endif
+	   ;
+  UCSR0B = 1<<RXEN0^1<<TXEN0^		// enable RX, TX
+	   1<<RXCIE0;			// enable RX interrupt
+  rx_in = rx_out;			// set buffer empty
+  tx_in = tx_out;
+}
+
+
+u8 ukbhit0( void )
+{
+  return rx_out ^ vu8(rx_in);		// rx_in modified by interrupt !
+}
+
+
+u8 ugetchar0( void )
+{
+  u8 data;
+
+  while( !ukbhit0() );			// until at least one byte in
+  data = rx_buff[rx_out];		// get byte
+  ROLLOVER( rx_out, RX0_SIZE );
+  URX0_IEN = 1;				// enable RX interrupt
+  return data;
+}
+
+
+ISR( USART0_RX_vect )
+{
+  u8 i = rx_in;
+
+  ROLLOVER( i, RX0_SIZE );
+  if( i == rx_out ){			// buffer overflow
+    URX0_IEN = 0;			// disable RX interrupt
+    return;
+  }
+  rx_buff[rx_in] = UDR0;
+  rx_in = i;
+}
+
+
+ISR( USART0_UDRE_vect )
+{
+  if( tx_in == tx_out ){		// nothing to sent
+    UTX0_IEN = 0;			// disable TX interrupt
+    return;
+  }
+  UDR0 = tx_buff[tx_out];
+  ROLLOVER( tx_out, TX0_SIZE );
+}
+
+
+u8 utx0_ready( void )
+{
+  u8 i = tx_in;
+
+  ROLLOVER( i, TX0_SIZE );
+  return vu8(tx_out) ^ i;		// 0 = busy
+}
+
+
+void uputchar0( u8 c )
+{
+  u8 i = tx_in;
+
+  ROLLOVER( i, TX0_SIZE );
+  tx_buff[tx_in] = c;
+  while( i == vu8(tx_out));		// until at least one byte free
+					// tx_out modified by interrupt !
+  tx_in = i;
+  UTX0_IEN = 1;                         // enable TX interrupt
+}
+
+
+void uputs0_( u8 *s )
+{
+  while( *s )
+    uputchar0( *s++ );
+}
Index: /firmware/MSR/src/UARTBUF/UART0.H
===================================================================
--- /firmware/MSR/src/UARTBUF/UART0.H	(revision 10588)
+++ /firmware/MSR/src/UARTBUF/UART0.H	(revision 10588)
@@ -0,0 +1,90 @@
+/************************************************************************/
+/*                                                                      */
+/*                      Interrupt driven buffered UART                  */
+/*                                                                      */
+/*              Author: Peter Dannegger                                 */
+/*                                                                      */
+/************************************************************************/
+#ifndef _uart0_h_
+#define _uart0_h_
+
+					// size must be in range 2 .. 256
+#define RX0_SIZE	10		// usable: RX0_SIZE + 2 (4 .. 258)
+#define TX0_SIZE	8		// usable: TX0_SIZE + 1 (3 .. 257)
+
+#define	uputs0(x)	uputs0_((u8*)(x))	// avoid char warning
+
+
+u8 ukbhit0( void );			// 0 = rx buffer empty
+u8 ugetchar0( void );			// get received byte
+u8 utx0_ready( void );			// 0 = tx still busy
+void uputchar0( u8 c );			// send byte
+void uputs0_( u8 *s );			// send string from SRAM
+void init_uart0( u16 bauddivider );
+
+
+#define	UTX0_IEN	SBIT( UCSR0B, UDRIE0 )
+#define	URX0_IEN	SBIT( UCSR0B, RXCIE0 )
+
+
+/******************************	Resolve AVR naming chaos ****************/
+
+//-----------------------------	Interrupt vectors -----------------------/
+#ifndef	USART0_RX_vect
+#if defined 	USART_RX_vect
+#define		USART0_RX_vect	USART_RX_vect
+#elif defined	USART_RXC_vect
+#define		USART0_RX_vect	USART_RXC_vect
+#elif defined	USART0_RXC_vect
+#define		USART0_RX_vect	USART0_RXC_vect
+#endif
+#endif
+
+#if !defined USART0_UDRE_vect && defined USART_UDRE_vect
+#define	USART0_UDRE_vect USART_UDRE_vect
+#endif
+
+//-----------------------------	Register names --------------------------/
+#ifndef	UCSR0A
+#define	UCSR0A	UCSRA
+#endif
+#ifndef	UCSR0B
+#define	UCSR0B	UCSRB
+#endif
+#ifndef	UCSR0C
+#define	UCSR0C	UCSRC
+#endif
+#ifndef	UDR0
+#define	UDR0	UDR
+#endif
+#ifndef	UBRR0L
+#define	UBRR0L	UBRRL
+#endif
+#ifndef	UBRR0H
+#define	UBRR0H	UBRRH
+#endif
+
+//-----------------------------	Bit names -------------------------------/
+#ifndef	UCSZ00
+#define	UCSZ00	UCSZ0
+#endif
+#ifndef	UCSZ01
+#define	UCSZ01	UCSZ1
+#endif
+#if !defined URSEL0 && defined URSEL
+#define	URSEL0	URSEL
+#endif
+#ifndef	RXEN0
+#define	RXEN0	RXEN
+#endif
+#ifndef	TXEN0
+#define	TXEN0	TXEN
+#endif
+#ifndef	UDRIE0
+#define	UDRIE0	UDRIE
+#endif
+#ifndef	RXCIE0
+#define	RXCIE0	RXCIE
+#endif
+
+#endif
Index: /firmware/MSR/src/ad7719_adc.c
===================================================================
--- /firmware/MSR/src/ad7719_adc.c	(revision 10588)
+++ /firmware/MSR/src/ad7719_adc.c	(revision 10588)
@@ -0,0 +1,156 @@
+//-----------------------------------------------------------------------------
+
+#include "ad7719_adc.h"       
+#include "spi_master.h"    
+
+//-----------------------------------------------------------------------------
+
+void ad7719_init(void)
+{
+
+	// ADC communiaction works like this:
+	// a write operation to the COM register takes place - telling the device what up next.
+	// a write or read operation to another register takes place
+	// COM register bits have the following meaning:
+	//
+	// |  7  |  6  |  5  |  4  |  3  |  2  |  1  |  0  |
+	// |#WEN |R/#W | zero| zero|  A3 |  A2 |  A1 |  A0 |
+	//
+	// #WEN (inversed write enable) must be zero inorder to clock more bits into the SPI interface.
+	// R/#W (read / not write) must be zero if the next operation will be a WRITE. one if the next is READ.
+	// A3-A0 denote the address of the next register.
+
+  
+  CLR_BIT(PORTB,ADC_RST);		// Reset ADC (active low) 	
+  SET_BIT(PORTB,ADC_RST);		// Stop Reset ADC
+
+  CLR_BIT(PORTB,SPI_AD_CS);  			// Set CS low
+  spi_transfer_byte(FILTER_RD); // Next Operation is write to IOCON
+  SET_BIT(PORTB,SPI_AD_CS);
+
+_delay_us(50);
+
+  CLR_BIT(PORTB,SPI_AD_CS);  			// Set CS low
+  spi_transfer_byte(0); // Next Operation is write to IOCON
+  SET_BIT(PORTB,SPI_AD_CS);
+
+_delay_us(50);
+
+  CLR_BIT(PORTB,SPI_AD_CS);  			// Set CS low
+  spi_transfer_byte(IOCON_WR); // Next Operation is write to IOCON
+  SET_BIT(PORTB,SPI_AD_CS);
+  
+  _delay_us(50);
+
+  CLR_BIT(PORTB,SPI_AD_CS);
+  spi_transfer_byte(IOCON_INIT_HIGH);  	// Write to IOCON1 
+  SET_BIT(PORTB,SPI_AD_CS);
+_delay_us(50);
+  CLR_BIT(PORTB,SPI_AD_CS);
+  spi_transfer_byte(IOCON_INIT_LOWBYTE);  	// Write to IOCON2 
+  SET_BIT(PORTB,SPI_AD_CS);	// Set CS high
+
+_delay_us(50);
+
+  CLR_BIT(PORTB,SPI_AD_CS);  	// Set CS low
+  spi_transfer_byte(FILTER_WR);     	// Next Operation is write to FILTER  Start SPI
+  SET_BIT(PORTB,SPI_AD_CS);
+
+_delay_us(50);
+  CLR_BIT(PORTB,SPI_AD_CS);
+
+  spi_transfer_byte(FILTER_INIT);  	// Write to FILTER 
+  SET_BIT(PORTB,SPI_AD_CS);	// Set CS high
+_delay_us(50);
+  CLR_BIT(PORTB,SPI_AD_CS);  	// Set CS low
+  spi_transfer_byte(AD1CON_WR);     	// Next Operation is write to AD1CON  Start SPI
+  SET_BIT(PORTB,SPI_AD_CS);
+
+_delay_us(50);
+
+  CLR_BIT(PORTB,SPI_AD_CS);
+  spi_transfer_byte(AD1CON_INIT);  	// Write to AD1CON
+  SET_BIT(PORTB,SPI_AD_CS);	// Set CS high
+
+_delay_us(50);
+
+  CLR_BIT(PORTB,SPI_AD_CS);  	// Set CS low
+  spi_transfer_byte(AD0CON_WR);     	// Next Operation is write to AD0CON  Start SPI
+  SET_BIT(PORTB,SPI_AD_CS);
+
+_delay_us(50);
+
+  CLR_BIT(PORTB,SPI_AD_CS);
+  spi_transfer_byte(AD0CON_INIT);  	// Write to AD0CON
+  SET_BIT(PORTB,SPI_AD_CS);	// Set CS high
+
+_delay_us(50);
+
+  CLR_BIT(PORTB,SPI_AD_CS);  	// Set CS low
+  spi_transfer_byte(MODE_WR);     	// Next Operation is write to MODE Start SPI
+  SET_BIT(PORTB,SPI_AD_CS);
+
+_delay_us(50);
+
+  CLR_BIT(PORTB,SPI_AD_CS);
+  spi_transfer_byte(MODE_CONT);  	// Write to MODE
+  SET_BIT(PORTB,SPI_AD_CS);	// Set CS high
+
+_delay_us(50);
+
+  CLR_BIT(PORTB,SPI_AD_CS);  			// Set CS low
+  spi_transfer_byte(FILTER_RD); // Next Operation is write to IOCON
+  SET_BIT(PORTB,SPI_AD_CS);
+
+_delay_us(50);
+
+  CLR_BIT(PORTB,SPI_AD_CS);  			// Set CS low
+  spi_transfer_byte(0); // Next Operation is write to IOCON
+  SET_BIT(PORTB,SPI_AD_CS);
+
+_delay_us(50);
+
+
+} 
+          
+void startconv(U08 continuous)
+{
+	CLR_BIT(PORTB,SPI_AD_CS);       // Set CS low
+	spi_transfer_byte(MODE_WR);        // Next Operation is write to Mode Register
+  SET_BIT(PORTB,SPI_AD_CS);
+  CLR_BIT(PORTB,SPI_AD_CS);
+	if (continuous)	spi_transfer_byte(MODE_SINGLE);	 // Start new A/D conversion
+	else spi_transfer_byte(MODE_CONT);	 // Start continous conversion mode
+	SET_BIT(PORTB,SPI_AD_CS);  
+}
+
+void stopconv(void)
+{
+	CLR_BIT(PORTB,SPI_AD_CS);       // Set CS low
+	spi_transfer_byte(MODE_WR);        // Next Operation is write to Mode Register
+    SET_BIT(PORTB,SPI_AD_CS);
+    CLR_BIT(PORTB,SPI_AD_CS);
+	spi_transfer_byte(MODE_IDLE);
+	SET_BIT(PORTB,SPI_AD_CS);  
+}
+
+
+U32 read_adc(void)
+{ 
+	CLR_BIT(PORTB,SPI_AD_CS);       // Set CS low
+	spi_transfer_byte(AD0DAT_RD);   // Next Operation is read from Main ADC Data Register
+    SET_BIT(PORTB,SPI_AD_CS);
+	_delay_us(50);
+
+    CLR_BIT(PORTB,SPI_AD_CS);
+	U32 value=0; 					// actually a 24bit value is returned
+	value |= spi_transfer_byte(0) ;
+	value =value<<8;
+	value |= spi_transfer_byte(0) ;
+	value =value<<8;
+	value |= spi_transfer_byte(0) ;
+	SET_BIT(PORTB,SPI_AD_CS);	// Set CS high
+	return value;                                                                                                 
+}   
+  
+  
Index: /firmware/MSR/src/ad7719_adc.h
===================================================================
--- /firmware/MSR/src/ad7719_adc.h	(revision 10588)
+++ /firmware/MSR/src/ad7719_adc.h	(revision 10588)
@@ -0,0 +1,93 @@
+#ifndef __AD7719_ADC_H
+#define __AD7719_ADC_H
+//-----------------------------------------------------------------------------
+
+#include "typedefs.h"
+#include "application.h"
+#include "num_conversion.h"
+//-----------------------------------------------------------------------------
+// Bit Definitions
+#define ADC_RDY PD2
+#define ADC_RST PB1
+#define AD7719_IS_READY() (!(PIND & (1<<PD2))) // TRUE if PD2=0 AD_RDY is inverted logic.
+
+
+
+
+
+// ON CHIP REGISTER ADDRESSES
+#define STATUS_RD 0x40
+
+#define MODE_WR 0x01
+#define MODE_RD 0x41
+
+#define AD0CON_WR 0x02
+#define AD0CON_RD 0x42
+
+#define AD1CON_WR 0x03
+#define AD1CON_RD 0x43
+
+#define FILTER_WR 0x04
+#define FILTER_RD 0x44
+
+#define AD0DAT_RD 0x45
+#define AD1DAT_RD 0x46
+
+#define IOCON_WR 0x07
+#define IOCON_RD 0x47
+
+#define AD0OFS_WR 0x08
+#define AD0OFS_RD 0x48
+
+#define AD1OFS_WR 0x09
+#define AD1OFS_RD 0x49
+
+#define AD0GAIN_WR 0x0A
+#define AD0GAIN_RD 0x4A
+
+#define AD1GAIN_WR 0x0B
+#define AD1GAIN_RD 0x4B
+
+#define ID_RD 0x4F
+
+// REGISTER INIT VALUES
+
+	//Init Configure and Initialize AD7719
+	//http://designtools.analog.com/dt/adc/codegen/ad7719.html 
+
+#define IOCON_INIT_HIGH 0x03	//0000.0011 // I-sources I1 and I2 are switched on, thats all
+#define IOCON_INIT_LOWBYTE 0x00
+
+#define FILTER_INIT 0x52	//0x52 euro use 50Hz = -171dB and 60Hz = -58dB Rejectjon Updaterate = 4Hz
+											// 0x52=82 decimal. f_ADC=16.6Hz; t_ADC=60ms; t_settle = 120ms
+
+#define AD1CON_INIT 0x31	//0011.0001  	
+	// AD1EN is set --> AUX ADc is used for Temp measurement.
+	// ACH = 011 --> Tempsensor
+	// U/#B = 0 --> bipolar, but i'm not entirely sure if this is correct.
+	// ARN = 1 --> input range is REFIN2 , but when tempsensor is chosen, internal ref is used ... 
+
+#define AD0CON_INIT 0x8E // 1000.1110
+	// AD0EN is set
+	// WL is cleared --> 24bit
+	// CH = 00 --> AIN1 , AIN2 used 
+	// U/#B = 1 --> unipolar
+	// RN=110 --> input range = +-1.28V --> whatever this means in ratiometric measurements.
+
+
+#define MODE_IDLE 0x01
+#define MODE_SINGLE 0x02
+#define MODE_CONT 0x03
+#define MODE_INTERNAL_ZERO_CAL 0x04		// not tested
+#define MODE_INTERNAL_FULL_CAL 0x05		// not tested
+
+// since the ADC is chopped, one should wait 3 conversions
+// after the muxer was switched, until the reading is okay.
+#define READINGS_UNTIL_AD7719_SETTLED 3
+
+void ad7719_init(void);
+void startconv(U08 continuous);
+void stopconv(void);
+U32 read_adc(void);
+//-----------------------------------------------------------------------------
+#endif
Index: /firmware/MSR/src/application.c
===================================================================
--- /firmware/MSR/src/application.c	(revision 10588)
+++ /firmware/MSR/src/application.c	(revision 10588)
@@ -0,0 +1,102 @@
+//-----------------------------------------------------------------------------
+
+#include "application.h"
+#include <avr/wdt.h> 
+
+
+//-----------------------------------------------------------------------------
+
+volatile U08 app_reset_source;
+//-----------------------------------------------------------------------------
+
+void app_init(void)
+{
+  app_reset_source = MCUSR; // Save last reset source
+  MCUSR = 0x00; // Clear reset source for next reset cycle
+
+
+	// Dangerous here: I still do not know much about the watchdog.
+	// This code is still from Udo Juerss. 
+
+  // The watchdog timer is disabled by default ("startup.asm")
+	#ifdef USE_WATCHDOG
+	 WDTCSR = WDTOE | (1 << WDE); // Enable watchdog reset (~16ms)
+	#endif
+
+	// define PORTS
+	// USART
+	DDRD &= ~(1<<PD0);				// PD0 = RXD is input
+	DDRD |= 1<<PD1; 					// PD1 = TXD is output
+	
+
+	// SPARE OUT/-INPUTS
+	// I set (nearly) all spare pins as inputs, so they are high-Z ... that's safe I guess.
+	DDRA &= ~(1<<PA5);
+	DDRA &= ~(1<<PA6);
+	DDRA &= ~(1<<PC4);
+	DDRA &= ~(1<<PC5);
+	DDRA &= ~(1<<PC6);
+	DDRA &= ~(1<<PC7);
+	// But this pin, is the heartbeat pin... 
+	DDRA |= (1<<PA4);
+	
+	
+	// the pull ups should be off by default :-)
+
+	// ATmega internal ADC input 
+	DDRA &= ~(1<<PA7);
+
+	// MUXER ADDRESS OUTs
+	DDRA |= 0x0F; // SA-pins -> output
+	DDRC |= 0x0F; // SB-pins -> output
+
+	// SPI
+	// set all CS's: output
+
+	DDRB |= (1 << SPI_E_CS);
+	DDRB |= (1 << SPI_AD_CS);
+
+	// set all Chips selects HIGH
+	PORTB |= (1 << SPI_E_CS);
+	PORTB |= (1 << SPI_AD_CS);
+	
+	
+
+	// set MOSI and SCK: output & // set MISO: input
+	SPI_DDR |= (1 << SPI_MOSI);
+	SPI_DDR |= (1 << SPI_SCLK);
+	SPI_DDR &= ~(1 << SPI_MISO);
+
+	// set MOSI, SCK: HIGH. MISO leave alone.
+	SPI_PRT |= (1 << SPI_MOSI);
+	SPI_PRT |= (1 << SPI_SCLK);
+	//SPI_PRT |= (1 << SPI_MISO);
+
+	// ADC 
+	DDRD &= ~(1<<PD2);					// PD2 is AD_READY input
+	DDRB |= 1<<PB1;							// PB1 is AD_RESET output
+
+	// ACCELEROMETER
+	DDRB &= ~(1<<PB0);					// PB0 is ACC_READY input (existiert nichtmehr, umgelegt)
+
+	//MAX6662   <--- not assembled 
+	// DDRB &= ~(1<<PB0); 			// PB0 is over temperature alert input
+	// DDRB &= ~(1<<PB1);				// PB1 is general temperature altert input
+}
+
+
+
+//-----------------------------------------------------------------------------
+
+void app_set_watchdog_prescaler(tWDT_PRESCALE wdt_prescale) // Set watchdog prescale
+{
+  U08 sreg_backup = SREG; // Copy status register to variable
+  U08 wdtcsr_value = WDE + wdt_prescale; // Set new prescale value to variable
+
+  cli(); // Disable interrups
+  wdt_reset(); // Reset watchdog
+
+  WDTCR |= (1 << WDTOE) | (1 << WDE); // Unlock register access, 4 cycles to store new value
+  WDTCR = wdtcsr_value; // Set new watchdog prescaler
+  SREG = sreg_backup; // Restore status register
+}
Index: /firmware/MSR/src/application.h
===================================================================
--- /firmware/MSR/src/application.h	(revision 10588)
+++ /firmware/MSR/src/application.h	(revision 10588)
@@ -0,0 +1,56 @@
+#ifndef __APPLICATION_H
+#define __APPLICATION_H
+//-----------------------------------------------------------------------------
+
+#include "typedefs.h"
+//-----------------------------------------------------------------------------
+
+#define USART_RX_BUFFER_SIZE 32 // Receive buffer size
+#define USART_TX_BUFFER_SIZE 5 // Receive buffer size. MUST not be larger 255
+
+#define USART_BAUDRATE 9600 // USART baudrate original
+#define USART_USE_TX // Transmitter used?
+#define USART_USE_RX // Receiver used?
+//#define USART_USE_RX_IRQ // RX interrupt used?
+#define USART_USE_UPPERCASE // Convert received chars to uppercase?
+//-----------------------------------------------------------------------------
+
+// SPI DEFINITIONS
+// Port Definitions
+#define SPI_PRT PORTB
+#define SPI_DDR DDRB
+
+// Bit Definitions
+#define SPI_MOSI PB5
+#define SPI_MISO PB6
+#define SPI_SCLK PB7
+
+
+#define SPI_E_CS PB3
+#define SPI_AD_CS PB4
+
+
+//-----------------------------------------------------------------------------
+extern volatile U08 app_reset_source;
+//-----------------------------------------------------------------------------
+
+void app_init(void); // Initialize application
+void app_set_watchdog_prescaler(tWDT_PRESCALE wdt_prescale); // Set watchdog prescale
+
+//methods in main ... declared here ... don't ask why ... 
+// definition of some functions:
+// these function are implemented in this file, this is not doog coding style.
+// sooner or later, they will be moved into more apropriate files.
+//void set_adc_enable_register();
+//void set_ad7719_enable_register();
+//U08	increase_adc (U08 channel);
+//U08	increase_ad7719 (U08 channel);
+//void check_what_measurement_was_finished() ;
+// end of function definition:
+//-----------------------------------------------------------------------------
+
+
+
+//-----------------------------------------------------------------------------
+
+#endif
Index: /firmware/MSR/src/atmega_adc.c
===================================================================
--- /firmware/MSR/src/atmega_adc.c	(revision 10588)
+++ /firmware/MSR/src/atmega_adc.c	(revision 10588)
@@ -0,0 +1,25 @@
+#include "atmega_adc.h"
+#include "typedefs.h"
+
+void atmega_adc_init(void)
+{
+//ADC einschalten
+	ADCSRA |= (1<<ADPS2) | (1<<ADPS1);     // ADC_clk = 125kHz
+	ADCSRA &= ~(1<<ADPS0);
+		// normal conversion takes: 13 adc_clk cycles = 104us
+		// 1st conversion takes longer: 25 clk cycles = 200us
+	ADCSRA |= 1<<ADATE; // autotrigger enable
+	SFIOR &= ~(0xE0);		//ADTS=000 --> free running mode 
+	ADCSRA |= (1<<ADEN);                  // ADC aktivieren
+
+	ADMUX &= ~(1<<REFS0); 
+	ADMUX &= ~(1<<REFS1); 	//REFS = 00 --> use external reference voltage.
+	
+	//ADMUX |= 1<<ADLAR;		//ADLAR =1 	--> left adjust ac result in ADCH register --> 8bit resolution only.				
+	ADMUX &= ~(1<<ADLAR);		//ADLAR =0 	10bit :-)
+	
+	ADMUX |= (0x1F & 0x07); //MUX = 0x07 --> Pin ADC7 = PA7 is used as ADC input pin.
+	
+	ADCSRA |= (1<<ADSC); 	// start 1st conversion
+
+}
Index: /firmware/MSR/src/atmega_adc.h
===================================================================
--- /firmware/MSR/src/atmega_adc.h	(revision 10588)
+++ /firmware/MSR/src/atmega_adc.h	(revision 10588)
@@ -0,0 +1,6 @@
+#ifndef __ATMEGA_ADC_H
+#define __ATMEGA_ADC_H
+
+
+void atmega_adc_init(void);
+#endif
Index: /firmware/MSR/src/macros.h
===================================================================
--- /firmware/MSR/src/macros.h	(revision 10588)
+++ /firmware/MSR/src/macros.h	(revision 10588)
@@ -0,0 +1,21 @@
+#ifndef __MACROS_H
+#define __MACROS_H
+//-----------------------------------------------------------------------------
+
+#define SET_BIT(byte,bit) (byte |= (1 << bit)) // Set bit in byte
+#define CLR_BIT(byte,bit) (byte &= ~(1 << bit)) // Clear bit in byte
+#define TGL_BIT(byte,bit) (byte ^= (1 << bit)) // Toggle bit in byte
+
+#define IS_SET(reg,bit) (reg & bit) // TRUE if bit = 1
+#define IS_CLR(reg,bit) !(reg & bit) // TRUE if bit = 0
+
+#define BIT(x) (1 << (x)) // Define bit value
+#define HI(x) ((x) >> 8) // Highbyte of 16-bit value
+
+#define ABS(x) ((x >= 0) ? x : -x) // Absolute value of x
+
+#define HI_HEX(x) ("0123456789ABCDEF" [x >> 4]) // Create hex of high nibble
+#define LO_HEX(x) ("0123456789ABCDEF" [x & 0x0F]) // Create hex of low nibble
+//-----------------------------------------------------------------------------
+
+#endif
Index: /firmware/MSR/src/num_conversion.c
===================================================================
--- /firmware/MSR/src/num_conversion.c	(revision 10588)
+++ /firmware/MSR/src/num_conversion.c	(revision 10588)
@@ -0,0 +1,371 @@
+//-----------------------------------------------------------------------------
+
+#include "num_conversion.h"
+//-----------------------------------------------------------------------------
+
+//__flash U08 NC_HEX_ARRAY[] = "0123456789ABCDEF";
+U08 NC_HEX_ARRAY[] = "0123456789ABCDEF";
+//-----------------------------------------------------------------------------
+
+U08 nc_buffer[NC_BUFFER_LENGTH]; // Conversion buffer
+U08 nc_format_buffer[NC_BUFFER_LENGTH]; // Format buffer
+
+static U08 nc_int_digits[8];
+static U08 nc_dec_digits[6];
+//-----------------------------------------------------------------------------
+
+pU08 nc_format(pU08 source_ptr,U08 digits)
+{
+  U08 len = strlen((const char *)source_ptr);
+  pU08 dest_ptr = (pU08)&nc_format_buffer;
+
+  // Fillup loop
+  while (digits-- > len)
+  {
+    *dest_ptr++ = NC_FILL_CHAR;
+  }
+
+  // Copy loop
+  while (len--)
+  {
+    *dest_ptr++ = *source_ptr++;
+  }
+
+  *dest_ptr = 0; // Terminate format string
+
+  return (pU08)&nc_format_buffer;
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_U08_to_str(U08 value,U08 digits)
+{
+  pU08 pstr = nc_buffer;
+
+  if (value >= 100) *pstr++ = ('0' + (value % 1000 / 100));
+  if (value >= 10) *pstr++ = ('0' + (value % 100 / 10));
+  *pstr++ = ('0' + (value % 10));
+  *pstr = 0;
+
+  if (!digits) // If digits = 0, then return buffer start
+  {
+    return nc_buffer;
+  }
+  else // Do formatted output
+  {
+    return nc_format(nc_buffer,digits);
+  }
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_S08_to_str(S08 signed_value,U08 digits)
+{
+  pU08 pstr = nc_buffer;
+  U08 value;
+
+  if (signed_value < 0)
+  {
+    *pstr++ = '-';
+    value = -signed_value;
+  }
+  else
+  {
+    value = signed_value;
+  }
+
+  if (value >= 100) *pstr++ = ('0' + (value % 1000 / 100));
+  if (value >= 10) *pstr++ = ('0' + (value % 100 / 10));
+  *pstr++ = ('0' + (value % 10));
+  *pstr = 0;
+
+  if (!digits) // If digits = 0, then return buffer start
+  {
+    return nc_buffer;
+  }
+  else // Do formatted output
+  {
+    return nc_format(nc_buffer,digits);
+  }
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_U08_to_hex(U08 value)
+{
+  pU08 pstr = nc_buffer;
+
+  *pstr++ = NC_HEX_ARRAY[value >> 4];
+  *pstr++ = NC_HEX_ARRAY[value & 0x0F];
+  *pstr = 0;
+
+  return (nc_buffer);
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_U08_to_bin(U08 value)
+{
+  pU08 pstr = nc_buffer;
+  U08 n;
+
+  for (n = 7; n < 8; n--)
+  {
+    if (value & (1 << n))
+    {
+      *pstr++ = '1';
+    }
+    else
+    {
+      *pstr++ = '0';
+    }
+  }
+
+  *pstr = 0;
+
+  return (nc_buffer);
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_U16_to_str(U16 value,U08 digits)
+{
+  pU08 pstr = nc_buffer;
+
+  if (value >= 10000) *pstr++ = ('0' + (value / 10000));
+  if (value >= 1000) *pstr++ = ('0' + (value % 10000 / 1000));
+  if (value >= 100) *pstr++ = ('0' + (value % 1000 / 100));
+  if (value >= 10)*pstr++ = ('0' + (value % 100 / 10));
+  *pstr++ = ('0' + (value % 10));
+  *pstr = 0;
+
+  if (!digits) // If digits = 0, then return buffer start
+  {
+    return nc_buffer;
+  }
+  else // Do formatted output
+  {
+    return nc_format(nc_buffer,digits);
+  }
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_S16_to_str(S16 signed_value,U08 digits)
+{
+  pU08 pstr = nc_buffer;
+  U16 value;
+
+  if (signed_value < 0)
+  {
+    *pstr++ = '-';
+    value = -signed_value;
+  }
+  else
+  {
+    value = signed_value;
+  }
+
+  if (value >= 10000) *pstr++ = ('0' + (value / 10000));
+  if (value >= 1000) *pstr++ = ('0' + (value % 10000 / 1000));
+  if (value >= 100) *pstr++ = ('0' + (value % 1000 / 100));
+  if (value >= 10) *pstr++ = ('0' + (value % 100 / 10));
+  *pstr++ = ('0' + (value % 10));
+  *pstr = 0;
+
+  if (!digits) // If digits = 0, then return buffer start
+  {
+    return nc_buffer;
+  }
+  else // Do formatted output
+  {
+    return nc_format(nc_buffer,digits);
+  }
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_U16_to_hex(U16 value)
+{
+  pU08 pstr = nc_buffer;
+  tMEM16 data;
+
+  data.word = value;
+
+  *pstr++ = NC_HEX_ARRAY[(data.byte[1]) >> 4];
+  *pstr++ = NC_HEX_ARRAY[(data.byte[1]) & 0x0F];
+
+  *pstr++ = NC_HEX_ARRAY[(data.byte[0]) >> 4];
+  *pstr++ = NC_HEX_ARRAY[(data.byte[0]) & 0x0F];
+
+  *pstr = 0;
+
+  return (nc_buffer);
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_U32_to_str(U32 value,U08 digits)
+{
+  pU08 pstr = nc_buffer;
+
+  if (value >= 1000000000) *pstr++ = ('0' + (value / 1000000000));
+  if (value >= 100000000) *pstr++ = ('0' + (value % 1000000000 / 100000000));
+  if (value >= 10000000) *pstr++ = ('0' + (value % 100000000 / 10000000));
+  if (value >= 1000000) *pstr++ = ('0' + (value % 10000000 / 1000000));
+  if (value >= 100000) *pstr++ = ('0' + (value % 1000000 / 100000));
+  if (value >= 10000) *pstr++ = ('0' + (value % 100000 / 10000));
+  if (value >= 1000) *pstr++ = ('0' + (value % 10000 / 1000));
+  if (value >= 100) *pstr++ = ('0' + (value % 1000 / 100));
+  if (value >= 10) *pstr++ = ('0' + (value % 100 / 10));
+
+  *pstr++ = ('0' + (value % 10));
+  *pstr = 0;
+
+  if (!digits) // If digits = 0, then return buffer start
+  {
+    return nc_buffer;
+  }
+  else // Do formatted output
+  {
+    return nc_format(nc_buffer,digits);
+  }
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_S32_to_str(S32 signed_value,U08 digits)
+{
+  pU08 pstr = nc_buffer;
+  U32 value;
+
+  if (signed_value < 0)
+  {
+    *pstr++ = '-';
+    value = -signed_value;
+  }
+  else
+  {
+    value = signed_value;
+  }
+
+  if (value >= 1000000000) *pstr++ = ('0' + (value / 1000000000));
+  if (value >= 100000000) *pstr++ = ('0' + (value % 1000000000 / 100000000));
+  if (value >= 10000000) *pstr++ = ('0' + (value % 100000000 / 10000000));
+  if (value >= 1000000) *pstr++ = ('0' + (value % 10000000 / 1000000));
+  if (value >= 100000) *pstr++ = ('0' + (value % 1000000 / 100000));
+  if (value >= 10000) *pstr++ = ('0' + (value % 100000 / 10000));
+  if (value >= 1000) *pstr++ = ('0' + (value % 10000 / 1000));
+  if (value >= 100) *pstr++ = ('0' + (value % 1000 / 100));
+  if (value >= 10) *pstr++ = ('0' + (value % 100 / 10));
+
+  *pstr++ = ('0' + (value % 10));
+  *pstr = 0;
+
+  if (!digits) // If digits = 0, then return buffer start
+  {
+    return nc_buffer;
+  }
+  else // Do formatted output
+  {
+    return nc_format(nc_buffer,digits);
+  }
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_U32_to_hex(U32 value)
+{
+  pU08 pstr = nc_buffer;
+  tMEM32 data;
+
+  data.dword = value;
+
+  *pstr++ = NC_HEX_ARRAY[(data.byte[3]) >> 4];
+  *pstr++ = NC_HEX_ARRAY[(data.byte[3]) & 0x0F];
+
+  *pstr++ = NC_HEX_ARRAY[(data.byte[2]) >> 4];
+  *pstr++ = NC_HEX_ARRAY[(data.byte[2]) & 0x0F];
+
+  *pstr++ = NC_HEX_ARRAY[(data.byte[1]) >> 4];
+  *pstr++ = NC_HEX_ARRAY[(data.byte[1]) & 0x0F];
+
+  *pstr++ = NC_HEX_ARRAY[(data.byte[0]) >> 4];
+  *pstr++ = NC_HEX_ARRAY[(data.byte[0]) & 0x0F];
+
+  *pstr = 0;
+
+  return (nc_buffer);
+}
+//-----------------------------------------------------------------------------
+
+pU08 nc_float_to_str(float value,U08 decimals,U08 digits)
+{
+  S08 n;
+  U08 int_count;
+  U08 dec_count;
+  float dec_part;
+  U32 int_part;
+  pU08 pstr = nc_buffer;
+
+  if (decimals > 5)
+  {
+    decimals = 5;
+  }
+
+  if (value < 0.0)
+  {
+    *pstr++ = '-';
+    value = -value;
+  }
+
+  int_part = value;
+  dec_part = value - int_part;
+  int_count = 0;
+  dec_count = 0;
+
+  if (int_part == 0)
+  {
+    *pstr++ = '0';
+  }
+
+  while (int_part > 0)
+  {
+    nc_int_digits[int_count] = int_part % 10;
+    int_part = int_part - nc_int_digits[int_count];
+
+    if (int_part > 0)
+    {
+      int_part = int_part / 10;
+    }
+
+    int_count++; // go to the next digit
+  }
+
+  while (dec_count < decimals)
+  {
+    dec_part = dec_part * 10.0;
+    nc_dec_digits[dec_count] = dec_part;
+
+    if (nc_dec_digits[dec_count] > 0)
+    {
+      dec_part = dec_part - nc_dec_digits[dec_count];
+    }
+
+    dec_count++;
+  }
+
+  for (n = int_count - 1; n > -1; n--)
+  {
+    *pstr++ = 48 + nc_int_digits[n];
+  }
+
+  *pstr++ = '.';
+
+  for (n = 0; n < dec_count; n++)
+  {
+    *pstr++ = 48 + nc_dec_digits[n];
+  }
+
+  // Terminate string
+  *pstr = 0;
+
+  if (!digits) // If digits = 0, then return buffer start
+  {
+    return nc_buffer;
+  }
+  else // Do formatted output
+  {
+    return nc_format(nc_buffer,digits);
+  }
+}
Index: /firmware/MSR/src/num_conversion.h
===================================================================
--- /firmware/MSR/src/num_conversion.h	(revision 10588)
+++ /firmware/MSR/src/num_conversion.h	(revision 10588)
@@ -0,0 +1,29 @@
+#ifndef __NUM_CONVERSION_H
+#define __NUM_CONVERSION_H
+//-----------------------------------------------------------------------------
+
+#include "typedefs.h"
+//-----------------------------------------------------------------------------
+
+#define NC_BUFFER_LENGTH 16 // Conversion buffer size
+#define NC_FILL_CHAR 32 // Character for post digits
+//-----------------------------------------------------------------------------
+
+extern U08 nc_buffer[];
+//-----------------------------------------------------------------------------
+
+pU08 nc_format(pU08 source_ptr,U08 digits);
+pU08 nc_U08_to_str(U8 value,U08 digits);
+pU08 nc_S08_to_str(S08 signed_value,U08 digits);
+pU08 nc_U08_to_hex(U08 value);
+pU08 nc_U08_to_bin(U08 value);
+pU08 nc_U16_to_str(U16 value,U08 digits);
+pU08 nc_S16_to_str(S16 signed_value,U08 digits);
+pU08 nc_U16_to_hex(U16 value);
+pU08 nc_U32_to_str(U32 value,U08 digits);
+pU08 nc_S32_to_str(S32 signed_value,U08 digits);
+pU08 nc_U32_to_hex(U32 value);
+pU08 nc_float_to_str(float value,U08 decimals,U08 digits);
+//-----------------------------------------------------------------------------
+
+#endif
Index: /firmware/MSR/src/spi_master.c
===================================================================
--- /firmware/MSR/src/spi_master.c	(revision 10588)
+++ /firmware/MSR/src/spi_master.c	(revision 10588)
@@ -0,0 +1,273 @@
+//-----------------------------------------------------------------------------
+#include "spi_master.h"
+
+//-----------------------------------------------------------------------------
+volatile U08 spi_clock_index;
+volatile U08 spi_cpol;
+volatile U08 spi_cpha;
+volatile U08 spi_dord;
+volatile BOOL spi_ss_active_high;
+volatile U08 spi_read_buffer[SPI_READ_BUFFER_SIZE];
+volatile U08 spi_write_buffer[SPI_WRITE_BUFFER_SIZE];
+
+volatile U08 SPI_DEVICE_SS[2]={SPI_E_CS ,SPI_AD_CS};
+volatile BOOL SPI_DEVICE_ACTIVE_HIGH[2]={false ,false};
+//-----------------------------------------------------------------------------
+
+
+
+
+void spi_init(void)
+{
+  // there are a total of 4 devices on the SPI bus:
+	// 1.) Ethernet Modul WIZ812MJ 
+	// 2.) AD7719 24bit ADC
+	// 3.) LIS3LV accelerometer
+	// 4.) MAX6662 temp sensor <---- not assembled!
+
+	// We check if they all can live with the same SPI settings:
+	// 1.) Ethernet modul:
+	// supports spi mode=0 or mode=3 --> eighther cpol=cpha=0 or cpol=cpha=1
+	//	THAT IS NOT TRUE!!!!
+	// only mode 0 !!!!!!!!!!!!!!!!!!!!!!!!!!!1
+	// MSB first
+	// SCLK time 70ns minimum --> 14.2MHz maximum
+	//
+	// 2.) AD7719
+	// supports mode=3 --> cpol=cpha=1
+	// MSB first
+	// SCLK time 200ns minimum --> 5MHz maximum
+	//
+	// 3.) LIS3LV
+	// SPI CLK idles high 				--> cpol=1
+	// data valid at rising edge. --> cpha=1 as well 
+	// ==> mode 3 is supported only.
+	// MSB first, but take take at multi byte transfers. LSbyte first
+	// SCLK time - is not mentioned in the datasheet
+	//
+	// 4.) MAX6662 Tempsensor
+	// since it is not assembled, this information is not necessary.
+
+	// fastes SPI CLK frequency can be 					--> F_CPU/2 	= 4MHz
+	// slowest can be 													--> F_CPU/128	= 62.5KHz
+	
+	// Lets try with the fastest!
+	spi_clock_index = 0;  // Set Clockindex for lowest clock speed (F_CPU / 128)
+
+  spi_dord = 0;					// Data Order MSB first dord = 0  --> good for all devices
+  spi_cpol = 1;	spi_cpha = 1;					// SPI mode=3 			--> good for all devices
+  spi_setup(); 					// Setup SPI bits and clock speed
+
+}
+//-----------------------------------------------------------------------------
+void spi_setup(void)
+{
+  // Disable SPI, clear all flags
+  SPCR = 0;
+
+  // Set/Clear bits DORD, CPOL and CPHA in SPI Control Register
+  spi_dord & 0x01 ? (SPCR |= (1 << DORD)) : (SPCR &= ~(1 << DORD));
+  spi_cpol & 0x01 ? (SPCR |= (1 << CPOL)) : (SPCR &= ~(1 << CPOL));
+  spi_cpha & 0x01 ? (SPCR |= (1 << CPHA)) : (SPCR &= ~(1 << CPHA));
+
+  switch (spi_clock_index)
+  {
+    case 0:{ // F_CPU / 128
+      SPCR |= (1 << SPR1) | (1 << SPR0);
+      SPSR &= ~(1 <<SPI2X);
+	  }
+    break;
+
+    case 1:{ // F_CPU / 64
+      SPCR |= (1 << SPR1);
+      SPSR &= ~(1 << SPI2X);
+	  }
+    break;
+
+    case 2:{ // F_CPU / 32
+      SPCR |= (1 << SPR1);
+      SPSR |= (1 << SPI2X);
+	  }
+    break;
+
+    case 3:{ // F_CPU / 16
+      SPCR |= (1 << SPR0);
+      SPSR &= ~(1 << SPI2X);
+	  }
+    break;
+
+    case 4:{ // F_CPU / 8
+      SPCR |= (1 << SPR0);
+      SPSR |= (1 << SPI2X);
+	  }
+    break;
+
+    case 5: // F_CPU / 4
+      SPSR &= ~(1 << SPI2X);
+    break;
+
+    case 6: // F_CPU / 2
+      SPSR |= (1 << SPI2X);
+    break;
+
+    default:{ // F_CPU / 128
+      SPCR |= (1 << SPR1) | (1 << SPR0);
+      SPSR &= ~(1 << SPI2X);
+	  }
+  }
+
+  // Enable SPI in Master Mode
+  SPCR |= (1 << SPE) | (1 << MSTR);
+}
+
+//-----------------------------------------------------------------------------
+
+void spi_set_clock_index(U08 clock_index)
+{
+  if (clock_index > SPI_MAX_CLOCK_INDEX)
+  {
+    clock_index = SPI_MAX_CLOCK_INDEX;
+  }
+
+  spi_clock_index = clock_index;
+
+  spi_setup(); // Setup SPI bits and clock speed
+}
+//-----------------------------------------------------------------------------
+
+void spi_set_dord(U08 dord)
+{
+  if (dord > 1)
+  {
+    dord = 1;
+  }
+
+  spi_dord = dord;
+
+  spi_setup(); // Setup SPI bits and clock speed
+}
+//-----------------------------------------------------------------------------
+
+void spi_set_cpol(U08 cpol)
+{
+  if (cpol > 1)
+  {
+    cpol = 1;
+  }
+
+  spi_cpol = cpol;
+
+  spi_setup(); // Setup SPI bits and clock speed
+}
+//-----------------------------------------------------------------------------
+
+void spi_set_cpha(U08 cpha)
+{
+  if (cpha > 1)
+  {
+    cpha = 1;
+  }
+
+  spi_cpha = cpha;
+
+  spi_setup(); // Setup SPI bits and clock speed
+}
+
+//-----------------------------------------------------------------------------
+
+void spi_transfer(U08 bytes, U08 device)
+{
+
+  U08 n;
+  // Transfer requested bytes
+  for (n = 0; n < bytes; n++)
+  {
+  // Check for active slave select level
+  if (SPI_DEVICE_ACTIVE_HIGH[device])
+  {
+		if (device == 0) {
+    	PORTB |= (1 << SPI_DEVICE_SS[device]); // Set Slave Select high
+		} else {
+			PORTD |= (1 << SPI_DEVICE_SS[device]); // Set Slave Select high
+		}
+  }
+  else
+  {
+		if (device == 0) {
+    	PORTB &= ~(1 << SPI_DEVICE_SS[device]); // Set Slave Select low
+		} else {
+			PORTD &= ~(1 << SPI_DEVICE_SS[device]); // Set Slave Select low
+		}
+  }
+
+  
+    spi_read_buffer[n] = spi_transfer_byte(spi_write_buffer[n]);
+  
+
+  // Check for inactive slave select level
+  if (SPI_DEVICE_ACTIVE_HIGH[device])
+  {
+		if (device == 0) {
+    	PORTB &= ~(1 << SPI_DEVICE_SS[device]); // Set Slave Select low
+		} else {
+			PORTD &= ~(1 << SPI_DEVICE_SS[device]); // Set Slave Select low
+		}
+  }
+  else
+  {
+		if (device == 0) {
+    	PORTB |= (1 << SPI_DEVICE_SS[device]); // Set Slave Select high
+		} else {
+			PORTD |= (1 << SPI_DEVICE_SS[device]); // Set Slave Select high
+		}
+  }
+  
+  }
+}
+//-----------------------------------------------------------------------------
+
+U08 spi_transfer_byte(U08 data)
+{
+  // Start SPI Transfer
+	if (!(SPCR & (1<<MSTR)) )
+		SPCR |= 1<<MSTR;
+  SPDR = data;
+
+  // Wait for transfer completed
+  while (!(SPSR & (1 << SPIF)))
+  {
+  }
+
+  // Return result of transfer
+  return SPDR;
+}
+
+//-----------------------------------------------------------------------------
+void spi_transfer_string(U08 length, U08* addr, U08 device)
+{
+
+  U08 n;
+  
+  // I assume the CS line is in "not enable"-state;
+	if ( device == 0 ){
+  	TGL_BIT(PORTB, SPI_DEVICE_SS[device]);  // I toggle the line
+	} else {
+		TGL_BIT(PORTD, SPI_DEVICE_SS[device]);  // I toggle the line
+	}
+  // now the line is in "enable"-state
+  
+
+  // Transfer requested bytes
+  for (n = 0; n < length; n++)
+  {
+    spi_transfer_byte(addr[n]);
+  }
+	
+		if ( device == 0 ){
+  	TGL_BIT(PORTB, SPI_DEVICE_SS[device]);  // I toggle the line
+	} else {
+		TGL_BIT(PORTD, SPI_DEVICE_SS[device]);  // I toggle the line
+	}
+
+}
+//-----------------------------------------------------------------------------
Index: /firmware/MSR/src/spi_master.h
===================================================================
--- /firmware/MSR/src/spi_master.h	(revision 10588)
+++ /firmware/MSR/src/spi_master.h	(revision 10588)
@@ -0,0 +1,37 @@
+#ifndef __SPI_MASTER_H
+#define __SPI_MASTER_H
+//-----------------------------------------------------------------------------
+
+#include "typedefs.h"
+#include "application.h"
+#include "usart.h"
+//-----------------------------------------------------------------------------
+#define SPI_READ_BUFFER_SIZE 16
+#define SPI_WRITE_BUFFER_SIZE 16
+
+#define SPI_MAX_SLAVE_INDEX 2 //?
+#define SPI_MAX_CLOCK_INDEX 6 //?
+//-----------------------------------------------------------------------------
+extern volatile U08 spi_clock_index;
+extern volatile U08 spi_cpol;
+extern volatile U08 spi_cpha;
+extern volatile U08 spi_dord;
+extern volatile U08 SPI_DEVICE_SS[2];
+extern volatile BOOL SPI_DEVICE_ACTIVE_HIGH[2];
+
+extern volatile U08 spi_read_buffer[SPI_READ_BUFFER_SIZE];
+extern volatile U08 spi_write_buffer[SPI_WRITE_BUFFER_SIZE];
+//-----------------------------------------------------------------------------
+
+void spi_init(void);
+void spi_transfer(U08 bytes, U08 device);
+U08 spi_transfer_byte(U08 data);
+void spi_set_clock_index(U08 clock_index);
+void spi_set_dord(U08 dord);
+void spi_set_cpol(U08 cpol);
+void spi_set_cpha(U08 cpha);
+void spi_setup(void);
+void spi_transfer_string(U08 length, U08* addr, U08 device);
+//-----------------------------------------------------------------------------
+
+#endif
Index: /firmware/MSR/src/typedefs.h
===================================================================
--- /firmware/MSR/src/typedefs.h	(revision 10588)
+++ /firmware/MSR/src/typedefs.h	(revision 10588)
@@ -0,0 +1,141 @@
+#ifndef __TYPEDEFS_H
+#define __TYPEDEFS_H
+//-----------------------------------------------------------------------------
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <limits.h>
+#include <util/delay.h>
+#include <avr/io.h>
+#include <avr/interrupt.h>
+#include "macros.h"
+#include <avr/pgmspace.h>
+
+//-----------------------------------------------------------------------------
+
+#define true 1
+#define TRUE 1
+#define ON 1
+#define on 1
+#define SET 1
+#define set 1
+
+#define false 0
+#define FALSE 0
+#define OFF 0
+#define off 0
+#define CLEAR 0
+#define clear 0
+
+#define BIT0 0x01
+#define BIT1 0x02
+#define BIT2 0x04
+#define BIT3 0x08
+#define BIT4 0x10
+#define BIT5 0x20
+#define BIT6 0x40
+#define BIT7 0x80
+#define BIT8 0x0100
+#define BIT9 0x0200
+#define BIT10 0x0400
+#define BIT11 0x0800
+#define BIT12 0x1000
+#define BIT13 0x2000
+#define BIT14 0x4000
+#define BIT15 0x8000
+#define BIT16 0x010000
+#define BIT17 0x020000
+#define BIT18 0x040000
+#define BIT19 0x080000
+#define BIT20 0x100000
+#define BIT21 0x200000
+#define BIT22 0x400000
+#define BIT23 0x800000
+#define BIT24 0x01000000
+#define BIT25 0x02000000
+#define BIT26 0x04000000
+#define BIT27 0x08000000
+#define BIT28 0x10000000
+#define BIT29 0x20000000
+#define BIT30 0x40000000
+#define BIT31 0x80000000
+//-----------------------------------------------------------------------------
+
+// Typendeklarationen
+typedef signed char S8;
+typedef signed char S08;
+typedef signed char tS08;
+typedef unsigned char U8;
+typedef unsigned char U08;
+typedef unsigned char tU08;
+
+typedef signed int S16;
+typedef signed int tS16;
+typedef unsigned int U16;
+typedef unsigned int tU16;
+typedef signed long S32;
+typedef signed long tS32;
+typedef unsigned long U32;
+typedef unsigned long tU32;
+
+typedef S08 *pS8;
+typedef S08 *pS08;
+typedef U08 *pU8;
+typedef U08 *pU08;
+typedef S16 *pS16;
+typedef U16 *pU16;
+typedef S32 *pS32;
+typedef U32 *pU32;
+typedef float *pfloat;
+
+typedef U08 BOOL;
+typedef BOOL *pBOOL;
+typedef U08 bool;
+
+//typedef U08 __flash *fpU08; //geht nicht mit gcc
+//typedef U08 PROGMEM prog_U08;
+//typedef prog_U08 *fpU08;
+typedef U08 *fpU08;
+
+typedef union uMEM16 // Word and Byte access to 16-Bit data
+{
+  U16 word; // Word
+  pU16 pword; // Pointer to Word
+  U08 byte[2]; // Byte
+  pU08 pbyte; // Pointer to Byte
+} tMEM16;
+
+typedef union uMEM32 // DWord, Word and Byte access to 32-Bit data
+{
+  U32 dword; // DWORD
+  pU32 pdword[2]; // Pointer to U32
+
+  float fp; // Float
+  pfloat pfp[2]; // Pointer to float
+
+  U16 word[2]; // Word
+  pU16 pword[2]; // Pointer to U16
+
+  U08 byte[4]; // Byte
+  pU08 pbyte[2]; // Pointer to U08
+
+} tMEM32;
+
+typedef enum // Enumeration of watchdog prescale values
+{
+  WDT_PS_2K, // 2048 cycles (16ms)
+  WDT_PS_4K, // 40968 cycles (32ms)
+  WDT_PS_8K, // 8192 cycles (64ms)
+  WDT_PS_16K, // 16384 cycles (0.125s)
+  WDT_PS_32K, // 32768 cycles (0.25s)
+  WDT_PS_64K, // 65536 cycles (0.5s)
+  WDT_PS_128K, // 131072 cycles (1.0s)
+  WDT_PS_256K, // 262144 cycles (2.0s)
+  WDT_PS_512K, // 524288 cycles (4.0s)
+  WDT_PS_1024K // 1048576 cycles (8.0s)
+} tWDT_PRESCALE;
+//-----------------------------------------------------------------------------
+
+#endif
Index: /firmware/MSR/src/usart.c
===================================================================
--- /firmware/MSR/src/usart.c	(revision 10588)
+++ /firmware/MSR/src/usart.c	(revision 10588)
@@ -0,0 +1,269 @@
+//-----------------------------------------------------------------------------
+
+#include "usart.h"
+#include <avr/interrupt.h>
+//-----------------------------------------------------------------------------
+
+#ifdef USART_USE_RX_IRQ
+  U08 usart_rx_buffer[USART_RX_BUFFER_SIZE];
+  //U08 *usart_rx_buffer_ptr = &usart_rx_buffer[0];
+  U08 usart_received_chars;
+  volatile BOOL usart_rx_ready = false;
+  static U08 usart_rx_buffer_index = 0;
+  static U08 usart_receive_char;
+  static BOOL usart_receive_suspended = false;
+  volatile BOOL ISR_toggle_out = false;
+#endif
+//-----------------------------------------------------------------------------
+
+void usart_init(void)
+{
+  USART_SET_BAUDRATE(USART_BAUDRATE);
+
+  UCSRA = 0x00;
+
+  UCSRB = 0x00; // Disable receiver and transmitter and interrupts
+
+#ifdef USART_USE_RX
+  UCSRB |= (1 << RXEN);			// Turn on receiver
+	DDRD &= ~(1<<PD0);				// PD0 is RXD
+#endif
+
+#ifdef USART_USE_RX_IRQ
+  UCSRB |= (1 << RXCIE);		// Enable rx interrupt
+#endif
+
+#ifdef USART_USE_TX
+  UCSRB |= (1 << TXEN);			// Turn on transmitter
+	DDRD |= 1<<PD1; 					// PD1 is TXD
+#endif
+
+  UCSRC = (1 << URSEL) | (1 << UCSZ1) | (1 << UCSZ0); // 8-Bit character length
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_char(U08 data)
+{
+  while (!(UCSRA & (1 << UDRE))) ; // Wait until tx register is empty
+  UDR = data;
+
+//	if ( usart_tx_buffer_index < USART_TX_BUFFER_SIZE-1){
+//		usart_tx_buffer[usart_tx_buffer_index] = data;
+//		++usart_tx_buffer_index;
+//	} else {
+//		usart_tx_buffer_overflow = true;
+//	}
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_crlf(void)
+{
+  usart_write_char(USART_CHAR_CR);
+  usart_write_char(USART_CHAR_LF);
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_str(pU08 str)
+{
+  while (*str)
+  {
+    usart_write_char(*str++);
+  }
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_flash_str(fpU08 str)
+{
+  while (*str)
+  {
+    usart_write_char(*str++);
+  }
+}
+//-----------------------------------------------------------------------------
+
+void usart_writeln_flash_str(fpU08 str)
+{
+  while (*str)
+  {
+    usart_write_char(*str++);
+  }
+
+  usart_write_char(USART_CHAR_CR);
+  usart_write_char(USART_CHAR_LF);
+}
+//-----------------------------------------------------------------------------
+
+void usart_writeln_str(pU08 str)
+{
+  usart_write_str(str);
+  usart_write_char(USART_CHAR_CR);
+  usart_write_char(USART_CHAR_LF);
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_U08(U08 value,U08 digits)
+{
+  usart_write_str(nc_U08_to_str(value,digits));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_S08(S08 value,U08 digits)
+{
+  usart_write_str(nc_S08_to_str(value,digits));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_U08_hex(U08 value)
+{
+  usart_write_str(nc_U08_to_hex(value));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_U08_bin(U08 value)
+{
+  usart_write_str(nc_U08_to_bin(value));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_U16(U16 value,U08 digits)
+{
+  usart_write_str(nc_U16_to_str(value,digits));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_S16(S16 value,U08 digits)
+{
+  usart_write_str(nc_S16_to_str(value,digits));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_U16_hex(U16 value)
+{
+  usart_write_str(nc_U16_to_hex(value));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_U32(U32 value,U08 digits)
+{
+  usart_write_str(nc_U32_to_str(value,digits));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_S32(S32 value,U08 digits)
+{
+  usart_write_str(nc_S32_to_str(value,digits));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_U32_hex(U32 value)
+{
+  usart_write_str(nc_U32_to_hex(value));
+}
+//-----------------------------------------------------------------------------
+
+void usart_write_float(float value,U08 decimals,U08 digits)
+{
+  usart_write_str(nc_float_to_str(value,decimals,digits));
+}
+//-----------------------------------------------------------------------------
+
+#ifdef USART_USE_RX_IRQ
+
+ISR(SIG_USART_RECV)
+{
+  if (ISR_toggle_out) PORTB ^= (1<<PB3); // toggle Out2_spare when starting ISR
+
+  usart_receive_char = UDR;
+
+  if (usart_rx_ready) // Exit if ready flag is still set 
+  {
+    return;
+  }
+
+  // If CR received, then set ready flag
+  if (usart_receive_char == USART_CHAR_CR)
+  {
+    usart_rx_buffer[usart_rx_buffer_index] = 0; // Terminate input string
+    usart_received_chars = usart_rx_buffer_index;
+    usart_rx_buffer_index = 0;
+    usart_receive_suspended = false;
+    usart_rx_ready = TRUE;
+    return;
+  }
+
+  // Ignore all characters till next CR
+  if (usart_receive_suspended)
+  {
+    return;
+  }
+
+  // Check for underscore or comment
+  if (usart_receive_char == '_' || usart_receive_char == ';')
+  {
+    usart_receive_suspended = true;
+
+    return;
+  }
+
+  // If Backspace received, then delete last character
+  if (usart_receive_char == USART_CHAR_BS && usart_rx_buffer_index)
+  {
+    usart_rx_buffer_index--;
+
+    return;
+  }
+
+  // Ignore invalid characters
+  if (usart_receive_char < USART_CHAR_SPC)
+  {
+    return;
+  }
+
+#ifdef USART_USE_UPPERCASE
+  if (usart_receive_char >= 'a' && usart_receive_char <= 'z')
+  {
+    usart_receive_char -= 32;
+  }
+#endif
+
+  if (usart_rx_buffer_index < USART_RX_BUFFER_SIZE - 1) // Store character
+  {
+    usart_rx_buffer[usart_rx_buffer_index++] = usart_receive_char;
+    usart_writeln_str(usart_rx_buffer);
+  }
+
+  //usart_write_char(usart_rx_buffer[usart_rx_buffer_index]);
+ //usart_writeln_str(usart_rx_buffer);
+ //usart_write_char(usart_rx_buffer[1,2]);
+ //usart_write_char(usart_rx_buffer[usart_rx_buffer_index]);
+ //usart_writeln_flash_str(*usart_rx_buffer);
+ //usart_write_char(usart_rx_buffer);
+}  
+#endif 
+/*
+#define uart_maxstrlen 64
+ 
+volatile U8 uart_str_complete=0;
+volatile U8 uart_str_count=0;
+volatile U8 uart_string[uart_maxstrlen+1]="";
+
+ISR(USART_RXC_vect)
+{
+    unsigned char buffer = 64;
+    // Daten aus dem Puffer lesen
+    buffer = UDR;
+	UDR = buffer;
+	if ( uart_str_complete==0 ){	// wenn uart_string gerade in Verwendung, neues Zeichen verwerfen
+		// Daten werden erst in string geschrieben, wenn nicht String-Ende/max Zeichenlänge erreicht ist/string gerade verarbeitet wird
+	  	if (buffer!='\n' && buffer!='\r' && uart_str_count<uart_maxstrlen-1){
+			uart_string[uart_str_count]=buffer;
+			uart_str_count++;
+		} else {
+			uart_string[uart_str_count]='\0';
+			uart_str_count=0;
+			uart_str_complete=1;
+		}
+	}
+}
+
+*/
Index: /firmware/MSR/src/usart.h
===================================================================
--- /firmware/MSR/src/usart.h	(revision 10588)
+++ /firmware/MSR/src/usart.h	(revision 10588)
@@ -0,0 +1,54 @@
+#ifndef __USART_H
+#define __USART_H
+//-----------------------------------------------------------------------------
+
+#include "typedefs.h"
+#include "application.h"
+#include "num_conversion.h"
+//-----------------------------------------------------------------------------
+
+#define USART_CHAR_BS 8
+#define USART_CHAR_LF 10
+#define USART_CHAR_CR 13
+#define USART_CHAR_ESC 27
+#define USART_CHAR_SPC 32
+//-----------------------------------------------------------------------------
+
+#define USART_SET_BAUDRATE(br) (UBRRH = (U08)((((U32)F_CPU) /\
+                                ((U32)br * 16) - 1) >> 8),\
+                                UBRRL = (U08)(((U32)F_CPU) /\
+                                ((U32)br * 16) - 1))
+//-----------------------------------------------------------------------------
+/*
+extern U08 usart_rx_buffer[];
+extern volatile BOOL usart_rx_ready;
+extern volatile BOOL ISR_toggle_out;
+extern U08 usart_received_chars;
+*/
+extern bool usart_tx_buffer_overflow;
+extern U08 usart_tx_buffer_index;
+extern U08 usart_tx_buffer[USART_TX_BUFFER_SIZE];
+extern U08 usart_received_chars;
+//-----------------------------------------------------------------------------
+
+void usart_init(void);
+void usart_write_char(U08 data);
+void usart_write_crlf(void);
+void usart_write_str(pU08 str);
+void usart_writeln_str(pU08 str);
+void usart_write_flash_str(fpU08 str);
+void usart_writeln_flash_str(fpU08 str);
+void usart_write_U08(U08 value,U08 digits);
+void usart_write_S08(S08 value,U08 digits);
+void usart_write_U08_hex(U08 value);
+void usart_write_U08_bin(U08 value);
+void usart_write_U16(U16 value,U08 digits);
+void usart_write_S16(S16 value,U08 digits);
+void usart_write_U16_hex(U16 value);
+void usart_write_U32(U32 value,U08 digits);
+void usart_write_S32(S32 value,U08 digits);
+void usart_write_U32_hex(U32 value);
+void usart_write_float(float value,U08 decimals,U08 digits);
+//-----------------------------------------------------------------------------
+
+#endif
