Mon, 23 Dec 2013 14:05:53 +0100
finished car id programming and brake function
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
1 | #include <avr/interrupt.h> |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
2 | #include <avr/io.h> |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
3 | #include <avr/wdt.h> |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
4 | #include <avr/eeprom.h> |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
5 | #include <stdlib.h> |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
6 | #include <stdint.h> |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
7 | #include <avr/pgmspace.h> |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
8 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
9 | #include "main.h" |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
10 | #include "util/delay.h" |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
11 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
12 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
13 | ISR ( USART_RXC_vect ) { |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
14 | } |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
15 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
16 | #define PULSE_PORT PORTD |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
17 | #define PULSE_BIT PD2 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
18 | |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
19 | typedef struct { |
152 | 20 | uint8_t calibration; // AVR Chip calibration byte written by avrdude |
21 | uint8_t initialized; // if 0xff, reset config to defaults on first boot | |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
22 | uint8_t slot; |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
23 | uint8_t light; |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
24 | uint8_t program; // 0xff = inactive ; programming mode active on slot X |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
25 | } config_t; |
152 | 26 | config_t EEMEM eeconfig = {0,0,0,0xff,0}; |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
27 | config_t config; |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
28 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
29 | volatile uint16_t data = 0; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
30 | volatile uint8_t data_len = 0; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
31 | volatile uint8_t bitbuf_len = 0; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
32 | volatile uint16_t bitbuf = 0; |
152 | 33 | volatile uint8_t car_speed[MAX_SLOTS]; |
34 | volatile uint8_t car_switch[MAX_SLOTS]; | |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
35 | |
152 | 36 | volatile uint8_t car_timeout[MAX_SLOTS]; |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
37 | volatile uint8_t timeout = 0; |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
38 | volatile uint8_t brake_timeout = 0; |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
39 | |
152 | 40 | uint8_t old_switch[MAX_SLOTS]; |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
41 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
42 | uint8_t my_switch; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
43 | uint8_t my_speed; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
44 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
45 | ISR ( INT0_vect ) { |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
46 | GICR &= ~_BV(INT0) ; // Disable INT0 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
47 | // Startsignal erkannt, ab hier den Timer2 starten, |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
48 | // der liest dann alle 50µs den Zustand ein und schreibt das |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
49 | // empfangene Bit in den Puffer |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
50 | bitbuf = 0; // init |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
51 | bitbuf_len = 0b10000000; // init 1 pulse received |
152 | 52 | |
53 | TCNT2 = 10; | |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
54 | TIMSK |= _BV(OCIE2); //enable timer2 interrupt |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
55 | } |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
56 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
57 | ISR ( TIMER2_COMP_vect ) { |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
58 | uint8_t clock; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
59 | uint8_t state; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
60 | uint8_t state2; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
61 | if ((bitbuf_len & 0b10000000) == 0) clock = 0; else clock = 0xff; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
62 | if ((bitbuf_len & 0b01000000) == 0) state = 0; else state = 0xff; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
63 | if ((PIN(PULSE_PORT) & _BV(PULSE_BIT)) == 0) state2 = 0xff; else state2 = 0; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
64 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
65 | if (clock) { |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
66 | bitbuf_len &= ~_BV(7); // switch clock to low |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
67 | // second pulse of bit |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
68 | if ((state==state2) & state2) { |
152 | 69 | TIMSK &= ~_BV(OCIE2); //disable timer2 interrupt |
70 | ||
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
71 | // two cycles high: packet end received |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
72 | data_len = (bitbuf_len & 0b00111111); |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
73 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
74 | //data = bitbuf; // output data |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
75 | // write data of controllers to array |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
76 | if (data_len == 10) { // controller data packet |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
77 | clock = (bitbuf >> 6) & 0b00000111; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
78 | car_speed[clock] = (bitbuf >> 1) & 0x0F; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
79 | car_switch[clock] = (bitbuf >> 5) & 1; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
80 | // current response for this car? |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
81 | /* |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
82 | if (response != 0) { |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
83 | if ( ((response & 0b00001110) >> 1) == clock) { |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
84 | // add our ID to response: |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
85 | send_response(response | self_id << 6); |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
86 | response = 0; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
87 | } |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
88 | } |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
89 | */ |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
90 | } |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
91 | |
152 | 92 | // bugfix 20131223: timing errors, CLEAR timer2 flag before enable |
93 | // if this works, apply to track switches and pitlane too! | |
94 | //GIFR = _BV(INTF0); | |
95 | ||
96 | GICR |= _BV(INT0) ; // Enable INT0 | |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
97 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
98 | } else { |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
99 | bitbuf_len++; // increment bit counter |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
100 | bitbuf = bitbuf << 1; // shift bits |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
101 | if (state2 == 0) bitbuf |= 1; // receive logic one |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
102 | } |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
103 | } else { |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
104 | bitbuf_len |= _BV(7); // switch clock to high |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
105 | // first pulse of bit |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
106 | if (state2) { |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
107 | bitbuf_len |= _BV(6); // store new state |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
108 | } else { |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
109 | bitbuf_len &= ~_BV(6); // store new state |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
110 | } |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
111 | } |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
112 | } |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
113 | |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
114 | ISR (INT1_vect) { |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
115 | } |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
116 | |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
117 | ISR (TIMER0_OVF_vect) { |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
118 | TCNT0 = 100; // TIMER0 vorladen mit 100 |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
119 | if (brake_timeout > 1) brake_timeout--; |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
120 | if (timeout > 1) timeout--; |
152 | 121 | for (uint8_t i=0; i<MAX_SLOTS; i++) |
122 | if (car_timeout[i] > 1) car_timeout[i]--; | |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
123 | } |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
124 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
125 | #define LIGHT_PORT PORTC |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
126 | #define LIGHT_FRONT 2 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
127 | #define LIGHT_BRAKE 4 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
128 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
129 | #define IR_PORT PORTB |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
130 | #define IR_LED 3 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
131 | |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
132 | #define LIGHT_MODES 1 // anzahl der lichtmodi (ohne den modus "aus") |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
133 | #define BRAKE_OFF_TIMEOUT 60 // value * 10ms |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
134 | |
151 | 135 | //#define CAR_DEBUG 1 |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
136 | #define EE_CONFIG_ADDR 64 |
151 | 137 | #define DOUBLE_CLICK_TIMEOUT 50 // 500ms |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
138 | |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
139 | void config_save(void) { |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
140 | eeprom_write_block( &config, &eeconfig, sizeof(config_t) ); |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
141 | } |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
142 | |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
143 | |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
144 | void brake_on(void) { |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
145 | LIGHT_PORT |= _BV(LIGHT_BRAKE); // brake light on |
152 | 146 | DDRB |= _BV(1); // PB1 PWM Output enable |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
147 | brake_timeout = BRAKE_OFF_TIMEOUT; |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
148 | } |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
149 | |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
150 | void brake_off(void) { |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
151 | LIGHT_PORT &= ~_BV(LIGHT_BRAKE); // brake light off |
151 | 152 | DDRB &= ~_BV(1); // PB1 PWM Output disable |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
153 | brake_timeout = 0; |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
154 | } |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
155 | |
151 | 156 | uint8_t set_id(void) { |
157 | _delay_ms(100); // short wait | |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
158 | uint8_t temp; |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
159 | timeout = 1; |
151 | 160 | brake_timeout = 0xff; |
161 | // wait for key press and assign on double click | |
162 | while ((car_speed[config.slot] == 0) && (brake_timeout > 1)) { | |
163 | temp = car_switch[config.program]; | |
164 | if (temp == 0) { | |
165 | // wait for second key press within timeout period to assign successfully | |
166 | brake_timeout = DOUBLE_CLICK_TIMEOUT; | |
167 | timeout = 1; | |
168 | while (brake_timeout > 1) { | |
169 | if (temp != car_switch[config.program]) { | |
170 | temp = car_switch[config.program]; | |
171 | if (temp == 0) { | |
172 | config.slot = config.program; | |
173 | return 1; | |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
174 | } |
151 | 175 | } |
176 | // toggle lights if timeout | |
177 | if (timeout == 1) { | |
178 | LIGHT_PORT ^= _BV(LIGHT_FRONT); | |
179 | timeout = 5; | |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
180 | } |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
181 | } |
151 | 182 | return 0; |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
183 | } |
151 | 184 | |
185 | // toggle lights if timeout | |
186 | if (timeout == 1) { | |
187 | LIGHT_PORT ^= _BV(LIGHT_FRONT); | |
188 | timeout = 10; | |
189 | } | |
190 | } | |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
191 | return 0; |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
192 | } |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
193 | |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
194 | int main(void) |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
195 | { |
152 | 196 | // config (from eeprom!) |
197 | eeprom_read_block( &config, &eeconfig, sizeof(config_t) ); | |
198 | ||
199 | // set the internal calibration byte | |
200 | OSCCAL = config.calibration; | |
201 | // TODO: Vielleicht den internen Takt des AVR anhand der Bitclock auf den Schienen synchronisieren??? | |
202 | // Das Calibration byte scheint nicht zu stimmen | |
203 | ||
204 | if (config.initialized == 0xff) { | |
205 | config.slot = 0; | |
206 | config.light = 0; | |
207 | config.program = 0xff; | |
208 | config.initialized = 0; | |
209 | config_save(); | |
210 | } | |
211 | ||
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
212 | uint8_t temp; |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
213 | |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
214 | // setup data bit timer2 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
215 | TCCR2 = (1<<CS21) | (1<<WGM21); //divide by 8, set compare match |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
216 | OCR2 = TIMER2_50US; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
217 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
218 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
219 | // enable both external interrupts |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
220 | // int 0 = data RX |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
221 | MCUCR = _BV(ISC00) | _BV(ISC01) | _BV(ISC10) | _BV(ISC11); // INT0/1 rising edge |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
222 | GICR = _BV(INT0) | _BV(INT1) ; // Enable INT0 + INT1 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
223 | |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
224 | |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
225 | DDR(LIGHT_PORT) |= _BV(LIGHT_FRONT) | _BV(LIGHT_BRAKE); |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
226 | |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
227 | TCCR1A = (1<<WGM10)|(1<<COM1A1) // Set up the two Control registers of Timer1. |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
228 | |(1<<COM1B1); // Wave Form Generation is Fast PWM 8 Bit, |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
229 | |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
230 | TCCR1B = (1<<WGM12)|(1<<CS10); // OC1A and OC1B are cleared on compare match |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
231 | // and set at BOTTOM. Clock Prescaler is 1. |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
232 | |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
233 | |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
234 | //OCR1A = 63; // Dutycycle of OC1A = 25% |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
235 | //OCR1B = 127; // Dutycycle of OC1B = 50% |
152 | 236 | OCR1A = 0xff; // brake PWM! |
151 | 237 | OCR1B = 0; // Motor drive PWM |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
238 | DDRB &= ~_BV(2); // PB2 PWM Output disable |
151 | 239 | DDRB &= ~_BV(1); // PB1 PWM Output disable |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
240 | |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
241 | // configure TIMER0 to overflow every 10ms at 4 MHz |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
242 | TIMSK = _BV(TOIE0); // Timer0 Overflow INT erlauben |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
243 | TCNT0 = 100; // TIMER0 vorladen mit 100 |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
244 | TCCR0 = _BV(CS02) ; // Vorteiler auf 256, ab hier läuft der TIMER0 |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
245 | |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
246 | sei(); |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
247 | |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
248 | |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
249 | if ((config.program != 0xff) || (config.slot > 5 )) { |
151 | 250 | temp = set_id(); |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
251 | config.program = 0xff; |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
252 | config_save(); |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
253 | if (temp == 1) { |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
254 | // acknowledge with the engine |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
255 | OCR1B = 25; |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
256 | DDRB &= ~_BV(2); // PB2 PWM Output disable |
151 | 257 | for (temp = 128; temp > 0; temp--) { |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
258 | DDRB ^= _BV(2); // PB2 PWM Output toggle |
151 | 259 | _delay_ms(2); |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
260 | DDRB ^= _BV(2); // PB2 PWM Output toggle |
151 | 261 | _delay_ms(3); |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
262 | } |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
263 | |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
264 | } |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
265 | timeout = 0; |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
266 | } |
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
267 | |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
268 | |
151 | 269 | my_switch = car_switch[config.slot]; // initialize |
270 | my_speed = car_speed[config.slot]; // initialize | |
271 | ||
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
272 | while (1) { |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
273 | // main loop |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
274 | |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
275 | if (brake_timeout == 1) brake_off(); |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
276 | |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
277 | if (my_speed != car_speed[config.slot]) { |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
278 | my_speed = car_speed[config.slot]; |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
279 | OCR1B = (int) ((float)0xff * (float)((float)my_speed / (float)15)); |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
280 | if (my_speed == 0) { |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
281 | DDRB &= ~_BV(2); // PB2 PWM Output disable |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
282 | brake_on(); |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
283 | } else { |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
284 | brake_off(); |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
285 | DDRB |= _BV(2); // PB2 PWM Output enable |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
286 | } |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
287 | } |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
288 | |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
289 | // Light cycle if switch pressed without speed |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
290 | if (car_speed[config.slot] == 0) { |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
291 | if (my_switch != car_switch[config.slot]) { |
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
292 | my_switch = car_switch[config.slot]; |
151 | 293 | if (my_switch == 0) { |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
294 | // cycle light |
152 | 295 | if (config.light >= LIGHT_MODES) config.light = 0; else config.light++; |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
296 | config_save(); |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
297 | } |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
298 | } |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
299 | } |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
300 | |
152 | 301 | // check any car switch for a double click and speed = 0 |
302 | for (temp = 0; temp<MAX_SLOTS; temp++) if (car_switch[temp] != old_switch[temp]) { | |
303 | old_switch[temp] = car_switch[temp]; | |
304 | if ((car_speed[temp] == 0) && (old_switch[temp] == 0)) { | |
305 | // key pressed | |
306 | if (car_timeout[temp] > 1) { | |
307 | // second key press within timeout, enter program mode for this key | |
308 | config.program = temp; | |
309 | config_save(); | |
310 | car_timeout[temp] = 0xff; // the car has to be reset within this timeout | |
311 | } else { | |
312 | car_timeout[temp] = DOUBLE_CLICK_TIMEOUT; | |
313 | } | |
314 | } | |
315 | ||
316 | if (car_timeout[temp] == 1) { | |
317 | if (config.program == temp) { | |
318 | // cancel ID programming mode | |
319 | config.program = 0xff; | |
320 | config_save(); | |
321 | } | |
322 | car_timeout[temp] = 0; | |
323 | } | |
324 | } | |
325 | ||
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
326 | switch (config.light) { |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
327 | case 0: |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
328 | LIGHT_PORT &= ~_BV(LIGHT_FRONT); // switch lights off |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
329 | break; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
330 | case 1: |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
331 | LIGHT_PORT |= _BV(LIGHT_FRONT); // switch lights on |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
332 | break; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
333 | } |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
334 | |
148
08cb88614d69
car firmware: finished pwm drive and lights switching
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
335 | |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
148
diff
changeset
|
336 | // timeout reset |
151 | 337 | if (timeout == 1) timeout = 0; |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
338 | } // main loop end |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
339 | }; |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
340 |