diff --git a/Mainboard/Mainboard.atsuo b/Mainboard/Mainboard.atsuo index a52161b..1602e93 100644 Binary files a/Mainboard/Mainboard.atsuo and b/Mainboard/Mainboard.atsuo differ diff --git a/Mainboard/Mainboard/Can.h b/Mainboard/Mainboard/Can.h index 12a9751..dc06e08 100644 --- a/Mainboard/Mainboard/Can.h +++ b/Mainboard/Mainboard/Can.h @@ -21,6 +21,7 @@ typedef struct uint8_t data[8]; } CANMessage; +template class Can { private: void init_can(); @@ -29,9 +30,8 @@ class Can { uint8_t mcp2515_read_register(uint8_t adress); void mcp2515_bit_modify(uint8_t adress, uint8_t mask, uint8_t data); uint8_t mcp2515_read_rx_status(void); - Spi s; public: - Can(Spi spi); + Can(); uint8_t can_send_message(CANMessage *p_message); uint8_t can_get_message(CANMessage *p_message); }; diff --git a/Mainboard/Mainboard/Debug/Mainboard.d b/Mainboard/Mainboard/Debug/Mainboard.d index a897c94..e5e414c 100644 --- a/Mainboard/Mainboard/Debug/Mainboard.d +++ b/Mainboard/Mainboard/Debug/Mainboard.d @@ -1,4 +1,5 @@ Mainboard.d Mainboard.o: .././Mainboard.cpp .././config.h .././Led.h \ + .././portc.hpp \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/io.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/sfr_defs.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/inttypes.h \ @@ -10,7 +11,7 @@ Mainboard.d Mainboard.o: .././Mainboard.cpp .././config.h .././Led.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/version.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/fuse.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/lock.h \ - .././Rs232.h \ + .././pin.hpp .././Rs232.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/stdio.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/include/stdarg.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/include/stddef.h \ @@ -18,12 +19,14 @@ Mainboard.d Mainboard.o: .././Mainboard.cpp .././config.h .././Led.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/util/delay.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/util/delay_basic.h \ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/math.h \ - .././mcp2515_defs.h .././Spi.h + .././mcp2515_defs.h .././Spi.h .././portb.hpp .././config.h: .././Led.h: +.././portc.hpp: + c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/io.h: c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/sfr_defs.h: @@ -46,6 +49,8 @@ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8- c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/avr/lock.h: +.././pin.hpp: + .././Rs232.h: c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8-gnu-toolchain\bin\../lib/gcc/avr/4.7.2/../../../../avr/include/stdio.h: @@ -65,3 +70,5 @@ c:\program\ files\ (x86)\atmel\atmel\ toolchain\avr8\ gcc\native\3.4.2.876\avr8- .././mcp2515_defs.h: .././Spi.h: + +.././portb.hpp: diff --git a/Mainboard/Mainboard/Debug/Mainboard.elf b/Mainboard/Mainboard/Debug/Mainboard.elf index 9b18bea..9cce564 100644 Binary files a/Mainboard/Mainboard/Debug/Mainboard.elf and b/Mainboard/Mainboard/Debug/Mainboard.elf differ diff --git a/Mainboard/Mainboard/Debug/Mainboard.hex b/Mainboard/Mainboard/Debug/Mainboard.hex index 6571d33..f042829 100644 --- a/Mainboard/Mainboard/Debug/Mainboard.hex +++ b/Mainboard/Mainboard/Debug/Mainboard.hex @@ -5,20 +5,20 @@ :100040000C9463000C9463000C9463000C946300A4 :100050000C9463000C9463000C9463000C94630094 :100060000C9463000C9463000C9463000C94630084 -:100070000C9463005E0211241FBECFEFD4E0DEBFFC -:10008000CDBF11E0A0E0B1E0EAEFF5E002C00590DD +:100070000C946300400211241FBECFEFD4E0DEBF1A +:10008000CDBF11E0A0E0B1E0E4EAF5E002C00590E8 :100090000D92A630B107D9F721E0A6E0B1E001C08A -:1000A0001D92AB30B207E1F710E0C6E7D0E004C024 -:1000B0002297FE010E94F702C437D107C9F70E94B8 -:1000C00009020C94FB020C940000FF920F931F9303 +:1000A0001D92A930B207E1F710E0C6E7D0E004C026 +:1000B0002297FE010E94CC02C437D107C9F70E94E3 +:1000C000F9010C94D0020C940000FF920F931F933F :1000D000CF93DF931F92CDB7DEB7F82E092F162FDF -:1000E00049830E94C40262E08F2D902F0E94E90292 -:1000F000612F8F2D902F0E94E9024981642F8F2D4F -:10010000902F0E94E9028F2D902F0F90DF91CF91B9 -:100110001F910F91FF900C94C202CF93DF93D82FC1 -:10012000C92F0E94C40260EC8D2F9C2F0E94E9020F +:1000E00049830E949A0262E08F2D902F0E94BE02E7 +:1000F000612F8F2D902F0E94BE024981642F8F2D7A +:10010000902F0E94BE028F2D902F0F90DF91CF91E4 +:100110001F910F91FF900C949702CF93DF93D82FEC +:10012000C92F0E949A0260EC8D2F9C2F0E94BE0264 :100130008FE99FE00197F1F700C000008D2F9C2F01 -:100140000E94C2028FE39CE90197F1F700C0000012 +:100140000E9497028FE39CE90197F1F700C000003D :1001500047E06AE28D2F9C2F0E94650040E969E22A :100160008D2F9C2F0E94650042E068E28D2F9C2F0E :100170000E94650043E06BE28D2F9C2F0E9465007A @@ -30,69 +30,64 @@ :1001D0000E94650040E065E28D2F9C2F0E94650023 :1001E00040E066E28D2F9C2F0E94650040E067E2B0 :1001F0008D2F9C2F0E94650040E06CE08D2F9C2F7E -:10020000DF91CF910C946500FC01408351836283A0 -:100210000C948D00FF920F931F93CF93DF9300D028 -:10022000CDB7DEB7F82E092F162F2A8349830E94F7 -:10023000C40265E08F2D902F0E94E902612F8F2D5F -:10024000902F0E94E9024981642F8F2D902F0E94E8 -:10025000E9022A81622F8F2D902F0E94E9028F2DB3 -:10026000902F0F900F90DF91CF911F910F91FF90E2 -:100270000C94C2021F93CF93DF93D82FC92F0E94F3 -:10028000C40260EB8D2F9C2F0E94E9026FEF8D2F2F -:100290009C2F0E94E902182F6FEF8D2F9C2F0E9438 -:1002A000E9028D2F9C2F0E94C202812FDF91CF91F6 -:1002B0001F9108959F92AF92BF92CF92DF92EF92DB -:1002C000FF920F931F93CF93DF931F92CDB7DEB7AB -:1002D0005C016B010E943A01982E8983898186FD19 -:1002E00011C0898187FD7FC08FEF0F90DF91CF9183 -:1002F0001F910F91FF90EF90DF90CF90BF90AF9044 -:100300009F900895C5010E94C40260E9C5010E9442 -:10031000E9026FEFC5010E94E902282F30E0220FA9 -:10032000331F220F331F220F331FF6013183208327 -:100330006FEFC5010E94E902482F50E0569547959E -:10034000529542954F7045275F704527F6012081F1 -:100350003181242B352B318320836FEFC5010E941F -:10036000E9026FEFC5010E94E9026FEFC5010E942B -:10037000E9028F70F60183838823A1F086010C5F68 -:100380001F4F7601F5E0EF0EF11C8150E80EF11CD5 -:100390006FEFC5010E94E902F80181938F01EE150C -:1003A000FF05B1F7C5010E94C202898183FD0EC01D -:1003B000F6011282898120E086FF0FC041E06CE2E5 -:1003C000C5010E940A01892D87708FCF81E0F60157 -:1003D0008283898120E086FDF1CF42E06CE2C50195 -:1003E0000E940A01F0CFC5010E94C40264E9C50160 -:1003F0000E94E9028ECF84B1806E84B9089585B1E0 -:100400008F7185B985B16295660F607E682B65B97D -:100410000895CF93DF93CDB7DEB72C970FB6F8943E -:10042000DEBF0FBECDBF66E08AE091E00E94FF0113 -:1004300060E071E089E091E00E948A0283E291E04D -:100440009A8389831B8282E08C838FEA8D838EEF6F -:100450008E830EC061E08AE091E00E94FF012FEFE1 -:1004600083ED90E3215080409040E1F700C0000010 -:1004700062E08AE091E00E94FF012FEF81EE94E0BC -:10048000215080409040E1F700C00000BE016F5F46 -:100490007F4F86E091E00E945A018F3FD9F664E0D9 -:1004A0008AE091E00E94FF012FEF81EE94E021505D -:1004B00080409040E1F700C00000DACFCF93DF9397 -:1004C00000D01F92CDB7DEB78AE091E00E94FB0119 -:1004D00089E091E00E947E0260E0CE0101960E94D8 -:1004E000B90249815A816B8186E091E00E94040142 -:1004F0000F900F900F90DF91CF91089586E0809339 -:10050000CA00E9ECF0E080818860808387E6809310 -:10051000CC000895FB019081992351F03196809190 -:10052000C80085FFFCCF9093CE0091919111F7CF39 -:10053000089524B1266124B9239825B1217F25B9D6 -:10054000DC011196ED91FC9112978081817F80836F -:100550002C9A0895CF93DF93EC010E949902888131 -:10056000811104C080E58CBD81E08DBDDF91CF910C -:10057000089521E0FC01208325E230E032832183CD -:100580000C94AA022C9A08952C98089598E080E083 -:1005900060FD2A9A60FF2A9829986695000000005D -:1005A000000000000000000000000000000000004B -:1005B000000000000000000000000000299A000078 -:1005C00023B123FB222720F9880F822B915001F7BA -:1005D0000895FC012081211106C06EBD0DB407FEF7 -:1005E000FDCF8EB508950C94C602EE0FFF1F059047 -:0A05F000F491E02D0994F894FFCF78 -:0605FA00626C610A0000C2 +:10020000DF91CF910C946500FC0160830C948D000C +:10021000FF920F931F93CF93DF9300D0CDB7DEB73C +:10022000F82E092F162F2A8349830E949A0265E02F +:100230008F2D902F0E94BE02612F8F2D902F0E9434 +:10024000BE024981642F8F2D902F0E94BE022A8109 +:10025000622F8F2D902F0E94BE028F2D902F0F9016 +:100260000F90DF91CF911F910F91FF900C94970207 +:100270001F93CF93DF93D82FC92F0E949A0260EB70 +:100280008D2F9C2F0E94BE026FEF8D2F9C2F0E94FE +:10029000BE02182F6FEF8D2F9C2F0E94BE028D2F54 +:1002A0009C2F0E949702812FDF91CF911F9108957B +:1002B0009F92AF92BF92CF92DF92EF92FF920F93F5 +:1002C0001F93CF93DF931F92CDB7DEB75C016B0115 +:1002D0000E943801982E8983898186FD11C0898109 +:1002E00087FD7FC08FEF0F90DF91CF911F910F910E +:1002F000FF90EF90DF90CF90BF90AF909F900895C8 +:10030000C5010E949A0260E9C5010E94BE026FEF1A +:10031000C5010E94BE02282F30E0220F331F220F9A +:10032000331F220F331FF601318320836FEFC50186 +:100330000E94BE02482F50E056954795529542952F +:100340004F7045275F704527F60120813181242BAE +:10035000352B318320836FEFC5010E94BE026FEF02 +:10036000C5010E94BE026FEFC5010E94BE028F70E0 +:10037000F60183838823A1F086010C5F1F4F76016D +:10038000F5E0EF0EF11C8150E80EF11C6FEFC50196 +:100390000E94BE02F80181938F01EE15FF05B1F7AF +:1003A000C5010E949702898183FD0EC0F601128269 +:1003B000898120E086FF0FC041E06CE2C5010E9408 +:1003C0000801892D87708FCF81E0F60182838981B2 +:1003D00020E086FDF1CF42E06CE2C5010E940801F9 +:1003E000F0CFC5010E949A0264E9C5010E94BE02D5 +:1003F0008ECFCF93DF93CDB7DEB72C970FB6F8949F +:10040000DEBF0FBECDBF47983F9A469A3E9A459AA7 +:100410003D9A60E071E087E091E00E94660283E22D +:1004200091E09A8389831B8282E08C838FEA8D839B +:100430008EEF8E8309C02FEF83ED90E32150804033 +:100440009040E1F700C000002FEF81EE94E02150D2 +:1004500080409040E1F700C00000BE016F5F7F4F19 +:1004600086E091E00E9458018F3F29F72FEF81EE3F +:1004700094E0215080409040E1F700C00000E4CFBC +:10048000CF93DF931F92CDB7DEB73D9A3E9A3F9A46 +:1004900087E091E00E945A0260E0CE0101960E943E +:1004A0009202698186E091E00E9404010F90DF9141 +:1004B000CF91089586E08093CA00E9ECF0E0808156 +:1004C0008860808387E68093CC000895FB0190814B +:1004D000992351F031968091C80085FFFCCF90930D +:1004E000CE0091919111F7CF0895229A2A98229ADD +:1004F000219A2998219A249A2C9A249A23982B9805 +:100500002B98239A0895CF93DF93EC010E947502F4 +:100510008881811104C080E58CBD81E08DBDDF91B3 +:10052000CF91089521E0FC0120830C9483022C9A42 +:10053000249A08952C98249A089598E080E015C094 +:100540002A98229A25E02A95F1F700001B998160EC +:1005500025E02A95F1F70000299A219A2AE02A95A8 +:10056000F1F700C0660F915041F0880F2998219A49 +:1005700067FFE6CF2A9A229AE5CF0895FC012081F1 +:10058000211106C06EBD0DB407FEFDCF8EB50895D6 +:100590000C949D02EE0FFF1F0590F491E02D09943D +:0405A000F894FFCFFD +:0605A400626C610A000018 :00000001FF diff --git a/Mainboard/Mainboard/Debug/Mainboard.lss b/Mainboard/Mainboard/Debug/Mainboard.lss index 0a9b025..10f588a 100644 --- a/Mainboard/Mainboard/Debug/Mainboard.lss +++ b/Mainboard/Mainboard/Debug/Mainboard.lss @@ -3,33 +3,33 @@ Mainboard.elf: file format elf32-avr Sections: Idx Name Size VMA LMA File off Algn - 0 .data 00000006 00800100 000005fa 0000068e 2**0 + 0 .data 00000006 00800100 000005a4 00000638 2**0 CONTENTS, ALLOC, LOAD, DATA - 1 .text 000005fa 00000000 00000000 00000094 2**1 + 1 .text 000005a4 00000000 00000000 00000094 2**1 CONTENTS, ALLOC, LOAD, READONLY, CODE - 2 .bss 00000005 00800106 00800106 00000694 2**0 + 2 .bss 00000003 00800106 00800106 0000063e 2**0 ALLOC - 3 .stab 000006cc 00000000 00000000 00000694 2**2 + 3 .stab 000006cc 00000000 00000000 00000640 2**2 CONTENTS, READONLY, DEBUGGING - 4 .stabstr 00000082 00000000 00000000 00000d60 2**0 + 4 .stabstr 00000082 00000000 00000000 00000d0c 2**0 CONTENTS, READONLY, DEBUGGING - 5 .comment 0000002f 00000000 00000000 00000de2 2**0 + 5 .comment 0000002f 00000000 00000000 00000d8e 2**0 CONTENTS, READONLY - 6 .debug_aranges 00000160 00000000 00000000 00000e11 2**0 + 6 .debug_aranges 00000130 00000000 00000000 00000dbd 2**0 CONTENTS, READONLY, DEBUGGING - 7 .debug_info 0000233b 00000000 00000000 00000f71 2**0 + 7 .debug_info 000031fa 00000000 00000000 00000eed 2**0 CONTENTS, READONLY, DEBUGGING - 8 .debug_abbrev 00000c52 00000000 00000000 000032ac 2**0 + 8 .debug_abbrev 00000c55 00000000 00000000 000040e7 2**0 CONTENTS, READONLY, DEBUGGING - 9 .debug_line 000008ce 00000000 00000000 00003efe 2**0 + 9 .debug_line 0000088d 00000000 00000000 00004d3c 2**0 CONTENTS, READONLY, DEBUGGING - 10 .debug_frame 0000035c 00000000 00000000 000047cc 2**2 + 10 .debug_frame 000002d8 00000000 00000000 000055cc 2**2 CONTENTS, READONLY, DEBUGGING - 11 .debug_str 0000054c 00000000 00000000 00004b28 2**0 + 11 .debug_str 00000f02 00000000 00000000 000058a4 2**0 CONTENTS, READONLY, DEBUGGING - 12 .debug_loc 00000dbb 00000000 00000000 00005074 2**0 + 12 .debug_loc 00000c7f 00000000 00000000 000067a6 2**0 CONTENTS, READONLY, DEBUGGING - 13 .debug_ranges 00000188 00000000 00000000 00005e2f 2**0 + 13 .debug_ranges 00000120 00000000 00000000 00007425 2**0 CONTENTS, READONLY, DEBUGGING Disassembly of section .text: @@ -66,7 +66,7 @@ Disassembly of section .text: 70: 0c 94 63 00 jmp 0xc6 ; 0xc6 <__bad_interrupt> 00000074 <__ctors_start>: - 74: 5e 02 muls r21, r30 + 74: 40 02 muls r20, r16 00000076 <__ctors_end>: 76: 11 24 eor r1, r1 @@ -80,7 +80,7 @@ Disassembly of section .text: 82: 11 e0 ldi r17, 0x01 ; 1 84: a0 e0 ldi r26, 0x00 ; 0 86: b1 e0 ldi r27, 0x01 ; 1 - 88: ea ef ldi r30, 0xFA ; 250 + 88: e4 ea ldi r30, 0xA4 ; 164 8a: f5 e0 ldi r31, 0x05 ; 5 8c: 02 c0 rjmp .+4 ; 0x92 <__do_copy_data+0x10> 8e: 05 90 lpm r0, Z+ @@ -99,7 +99,7 @@ Disassembly of section .text: a0: 1d 92 st X+, r1 000000a2 <.do_clear_bss_start>: - a2: ab 30 cpi r26, 0x0B ; 11 + a2: a9 30 cpi r26, 0x09 ; 9 a4: b2 07 cpc r27, r18 a6: e1 f7 brne .-8 ; 0xa0 <.do_clear_bss_loop> @@ -110,12 +110,12 @@ Disassembly of section .text: ae: 04 c0 rjmp .+8 ; 0xb8 <__do_global_ctors+0x10> b0: 22 97 sbiw r28, 0x02 ; 2 b2: fe 01 movw r30, r28 - b4: 0e 94 f7 02 call 0x5ee ; 0x5ee <__tablejump__> + b4: 0e 94 cc 02 call 0x598 ; 0x598 <__tablejump__> b8: c4 37 cpi r28, 0x74 ; 116 ba: d1 07 cpc r29, r17 bc: c9 f7 brne .-14 ; 0xb0 <__do_global_ctors+0x8> - be: 0e 94 09 02 call 0x412 ; 0x412
- c2: 0c 94 fb 02 jmp 0x5f6 ; 0x5f6 <_exit> + be: 0e 94 f9 01 call 0x3f2 ; 0x3f2
+ c2: 0c 94 d0 02 jmp 0x5a0 ; 0x5a0 <_exit> 000000c6 <__bad_interrupt>: c6: 0c 94 00 00 jmp 0 ; 0x0 <__vectors> @@ -148,15 +148,15 @@ Disassembly of section .text: return 1; e0: 49 83 std Y+1, r20 ; 0x01 } - e2: 0e 94 c4 02 call 0x588 ; 0x588 <_ZN3Spi4CSOnEv> + e2: 0e 94 9a 02 call 0x534 ; 0x534 <_ZN3Spi4CSOnEv> e6: 62 e0 ldi r22, 0x02 ; 2 e8: 8f 2d mov r24, r15 ea: 90 2f mov r25, r16 - ec: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> + ec: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> f0: 61 2f mov r22, r17 f2: 8f 2d mov r24, r15 f4: 90 2f mov r25, r16 - f6: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> + f6: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> fa: 49 81 ldd r20, Y+1 ; 0x01 fc: 64 2f mov r22, r20 */ @@ -168,7 +168,7 @@ Disassembly of section .text: fe: 8f 2d mov r24, r15 address = 0x02; 100: 90 2f mov r25, r16 - 102: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> + 102: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> Puffer gesendet werden soll */ s.CSOn(); // CS wieder Low if (address == 0x00) { @@ -189,7 +189,7 @@ Disassembly of section .text: s.send(length); 112: 0f 91 pop r16 114: ff 90 pop r15 - 116: 0c 94 c2 02 jmp 0x584 ; 0x584 <_ZN3Spi5CSOffEv> + 116: 0c 94 97 02 jmp 0x52e ; 0x52e <_ZN3Spi5CSOffEv> 0000011a <_ZN3Can8init_canEv>: @@ -205,11 +205,11 @@ Disassembly of section .text: uint8_t Can::can_send_message(CANMessage *p_message) 120: c9 2f mov r28, r25 - 122: 0e 94 c4 02 call 0x588 ; 0x588 <_ZN3Spi4CSOnEv> + 122: 0e 94 9a 02 call 0x534 ; 0x534 <_ZN3Spi4CSOnEv> 126: 60 ec ldi r22, 0xC0 ; 192 128: 8d 2f mov r24, r29 12a: 9c 2f mov r25, r28 - 12c: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> + 12c: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> 130: 8f e9 ldi r24, 0x9F ; 159 132: 9f e0 ldi r25, 0x0F ; 15 134: 01 97 sbiw r24, 0x01 ; 1 @@ -224,7 +224,7 @@ uint8_t Can::can_send_message(CANMessage *p_message) 13a: 00 00 nop 13c: 8d 2f mov r24, r29 13e: 9c 2f mov r25, r28 - 140: 0e 94 c2 02 call 0x584 ; 0x584 <_ZN3Spi5CSOffEv> + 140: 0e 94 97 02 call 0x52e ; 0x52e <_ZN3Spi5CSOffEv> { // Nachrichten Laenge einstellen s.send(length); @@ -390,863 +390,962 @@ uint8_t Can::can_send_message(CANMessage *p_message) Can::Can(Spi spi) : s(spi) { 208: fc 01 movw r30, r24 - 20a: 40 83 st Z, r20 - 20c: 51 83 std Z+1, r21 ; 0x01 - 20e: 62 83 std Z+2, r22 ; 0x02 + 20a: 60 83 st Z, r22 init_can(); - 210: 0c 94 8d 00 jmp 0x11a ; 0x11a <_ZN3Can8init_canEv> + 20c: 0c 94 8d 00 jmp 0x11a ; 0x11a <_ZN3Can8init_canEv> -00000214 <_ZN3Can18mcp2515_bit_modifyEhhh>: +00000210 <_ZN3Can18mcp2515_bit_modifyEhhh>: return data; } void Can::mcp2515_bit_modify(uint8_t adress, uint8_t mask, uint8_t data) { - 214: ff 92 push r15 - 216: 0f 93 push r16 - 218: 1f 93 push r17 - 21a: cf 93 push r28 - 21c: df 93 push r29 - 21e: 00 d0 rcall .+0 ; 0x220 <_ZN3Can18mcp2515_bit_modifyEhhh+0xc> - 220: cd b7 in r28, 0x3d ; 61 - 222: de b7 in r29, 0x3e ; 62 - 224: f8 2e mov r15, r24 - 226: 09 2f mov r16, r25 - 228: 16 2f mov r17, r22 + 210: ff 92 push r15 + 212: 0f 93 push r16 + 214: 1f 93 push r17 + 216: cf 93 push r28 + 218: df 93 push r29 + 21a: 00 d0 rcall .+0 ; 0x21c <_ZN3Can18mcp2515_bit_modifyEhhh+0xc> + 21c: cd b7 in r28, 0x3d ; 61 + 21e: de b7 in r29, 0x3e ; 62 + 220: f8 2e mov r15, r24 + 222: 09 2f mov r16, r25 + 224: 16 2f mov r17, r22 // /CS des MCP2515 auf Low ziehen s.CSOn(); - 22a: 2a 83 std Y+2, r18 ; 0x02 - 22c: 49 83 std Y+1, r20 ; 0x01 - 22e: 0e 94 c4 02 call 0x588 ; 0x588 <_ZN3Spi4CSOnEv> + 226: 2a 83 std Y+2, r18 ; 0x02 + 228: 49 83 std Y+1, r20 ; 0x01 + 22a: 0e 94 9a 02 call 0x534 ; 0x534 <_ZN3Spi4CSOnEv> s.send(SPI_BIT_MODIFY); - 232: 65 e0 ldi r22, 0x05 ; 5 - 234: 8f 2d mov r24, r15 - 236: 90 2f mov r25, r16 - 238: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> + 22e: 65 e0 ldi r22, 0x05 ; 5 + 230: 8f 2d mov r24, r15 + 232: 90 2f mov r25, r16 + 234: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> s.send(adress); - 23c: 61 2f mov r22, r17 - 23e: 8f 2d mov r24, r15 - 240: 90 2f mov r25, r16 - 242: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> + 238: 61 2f mov r22, r17 + 23a: 8f 2d mov r24, r15 + 23c: 90 2f mov r25, r16 + 23e: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> s.send(mask); - 246: 49 81 ldd r20, Y+1 ; 0x01 - 248: 64 2f mov r22, r20 - 24a: 8f 2d mov r24, r15 - 24c: 90 2f mov r25, r16 - 24e: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> + 242: 49 81 ldd r20, Y+1 ; 0x01 + 244: 64 2f mov r22, r20 + 246: 8f 2d mov r24, r15 + 248: 90 2f mov r25, r16 + 24a: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> s.send(data); - 252: 2a 81 ldd r18, Y+2 ; 0x02 - 254: 62 2f mov r22, r18 - 256: 8f 2d mov r24, r15 - 258: 90 2f mov r25, r16 - 25a: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> + 24e: 2a 81 ldd r18, Y+2 ; 0x02 + 250: 62 2f mov r22, r18 + 252: 8f 2d mov r24, r15 + 254: 90 2f mov r25, r16 + 256: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> // /CS Leitung wieder freigeben s.CSOff(); - 25e: 8f 2d mov r24, r15 - 260: 90 2f mov r25, r16 + 25a: 8f 2d mov r24, r15 + 25c: 90 2f mov r25, r16 } - 262: 0f 90 pop r0 - 264: 0f 90 pop r0 - 266: df 91 pop r29 - 268: cf 91 pop r28 - 26a: 1f 91 pop r17 - 26c: 0f 91 pop r16 - 26e: ff 90 pop r15 + 25e: 0f 90 pop r0 + 260: 0f 90 pop r0 + 262: df 91 pop r29 + 264: cf 91 pop r28 + 266: 1f 91 pop r17 + 268: 0f 91 pop r16 + 26a: ff 90 pop r15 s.send(adress); s.send(mask); s.send(data); // /CS Leitung wieder freigeben s.CSOff(); - 270: 0c 94 c2 02 jmp 0x584 ; 0x584 <_ZN3Spi5CSOffEv> + 26c: 0c 94 97 02 jmp 0x52e ; 0x52e <_ZN3Spi5CSOffEv> -00000274 <_ZN3Can22mcp2515_read_rx_statusEv>: +00000270 <_ZN3Can22mcp2515_read_rx_statusEv>: return (status & 0x07); } uint8_t Can::mcp2515_read_rx_status(void) { - 274: 1f 93 push r17 - 276: cf 93 push r28 - 278: df 93 push r29 - 27a: d8 2f mov r29, r24 - 27c: c9 2f mov r28, r25 + 270: 1f 93 push r17 + 272: cf 93 push r28 + 274: df 93 push r29 + 276: d8 2f mov r29, r24 + 278: c9 2f mov r28, r25 uint8_t data; // /CS des MCP2515 auf Low ziehen s.CSOn(); - 27e: 0e 94 c4 02 call 0x588 ; 0x588 <_ZN3Spi4CSOnEv> + 27a: 0e 94 9a 02 call 0x534 ; 0x534 <_ZN3Spi4CSOnEv> s.send(SPI_RX_STATUS); - 282: 60 eb ldi r22, 0xB0 ; 176 - 284: 8d 2f mov r24, r29 - 286: 9c 2f mov r25, r28 - 288: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> + 27e: 60 eb ldi r22, 0xB0 ; 176 + 280: 8d 2f mov r24, r29 + 282: 9c 2f mov r25, r28 + 284: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> data = s.send(0xff); - 28c: 6f ef ldi r22, 0xFF ; 255 - 28e: 8d 2f mov r24, r29 - 290: 9c 2f mov r25, r28 - 292: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> - 296: 18 2f mov r17, r24 + 288: 6f ef ldi r22, 0xFF ; 255 + 28a: 8d 2f mov r24, r29 + 28c: 9c 2f mov r25, r28 + 28e: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> + 292: 18 2f mov r17, r24 // Die Daten werden noch einmal wiederholt gesendet, // man braucht also nur eins der beiden Bytes auswerten. s.send(0xff); - 298: 6f ef ldi r22, 0xFF ; 255 - 29a: 8d 2f mov r24, r29 - 29c: 9c 2f mov r25, r28 - 29e: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> + 294: 6f ef ldi r22, 0xFF ; 255 + 296: 8d 2f mov r24, r29 + 298: 9c 2f mov r25, r28 + 29a: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> // /CS Leitung wieder freigeben s.CSOff(); - 2a2: 8d 2f mov r24, r29 - 2a4: 9c 2f mov r25, r28 - 2a6: 0e 94 c2 02 call 0x584 ; 0x584 <_ZN3Spi5CSOffEv> + 29e: 8d 2f mov r24, r29 + 2a0: 9c 2f mov r25, r28 + 2a2: 0e 94 97 02 call 0x52e ; 0x52e <_ZN3Spi5CSOffEv> return data; - 2aa: 81 2f mov r24, r17 - 2ac: df 91 pop r29 - 2ae: cf 91 pop r28 - 2b0: 1f 91 pop r17 - 2b2: 08 95 ret + 2a6: 81 2f mov r24, r17 + 2a8: df 91 pop r29 + 2aa: cf 91 pop r28 + 2ac: 1f 91 pop r17 + 2ae: 08 95 ret -000002b4 <_ZN3Can15can_get_messageEP10CANMessage>: +000002b0 <_ZN3Can15can_get_messageEP10CANMessage>: return 1; } uint8_t Can::can_get_message(CANMessage *p_message) { - 2b4: 9f 92 push r9 - 2b6: af 92 push r10 - 2b8: bf 92 push r11 - 2ba: cf 92 push r12 - 2bc: df 92 push r13 - 2be: ef 92 push r14 - 2c0: ff 92 push r15 - 2c2: 0f 93 push r16 - 2c4: 1f 93 push r17 - 2c6: cf 93 push r28 - 2c8: df 93 push r29 - 2ca: 1f 92 push r1 - 2cc: cd b7 in r28, 0x3d ; 61 - 2ce: de b7 in r29, 0x3e ; 62 - 2d0: 5c 01 movw r10, r24 - 2d2: 6b 01 movw r12, r22 + 2b0: 9f 92 push r9 + 2b2: af 92 push r10 + 2b4: bf 92 push r11 + 2b6: cf 92 push r12 + 2b8: df 92 push r13 + 2ba: ef 92 push r14 + 2bc: ff 92 push r15 + 2be: 0f 93 push r16 + 2c0: 1f 93 push r17 + 2c2: cf 93 push r28 + 2c4: df 93 push r29 + 2c6: 1f 92 push r1 + 2c8: cd b7 in r28, 0x3d ; 61 + 2ca: de b7 in r29, 0x3e ; 62 + 2cc: 5c 01 movw r10, r24 + 2ce: 6b 01 movw r12, r22 // Status auslesen uint8_t status = mcp2515_read_rx_status(); - 2d4: 0e 94 3a 01 call 0x274 ; 0x274 <_ZN3Can22mcp2515_read_rx_statusEv> - 2d8: 98 2e mov r9, r24 - 2da: 89 83 std Y+1, r24 ; 0x01 + 2d0: 0e 94 38 01 call 0x270 ; 0x270 <_ZN3Can22mcp2515_read_rx_statusEv> + 2d4: 98 2e mov r9, r24 + 2d6: 89 83 std Y+1, r24 ; 0x01 if (bit_is_set(status,6)) - 2dc: 89 81 ldd r24, Y+1 ; 0x01 - 2de: 86 fd sbrc r24, 6 - 2e0: 11 c0 rjmp .+34 ; 0x304 <_ZN3Can15can_get_messageEP10CANMessage+0x50> + 2d8: 89 81 ldd r24, Y+1 ; 0x01 + 2da: 86 fd sbrc r24, 6 + 2dc: 11 c0 rjmp .+34 ; 0x300 <_ZN3Can15can_get_messageEP10CANMessage+0x50> // Nachricht in Puffer 0 s.CSOn(); // CS Low s.send(SPI_READ_RX); } else if (bit_is_set(status,7)) - 2e2: 89 81 ldd r24, Y+1 ; 0x01 - 2e4: 87 fd sbrc r24, 7 - 2e6: 7f c0 rjmp .+254 ; 0x3e6 <_ZN3Can15can_get_messageEP10CANMessage+0x132> + 2de: 89 81 ldd r24, Y+1 ; 0x01 + 2e0: 87 fd sbrc r24, 7 + 2e2: 7f c0 rjmp .+254 ; 0x3e2 <_ZN3Can15can_get_messageEP10CANMessage+0x132> s.CSOn(); // CS Low s.send(SPI_READ_RX | 0x04); } else { /* Fehler: Keine neue Nachricht vorhanden */ return 0xff; - 2e8: 8f ef ldi r24, 0xFF ; 255 + 2e4: 8f ef ldi r24, 0xFF ; 255 } else { mcp2515_bit_modify(CANINTF, (1< + 300: c5 01 movw r24, r10 + 302: 0e 94 9a 02 call 0x534 ; 0x534 <_ZN3Spi4CSOnEv> s.send(SPI_READ_RX); - 30a: 60 e9 ldi r22, 0x90 ; 144 - 30c: c5 01 movw r24, r10 - 30e: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> + 306: 60 e9 ldi r22, 0x90 ; 144 + 308: c5 01 movw r24, r10 + 30a: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> /* Fehler: Keine neue Nachricht vorhanden */ return 0xff; } // Standard ID auslesen p_message->id = (uint16_t) s.send(0xff) << 3; - 312: 6f ef ldi r22, 0xFF ; 255 - 314: c5 01 movw r24, r10 - 316: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> - 31a: 28 2f mov r18, r24 - 31c: 30 e0 ldi r19, 0x00 ; 0 + 30e: 6f ef ldi r22, 0xFF ; 255 + 310: c5 01 movw r24, r10 + 312: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> + 316: 28 2f mov r18, r24 + 318: 30 e0 ldi r19, 0x00 ; 0 + 31a: 22 0f add r18, r18 + 31c: 33 1f adc r19, r19 31e: 22 0f add r18, r18 320: 33 1f adc r19, r19 322: 22 0f add r18, r18 324: 33 1f adc r19, r19 - 326: 22 0f add r18, r18 - 328: 33 1f adc r19, r19 - 32a: f6 01 movw r30, r12 - 32c: 31 83 std Z+1, r19 ; 0x01 - 32e: 20 83 st Z, r18 + 326: f6 01 movw r30, r12 + 328: 31 83 std Z+1, r19 ; 0x01 + 32a: 20 83 st Z, r18 p_message->id |= (uint16_t) s.send(0xff) >> 5; - 330: 6f ef ldi r22, 0xFF ; 255 - 332: c5 01 movw r24, r10 - 334: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> - 338: 48 2f mov r20, r24 - 33a: 50 e0 ldi r21, 0x00 ; 0 - 33c: 56 95 lsr r21 - 33e: 47 95 ror r20 - 340: 52 95 swap r21 - 342: 42 95 swap r20 - 344: 4f 70 andi r20, 0x0F ; 15 + 32c: 6f ef ldi r22, 0xFF ; 255 + 32e: c5 01 movw r24, r10 + 330: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> + 334: 48 2f mov r20, r24 + 336: 50 e0 ldi r21, 0x00 ; 0 + 338: 56 95 lsr r21 + 33a: 47 95 ror r20 + 33c: 52 95 swap r21 + 33e: 42 95 swap r20 + 340: 4f 70 andi r20, 0x0F ; 15 + 342: 45 27 eor r20, r21 + 344: 5f 70 andi r21, 0x0F ; 15 346: 45 27 eor r20, r21 - 348: 5f 70 andi r21, 0x0F ; 15 - 34a: 45 27 eor r20, r21 - 34c: f6 01 movw r30, r12 - 34e: 20 81 ld r18, Z - 350: 31 81 ldd r19, Z+1 ; 0x01 - 352: 24 2b or r18, r20 - 354: 35 2b or r19, r21 - 356: 31 83 std Z+1, r19 ; 0x01 - 358: 20 83 st Z, r18 + 348: f6 01 movw r30, r12 + 34a: 20 81 ld r18, Z + 34c: 31 81 ldd r19, Z+1 ; 0x01 + 34e: 24 2b or r18, r20 + 350: 35 2b or r19, r21 + 352: 31 83 std Z+1, r19 ; 0x01 + 354: 20 83 st Z, r18 s.send(0xff); - 35a: 6f ef ldi r22, 0xFF ; 255 - 35c: c5 01 movw r24, r10 - 35e: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> + 356: 6f ef ldi r22, 0xFF ; 255 + 358: c5 01 movw r24, r10 + 35a: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> s.send(0xff); - 362: 6f ef ldi r22, 0xFF ; 255 - 364: c5 01 movw r24, r10 - 366: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> + 35e: 6f ef ldi r22, 0xFF ; 255 + 360: c5 01 movw r24, r10 + 362: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> // Laenge auslesen uint8_t length = s.send(0xff) & 0x0f; - 36a: 6f ef ldi r22, 0xFF ; 255 - 36c: c5 01 movw r24, r10 - 36e: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> - 372: 8f 70 andi r24, 0x0F ; 15 + 366: 6f ef ldi r22, 0xFF ; 255 + 368: c5 01 movw r24, r10 + 36a: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> + 36e: 8f 70 andi r24, 0x0F ; 15 p_message->length = length; - 374: f6 01 movw r30, r12 - 376: 83 83 std Z+3, r24 ; 0x03 + 370: f6 01 movw r30, r12 + 372: 83 83 std Z+3, r24 ; 0x03 // Daten auslesen for (uint8_t i=0;i + 374: 88 23 and r24, r24 + 376: a1 f0 breq .+40 ; 0x3a0 <_ZN3Can15can_get_messageEP10CANMessage+0xf0> s.CSOff(); // CS auf High return 1; } uint8_t Can::can_get_message(CANMessage *p_message) - 37c: 86 01 movw r16, r12 - 37e: 0c 5f subi r16, 0xFC ; 252 - 380: 1f 4f sbci r17, 0xFF ; 255 - 382: 76 01 movw r14, r12 - 384: f5 e0 ldi r31, 0x05 ; 5 - 386: ef 0e add r14, r31 - 388: f1 1c adc r15, r1 - 38a: 81 50 subi r24, 0x01 ; 1 - 38c: e8 0e add r14, r24 - 38e: f1 1c adc r15, r1 + 378: 86 01 movw r16, r12 + 37a: 0c 5f subi r16, 0xFC ; 252 + 37c: 1f 4f sbci r17, 0xFF ; 255 + 37e: 76 01 movw r14, r12 + 380: f5 e0 ldi r31, 0x05 ; 5 + 382: ef 0e add r14, r31 + 384: f1 1c adc r15, r1 + 386: 81 50 subi r24, 0x01 ; 1 + 388: e8 0e add r14, r24 + 38a: f1 1c adc r15, r1 uint8_t length = s.send(0xff) & 0x0f; p_message->length = length; // Daten auslesen for (uint8_t i=0;idata[i] = s.send(0xff); - 390: 6f ef ldi r22, 0xFF ; 255 - 392: c5 01 movw r24, r10 - 394: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> - 398: f8 01 movw r30, r16 - 39a: 81 93 st Z+, r24 - 39c: 8f 01 movw r16, r30 + 38c: 6f ef ldi r22, 0xFF ; 255 + 38e: c5 01 movw r24, r10 + 390: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> + 394: f8 01 movw r30, r16 + 396: 81 93 st Z+, r24 + 398: 8f 01 movw r16, r30 // Laenge auslesen uint8_t length = s.send(0xff) & 0x0f; p_message->length = length; // Daten auslesen for (uint8_t i=0;i + 39a: ee 15 cp r30, r14 + 39c: ff 05 cpc r31, r15 + 39e: b1 f7 brne .-20 ; 0x38c <_ZN3Can15can_get_messageEP10CANMessage+0xdc> p_message->data[i] = s.send(0xff); } s.CSOff(); - 3a4: c5 01 movw r24, r10 - 3a6: 0e 94 c2 02 call 0x584 ; 0x584 <_ZN3Spi5CSOffEv> + 3a0: c5 01 movw r24, r10 + 3a2: 0e 94 97 02 call 0x52e ; 0x52e <_ZN3Spi5CSOffEv> if (bit_is_set(status,3)) { - 3aa: 89 81 ldd r24, Y+1 ; 0x01 - 3ac: 83 fd sbrc r24, 3 - 3ae: 0e c0 rjmp .+28 ; 0x3cc <_ZN3Can15can_get_messageEP10CANMessage+0x118> + 3a6: 89 81 ldd r24, Y+1 ; 0x01 + 3a8: 83 fd sbrc r24, 3 + 3aa: 0e c0 rjmp .+28 ; 0x3c8 <_ZN3Can15can_get_messageEP10CANMessage+0x118> p_message->rtr = 1; } else { p_message->rtr = 0; - 3b0: f6 01 movw r30, r12 - 3b2: 12 82 std Z+2, r1 ; 0x02 + 3ac: f6 01 movw r30, r12 + 3ae: 12 82 std Z+2, r1 ; 0x02 } // Interrupt Flag loeschen if (bit_is_set(status,6)) { - 3b4: 89 81 ldd r24, Y+1 ; 0x01 + 3b0: 89 81 ldd r24, Y+1 ; 0x01 mcp2515_bit_modify(CANINTF, (1<rtr = 0; } // Interrupt Flag loeschen if (bit_is_set(status,6)) { - 3b8: 86 ff sbrs r24, 6 - 3ba: 0f c0 rjmp .+30 ; 0x3da <_ZN3Can15can_get_messageEP10CANMessage+0x126> + 3b4: 86 ff sbrs r24, 6 + 3b6: 0f c0 rjmp .+30 ; 0x3d6 <_ZN3Can15can_get_messageEP10CANMessage+0x126> mcp2515_bit_modify(CANINTF, (1< + 3b8: 41 e0 ldi r20, 0x01 ; 1 + 3ba: 6c e2 ldi r22, 0x2C ; 44 + 3bc: c5 01 movw r24, r10 + 3be: 0e 94 08 01 call 0x210 ; 0x210 <_ZN3Can18mcp2515_bit_modifyEhhh> } else { mcp2515_bit_modify(CANINTF, (1< + 3c2: 89 2d mov r24, r9 + 3c4: 87 70 andi r24, 0x07 ; 7 + 3c6: 8f cf rjmp .-226 ; 0x2e6 <_ZN3Can15can_get_messageEP10CANMessage+0x36> } s.CSOff(); if (bit_is_set(status,3)) { p_message->rtr = 1; - 3cc: 81 e0 ldi r24, 0x01 ; 1 - 3ce: f6 01 movw r30, r12 - 3d0: 82 83 std Z+2, r24 ; 0x02 + 3c8: 81 e0 ldi r24, 0x01 ; 1 + 3ca: f6 01 movw r30, r12 + 3cc: 82 83 std Z+2, r24 ; 0x02 } else { p_message->rtr = 0; } // Interrupt Flag loeschen if (bit_is_set(status,6)) { - 3d2: 89 81 ldd r24, Y+1 ; 0x01 + 3ce: 89 81 ldd r24, Y+1 ; 0x01 mcp2515_bit_modify(CANINTF, (1<rtr = 0; } // Interrupt Flag loeschen if (bit_is_set(status,6)) { - 3d6: 86 fd sbrc r24, 6 - 3d8: f1 cf rjmp .-30 ; 0x3bc <_ZN3Can15can_get_messageEP10CANMessage+0x108> + 3d2: 86 fd sbrc r24, 6 + 3d4: f1 cf rjmp .-30 ; 0x3b8 <_ZN3Can15can_get_messageEP10CANMessage+0x108> mcp2515_bit_modify(CANINTF, (1< - 3e4: f0 cf rjmp .-32 ; 0x3c6 <_ZN3Can15can_get_messageEP10CANMessage+0x112> + 3d6: 42 e0 ldi r20, 0x02 ; 2 + 3d8: 6c e2 ldi r22, 0x2C ; 44 + 3da: c5 01 movw r24, r10 + 3dc: 0e 94 08 01 call 0x210 ; 0x210 <_ZN3Can18mcp2515_bit_modifyEhhh> + 3e0: f0 cf rjmp .-32 ; 0x3c2 <_ZN3Can15can_get_messageEP10CANMessage+0x112> } else if (bit_is_set(status,7)) { // Nachricht in Puffer 1 s.CSOn(); // CS Low - 3e6: c5 01 movw r24, r10 - 3e8: 0e 94 c4 02 call 0x588 ; 0x588 <_ZN3Spi4CSOnEv> + 3e2: c5 01 movw r24, r10 + 3e4: 0e 94 9a 02 call 0x534 ; 0x534 <_ZN3Spi4CSOnEv> s.send(SPI_READ_RX | 0x04); - 3ec: 64 e9 ldi r22, 0x94 ; 148 - 3ee: c5 01 movw r24, r10 - 3f0: 0e 94 e9 02 call 0x5d2 ; 0x5d2 <_ZN3Spi4sendEh> - 3f4: 8e cf rjmp .-228 ; 0x312 <_ZN3Can15can_get_messageEP10CANMessage+0x5e> + 3e8: 64 e9 ldi r22, 0x94 ; 148 + 3ea: c5 01 movw r24, r10 + 3ec: 0e 94 be 02 call 0x57c ; 0x57c <_ZN3Spi4sendEh> + 3f0: 8e cf rjmp .-228 ; 0x30e <_ZN3Can15can_get_messageEP10CANMessage+0x5e> -000003f6 <_ZN3LedC1Ev>: -Led::Led() { - init(); -} - -void Led::init() { - LEDDDR |= (1<: - int rgb = 0; - rgb |= (mask & (1<<0)) ? (1<<0) : (0<<0); - rgb |= (mask & (1<<1)) ? (1<<1) : (0<<1); - rgb |= (mask & (1<<2)) ? (1<<2) : (0<<2); - - LEDPORT &= ~((1<: -Led l; +000003f2
: +ledclass l; Rs232 r; Can c(Spi(0)); int main(void) { - 412: cf 93 push r28 - 414: df 93 push r29 - 416: cd b7 in r28, 0x3d ; 61 - 418: de b7 in r29, 0x3e ; 62 - 41a: 2c 97 sbiw r28, 0x0c ; 12 - 41c: 0f b6 in r0, 0x3f ; 63 - 41e: f8 94 cli - 420: de bf out 0x3e, r29 ; 62 - 422: 0f be out 0x3f, r0 ; 63 - 424: cd bf out 0x3d, r28 ; 61 - l.color(Led::YELLOW); - 426: 66 e0 ldi r22, 0x06 ; 6 - 428: 8a e0 ldi r24, 0x0A ; 10 - 42a: 91 e0 ldi r25, 0x01 ; 1 - 42c: 0e 94 ff 01 call 0x3fe ; 0x3fe <_ZN3Led5colorEh> + 3f2: cf 93 push r28 + 3f4: df 93 push r29 + 3f6: cd b7 in r28, 0x3d ; 61 + 3f8: de b7 in r29, 0x3e ; 62 + 3fa: 2c 97 sbiw r28, 0x0c ; 12 + 3fc: 0f b6 in r0, 0x3f ; 63 + 3fe: f8 94 cli + 400: de bf out 0x3e, r29 ; 62 + 402: 0f be out 0x3f, r0 ; 63 + 404: cd bf out 0x3d, r28 ; 61 +namespace avrlib { + + struct portc + { + static uint8_t port() { return PORTC; } + static void port(uint8_t v) { PORTC = v; } + 406: 47 98 cbi 0x08, 7 ; 8 + + static uint8_t pin() { return PINC; } + static void pin(uint8_t v) { PINC = v; } + + static uint8_t dir() { return DDRC; } + static void dir(uint8_t v) { DDRC = v; } + 408: 3f 9a sbi 0x07, 7 ; 7 +namespace avrlib { + + struct portc + { + static uint8_t port() { return PORTC; } + static void port(uint8_t v) { PORTC = v; } + 40a: 46 9a sbi 0x08, 6 ; 8 + + static uint8_t pin() { return PINC; } + static void pin(uint8_t v) { PINC = v; } + + static uint8_t dir() { return DDRC; } + static void dir(uint8_t v) { DDRC = v; } + 40c: 3e 9a sbi 0x07, 6 ; 7 +namespace avrlib { + + struct portc + { + static uint8_t port() { return PORTC; } + static void port(uint8_t v) { PORTC = v; } + 40e: 45 9a sbi 0x08, 5 ; 8 + + static uint8_t pin() { return PINC; } + static void pin(uint8_t v) { PINC = v; } + + static uint8_t dir() { return DDRC; } + static void dir(uint8_t v) { DDRC = v; } + 410: 3d 9a sbi 0x07, 5 ; 7 + //l.color(Led::YELLOW); + l.color(l.YELLOW); r.send("bla\n"); - 430: 60 e0 ldi r22, 0x00 ; 0 - 432: 71 e0 ldi r23, 0x01 ; 1 - 434: 89 e0 ldi r24, 0x09 ; 9 - 436: 91 e0 ldi r25, 0x01 ; 1 - 438: 0e 94 8a 02 call 0x514 ; 0x514 <_ZN5Rs2324sendEPKc> + 412: 60 e0 ldi r22, 0x00 ; 0 + 414: 71 e0 ldi r23, 0x01 ; 1 + 416: 87 e0 ldi r24, 0x07 ; 7 + 418: 91 e0 ldi r25, 0x01 ; 1 + 41a: 0e 94 66 02 call 0x4cc ; 0x4cc <_ZN5Rs2324sendEPKc> CANMessage m; m.id = 0x0123; - 43c: 83 e2 ldi r24, 0x23 ; 35 - 43e: 91 e0 ldi r25, 0x01 ; 1 - 440: 9a 83 std Y+2, r25 ; 0x02 - 442: 89 83 std Y+1, r24 ; 0x01 + 41e: 83 e2 ldi r24, 0x23 ; 35 + 420: 91 e0 ldi r25, 0x01 ; 1 + 422: 9a 83 std Y+2, r25 ; 0x02 + 424: 89 83 std Y+1, r24 ; 0x01 m.rtr = 0; - 444: 1b 82 std Y+3, r1 ; 0x03 + 426: 1b 82 std Y+3, r1 ; 0x03 m.length = 2; - 446: 82 e0 ldi r24, 0x02 ; 2 - 448: 8c 83 std Y+4, r24 ; 0x04 + 428: 82 e0 ldi r24, 0x02 ; 2 + 42a: 8c 83 std Y+4, r24 ; 0x04 m.data[0] = 0xAF; - 44a: 8f ea ldi r24, 0xAF ; 175 - 44c: 8d 83 std Y+5, r24 ; 0x05 + 42c: 8f ea ldi r24, 0xAF ; 175 + 42e: 8d 83 std Y+5, r24 ; 0x05 m.data[1] = 0xFE; - 44e: 8e ef ldi r24, 0xFE ; 254 - 450: 8e 83 std Y+6, r24 ; 0x06 - 452: 0e c0 rjmp .+28 ; 0x470 - uint8_t r = c.can_get_message(&m); - if(r == 0xFF) { - l.color(Led::RED); - _delay_ms(100); - } else { - l.color(Led::BLUE); - 454: 61 e0 ldi r22, 0x01 ; 1 - 456: 8a e0 ldi r24, 0x0A ; 10 - 458: 91 e0 ldi r25, 0x01 ; 1 - 45a: 0e 94 ff 01 call 0x3fe ; 0x3fe <_ZN3Led5colorEh> + 430: 8e ef ldi r24, 0xFE ; 254 + 432: 8e 83 std Y+6, r24 ; 0x06 + 434: 09 c0 rjmp .+18 ; 0x448 #else //round up by default __ticks_dc = (uint32_t)(ceil(fabs(__tmp))); #endif __builtin_avr_delay_cycles(__ticks_dc); - 45e: 2f ef ldi r18, 0xFF ; 255 - 460: 83 ed ldi r24, 0xD3 ; 211 - 462: 90 e3 ldi r25, 0x30 ; 48 - 464: 21 50 subi r18, 0x01 ; 1 - 466: 80 40 sbci r24, 0x00 ; 0 - 468: 90 40 sbci r25, 0x00 ; 0 - 46a: e1 f7 brne .-8 ; 0x464 - 46c: 00 c0 rjmp .+0 ; 0x46e - 46e: 00 00 nop - m.length = 2; - m.data[0] = 0xAF; - m.data[1] = 0xFE; - while(1) - { - l.color(Led::GREEN); - 470: 62 e0 ldi r22, 0x02 ; 2 - 472: 8a e0 ldi r24, 0x0A ; 10 - 474: 91 e0 ldi r25, 0x01 ; 1 - 476: 0e 94 ff 01 call 0x3fe ; 0x3fe <_ZN3Led5colorEh> - 47a: 2f ef ldi r18, 0xFF ; 255 - 47c: 81 ee ldi r24, 0xE1 ; 225 - 47e: 94 e0 ldi r25, 0x04 ; 4 - 480: 21 50 subi r18, 0x01 ; 1 - 482: 80 40 sbci r24, 0x00 ; 0 - 484: 90 40 sbci r25, 0x00 ; 0 - 486: e1 f7 brne .-8 ; 0x480 - 488: 00 c0 rjmp .+0 ; 0x48a - 48a: 00 00 nop + 436: 2f ef ldi r18, 0xFF ; 255 + 438: 83 ed ldi r24, 0xD3 ; 211 + 43a: 90 e3 ldi r25, 0x30 ; 48 + 43c: 21 50 subi r18, 0x01 ; 1 + 43e: 80 40 sbci r24, 0x00 ; 0 + 440: 90 40 sbci r25, 0x00 ; 0 + 442: e1 f7 brne .-8 ; 0x43c + 444: 00 c0 rjmp .+0 ; 0x446 + 446: 00 00 nop + 448: 2f ef ldi r18, 0xFF ; 255 + 44a: 81 ee ldi r24, 0xE1 ; 225 + 44c: 94 e0 ldi r25, 0x04 ; 4 + 44e: 21 50 subi r18, 0x01 ; 1 + 450: 80 40 sbci r24, 0x00 ; 0 + 452: 90 40 sbci r25, 0x00 ; 0 + 454: e1 f7 brne .-8 ; 0x44e + 456: 00 c0 rjmp .+0 ; 0x458 + 458: 00 00 nop //c.can_send_message(&m); //l.color(Led::BLACK); //_delay_ms(100); //l.color(Led::GREEN); //c.can_send_message(&m); uint8_t r = c.can_get_message(&m); - 48c: be 01 movw r22, r28 - 48e: 6f 5f subi r22, 0xFF ; 255 - 490: 7f 4f sbci r23, 0xFF ; 255 - 492: 86 e0 ldi r24, 0x06 ; 6 - 494: 91 e0 ldi r25, 0x01 ; 1 - 496: 0e 94 5a 01 call 0x2b4 ; 0x2b4 <_ZN3Can15can_get_messageEP10CANMessage> + 45a: be 01 movw r22, r28 + 45c: 6f 5f subi r22, 0xFF ; 255 + 45e: 7f 4f sbci r23, 0xFF ; 255 + 460: 86 e0 ldi r24, 0x06 ; 6 + 462: 91 e0 ldi r25, 0x01 ; 1 + 464: 0e 94 58 01 call 0x2b0 ; 0x2b0 <_ZN3Can15can_get_messageEP10CANMessage> if(r == 0xFF) { - 49a: 8f 3f cpi r24, 0xFF ; 255 - 49c: d9 f6 brne .-74 ; 0x454 - l.color(Led::RED); - 49e: 64 e0 ldi r22, 0x04 ; 4 - 4a0: 8a e0 ldi r24, 0x0A ; 10 - 4a2: 91 e0 ldi r25, 0x01 ; 1 - 4a4: 0e 94 ff 01 call 0x3fe ; 0x3fe <_ZN3Led5colorEh> - 4a8: 2f ef ldi r18, 0xFF ; 255 - 4aa: 81 ee ldi r24, 0xE1 ; 225 - 4ac: 94 e0 ldi r25, 0x04 ; 4 - 4ae: 21 50 subi r18, 0x01 ; 1 - 4b0: 80 40 sbci r24, 0x00 ; 0 - 4b2: 90 40 sbci r25, 0x00 ; 0 - 4b4: e1 f7 brne .-8 ; 0x4ae - 4b6: 00 c0 rjmp .+0 ; 0x4b8 - 4b8: 00 00 nop - 4ba: da cf rjmp .-76 ; 0x470 + 468: 8f 3f cpi r24, 0xFF ; 255 + 46a: 29 f7 brne .-54 ; 0x436 + 46c: 2f ef ldi r18, 0xFF ; 255 + 46e: 81 ee ldi r24, 0xE1 ; 225 + 470: 94 e0 ldi r25, 0x04 ; 4 + 472: 21 50 subi r18, 0x01 ; 1 + 474: 80 40 sbci r24, 0x00 ; 0 + 476: 90 40 sbci r25, 0x00 ; 0 + 478: e1 f7 brne .-8 ; 0x472 + 47a: 00 c0 rjmp .+0 ; 0x47c + 47c: 00 00 nop + 47e: e4 cf rjmp .-56 ; 0x448 -000004bc <_GLOBAL__sub_I_l>: +00000480 <_GLOBAL__sub_I_l>: } else { - l.color(Led::BLUE); + //l.color(Led::BLUE); _delay_ms(1000); } } - 4bc: cf 93 push r28 - 4be: df 93 push r29 - 4c0: 00 d0 rcall .+0 ; 0x4c2 <_GLOBAL__sub_I_l+0x6> - 4c2: 1f 92 push r1 - 4c4: cd b7 in r28, 0x3d ; 61 - 4c6: de b7 in r29, 0x3e ; 62 -#include "Rs232.h" -#include "Can.h" -#include "Spi.h" + 480: cf 93 push r28 + 482: df 93 push r29 + 484: 1f 92 push r1 + 486: cd b7 in r28, 0x3d ; 61 + 488: de b7 in r29, 0x3e ; 62 + 48a: 3d 9a sbi 0x07, 5 ; 7 + 48c: 3e 9a sbi 0x07, 6 ; 7 + 48e: 3f 9a sbi 0x07, 7 ; 7 #include -Led l; - 4c8: 8a e0 ldi r24, 0x0A ; 10 - 4ca: 91 e0 ldi r25, 0x01 ; 1 - 4cc: 0e 94 fb 01 call 0x3f6 ; 0x3f6 <_ZN3LedC1Ev> +//Led l; +typedef Led ledclass; +ledclass l; Rs232 r; - 4d0: 89 e0 ldi r24, 0x09 ; 9 - 4d2: 91 e0 ldi r25, 0x01 ; 1 - 4d4: 0e 94 7e 02 call 0x4fc ; 0x4fc <_ZN5Rs232C1Ev> + 490: 87 e0 ldi r24, 0x07 ; 7 + 492: 91 e0 ldi r25, 0x01 ; 1 + 494: 0e 94 5a 02 call 0x4b4 ; 0x4b4 <_ZN5Rs232C1Ev> Can c(Spi(0)); - 4d8: 60 e0 ldi r22, 0x00 ; 0 - 4da: ce 01 movw r24, r28 - 4dc: 01 96 adiw r24, 0x01 ; 1 - 4de: 0e 94 b9 02 call 0x572 ; 0x572 <_ZN3SpiC1Eh> - 4e2: 49 81 ldd r20, Y+1 ; 0x01 - 4e4: 5a 81 ldd r21, Y+2 ; 0x02 - 4e6: 6b 81 ldd r22, Y+3 ; 0x03 - 4e8: 86 e0 ldi r24, 0x06 ; 6 - 4ea: 91 e0 ldi r25, 0x01 ; 1 - 4ec: 0e 94 04 01 call 0x208 ; 0x208 <_ZN3CanC1E3Spi> + 498: 60 e0 ldi r22, 0x00 ; 0 + 49a: ce 01 movw r24, r28 + 49c: 01 96 adiw r24, 0x01 ; 1 + 49e: 0e 94 92 02 call 0x524 ; 0x524 <_ZN3SpiC1Eh> + 4a2: 69 81 ldd r22, Y+1 ; 0x01 + 4a4: 86 e0 ldi r24, 0x06 ; 6 + 4a6: 91 e0 ldi r25, 0x01 ; 1 + 4a8: 0e 94 04 01 call 0x208 ; 0x208 <_ZN3CanC1E3Spi> } else { - l.color(Led::BLUE); + //l.color(Led::BLUE); _delay_ms(1000); } } - 4f0: 0f 90 pop r0 - 4f2: 0f 90 pop r0 - 4f4: 0f 90 pop r0 - 4f6: df 91 pop r29 - 4f8: cf 91 pop r28 - 4fa: 08 95 ret + 4ac: 0f 90 pop r0 + 4ae: df 91 pop r29 + 4b0: cf 91 pop r28 + 4b2: 08 95 ret -000004fc <_ZN5Rs232C1Ev>: +000004b4 <_ZN5Rs232C1Ev>: return 0; } void Rs232::init() { UCSR1C = (1 << UCSZ11) |(1 << UCSZ10); //8N1 - 4fc: 86 e0 ldi r24, 0x06 ; 6 - 4fe: 80 93 ca 00 sts 0x00CA, r24 + 4b4: 86 e0 ldi r24, 0x06 ; 6 + 4b6: 80 93 ca 00 sts 0x00CA, r24 UCSR1B |= /*(1<: +000004cc <_ZN5Rs2324sendEPKc>: } void Rs232::send(const char * text) { while (*text) - 514: fb 01 movw r30, r22 - 516: 90 81 ld r25, Z - 518: 99 23 and r25, r25 - 51a: 51 f0 breq .+20 ; 0x530 <_ZN5Rs2324sendEPKc+0x1c> + 4cc: fb 01 movw r30, r22 + 4ce: 90 81 ld r25, Z + 4d0: 99 23 and r25, r25 + 4d2: 51 f0 breq .+20 ; 0x4e8 <_ZN5Rs2324sendEPKc+0x1c> UCSR1C = (1 << UCSZ11) |(1 << UCSZ10); //8N1 UCSR1B |= /*(1< + 4d6: 80 91 c8 00 lds r24, 0x00C8 + 4da: 85 ff sbrs r24, 5 + 4dc: fc cf rjmp .-8 ; 0x4d6 <_ZN5Rs2324sendEPKc+0xa> UDR1 = c; - 526: 90 93 ce 00 sts 0x00CE, r25 + 4de: 90 93 ce 00 sts 0x00CE, r25 UCSR1B |= /*(1< - 530: 08 95 ret + 4e2: 91 91 ld r25, Z+ + 4e4: 91 11 cpse r25, r1 + 4e6: f7 cf rjmp .-18 ; 0x4d6 <_ZN5Rs2324sendEPKc+0xa> + 4e8: 08 95 ret -00000532 <_ZN3Spi9init_portEv>: -#define CANP_MOSI PINB2 -#define CANP_SCK PINB1 -#define CANP_CS PINB4 +000004ea <_ZN3Spi9init_portEv>: -void Spi::init_port() { - CANDDR_SPI |= (1<: + static uint8_t dir() { return DDRB; } + static void dir(uint8_t v) { DDRB = v; } + 4ea: 22 9a sbi 0x04, 2 ; 4 +namespace avrlib { -Spi::Spi(uint8_t index) : mode(1), canport(&PORTB) /* : m_index (index) {} */ { + struct portb + { + static uint8_t port() { return PORTB; } + static void port(uint8_t v) { PORTB = v; } + 4ec: 2a 98 cbi 0x05, 2 ; 5 + + static uint8_t pin() { return PINB; } + static void pin(uint8_t v) { PINB = v; } + + static uint8_t dir() { return DDRB; } + static void dir(uint8_t v) { DDRB = v; } + 4ee: 22 9a sbi 0x04, 2 ; 4 + 4f0: 21 9a sbi 0x04, 1 ; 4 +namespace avrlib { + + struct portb + { + static uint8_t port() { return PORTB; } + static void port(uint8_t v) { PORTB = v; } + 4f2: 29 98 cbi 0x05, 1 ; 5 + + static uint8_t pin() { return PINB; } + static void pin(uint8_t v) { PINB = v; } + + static uint8_t dir() { return DDRB; } + static void dir(uint8_t v) { DDRB = v; } + 4f4: 21 9a sbi 0x04, 1 ; 4 + 4f6: 24 9a sbi 0x04, 4 ; 4 +namespace avrlib { + + struct portb + { + static uint8_t port() { return PORTB; } + static void port(uint8_t v) { PORTB = v; } + 4f8: 2c 9a sbi 0x05, 4 ; 5 + + static uint8_t pin() { return PINB; } + static void pin(uint8_t v) { PINB = v; } + + static uint8_t dir() { return DDRB; } + static void dir(uint8_t v) { DDRB = v; } + 4fa: 24 9a sbi 0x04, 4 ; 4 + 4fc: 23 98 cbi 0x04, 3 ; 4 +namespace avrlib { + + struct portb + { + static uint8_t port() { return PORTB; } + static void port(uint8_t v) { PORTB = v; } + 4fe: 2b 98 cbi 0x05, 3 ; 5 + 500: 2b 98 cbi 0x05, 3 ; 5 + + static uint8_t pin() { return PINB; } + static void pin(uint8_t v) { PINB = v; } + + static uint8_t dir() { return DDRB; } + static void dir(uint8_t v) { DDRB = v; } + 502: 23 9a sbi 0x04, 3 ; 4 + 504: 08 95 ret + +00000506 <_ZN3Spi4initEv>: + +Spi::Spi(uint8_t index) : mode(1) { //, canport(&PORTB) /* : m_index (index) {} */ { init(); } void Spi::init() { - 554: cf 93 push r28 - 556: df 93 push r29 - 558: ec 01 movw r28, r24 + 506: cf 93 push r28 + 508: df 93 push r29 + 50a: ec 01 movw r28, r24 init_port(); - 55a: 0e 94 99 02 call 0x532 ; 0x532 <_ZN3Spi9init_portEv> + 50c: 0e 94 75 02 call 0x4ea ; 0x4ea <_ZN3Spi9init_portEv> if(mode == 0) { - 55e: 88 81 ld r24, Y - 560: 81 11 cpse r24, r1 - 562: 04 c0 rjmp .+8 ; 0x56c <_ZN3Spi4initEv+0x18> - *canport &= ~((1< + miso::make_input(); + miso::make_low(); } void Spi::init_spi() { SPCR = (1<: +00000524 <_ZN3SpiC1Eh>: * Author: netz */ #include "Spi.h" -Spi::Spi(uint8_t index) : mode(1), canport(&PORTB) /* : m_index (index) {} */ { - 572: 21 e0 ldi r18, 0x01 ; 1 - 574: fc 01 movw r30, r24 - 576: 20 83 st Z, r18 - 578: 25 e2 ldi r18, 0x25 ; 37 - 57a: 30 e0 ldi r19, 0x00 ; 0 - 57c: 32 83 std Z+2, r19 ; 0x02 - 57e: 21 83 std Z+1, r18 ; 0x01 +Spi::Spi(uint8_t index) : mode(1) { //, canport(&PORTB) /* : m_index (index) {} */ { + 524: 21 e0 ldi r18, 0x01 ; 1 + 526: fc 01 movw r30, r24 + 528: 20 83 st Z, r18 init(); - 580: 0c 94 aa 02 jmp 0x554 ; 0x554 <_ZN3Spi4initEv> + 52a: 0c 94 83 02 jmp 0x506 ; 0x506 <_ZN3Spi4initEv> -00000584 <_ZN3Spi5CSOffEv>: - SPCR = (1<: +namespace avrlib { -void Spi::CSOff() { - CANPORT_SPI |= (1<: -} + static uint8_t pin() { return PINB; } + static void pin(uint8_t v) { PINB = v; } -void Spi::CSOn() { - CANPORT_SPI &= ~(1<: +00000534 <_ZN3Spi4CSOnEv>: +namespace avrlib { + + struct portb + { + static uint8_t port() { return PORTB; } + static void port(uint8_t v) { PORTB = v; } + 534: 2c 98 cbi 0x05, 4 ; 5 + + static uint8_t pin() { return PINB; } + static void pin(uint8_t v) { PINB = v; } + + static uint8_t dir() { return DDRB; } + static void dir(uint8_t v) { DDRB = v; } + 536: 24 9a sbi 0x04, 4 ; 4 + 538: 08 95 ret + +0000053a <_ZN3Spi9send_softEh>: loop_until_bit_is_set(SPSR, SPIF); return SPDR; } uint8_t Spi::send_soft(uint8_t data) { - 58c: 98 e0 ldi r25, 0x08 ; 8 - uint8_t werti = 0; - 58e: 80 e0 ldi r24, 0x00 ; 0 - - for (uint8_t i = 8; i != 0; i--) { - CANPORT_SPI = (CANPORT_SPI & (~(1 << CANP_MOSI))) | ((data & 1) << CANP_MOSI); - 590: 60 fd sbrc r22, 0 - 592: 2a 9a sbi 0x05, 2 ; 5 - 594: 60 ff sbrs r22, 0 - 596: 2a 98 cbi 0x05, 2 ; 5 - CANPORT_SPI &= ~(1<>= 1; - 59a: 66 95 lsr r22 - ... - asm volatile ("nop");asm volatile ("nop");asm volatile ("nop");asm volatile ("nop"); - asm volatile ("nop");asm volatile ("nop");asm volatile ("nop");asm volatile ("nop"); - asm volatile ("nop");asm volatile ("nop");asm volatile ("nop");asm volatile ("nop"); - asm volatile ("nop");asm volatile ("nop");asm volatile ("nop");asm volatile ("nop"); - CANPORT_SPI |= (1<> CANP_MISO) & 1); - 5c0: 23 b1 in r18, 0x03 ; 3 - 5c2: 23 fb bst r18, 3 - 5c4: 22 27 eor r18, r18 - 5c6: 20 f9 bld r18, 0 - 5c8: 88 0f add r24, r24 - 5ca: 82 2b or r24, r18 - 5cc: 91 50 subi r25, 0x01 ; 1 + 53a: 98 e0 ldi r25, 0x08 ; 8 + uint8_t datain=0; + 53c: 80 e0 ldi r24, 0x00 ; 0 + 53e: 15 c0 rjmp .+42 ; 0x56a <_ZN3Spi9send_softEh+0x30> +namespace avrlib { + + struct portb + { + static uint8_t port() { return PORTB; } + static void port(uint8_t v) { PORTB = v; } + 540: 2a 98 cbi 0x05, 2 ; 5 + + static uint8_t pin() { return PINB; } + static void pin(uint8_t v) { PINB = v; } + + static uint8_t dir() { return DDRB; } + static void dir(uint8_t v) { DDRB = v; } + 542: 22 9a sbi 0x04, 2 ; 4 + #else + //round up by default + __ticks_dc = (uint32_t)(ceil(fabs(__tmp))); + #endif + + __builtin_avr_delay_cycles(__ticks_dc); + 544: 25 e0 ldi r18, 0x05 ; 5 + 546: 2a 95 dec r18 + 548: f1 f7 brne .-4 ; 0x546 <_ZN3Spi9send_softEh+0xc> + 54a: 00 00 nop + } + else{ + mosi::make_low(); //Set Output Low + } + _delay_us(1); + if(miso::read()) //Lesen des Pegels + 54c: 1b 99 sbic 0x03, 3 ; 3 + { + datain |= 1; + 54e: 81 60 ori r24, 0x01 ; 1 + 550: 25 e0 ldi r18, 0x05 ; 5 + 552: 2a 95 dec r18 + 554: f1 f7 brne .-4 ; 0x552 <_ZN3Spi9send_softEh+0x18> + 556: 00 00 nop +namespace avrlib { + + struct portb + { + static uint8_t port() { return PORTB; } + static void port(uint8_t v) { PORTB = v; } + 558: 29 9a sbi 0x05, 1 ; 5 + + static uint8_t pin() { return PINB; } + static void pin(uint8_t v) { PINB = v; } + + static uint8_t dir() { return DDRB; } + static void dir(uint8_t v) { DDRB = v; } + 55a: 21 9a sbi 0x04, 1 ; 4 + 55c: 2a e0 ldi r18, 0x0A ; 10 + 55e: 2a 95 dec r18 + 560: f1 f7 brne .-4 ; 0x55e <_ZN3Spi9send_softEh+0x24> + 562: 00 c0 rjmp .+0 ; 0x564 <_ZN3Spi9send_softEh+0x2a> + } + _delay_us(1); + sck::make_high(); // Clock auf High + _delay_us(2); + data<<=1; //Schiebe um nächstes Bit zusenden + 564: 66 0f add r22, r22 + 566: 91 50 subi r25, 0x01 ; 1 + return SPDR; } uint8_t Spi::send_soft(uint8_t data) { - uint8_t werti = 0; - - for (uint8_t i = 8; i != 0; i--) { - 5ce: 01 f7 brne .-64 ; 0x590 <_ZN3Spi9send_softEh+0x4> - _delay_us(0.3); - CANPORT_SPI &= ~(1<0; a--){ //das Byte wird Bitweise nacheinander Gesendet MSB zuerst + 568: 41 f0 breq .+16 ; 0x57a <_ZN3Spi9send_softEh+0x40> + datain<<=1; //Schieben um das Richtige Bit zusetzen + 56a: 88 0f add r24, r24 +namespace avrlib { -000005d2 <_ZN3Spi4sendEh>: + struct portb + { + static uint8_t port() { return PORTB; } + static void port(uint8_t v) { PORTB = v; } + 56c: 29 98 cbi 0x05, 1 ; 5 + + static uint8_t pin() { return PINB; } + static void pin(uint8_t v) { PINB = v; } + + static uint8_t dir() { return DDRB; } + static void dir(uint8_t v) { DDRB = v; } + 56e: 21 9a sbi 0x04, 1 ; 4 + sck::make_low(); // Clock auf LOW + if (data & 0x80) { //Ist Bit a in Byte gesetzt + 570: 67 ff sbrs r22, 7 + 572: e6 cf rjmp .-52 ; 0x540 <_ZN3Spi9send_softEh+0x6> +namespace avrlib { + + struct portb + { + static uint8_t port() { return PORTB; } + static void port(uint8_t v) { PORTB = v; } + 574: 2a 9a sbi 0x05, 2 ; 5 + + static uint8_t pin() { return PINB; } + static void pin(uint8_t v) { PINB = v; } + + static uint8_t dir() { return DDRB; } + static void dir(uint8_t v) { DDRB = v; } + 576: 22 9a sbi 0x04, 2 ; 4 + 578: e5 cf rjmp .-54 ; 0x544 <_ZN3Spi9send_softEh+0xa> + CANPORT_SPI |= (1<> CANP_MISO) & 1); + } + return werti; */ + 57a: 08 95 ret + +0000057c <_ZN3Spi4sendEh>: void Spi::CSOn() { - CANPORT_SPI &= ~(1< + 57c: fc 01 movw r30, r24 + 57e: 20 81 ld r18, Z + 580: 21 11 cpse r18, r1 + 582: 06 c0 rjmp .+12 ; 0x590 <_ZN3Spi4sendEh+0x14> return send_soft(data); } uint8_t Spi::send_hard( uint8_t data ) { // Sendet ein Byte SPDR = data; - 5da: 6e bd out 0x2e, r22 ; 46 + 584: 6e bd out 0x2e, r22 ; 46 // Wartet bis Byte gesendet wurde loop_until_bit_is_set(SPSR, SPIF); - 5dc: 0d b4 in r0, 0x2d ; 45 - 5de: 07 fe sbrs r0, 7 - 5e0: fd cf rjmp .-6 ; 0x5dc <_ZN3Spi4sendEh+0xa> + 586: 0d b4 in r0, 0x2d ; 45 + 588: 07 fe sbrs r0, 7 + 58a: fd cf rjmp .-6 ; 0x586 <_ZN3Spi4sendEh+0xa> return SPDR; - 5e2: 8e b5 in r24, 0x2e ; 46 - 5e4: 08 95 ret + 58c: 8e b5 in r24, 0x2e ; 46 + 58e: 08 95 ret uint8_t Spi::send(uint8_t data) { if(mode == 0) { return send_hard(data); } return send_soft(data); - 5e6: 0c 94 c6 02 jmp 0x58c ; 0x58c <_ZN3Spi9send_softEh> + 590: 0c 94 9d 02 jmp 0x53a ; 0x53a <_ZN3Spi9send_softEh> -000005ea <__tablejump2__>: - 5ea: ee 0f add r30, r30 - 5ec: ff 1f adc r31, r31 +00000594 <__tablejump2__>: + 594: ee 0f add r30, r30 + 596: ff 1f adc r31, r31 -000005ee <__tablejump__>: - 5ee: 05 90 lpm r0, Z+ - 5f0: f4 91 lpm r31, Z - 5f2: e0 2d mov r30, r0 - 5f4: 09 94 ijmp +00000598 <__tablejump__>: + 598: 05 90 lpm r0, Z+ + 59a: f4 91 lpm r31, Z + 59c: e0 2d mov r30, r0 + 59e: 09 94 ijmp -000005f6 <_exit>: - 5f6: f8 94 cli +000005a0 <_exit>: + 5a0: f8 94 cli -000005f8 <__stop_program>: - 5f8: ff cf rjmp .-2 ; 0x5f8 <__stop_program> +000005a2 <__stop_program>: + 5a2: ff cf rjmp .-2 ; 0x5a2 <__stop_program> diff --git a/Mainboard/Mainboard/Debug/Mainboard.map b/Mainboard/Mainboard/Debug/Mainboard.map index 79f3b29..345a2cb 100644 --- a/Mainboard/Mainboard/Debug/Mainboard.map +++ b/Mainboard/Mainboard/Debug/Mainboard.map @@ -22,14 +22,6 @@ Discarded input sections 0x00000000 0x154 Can.o .text 0x00000000 0x0 Led.o .bss 0x00000000 0x0 Led.o - .text._ZN3Led4initEv - 0x00000000 0x8 Led.o - .text._ZN3Led6uninitEv - 0x00000000 0x2 Led.o - .text._ZN3Led4fadeEiii - 0x00000000 0x68 Led.o - .text._ZN3Led7rainbowEh - 0x00000000 0x7a Led.o .text 0x00000000 0x0 Mainboard.o .text 0x00000000 0x0 Rs232.o .bss 0x00000000 0x0 Rs232.o @@ -228,7 +220,7 @@ LOAD c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8 .rela.plt *(.rela.plt) -.text 0x00000000 0x5fa +.text 0x00000000 0x5a4 *(.vectors) .vectors 0x00000000 0x74 c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/../../../../avr/lib/avr35/crtm32u2.o 0x00000000 __vector_default @@ -325,67 +317,60 @@ LOAD c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8 0x0000011a 0xee Can.o 0x0000011a _ZN3Can8init_canEv .text._ZN3CanC2E3Spi - 0x00000208 0xc Can.o + 0x00000208 0x8 Can.o 0x00000208 _ZN3CanC2E3Spi 0x00000208 _ZN3CanC1E3Spi .text._ZN3Can18mcp2515_bit_modifyEhhh - 0x00000214 0x60 Can.o - 0x00000214 _ZN3Can18mcp2515_bit_modifyEhhh + 0x00000210 0x60 Can.o + 0x00000210 _ZN3Can18mcp2515_bit_modifyEhhh .text._ZN3Can22mcp2515_read_rx_statusEv - 0x00000274 0x40 Can.o - 0x00000274 _ZN3Can22mcp2515_read_rx_statusEv + 0x00000270 0x40 Can.o + 0x00000270 _ZN3Can22mcp2515_read_rx_statusEv .text._ZN3Can15can_get_messageEP10CANMessage - 0x000002b4 0x142 Can.o - 0x000002b4 _ZN3Can15can_get_messageEP10CANMessage - .text._ZN3LedC2Ev - 0x000003f6 0x8 Led.o - 0x000003f6 _ZN3LedC1Ev - 0x000003f6 _ZN3LedC2Ev - .text._ZN3Led5colorEh - 0x000003fe 0x14 Led.o - 0x000003fe _ZN3Led5colorEh + 0x000002b0 0x142 Can.o + 0x000002b0 _ZN3Can15can_get_messageEP10CANMessage .text.startup.main - 0x00000412 0xaa Mainboard.o - 0x00000412 main + 0x000003f2 0x8e Mainboard.o + 0x000003f2 main .text.startup._GLOBAL__sub_I_l - 0x000004bc 0x40 Mainboard.o + 0x00000480 0x34 Mainboard.o .text._ZN5Rs232C2Ev - 0x000004fc 0x18 Rs232.o - 0x000004fc _ZN5Rs232C2Ev - 0x000004fc _ZN5Rs232C1Ev + 0x000004b4 0x18 Rs232.o + 0x000004b4 _ZN5Rs232C2Ev + 0x000004b4 _ZN5Rs232C1Ev .text._ZN5Rs2324sendEPKc - 0x00000514 0x1e Rs232.o - 0x00000514 _ZN5Rs2324sendEPKc + 0x000004cc 0x1e Rs232.o + 0x000004cc _ZN5Rs2324sendEPKc .text._ZN3Spi9init_portEv - 0x00000532 0x22 Spi.o - 0x00000532 _ZN3Spi9init_portEv + 0x000004ea 0x1c Spi.o + 0x000004ea _ZN3Spi9init_portEv .text._ZN3Spi4initEv - 0x00000554 0x1e Spi.o - 0x00000554 _ZN3Spi4initEv + 0x00000506 0x1e Spi.o + 0x00000506 _ZN3Spi4initEv .text._ZN3SpiC2Eh - 0x00000572 0x12 Spi.o - 0x00000572 _ZN3SpiC1Eh - 0x00000572 _ZN3SpiC2Eh + 0x00000524 0xa Spi.o + 0x00000524 _ZN3SpiC1Eh + 0x00000524 _ZN3SpiC2Eh .text._ZN3Spi5CSOffEv - 0x00000584 0x4 Spi.o - 0x00000584 _ZN3Spi5CSOffEv + 0x0000052e 0x6 Spi.o + 0x0000052e _ZN3Spi5CSOffEv .text._ZN3Spi4CSOnEv - 0x00000588 0x4 Spi.o - 0x00000588 _ZN3Spi4CSOnEv + 0x00000534 0x6 Spi.o + 0x00000534 _ZN3Spi4CSOnEv .text._ZN3Spi9send_softEh - 0x0000058c 0x46 Spi.o - 0x0000058c _ZN3Spi9send_softEh + 0x0000053a 0x42 Spi.o + 0x0000053a _ZN3Spi9send_softEh .text._ZN3Spi4sendEh - 0x000005d2 0x18 Spi.o - 0x000005d2 _ZN3Spi4sendEh - .text.libgcc 0x000005ea 0xc c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/avr35\libgcc.a(_tablejump.o) - 0x000005ea __tablejump2__ - 0x000005ee __tablejump__ - 0x000005f6 . = ALIGN (0x2) + 0x0000057c 0x18 Spi.o + 0x0000057c _ZN3Spi4sendEh + .text.libgcc 0x00000594 0xc c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/avr35\libgcc.a(_tablejump.o) + 0x00000594 __tablejump2__ + 0x00000598 __tablejump__ + 0x000005a0 . = ALIGN (0x2) *(.fini9) - .fini9 0x000005f6 0x0 c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/avr35\libgcc.a(_exit.o) - 0x000005f6 _exit - 0x000005f6 exit + .fini9 0x000005a0 0x0 c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/avr35\libgcc.a(_exit.o) + 0x000005a0 _exit + 0x000005a0 exit *(.fini9) *(.fini8) *(.fini8) @@ -404,11 +389,11 @@ LOAD c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8 *(.fini1) *(.fini1) *(.fini0) - .fini0 0x000005f6 0x4 c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/avr35\libgcc.a(_exit.o) + .fini0 0x000005a0 0x4 c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/avr35\libgcc.a(_exit.o) *(.fini0) - 0x000005fa _etext = . + 0x000005a4 _etext = . -.data 0x00800100 0x6 load address 0x000005fa +.data 0x00800100 0x6 load address 0x000005a4 0x00800100 PROVIDE (__data_start, .) *(.data) .data 0x00800100 0x0 c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8-gnu-toolchain/bin/../lib/gcc/avr/4.7.2/../../../../avr/lib/avr35/crtm32u2.o @@ -433,25 +418,25 @@ LOAD c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8 0x00800106 _edata = . 0x00800106 PROVIDE (__data_end, .) -.bss 0x00800106 0x5 +.bss 0x00800106 0x3 0x00800106 PROVIDE (__bss_start, .) *(.bss) - .bss 0x00800106 0x5 Mainboard.o + .bss 0x00800106 0x3 Mainboard.o 0x00800106 c - 0x00800109 r - 0x0080010a l + 0x00800107 r + 0x00800108 l *(.bss*) *(COMMON) - 0x0080010b PROVIDE (__bss_end, .) - 0x000005fa __data_load_start = LOADADDR (.data) - 0x00000600 __data_load_end = (__data_load_start + SIZEOF (.data)) + 0x00800109 PROVIDE (__bss_end, .) + 0x000005a4 __data_load_start = LOADADDR (.data) + 0x000005aa __data_load_end = (__data_load_start + SIZEOF (.data)) -.noinit 0x0080010b 0x0 - 0x0080010b PROVIDE (__noinit_start, .) +.noinit 0x00800109 0x0 + 0x00800109 PROVIDE (__noinit_start, .) *(.noinit*) - 0x0080010b PROVIDE (__noinit_end, .) - 0x0080010b _end = . - 0x0080010b PROVIDE (__heap_start, .) + 0x00800109 PROVIDE (__noinit_end, .) + 0x00800109 _end = . + 0x00800109 PROVIDE (__heap_start, .) .eeprom 0x00810000 0x0 *(.eeprom*) @@ -513,75 +498,73 @@ LOAD c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8 .debug_sfnames *(.debug_sfnames) -.debug_aranges 0x00000000 0x160 +.debug_aranges 0x00000000 0x130 *(.debug_aranges) .debug_aranges 0x00000000 0x58 Can.o .debug_aranges - 0x00000058 0x48 Led.o + 0x00000058 0x18 Led.o .debug_aranges - 0x000000a0 0x28 Mainboard.o + 0x00000070 0x28 Mainboard.o .debug_aranges - 0x000000c8 0x38 Rs232.o + 0x00000098 0x38 Rs232.o .debug_aranges - 0x00000100 0x60 Spi.o + 0x000000d0 0x60 Spi.o .debug_pubnames *(.debug_pubnames) -.debug_info 0x00000000 0x233b +.debug_info 0x00000000 0x31fa *(.debug_info) - .debug_info 0x00000000 0xdff Can.o - .debug_info 0x00000dff 0x564 Led.o - .debug_info 0x00001363 0x8d5 Mainboard.o - .debug_info 0x00001c38 0x27a Rs232.o - .debug_info 0x00001eb2 0x489 Spi.o + .debug_info 0x00000000 0xdec Can.o + .debug_info 0x00000dec 0x5d Led.o + .debug_info 0x00000e49 0xf68 Mainboard.o + .debug_info 0x00001db1 0x27a Rs232.o + .debug_info 0x0000202b 0x11cf Spi.o *(.gnu.linkonce.wi.*) -.debug_abbrev 0x00000000 0xc52 +.debug_abbrev 0x00000000 0xc55 *(.debug_abbrev) - .debug_abbrev 0x00000000 0x350 Can.o - .debug_abbrev 0x00000350 0x22c Led.o - .debug_abbrev 0x0000057c 0x33d Mainboard.o - .debug_abbrev 0x000008b9 0x15b Rs232.o - .debug_abbrev 0x00000a14 0x23e Spi.o + .debug_abbrev 0x00000000 0x354 Can.o + .debug_abbrev 0x00000354 0x31 Led.o + .debug_abbrev 0x00000385 0x414 Mainboard.o + .debug_abbrev 0x00000799 0x15b Rs232.o + .debug_abbrev 0x000008f4 0x361 Spi.o -.debug_line 0x00000000 0x8ce +.debug_line 0x00000000 0x88d *(.debug_line) - .debug_line 0x00000000 0x2b3 Can.o - .debug_line 0x000002b3 0x16e Led.o - .debug_line 0x00000421 0x1d8 Mainboard.o - .debug_line 0x000005f9 0x122 Rs232.o - .debug_line 0x0000071b 0x1b3 Spi.o + .debug_line 0x00000000 0x2be Can.o + .debug_line 0x000002be 0x2c Led.o + .debug_line 0x000002ea 0x1f6 Mainboard.o + .debug_line 0x000004e0 0x122 Rs232.o + .debug_line 0x00000602 0x28b Spi.o -.debug_frame 0x00000000 0x35c +.debug_frame 0x00000000 0x2d8 *(.debug_frame) .debug_frame 0x00000000 0x180 Can.o - .debug_frame 0x00000180 0x84 Led.o - .debug_frame 0x00000204 0x54 Mainboard.o - .debug_frame 0x00000258 0x54 Rs232.o - .debug_frame 0x000002ac 0xb0 Spi.o + .debug_frame 0x00000180 0x54 Mainboard.o + .debug_frame 0x000001d4 0x54 Rs232.o + .debug_frame 0x00000228 0xb0 Spi.o -.debug_str 0x00000000 0x54c +.debug_str 0x00000000 0xf02 *(.debug_str) - .debug_str 0x00000000 0x38c Can.o - 0x3e4 (size before relaxing) - .debug_str 0x0000038c 0xbb Led.o - 0x185 (size before relaxing) - .debug_str 0x00000447 0xbe Mainboard.o - 0x4f9 (size before relaxing) - .debug_str 0x00000505 0x22 Rs232.o + .debug_str 0x00000000 0x38b Can.o + 0x3e3 (size before relaxing) + .debug_str 0x0000038b 0xd Led.o + 0xc7 (size before relaxing) + .debug_str 0x00000398 0x618 Mainboard.o + 0x9d0 (size before relaxing) + .debug_str 0x000009b0 0x22 Rs232.o 0x14b (size before relaxing) - .debug_str 0x00000527 0x25 Spi.o - 0x1c8 (size before relaxing) + .debug_str 0x000009d2 0x530 Spi.o + 0x757 (size before relaxing) -.debug_loc 0x00000000 0xdbb +.debug_loc 0x00000000 0xc7f *(.debug_loc) - .debug_loc 0x00000000 0x6f2 Can.o - .debug_loc 0x000006f2 0x2c1 Led.o - .debug_loc 0x000009b3 0x16d Mainboard.o - .debug_loc 0x00000b20 0x8a Rs232.o - .debug_loc 0x00000baa 0x211 Spi.o + .debug_loc 0x00000000 0x6ea Can.o + .debug_loc 0x000006ea 0xf5 Mainboard.o + .debug_loc 0x000007df 0x8a Rs232.o + .debug_loc 0x00000869 0x416 Spi.o .debug_macinfo *(.debug_macinfo) @@ -589,13 +572,12 @@ LOAD c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8 .debug_pubtypes *(.debug_pubtypes) -.debug_ranges 0x00000000 0x188 +.debug_ranges 0x00000000 0x120 *(.debug_ranges) .debug_ranges 0x00000000 0x90 Can.o - .debug_ranges 0x00000090 0x68 Led.o - .debug_ranges 0x000000f8 0x18 Mainboard.o - .debug_ranges 0x00000110 0x28 Rs232.o - .debug_ranges 0x00000138 0x50 Spi.o + .debug_ranges 0x00000090 0x18 Mainboard.o + .debug_ranges 0x000000a8 0x28 Rs232.o + .debug_ranges 0x000000d0 0x50 Spi.o .debug_macro *(.debug_macro) diff --git a/Mainboard/Mainboard/Debug/Mainboard.srec b/Mainboard/Mainboard/Debug/Mainboard.srec index 5e4e4c0..21a107a 100644 --- a/Mainboard/Mainboard/Debug/Mainboard.srec +++ b/Mainboard/Mainboard/Debug/Mainboard.srec @@ -6,20 +6,20 @@ S11300300C9463000C9463000C9463000C946300B0 S11300400C9463000C9463000C9463000C946300A0 S11300500C9463000C9463000C9463000C94630090 S11300600C9463000C9463000C9463000C94630080 -S11300700C9463005E0211241FBECFEFD4E0DEBFF8 -S1130080CDBF11E0A0E0B1E0EAEFF5E002C00590D9 +S11300700C946300400211241FBECFEFD4E0DEBF16 +S1130080CDBF11E0A0E0B1E0E4EAF5E002C00590E4 S11300900D92A630B107D9F721E0A6E0B1E001C086 -S11300A01D92AB30B207E1F710E0C6E7D0E004C020 -S11300B02297FE010E94F702C437D107C9F70E94B4 -S11300C009020C94FB020C940000FF920F931F93FF +S11300A01D92A930B207E1F710E0C6E7D0E004C022 +S11300B02297FE010E94CC02C437D107C9F70E94DF +S11300C0F9010C94D0020C940000FF920F931F933B S11300D0CF93DF931F92CDB7DEB7F82E092F162FDB -S11300E049830E94C40262E08F2D902F0E94E9028E -S11300F0612F8F2D902F0E94E9024981642F8F2D4B -S1130100902F0E94E9028F2D902F0F90DF91CF91B5 -S11301101F910F91FF900C94C202CF93DF93D82FBD -S1130120C92F0E94C40260EC8D2F9C2F0E94E9020B +S11300E049830E949A0262E08F2D902F0E94BE02E3 +S11300F0612F8F2D902F0E94BE024981642F8F2D76 +S1130100902F0E94BE028F2D902F0F90DF91CF91E0 +S11301101F910F91FF900C949702CF93DF93D82FE8 +S1130120C92F0E949A0260EC8D2F9C2F0E94BE0260 S11301308FE99FE00197F1F700C000008D2F9C2FFD -S11301400E94C2028FE39CE90197F1F700C000000E +S11301400E9497028FE39CE90197F1F700C0000039 S113015047E06AE28D2F9C2F0E94650040E969E226 S11301608D2F9C2F0E94650042E068E28D2F9C2F0A S11301700E94650043E06BE28D2F9C2F0E94650076 @@ -31,69 +31,64 @@ S11301C08D2F9C2F0E94650040E064E28D2F9C2FB0 S11301D00E94650040E065E28D2F9C2F0E9465001F S11301E040E066E28D2F9C2F0E94650040E067E2AC S11301F08D2F9C2F0E94650040E06CE08D2F9C2F7A -S1130200DF91CF910C946500FC014083518362839C -S11302100C948D00FF920F931F93CF93DF9300D024 -S1130220CDB7DEB7F82E092F162F2A8349830E94F3 -S1130230C40265E08F2D902F0E94E902612F8F2D5B -S1130240902F0E94E9024981642F8F2D902F0E94E4 -S1130250E9022A81622F8F2D902F0E94E9028F2DAF -S1130260902F0F900F90DF91CF911F910F91FF90DE -S11302700C94C2021F93CF93DF93D82FC92F0E94EF -S1130280C40260EB8D2F9C2F0E94E9026FEF8D2F2B -S11302909C2F0E94E902182F6FEF8D2F9C2F0E9434 -S11302A0E9028D2F9C2F0E94C202812FDF91CF91F2 -S11302B01F9108959F92AF92BF92CF92DF92EF92D7 -S11302C0FF920F931F93CF93DF931F92CDB7DEB7A7 -S11302D05C016B010E943A01982E8983898186FD15 -S11302E011C0898187FD7FC08FEF0F90DF91CF917F -S11302F01F910F91FF90EF90DF90CF90BF90AF9040 -S11303009F900895C5010E94C40260E9C5010E943E -S1130310E9026FEFC5010E94E902282F30E0220FA5 -S1130320331F220F331F220F331FF6013183208323 -S11303306FEFC5010E94E902482F50E0569547959A -S1130340529542954F7045275F704527F6012081ED -S11303503181242B352B318320836FEFC5010E941B -S1130360E9026FEFC5010E94E9026FEFC5010E9427 -S1130370E9028F70F60183838823A1F086010C5F64 -S11303801F4F7601F5E0EF0EF11C8150E80EF11CD1 -S11303906FEFC5010E94E902F80181938F01EE1508 -S11303A0FF05B1F7C5010E94C202898183FD0EC019 -S11303B0F6011282898120E086FF0FC041E06CE2E1 -S11303C0C5010E940A01892D87708FCF81E0F60153 -S11303D08283898120E086FDF1CF42E06CE2C50191 -S11303E00E940A01F0CFC5010E94C40264E9C5015C -S11303F00E94E9028ECF84B1806E84B9089585B1DC -S11304008F7185B985B16295660F607E682B65B979 -S11304100895CF93DF93CDB7DEB72C970FB6F8943A -S1130420DEBF0FBECDBF66E08AE091E00E94FF010F -S113043060E071E089E091E00E948A0283E291E049 -S11304409A8389831B8282E08C838FEA8D838EEF6B -S11304508E830EC061E08AE091E00E94FF012FEFDD -S113046083ED90E3215080409040E1F700C000000C -S113047062E08AE091E00E94FF012FEF81EE94E0B8 -S1130480215080409040E1F700C00000BE016F5F42 -S11304907F4F86E091E00E945A018F3FD9F664E0D5 -S11304A08AE091E00E94FF012FEF81EE94E0215059 -S11304B080409040E1F700C00000DACFCF93DF9393 -S11304C000D01F92CDB7DEB78AE091E00E94FB0115 -S11304D089E091E00E947E0260E0CE0101960E94D4 -S11304E0B90249815A816B8186E091E00E9404013E -S11304F00F900F900F90DF91CF91089586E0809335 -S1130500CA00E9ECF0E080818860808387E680930C -S1130510CC000895FB019081992351F0319680918C -S1130520C80085FFFCCF9093CE0091919111F7CF35 -S1130530089524B1266124B9239825B1217F25B9D2 -S1130540DC011196ED91FC9112978081817F80836B -S11305502C9A0895CF93DF93EC010E94990288812D -S1130560811104C080E58CBD81E08DBDDF91CF9108 -S1130570089521E0FC01208325E230E032832183C9 -S11305800C94AA022C9A08952C98089598E080E07F -S113059060FD2A9A60FF2A98299866950000000059 -S11305A00000000000000000000000000000000047 -S11305B0000000000000000000000000299A000074 -S11305C023B123FB222720F9880F822B915001F7B6 -S11305D00895FC012081211106C06EBD0DB407FEF3 -S11305E0FDCF8EB508950C94C602EE0FFF1F059043 -S10D05F0F491E02D0994F894FFCF74 -S10905FA626C610A0000BE +S1130200DF91CF910C946500FC0160830C948D0008 +S1130210FF920F931F93CF93DF9300D0CDB7DEB738 +S1130220F82E092F162F2A8349830E949A0265E02B +S11302308F2D902F0E94BE02612F8F2D902F0E9430 +S1130240BE024981642F8F2D902F0E94BE022A8105 +S1130250622F8F2D902F0E94BE028F2D902F0F9012 +S11302600F90DF91CF911F910F91FF900C94970203 +S11302701F93CF93DF93D82FC92F0E949A0260EB6C +S11302808D2F9C2F0E94BE026FEF8D2F9C2F0E94FA +S1130290BE02182F6FEF8D2F9C2F0E94BE028D2F50 +S11302A09C2F0E949702812FDF91CF911F91089577 +S11302B09F92AF92BF92CF92DF92EF92FF920F93F1 +S11302C01F93CF93DF931F92CDB7DEB75C016B0111 +S11302D00E943801982E8983898186FD11C0898105 +S11302E087FD7FC08FEF0F90DF91CF911F910F910A +S11302F0FF90EF90DF90CF90BF90AF909F900895C4 +S1130300C5010E949A0260E9C5010E94BE026FEF16 +S1130310C5010E94BE02282F30E0220F331F220F96 +S1130320331F220F331FF601318320836FEFC50182 +S11303300E94BE02482F50E056954795529542952B +S11303404F7045275F704527F60120813181242BAA +S1130350352B318320836FEFC5010E94BE026FEFFE +S1130360C5010E94BE026FEFC5010E94BE028F70DC +S1130370F60183838823A1F086010C5F1F4F760169 +S1130380F5E0EF0EF11C8150E80EF11C6FEFC50192 +S11303900E94BE02F80181938F01EE15FF05B1F7AB +S11303A0C5010E949702898183FD0EC0F601128265 +S11303B0898120E086FF0FC041E06CE2C5010E9404 +S11303C00801892D87708FCF81E0F60182838981AE +S11303D020E086FDF1CF42E06CE2C5010E940801F5 +S11303E0F0CFC5010E949A0264E9C5010E94BE02D1 +S11303F08ECFCF93DF93CDB7DEB72C970FB6F8949B +S1130400DEBF0FBECDBF47983F9A469A3E9A459AA3 +S11304103D9A60E071E087E091E00E94660283E229 +S113042091E09A8389831B8282E08C838FEA8D8397 +S11304308EEF8E8309C02FEF83ED90E3215080402F +S11304409040E1F700C000002FEF81EE94E02150CE +S113045080409040E1F700C00000BE016F5F7F4F15 +S113046086E091E00E9458018F3F29F72FEF81EE3B +S113047094E0215080409040E1F700C00000E4CFB8 +S1130480CF93DF931F92CDB7DEB73D9A3E9A3F9A42 +S113049087E091E00E945A0260E0CE0101960E943A +S11304A09202698186E091E00E9404010F90DF913D +S11304B0CF91089586E08093CA00E9ECF0E0808152 +S11304C08860808387E68093CC000895FB01908147 +S11304D0992351F031968091C80085FFFCCF909309 +S11304E0CE0091919111F7CF0895229A2A98229AD9 +S11304F0219A2998219A249A2C9A249A23982B9801 +S11305002B98239A0895CF93DF93EC010E947502F0 +S11305108881811104C080E58CBD81E08DBDDF91AF +S1130520CF91089521E0FC0120830C9483022C9A3E +S1130530249A08952C98249A089598E080E015C090 +S11305402A98229A25E02A95F1F700001B998160E8 +S113055025E02A95F1F70000299A219A2AE02A95A4 +S1130560F1F700C0660F915041F0880F2998219A45 +S113057067FFE6CF2A9A229AE5CF0895FC012081ED +S1130580211106C06EBD0DB407FEFDCF8EB50895D2 +S11305900C949D02EE0FFF1F0590F491E02D099439 +S10705A0F894FFCFF9 +S10905A4626C610A000014 S9030000FC diff --git a/Mainboard/Mainboard/Led.h b/Mainboard/Mainboard/Led.h index 8f13188..4b7f2bd 100644 --- a/Mainboard/Mainboard/Led.h +++ b/Mainboard/Mainboard/Led.h @@ -5,11 +5,11 @@ * Author: BlubbFish */ -#include "portc.hpp" -#include "pin.hpp" - #ifndef LED_H_ #define LED_H_ + +#include "pin.hpp" + template class Led { public: diff --git a/Mainboard/Mainboard/Mainboard.cpp b/Mainboard/Mainboard/Mainboard.cpp index a921cff..0871614 100644 --- a/Mainboard/Mainboard/Mainboard.cpp +++ b/Mainboard/Mainboard/Mainboard.cpp @@ -11,17 +11,25 @@ #include "Can.h" #include "Spi.h" #include "portc.hpp" +#include "portb.hpp"; #include -//Led l; -typedef Led l; +//////////////////// LED /////////////////////////////// +typedef Led ledclass; +ledclass l; + +typedef Spi spiclass; +spiclass s; + +typedef Rs232<9600> rs232class; +rs232class r; + Rs232 r; -Can c(Spi(0)); +Can c(s); int main(void) { - //l.color(Led::YELLOW); - l::color(l::YELLOW); + l.color(l.YELLOW); r.send("bla\n"); CANMessage m; m.id = 0x0123; diff --git a/Mainboard/Mainboard/Rs232.cpp b/Mainboard/Mainboard/Rs232.cpp index 5f2bb33..a3c3975 100644 --- a/Mainboard/Mainboard/Rs232.cpp +++ b/Mainboard/Mainboard/Rs232.cpp @@ -5,7 +5,7 @@ * Author: netz */ -#include "Rs232.h" +/* #include "Rs232.h" Rs232::Rs232() { init(); @@ -21,7 +21,7 @@ uint8_t Rs232::uart_putchar(uint8_t c) void Rs232::init() { UCSR1C = (1 << UCSZ11) |(1 << UCSZ10); //8N1 - UCSR1B |= /*(1< #include +template class Rs232 { - private: - void init(); - uint8_t uart_putchar(uint8_t c); public: - Rs232(); - Rs232(int) {} - void send(const char *text); + Rs232() { + init(); + } + void send(const char *text) { + while (*text) + { + uart_putchar(*text); + text++; + } + } + private: + void init() { + UCSR1C = (1 << UCSZ11) |(1 << UCSZ10); //8N1 + UCSR1B |= /*(1<> CANP_MISO) & 1); } - return werti; */ -} \ No newline at end of file + return werti; *-/ +} */ \ No newline at end of file diff --git a/Mainboard/Mainboard/Spi.h b/Mainboard/Mainboard/Spi.h index 1df2512..9962542 100644 --- a/Mainboard/Mainboard/Spi.h +++ b/Mainboard/Mainboard/Spi.h @@ -13,30 +13,82 @@ #include #include #include "pin.hpp" -#include "portb.hpp" - +template class Spi { public: - Spi(uint8_t index); - void CSOn(); - void CSOff(); - uint8_t send(uint8_t data); + Spi() { + init(); + } + void CSOn() { + cs::make_low(); + } + void CSOff() { + cs::make_high(); + } + uint8_t send(uint8_t data) { + if(mode == 0) { + return send_hard(data); + } + return send_soft(data); + } private: - const uint8_t mode; //0 Hardware, 1 Software - const typedef avrlib::pin cs; - const typedef avrlib::pin miso; - const typedef avrlib::pin mosi; - const typedef avrlib::pin sck; - void init(); - void init_port(); - void init_spi(); - uint8_t send_soft(uint8_t data); - uint8_t send_hard(uint8_t data); - /*protected: - uint8_t m_index;*/ + const typedef avrlib::pin cs; + const typedef avrlib::pin miso; + const typedef avrlib::pin mosi; + const typedef avrlib::pin sck; + void init() { + init_port(); + if(mode == 0) { + init_spi(); + } + } + void init_port() { + mosi::make_output(); + mosi::make_low(); + sck::make_output(); + sck::make_low(); + cs::make_output(); + cs::make_high(); + miso::make_input(); + miso::make_low(); + } + void init_spi() { + SPCR = (1<0; a--) { //das Byte wird Bitweise nacheinander Gesendet MSB zuerst + datain<<=1; //Schieben um das Richtige Bit zusetzen + sck::make_low(); // Clock auf LOW + if (data & 0x80) { //Ist Bit a in Byte gesetzt + mosi::make_high(); //Set Output High + } + else{ + mosi::make_low(); //Set Output Low + } + _delay_us(1); + if(miso::read()) //Lesen des Pegels + { + datain |= 1; + } + _delay_us(1); + sck::make_high(); // Clock auf High + _delay_us(2); + data<<=1; //Schiebe um nächstes Bit zusenden + } + return datain; + } + uint8_t send_hard(uint8_t data) { + // Sendet ein Byte + SPDR = data; + + // Wartet bis Byte gesendet wurde + loop_until_bit_is_set(SPSR, SPIF); + + return SPDR; + } }; - - #endif /* SPI_H_ */ \ No newline at end of file diff --git a/Mainboard/Mainboard/Spi.hpp b/Mainboard/Mainboard/Spi.hpp new file mode 100644 index 0000000..b77a5bc --- /dev/null +++ b/Mainboard/Mainboard/Spi.hpp @@ -0,0 +1,7 @@ + +/* + * Spi.hpp + * + * Created: 11.11.2013 18:01:21 + * Author: netz + */ diff --git a/Mainboard/Mainboard/config.h b/Mainboard/Mainboard/config.h index 121c732..01820f0 100644 --- a/Mainboard/Mainboard/config.h +++ b/Mainboard/Mainboard/config.h @@ -10,6 +10,5 @@ #define CONFIG_H_ #define F_CPU 16000000 -#define BAUD_RATE 9600 #endif /* CONFIG_H_ */ \ No newline at end of file