20140508-181001

This commit is contained in:
BlubbFish 2014-05-08 16:10:03 +00:00
parent de5b2ecf4e
commit 4dd770c5b0
24 changed files with 776 additions and 197 deletions

View File

@ -32,7 +32,8 @@ LIB_DEP:=
# Every subdirectory with source files must be described here
SUBDIRS := \
../io
../io \
../io/hardware
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -0,0 +1,80 @@
Zeitschaltung_V6.d Zeitschaltung_V6.o: .././Zeitschaltung_V6.cpp \
.././config.h .././peripheral.h .././io/hardware/portb.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 \
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/stdint.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/stdint.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/iom168a.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/iom168.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/iomx8.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/portpins.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/common.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 \
.././io/hardware/portc.hpp .././io/hardware/portd.hpp .././io/Led.hpp \
.././io/hardware/pin.hpp .././io/Servo.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/interrupt.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 \
.././io/Start.hpp .././io/Spi.hpp .././io/../config.h .././io/rfm12.hpp
.././config.h:
.././peripheral.h:
.././io/hardware/portb.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:
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/stdint.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/stdint.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/iom168a.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/iom168.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/iomx8.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/portpins.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/common.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:
.././io/hardware/portc.hpp:
.././io/hardware/portd.hpp:
.././io/Led.hpp:
.././io/hardware/pin.hpp:
.././io/Servo.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/interrupt.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:
.././io/Start.hpp:
.././io/Spi.hpp:
.././io/../config.h:
.././io/rfm12.hpp:

View File

@ -2,16 +2,23 @@
:100010000C9452000C9452000C9452000C94520018
:100020000C9452000C9452000C9452000C94520008
:100030000C9452000C9452000C9452000C945200F8
:100040000C9452000C9452000C9452000C945200E8
:100040000C945F000C9452000C9452000C945200DB
:100050000C9452000C9452000C9452000C945200D8
:100060000C9452000C9452006C0011241FBECFEF70
:100060000C9452000C945200950011241FBECFEF47
:10007000D4E0DEBFCDBF21E0A0E0B1E001C01D9221
:10008000A130B207E1F710E0CAE6D0E004C0229741
:10009000FE010E947300C836D107C9F70E945400C0
:1000A0000C9477000C9400005E9A569A5F98579AC9
:1000B0005E9A569A5F9A579A5E98569A5F9A579A9E
:1000C0005E98569A5F98579AEFCF579A569A5E98CD
:1000D000569A5F98579A089580E091E00E946500D3
:1000E0000895EE0FFF1F0590F491E02D0994F89408
:0200F000FFCF40
:10008000A330B207E1F710E0CAE6D0E004C022973F
:10009000FE010E94B000C836D107C9F70E94540083
:1000A0000C94B4000C9400005E98569A5F98579A8E
:1000B0004B99FACF5E9A569A5F98579AF5CF1F924E
:1000C0000F920FB60F9211242F933F938F939F930C
:1000D00084E686BD2A9A229A8FEF94E00197F1F781
:1000E00000C0000080910101882369F080E090E069
:1000F00025E12A95F1F7000001962091010130E0F9
:1001000082179307A8F32A98229A9F918F913F9183
:100110002F910F900FBE0F901F901895579A569AD7
:100120005E98569A5F98579A089582E091E00E94EF
:100130008E0010920101219A2998219A229A14BCCA
:1001400085E085BD84E686BD17BC18BC81E0809340
:100150006E00789453985B985B9A0895EE0FFF1F9A
:0C0160000590F491E02D0994F894FFCF75
:00000001FF

View File

@ -3,31 +3,33 @@ Zeitschaltung_V6.elf: file format elf32-avr
Sections:
Idx Name Size VMA LMA File off Algn
0 .data 00000000 00800100 000000f2 00000186 2**0
0 .data 00000000 00800100 0000016c 00000200 2**0
CONTENTS, ALLOC, LOAD, DATA
1 .text 000000f2 00000000 00000000 00000094 2**1
1 .text 0000016c 00000000 00000000 00000094 2**1
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .bss 00000001 00800100 00800100 00000186 2**0
2 .bss 00000003 00800100 00800100 00000200 2**0
ALLOC
3 .stab 000006cc 00000000 00000000 00000188 2**2
3 .stab 000006cc 00000000 00000000 00000200 2**2
CONTENTS, READONLY, DEBUGGING
4 .stabstr 00000082 00000000 00000000 00000854 2**0
4 .stabstr 00000082 00000000 00000000 000008cc 2**0
CONTENTS, READONLY, DEBUGGING
5 .comment 0000002f 00000000 00000000 000008d6 2**0
5 .comment 0000002f 00000000 00000000 0000094e 2**0
CONTENTS, READONLY
6 .debug_aranges 00000030 00000000 00000000 00000905 2**0
6 .debug_aranges 00000038 00000000 00000000 0000097d 2**0
CONTENTS, READONLY, DEBUGGING
7 .debug_info 00000abc 00000000 00000000 00000935 2**0
7 .debug_info 0000136b 00000000 00000000 000009b5 2**0
CONTENTS, READONLY, DEBUGGING
8 .debug_abbrev 00000293 00000000 00000000 000013f1 2**0
8 .debug_abbrev 0000038d 00000000 00000000 00001d20 2**0
CONTENTS, READONLY, DEBUGGING
9 .debug_line 000001aa 00000000 00000000 00001684 2**0
9 .debug_line 00000290 00000000 00000000 000020ad 2**0
CONTENTS, READONLY, DEBUGGING
10 .debug_frame 00000044 00000000 00000000 00001830 2**2
10 .debug_frame 00000074 00000000 00000000 00002340 2**2
CONTENTS, READONLY, DEBUGGING
11 .debug_str 000004da 00000000 00000000 00001874 2**0
11 .debug_str 00000c3b 00000000 00000000 000023b4 2**0
CONTENTS, READONLY, DEBUGGING
12 .debug_ranges 00000020 00000000 00000000 00001d4e 2**0
12 .debug_loc 000000cc 00000000 00000000 00002fef 2**0
CONTENTS, READONLY, DEBUGGING
13 .debug_ranges 00000028 00000000 00000000 000030bb 2**0
CONTENTS, READONLY, DEBUGGING
Disassembly of section .text:
@ -49,7 +51,7 @@ Disassembly of section .text:
34: 0c 94 52 00 jmp 0xa4 ; 0xa4 <__bad_interrupt>
38: 0c 94 52 00 jmp 0xa4 ; 0xa4 <__bad_interrupt>
3c: 0c 94 52 00 jmp 0xa4 ; 0xa4 <__bad_interrupt>
40: 0c 94 52 00 jmp 0xa4 ; 0xa4 <__bad_interrupt>
40: 0c 94 5f 00 jmp 0xbe ; 0xbe <__vector_16>
44: 0c 94 52 00 jmp 0xa4 ; 0xa4 <__bad_interrupt>
48: 0c 94 52 00 jmp 0xa4 ; 0xa4 <__bad_interrupt>
4c: 0c 94 52 00 jmp 0xa4 ; 0xa4 <__bad_interrupt>
@ -61,7 +63,7 @@ Disassembly of section .text:
64: 0c 94 52 00 jmp 0xa4 ; 0xa4 <__bad_interrupt>
00000068 <__ctors_start>:
68: 6c 00 .word 0x006c ; ????
68: 95 00 .word 0x0095 ; ????
0000006a <__ctors_end>:
6a: 11 24 eor r1, r1
@ -81,7 +83,7 @@ Disassembly of section .text:
7e: 1d 92 st X+, r1
00000080 <.do_clear_bss_start>:
80: a1 30 cpi r26, 0x01 ; 1
80: a3 30 cpi r26, 0x03 ; 3
82: b2 07 cpc r27, r18
84: e1 f7 brne .-8 ; 0x7e <.do_clear_bss_loop>
@ -92,12 +94,12 @@ Disassembly of section .text:
8c: 04 c0 rjmp .+8 ; 0x96 <__do_global_ctors+0x10>
8e: 22 97 sbiw r28, 0x02 ; 2
90: fe 01 movw r30, r28
92: 0e 94 73 00 call 0xe6 ; 0xe6 <__tablejump__>
92: 0e 94 b0 00 call 0x160 ; 0x160 <__tablejump__>
96: c8 36 cpi r28, 0x68 ; 104
98: d1 07 cpc r29, r17
9a: c9 f7 brne .-14 ; 0x8e <__do_global_ctors+0x8>
9c: 0e 94 54 00 call 0xa8 ; 0xa8 <main>
a0: 0c 94 77 00 jmp 0xee ; 0xee <_exit>
a0: 0c 94 b4 00 jmp 0x168 ; 0x168 <_exit>
000000a4 <__bad_interrupt>:
a4: 0c 94 00 00 jmp 0 ; 0x0 <__vectors>
@ -109,7 +111,7 @@ namespace avrlib {
{
static uint8_t port() { return PORTD; }
static void port(uint8_t v) { PORTD = v; }
a8: 5e 9a sbi 0x0b, 6 ; 11
a8: 5e 98 cbi 0x0b, 6 ; 11
static uint8_t pin() { return PIND; }
static void pin(uint8_t v) { PIND = v; }
@ -131,149 +133,255 @@ namespace avrlib {
static uint8_t dir() { return DDRD; }
static void dir(uint8_t v) { DDRD = v; }
ae: 57 9a sbi 0x0a, 7 ; 10
{
while(1)
{
l.color(l.BLACK);
if(st.is_pressed()) {
b0: 4b 99 sbic 0x09, 3 ; 9
b2: fa cf rjmp .-12 ; 0xa8 <main>
namespace avrlib {
struct portd
{
static uint8_t port() { return PORTD; }
static void port(uint8_t v) { PORTD = v; }
b0: 5e 9a sbi 0x0b, 6 ; 11
b4: 5e 9a sbi 0x0b, 6 ; 11
static uint8_t pin() { return PIND; }
static void pin(uint8_t v) { PIND = v; }
static uint8_t dir() { return DDRD; }
static void dir(uint8_t v) { DDRD = v; }
b2: 56 9a sbi 0x0a, 6 ; 10
b6: 56 9a sbi 0x0a, 6 ; 10
namespace avrlib {
struct portd
{
static uint8_t port() { return PORTD; }
static void port(uint8_t v) { PORTD = v; }
b4: 5f 9a sbi 0x0b, 7 ; 11
b8: 5f 98 cbi 0x0b, 7 ; 11
static uint8_t pin() { return PIND; }
static void pin(uint8_t v) { PIND = v; }
static uint8_t dir() { return DDRD; }
static void dir(uint8_t v) { DDRD = v; }
b6: 57 9a sbi 0x0a, 7 ; 10
ba: 57 9a sbi 0x0a, 7 ; 10
bc: f5 cf rjmp .-22 ; 0xa8 <main>
000000be <__vector_16>:
l.color(l.GREEN);
}
}
}
ISR(TIMER0_OVF_vect) {
be: 1f 92 push r1
c0: 0f 92 push r0
c2: 0f b6 in r0, 0x3f ; 63
c4: 0f 92 push r0
c6: 11 24 eor r1, r1
c8: 2f 93 push r18
ca: 3f 93 push r19
cc: 8f 93 push r24
ce: 9f 93 push r25
}
void off() {
servo_act::make_low();
}
void timer() {
TCNT0 = 0x64; // Reinitialize Timer 0 value
d0: 84 e6 ldi r24, 0x64 ; 100
d2: 86 bd out 0x26, r24 ; 38
namespace avrlib {
struct portb
{
static uint8_t port() { return PORTB; }
static void port(uint8_t v) { PORTB = v; }
d4: 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; }
d6: 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);
d8: 8f ef ldi r24, 0xFF ; 255
da: 94 e0 ldi r25, 0x04 ; 4
dc: 01 97 sbiw r24, 0x01 ; 1
de: f1 f7 brne .-4 ; 0xdc <__vector_16+0x1e>
e0: 00 c0 rjmp .+0 ; 0xe2 <__vector_16+0x24>
e2: 00 00 nop
servo_io::make_high();
_delay_us(s_left);
for(uint16_t i = 0; i < servopos; i++) {
e4: 80 91 01 01 lds r24, 0x0101
e8: 88 23 and r24, r24
ea: 69 f0 breq .+26 ; 0x106 <__vector_16+0x48>
ec: 80 e0 ldi r24, 0x00 ; 0
ee: 90 e0 ldi r25, 0x00 ; 0
f0: 25 e1 ldi r18, 0x15 ; 21
f2: 2a 95 dec r18
f4: f1 f7 brne .-4 ; 0xf2 <__vector_16+0x34>
f6: 00 00 nop
f8: 01 96 adiw r24, 0x01 ; 1
fa: 20 91 01 01 lds r18, 0x0101
fe: 30 e0 ldi r19, 0x00 ; 0
100: 82 17 cp r24, r18
102: 93 07 cpc r25, r19
104: a8 f3 brcs .-22 ; 0xf0 <__vector_16+0x32>
namespace avrlib {
struct portb
{
static uint8_t port() { return PORTB; }
static void port(uint8_t v) { PORTB = v; }
106: 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; }
108: 22 9a sbi 0x04, 2 ; 4
s.timer();
10a: 9f 91 pop r25
10c: 8f 91 pop r24
10e: 3f 91 pop r19
110: 2f 91 pop r18
112: 0f 90 pop r0
114: 0f be out 0x3f, r0 ; 63
116: 0f 90 pop r0
118: 1f 90 pop r1
11a: 18 95 reti
0000011c <_ZN3LedIN6avrlib5portdELi7ELi6EE4initEv>:
11c: 57 9a sbi 0x0a, 7 ; 10
11e: 56 9a sbi 0x0a, 6 ; 10
namespace avrlib {
struct portd
{
static uint8_t port() { return PORTD; }
static void port(uint8_t v) { PORTD = v; }
b8: 5e 98 cbi 0x0b, 6 ; 11
120: 5e 98 cbi 0x0b, 6 ; 11
static uint8_t pin() { return PIND; }
static void pin(uint8_t v) { PIND = v; }
static uint8_t dir() { return DDRD; }
static void dir(uint8_t v) { DDRD = v; }
ba: 56 9a sbi 0x0a, 6 ; 10
122: 56 9a sbi 0x0a, 6 ; 10
namespace avrlib {
struct portd
{
static uint8_t port() { return PORTD; }
static void port(uint8_t v) { PORTD = v; }
bc: 5f 9a sbi 0x0b, 7 ; 11
124: 5f 98 cbi 0x0b, 7 ; 11
static uint8_t pin() { return PIND; }
static void pin(uint8_t v) { PIND = v; }
static uint8_t dir() { return DDRD; }
static void dir(uint8_t v) { DDRD = v; }
be: 57 9a sbi 0x0a, 7 ; 10
namespace avrlib {
126: 57 9a sbi 0x0a, 7 ; 10
128: 08 95 ret
struct portd
{
static uint8_t port() { return PORTD; }
static void port(uint8_t v) { PORTD = v; }
c0: 5e 98 cbi 0x0b, 6 ; 11
static uint8_t pin() { return PIND; }
static void pin(uint8_t v) { PIND = v; }
static uint8_t dir() { return DDRD; }
static void dir(uint8_t v) { DDRD = v; }
c2: 56 9a sbi 0x0a, 6 ; 10
namespace avrlib {
struct portd
{
static uint8_t port() { return PORTD; }
static void port(uint8_t v) { PORTD = v; }
c4: 5f 98 cbi 0x0b, 7 ; 11
static uint8_t pin() { return PIND; }
static void pin(uint8_t v) { PIND = v; }
static uint8_t dir() { return DDRD; }
static void dir(uint8_t v) { DDRD = v; }
c6: 57 9a sbi 0x0a, 7 ; 10
c8: ef cf rjmp .-34 ; 0xa8 <main>
000000ca <_ZN3LedIN6avrlib5portdELi7ELi6EE4initEv>:
ca: 57 9a sbi 0x0a, 7 ; 10
cc: 56 9a sbi 0x0a, 6 ; 10
namespace avrlib {
struct portd
{
static uint8_t port() { return PORTD; }
static void port(uint8_t v) { PORTD = v; }
ce: 5e 98 cbi 0x0b, 6 ; 11
static uint8_t pin() { return PIND; }
static void pin(uint8_t v) { PIND = v; }
static uint8_t dir() { return DDRD; }
static void dir(uint8_t v) { DDRD = v; }
d0: 56 9a sbi 0x0a, 6 ; 10
namespace avrlib {
struct portd
{
static uint8_t port() { return PORTD; }
static void port(uint8_t v) { PORTD = v; }
d2: 5f 98 cbi 0x0b, 7 ; 11
static uint8_t pin() { return PIND; }
static void pin(uint8_t v) { PIND = v; }
static uint8_t dir() { return DDRD; }
static void dir(uint8_t v) { DDRD = v; }
d4: 57 9a sbi 0x0a, 7 ; 10
d6: 08 95 ret
000000d8 <_GLOBAL__sub_I_l>:
0000012a <_GLOBAL__sub_I_l>:
template <typename Port, int pin_red, int pin_green>
class Led {
public:
Led() {
init();
d8: 80 e0 ldi r24, 0x00 ; 0
da: 91 e0 ldi r25, 0x01 ; 1
dc: 0e 94 65 00 call 0xca ; 0xca <_ZN3LedIN6avrlib5portdELi7ELi6EE4initEv>
e0: 08 95 ret
12a: 82 e0 ldi r24, 0x02 ; 2
12c: 91 e0 ldi r25, 0x01 ; 1
12e: 0e 94 8e 00 call 0x11c ; 0x11c <_ZN3LedIN6avrlib5portdELi7ELi6EE4initEv>
static const uint16_t MIDDLE = s_middle;
static const uint16_t RIGHT = s_right;
private:
uint8_t servopos;
void init() {
this->servopos = 0;
132: 10 92 01 01 sts 0x0101, r1
136: 21 9a sbi 0x04, 1 ; 4
namespace avrlib {
000000e2 <__tablejump2__>:
e2: ee 0f add r30, r30
e4: ff 1f adc r31, r31
struct portb
{
static uint8_t port() { return PORTB; }
static void port(uint8_t v) { PORTB = v; }
138: 29 98 cbi 0x05, 1 ; 5
000000e6 <__tablejump__>:
e6: 05 90 lpm r0, Z+
e8: f4 91 lpm r31, Z
ea: e0 2d mov r30, r0
ec: 09 94 ijmp
static uint8_t pin() { return PINB; }
static void pin(uint8_t v) { PINB = v; }
000000ee <_exit>:
ee: f8 94 cli
static uint8_t dir() { return DDRB; }
static void dir(uint8_t v) { DDRB = v; }
13a: 21 9a sbi 0x04, 1 ; 4
13c: 22 9a sbi 0x04, 2 ; 4
// Clock value: 7,813 kHz
// Mode: Normal top=0xFF
// OC0A output: Disconnected
// OC0B output: Disconnected
// Timer Period: 19,968 ms
TCCR0A=(0<<COM0A1) | (0<<COM0A0) | (0<<COM0B1) | (0<<COM0B0) | (0<<WGM01) | (0<<WGM00);
13e: 14 bc out 0x24, r1 ; 36
TCCR0B=(0<<WGM02) | (1<<CS02) | (0<<CS01) | (1<<CS00);
140: 85 e0 ldi r24, 0x05 ; 5
142: 85 bd out 0x25, r24 ; 37
TCNT0=0x64;
144: 84 e6 ldi r24, 0x64 ; 100
146: 86 bd out 0x26, r24 ; 38
OCR0A=0x00;
148: 17 bc out 0x27, r1 ; 39
OCR0B=0x00;
14a: 18 bc out 0x28, r1 ; 40
000000f0 <__stop_program>:
f0: ff cf rjmp .-2 ; 0xf0 <__stop_program>
// Timer/Counter 0 Interrupt(s) initialization
TIMSK0=(0<<OCIE0B) | (0<<OCIE0A) | (1<<TOIE0);
14c: 81 e0 ldi r24, 0x01 ; 1
14e: 80 93 6e 00 sts 0x006E, r24
this->servopos = 0;
servo_act::make_output();
servo_act::make_low();
servo_io::make_output();
this->init_timer();
sei();
152: 78 94 sei
154: 53 98 cbi 0x0a, 3 ; 10
namespace avrlib {
struct portd
{
static uint8_t port() { return PORTD; }
static void port(uint8_t v) { PORTD = v; }
156: 5b 98 cbi 0x0b, 3 ; 11
158: 5b 9a sbi 0x0b, 3 ; 11
15a: 08 95 ret
0000015c <__tablejump2__>:
15c: ee 0f add r30, r30
15e: ff 1f adc r31, r31
00000160 <__tablejump__>:
160: 05 90 lpm r0, Z+
162: f4 91 lpm r31, Z
164: e0 2d mov r30, r0
166: 09 94 ijmp
00000168 <_exit>:
168: f8 94 cli
0000016a <__stop_program>:
16a: ff cf rjmp .-2 ; 0x16a <__stop_program>

View File

@ -182,7 +182,7 @@ LOAD c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8
.rela.plt
*(.rela.plt)
.text 0x00000000 0xf2
.text 0x00000000 0x16c
*(.vectors)
.vectors 0x00000000 0x68 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/avr5/crtm168a.o
0x00000000 __vector_default
@ -262,26 +262,28 @@ LOAD c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8
0x000000a4 __vector_8
0x000000a4 __vector_14
0x000000a4 __vector_10
0x000000a4 __vector_16
0x000000a4 __vector_18
0x000000a4 __vector_20
0x000000a8 . = ALIGN (0x2)
*(.text.*)
.text.main 0x000000a8 0x22 Zeitschaltung_V6.o
.text.main 0x000000a8 0x16 Zeitschaltung_V6.o
0x000000a8 main
.text.__vector_16
0x000000be 0x5e Zeitschaltung_V6.o
0x000000be __vector_16
.text._ZN3LedIN6avrlib5portdELi7ELi6EE4initEv
0x000000ca 0xe Zeitschaltung_V6.o
0x000000ca _ZN3LedIN6avrlib5portdELi7ELi6EE4initEv
0x0000011c 0xe Zeitschaltung_V6.o
0x0000011c _ZN3LedIN6avrlib5portdELi7ELi6EE4initEv
.text._GLOBAL__sub_I_l
0x000000d8 0xa Zeitschaltung_V6.o
.text.libgcc 0x000000e2 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/avr5\libgcc.a(_tablejump.o)
0x000000e2 __tablejump2__
0x000000e6 __tablejump__
0x000000ee . = ALIGN (0x2)
0x0000012a 0x32 Zeitschaltung_V6.o
.text.libgcc 0x0000015c 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/avr5\libgcc.a(_tablejump.o)
0x0000015c __tablejump2__
0x00000160 __tablejump__
0x00000168 . = ALIGN (0x2)
*(.fini9)
.fini9 0x000000ee 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/avr5\libgcc.a(_exit.o)
0x000000ee _exit
0x000000ee exit
.fini9 0x00000168 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/avr5\libgcc.a(_exit.o)
0x00000168 _exit
0x00000168 exit
*(.fini9)
*(.fini8)
*(.fini8)
@ -300,11 +302,11 @@ LOAD c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8
*(.fini1)
*(.fini1)
*(.fini0)
.fini0 0x000000ee 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/avr5\libgcc.a(_exit.o)
.fini0 0x00000168 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/avr5\libgcc.a(_exit.o)
*(.fini0)
0x000000f2 _etext = .
0x0000016c _etext = .
.data 0x00800100 0x0 load address 0x000000f2
.data 0x00800100 0x0 load address 0x0000016c
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/avr5/crtm168a.o
@ -321,23 +323,25 @@ LOAD c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8
0x00800100 _edata = .
0x00800100 PROVIDE (__data_end, .)
.bss 0x00800100 0x1
.bss 0x00800100 0x3
0x00800100 PROVIDE (__bss_start, .)
*(.bss)
.bss 0x00800100 0x1 Zeitschaltung_V6.o
0x00800100 l
.bss 0x00800100 0x3 Zeitschaltung_V6.o
0x00800100 st
0x00800101 s
0x00800102 l
*(.bss*)
*(COMMON)
0x00800101 PROVIDE (__bss_end, .)
0x000000f2 __data_load_start = LOADADDR (.data)
0x000000f2 __data_load_end = (__data_load_start + SIZEOF (.data))
0x00800103 PROVIDE (__bss_end, .)
0x0000016c __data_load_start = LOADADDR (.data)
0x0000016c __data_load_end = (__data_load_start + SIZEOF (.data))
.noinit 0x00800101 0x0
0x00800101 PROVIDE (__noinit_start, .)
.noinit 0x00800103 0x0
0x00800103 PROVIDE (__noinit_start, .)
*(.noinit*)
0x00800101 PROVIDE (__noinit_end, .)
0x00800101 _end = .
0x00800101 PROVIDE (__heap_start, .)
0x00800103 PROVIDE (__noinit_end, .)
0x00800103 _end = .
0x00800103 PROVIDE (__heap_start, .)
.eeprom 0x00810000 0x0
*(.eeprom*)
@ -395,38 +399,39 @@ LOAD c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8
.debug_sfnames
*(.debug_sfnames)
.debug_aranges 0x00000000 0x30
.debug_aranges 0x00000000 0x38
*(.debug_aranges)
.debug_aranges
0x00000000 0x30 Zeitschaltung_V6.o
0x00000000 0x38 Zeitschaltung_V6.o
.debug_pubnames
*(.debug_pubnames)
.debug_info 0x00000000 0xabc
.debug_info 0x00000000 0x136b
*(.debug_info)
.debug_info 0x00000000 0xabc Zeitschaltung_V6.o
.debug_info 0x00000000 0x136b Zeitschaltung_V6.o
*(.gnu.linkonce.wi.*)
.debug_abbrev 0x00000000 0x293
.debug_abbrev 0x00000000 0x38d
*(.debug_abbrev)
.debug_abbrev 0x00000000 0x293 Zeitschaltung_V6.o
.debug_abbrev 0x00000000 0x38d Zeitschaltung_V6.o
.debug_line 0x00000000 0x1aa
.debug_line 0x00000000 0x290
*(.debug_line)
.debug_line 0x00000000 0x1aa Zeitschaltung_V6.o
.debug_line 0x00000000 0x290 Zeitschaltung_V6.o
.debug_frame 0x00000000 0x44
.debug_frame 0x00000000 0x74
*(.debug_frame)
.debug_frame 0x00000000 0x44 Zeitschaltung_V6.o
.debug_frame 0x00000000 0x74 Zeitschaltung_V6.o
.debug_str 0x00000000 0x4da
.debug_str 0x00000000 0xc3b
*(.debug_str)
.debug_str 0x00000000 0x4da Zeitschaltung_V6.o
0x51a (size before relaxing)
.debug_str 0x00000000 0xc3b Zeitschaltung_V6.o
0xc81 (size before relaxing)
.debug_loc
.debug_loc 0x00000000 0xcc
*(.debug_loc)
.debug_loc 0x00000000 0xcc Zeitschaltung_V6.o
.debug_macinfo
*(.debug_macinfo)
@ -434,9 +439,9 @@ LOAD c:/program files (x86)/atmel/atmel toolchain/avr8 gcc/native/3.4.2.876/avr8
.debug_pubtypes
*(.debug_pubtypes)
.debug_ranges 0x00000000 0x20
.debug_ranges 0x00000000 0x28
*(.debug_ranges)
.debug_ranges 0x00000000 0x20 Zeitschaltung_V6.o
.debug_ranges 0x00000000 0x28 Zeitschaltung_V6.o
.debug_macro
*(.debug_macro)

View File

@ -3,16 +3,23 @@ S11300000C9435000C9452000C9452000C94520041
S11300100C9452000C9452000C9452000C94520014
S11300200C9452000C9452000C9452000C94520004
S11300300C9452000C9452000C9452000C945200F4
S11300400C9452000C9452000C9452000C945200E4
S11300400C945F000C9452000C9452000C945200D7
S11300500C9452000C9452000C9452000C945200D4
S11300600C9452000C9452006C0011241FBECFEF6C
S11300600C9452000C945200950011241FBECFEF43
S1130070D4E0DEBFCDBF21E0A0E0B1E001C01D921D
S1130080A130B207E1F710E0CAE6D0E004C022973D
S1130090FE010E947300C836D107C9F70E945400BC
S11300A00C9477000C9400005E9A569A5F98579AC5
S11300B05E9A569A5F9A579A5E98569A5F9A579A9A
S11300C05E98569A5F98579AEFCF579A569A5E98C9
S11300D0569A5F98579A089580E091E00E946500CF
S11300E00895EE0FFF1F0590F491E02D0994F89404
S10500F0FFCF3C
S1130080A330B207E1F710E0CAE6D0E004C022973B
S1130090FE010E94B000C836D107C9F70E9454007F
S11300A00C94B4000C9400005E98569A5F98579A8A
S11300B04B99FACF5E9A569A5F98579AF5CF1F924A
S11300C00F920FB60F9211242F933F938F939F9308
S11300D084E686BD2A9A229A8FEF94E00197F1F77D
S11300E000C0000080910101882369F080E090E065
S11300F025E12A95F1F7000001962091010130E0F5
S113010082179307A8F32A98229A9F918F913F917F
S11301102F910F900FBE0F901F901895579A569AD3
S11301205E98569A5F98579A089582E091E00E94EB
S11301308E0010920101219A2998219A229A14BCC6
S113014085E085BD84E686BD17BC18BC81E080933C
S11301506E00789453985B985B9A0895EE0FFF1F96
S10F01600590F491E02D0994F894FFCF71
S9030000FC

View File

@ -32,7 +32,8 @@ LIB_DEP:=
# Every subdirectory with source files must be described here
SUBDIRS := \
../io
../io \
../io/hardware
# Add inputs and outputs from these tool invocations to the build variables

View File

@ -1,5 +1,5 @@
Zeitschaltung_V6.d Zeitschaltung_V6.o: .././Zeitschaltung_V6.cpp \
.././config.h .././peripheral.h .././io/Led.hpp .././io/pin.hpp \
.././config.h .././peripheral.h .././io/hardware/portd.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 \
@ -13,7 +13,8 @@ Zeitschaltung_V6.d Zeitschaltung_V6.o: .././Zeitschaltung_V6.cpp \
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 \
.././io/portd.hpp \
.././io/hardware/portc.hpp .././io/Led.hpp .././io/hardware/pin.hpp \
.././io/Spi.hpp .././io/../config.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
@ -22,9 +23,7 @@ Zeitschaltung_V6.d Zeitschaltung_V6.o: .././Zeitschaltung_V6.cpp \
.././peripheral.h:
.././io/Led.hpp:
.././io/pin.hpp:
.././io/hardware/portd.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:
@ -52,7 +51,15 @@ 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:
.././io/portd.hpp:
.././io/hardware/portc.hpp:
.././io/Led.hpp:
.././io/hardware/pin.hpp:
.././io/Spi.hpp:
.././io/../config.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:

View File

@ -9,18 +9,21 @@
#include <util/delay.h>
ledclass l;
servoclass s;
startclass st;
int main(void)
{
while(1)
{
l.color(l.GREEN);
_delay_ms(500);
l.color(l.YELLOW);
_delay_ms(500);
l.color(l.RED);
_delay_ms(500);
l.color(l.BLACK);
_delay_ms(500);
if(st.is_pressed()) {
l.color(l.GREEN);
}
}
}
}
ISR(TIMER0_OVF_vect) {
s.timer();
}

View File

@ -36,19 +36,19 @@
</dependencies>
</framework-data>
</AsfFrameworkConfig>
<avrtoolinterface>JTAG</avrtoolinterface>
<avrtoolinterface>ISP</avrtoolinterface>
<avrtool>com.atmel.avrdbg.tool.ispmk2</avrtool>
<com_atmel_avrdbg_tool_ispmk2>
<ToolType xmlns="">com.atmel.avrdbg.tool.ispmk2</ToolType>
<ToolName xmlns="">AVRISP mkII</ToolName>
<ToolNumber xmlns="">0000000000000</ToolNumber>
<Channel xmlns="">
<ToolType>com.atmel.avrdbg.tool.ispmk2</ToolType>
<ToolName>AVRISP mkII</ToolName>
<ToolNumber>0000000000000</ToolNumber>
<Channel>
<host>127.0.0.1</host>
<port>59286</port>
<ssl>False</ssl>
</Channel>
<ToolOptions xmlns="">
<InterfaceName>JTAG</InterfaceName>
<ToolOptions>
<InterfaceName>ISP</InterfaceName>
<InterfaceProperties>
<JtagDbgClock>249000</JtagDbgClock>
<JtagProgClock>1000000</JtagProgClock>
@ -62,6 +62,17 @@
</InterfaceProperties>
</ToolOptions>
</com_atmel_avrdbg_tool_ispmk2>
<com_atmel_avrdbg_tool_simulator>
<ToolType xmlns="">com.atmel.avrdbg.tool.simulator</ToolType>
<ToolName xmlns="">Simulator</ToolName>
<ToolNumber xmlns="">
</ToolNumber>
<Channel xmlns="">
<host>127.0.0.1</host>
<port>50091</port>
<ssl>False</ssl>
</Channel>
</com_atmel_avrdbg_tool_simulator>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings>
@ -153,16 +164,31 @@
<Compile Include="config.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="io\hardware\portc.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="io\hardware\pin.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="io\hardware\portb.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="io\hardware\portd.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="io\Led.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="io\portd.hpp">
<Compile Include="io\rfm12.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="io\pin.hpp">
<Compile Include="io\Servo.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="io\portb.hpp">
<Compile Include="io\Spi.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="io\Start.hpp">
<SubType>compile</SubType>
</Compile>
<Compile Include="peripheral.h">
@ -174,6 +200,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="io" />
<Folder Include="io\hardware" />
</ItemGroup>
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
</Project>

View File

@ -8,7 +8,7 @@
#ifndef LED_H_
#define LED_H_
#include "pin.hpp"
#include "hardware/pin.hpp"
template <typename Port, int pin_red, int pin_green>
class Led {

View File

@ -0,0 +1,77 @@
/*
* Servo.hpp
*
* Created: 08.05.2014 13:06:12
* Author: netz
*/
#ifndef SERVO_H_
#define SERVO_H_
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include "hardware/pin.hpp"
template <typename Port, int servo_io_pin, int servo_act_pin, uint16_t s_left, uint16_t s_middle, uint16_t s_right, uint8_t s_step>
class Servo {
public:
Servo() {
init();
}
void turn(uint16_t mask) {
this->servopos = mask;
}
void on() {
servo_act::make_high();
}
void off() {
servo_act::make_low();
}
void timer() {
TCNT0 = 0x64; // Reinitialize Timer 0 value
servo_io::make_high();
_delay_us(s_left);
for(uint16_t i = 0; i < servopos; i++) {
_delay_us(s_step);
}
servo_io::make_low();
}
static const uint16_t LEFT = 0;
static const uint16_t MIDDLE = s_middle;
static const uint16_t RIGHT = s_right;
private:
uint8_t servopos;
void init() {
this->servopos = 0;
servo_act::make_output();
servo_act::make_low();
servo_io::make_output();
this->init_timer();
sei();
}
void init_timer() {
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: 7,813 kHz
// Mode: Normal top=0xFF
// OC0A output: Disconnected
// OC0B output: Disconnected
// Timer Period: 19,968 ms
TCCR0A=(0<<COM0A1) | (0<<COM0A0) | (0<<COM0B1) | (0<<COM0B0) | (0<<WGM01) | (0<<WGM00);
TCCR0B=(0<<WGM02) | (1<<CS02) | (0<<CS01) | (1<<CS00);
TCNT0=0x64;
OCR0A=0x00;
OCR0B=0x00;
// Timer/Counter 0 Interrupt(s) initialization
TIMSK0=(0<<OCIE0B) | (0<<OCIE0A) | (1<<TOIE0);
}
void uninit();
const typedef avrlib::pin<Port, servo_io_pin> servo_io;
const typedef avrlib::pin<Port, servo_act_pin> servo_act;
};
#endif /* SERVO_H_ */

View File

@ -0,0 +1,92 @@
/*
* Spi.h
*
* Created: 06.11.2013 15:41:34
* Author: netz
*/
#ifndef SPI_H_
#define SPI_H_
#include "../config.h"
#include <avr/io.h>
#include <util/delay.h>
#include "hardware/pin.hpp"
template <typename Port, int cspin, int misopin, int mosipin, int sckpin, int mode>
class Spi {
public:
Spi() {
init();
}
void CSOn() {
cs::make_low();
}
void CSOff() {
cs::make_high();
}
uint8_t send(uint8_t data) {
uint8_t r;
if(mode == 0) {
r = send_hard(data);
} else {
r = send_soft(data);
}
return r;
}
private:
const typedef avrlib::pin<Port, cspin> cs;
const typedef avrlib::pin<Port, misopin> miso;
const typedef avrlib::pin<Port, mosipin> mosi;
const typedef avrlib::pin<Port, sckpin> 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<<SPE) | (1<<MSTR);
SPSR = (1<<SPI2X);
}
uint8_t send_soft(uint8_t data) {
uint8_t datain=0;
for (uint8_t a=8; a>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) {
SPDR = data; // Sendet ein Byte
loop_until_bit_is_set(SPSR, SPIF); // Wartet bis Byte gesendet wurde
return SPDR;
}
};
#endif /* SPI_H_ */

View File

@ -0,0 +1,33 @@
/*
* Start.hpp
*
* Created: 08.05.2014 17:55:29
* Author: netz
*/
#ifndef START_H_
#define START_H_
#include "hardware/pin.hpp"
template <typename Port, int start_pin>
class Start {
public:
Start() {
init();
}
uint8_t is_pressed() {
return (!start_in::read());
}
private:
void init() {
start_in::make_input();
start_in::pullup();
}
const typedef avrlib::pin<Port, start_pin> start_in;
};
#endif /* START_H_ */

View File

@ -0,0 +1,22 @@
#ifndef AVRLIB_PORTC_HPP
#define AVRLIB_PORTC_HPP
#include <avr/io.h>
namespace avrlib {
struct portc
{
static uint8_t port() { return PORTC; }
static void port(uint8_t v) { PORTC = v; }
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; }
};
}
#endif

View File

@ -0,0 +1,68 @@
/*
* rfm12.hpp
*
* Created: 08.05.2014 00:06:49
* Author: netz
*/
#ifndef RFM12_H_
#define RFM12_H_
#define RF12FREQ(freq) ((freq-430.0)/0.0025)
template <typename spi, uint8_t bandwidth, uint8_t gain, uint8_t drssi, uint16_t freq, uint16_t baud, uint8_t power, uint8_t mod>
class Rfm12 {
public:
Rfm12() {
this->init();
}
void send(uint16_t t) {
s.CSOn();
s.send((uint8_t)t>>8);
s.send((uint8_t)t);
s.CSOff();
}
private:
spi s;
void init() {
this->send(0xC0E0); // AVR CLK: 10MHz
this->send(0x80D7); // Enable FIFO
this->send(0xC2AB); // Data Filter: internal
this->send(0xCA81); // Set FIFO mode
this->send(0xE000); // disable wakeuptimer
this->send(0xC800); // disable low duty cycle
this->send(0xC4F7); // AFC settings: autotuning: -10kHz...+7,5kHz
this->setfreq();
this->setbandwidth();
this->setbaud();
this->setpower();
}
void setbandwidth() {
this->send(0x9400|((bandwidth&7)<<5)|((gain&3)<<3)|(drssi&7));
}
void setfreq() {
if (freq<96) { // 430,2400MHz
freq=96;
} else if (freq>3903) { // 439,7575MHz
freq=3903;
}
this->send(0xA000|freq);
}
void setbaud() {
if (baud<663) {
return;
}
if (baud<5400) { // Baudrate= 344827,58621/(R+1)/(1+CS*7)
this->send(0xC680|((43104/baud)-1));
} else {
this->send(0xC600|((344828UL/baud)-1));
}
}
void setpower() {
this->send(0x9800|(power&7)|((mod&15)<<4));
}
};
#endif /* RFM12_H_ */

View File

@ -9,7 +9,10 @@
#ifndef PERIPHERAL_H_
#define PERIPHERAL_H_
#include "io/portd.hpp"
#include "io/hardware/portb.hpp"
#include "io/hardware/portc.hpp"
#include "io/hardware/portd.hpp"
#include "io/Led.hpp"
typedef Led<
@ -18,6 +21,44 @@ typedef Led<
PIND6 //Grün
> ledclass;
#include "io/Servo.hpp"
typedef Servo< //640, 105, 210, 8 Blaue Servos
avrlib::portb, //Servo an PORTB
PINB2, //Datenpin des Servos
PINB1, //Mosfetpin des Servos
640, //Links
105, //Mitte
210, //Rechts
8 //Schrittweite
> servoclass;
#include "io/Start.hpp"
typedef Start<
avrlib::portd, //Startknopf an PORTD
PIND3 //Pin an dem der Startknopf hängt
> startclass;
#include "io/Spi.hpp"
typedef Spi<
avrlib::portc, //Funkmodul an PORTC
PINC4, //CS Pin (nSEL)
PINC3, //MOSI Pin (SDO)
PINC0, //MISO Pin (SDI)
PINC1, //SCK Pin
1 //0 Hardware, 1 Software
> spiclass;
#include "io/rfm12.hpp"
typedef Rfm12<
spiclass, //SPI Hardware
1, //Bandwidth // 400kHz Bandbreite, 0dB Verstärkung, DRSSI threshold: -61dBm
0, //Gain
7, //DRRSI
(uint16_t)RF12FREQ(433.92), // Sende/Empfangsfrequenz auf 433,92MHz einstellen
9600, //Baudrate // 9600 baud
0, //Power // 1mW Ausgangsleistung, 120kHz Frequenzshift
6 //Mod
> rfm12class;
#endif /* PERIPHERAL_H_ */