Mon, 23 Dec 2013 10:59:14 +0100
car: finished set_id function
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
1 | #include <avr/interrupt.h> |
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
2 | #include <avr/pgmspace.h> |
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
3 | #include <util/delay.h> |
0
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
4 | #include "stdint.h" |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
5 | #include "main.h" |
3 | 6 | #include "driver/adc.h" |
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
7 | #include "driver/rs232.h" |
3 | 8 | #include "lowlevel.h" |
0
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
9 | |
34 | 10 | void blinkdelay(void) { |
11 | _delay_ms(50); | |
12 | } | |
13 | ||
0
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
14 | void LED(uint8_t num, uint8_t state) { |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
15 | switch (num) { |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
16 | case 1: switch (state) { |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
17 | case 0: LED1_PORT &= ~_BV(LED1); break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
18 | case 1: LED1_PORT |= _BV(LED1); break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
19 | case 2: LED1_PORT ^= _BV(LED1); break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
20 | } break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
21 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
22 | case 2: switch (state) { |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
23 | case 0: LED2_PORT &= ~_BV(LED2); break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
24 | case 1: LED2_PORT |= _BV(LED2); break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
25 | case 2: LED2_PORT ^= _BV(LED2); break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
26 | } break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
27 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
28 | case 3: switch (state) { |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
29 | case 0: LED3_PORT &= ~_BV(LED3); break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
30 | case 1: LED3_PORT |= _BV(LED3); break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
31 | case 2: LED3_PORT ^= _BV(LED3); break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
32 | } break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
33 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
34 | case 4: switch (state) { |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
35 | case 0: LED4_PORT &= ~_BV(LED4); break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
36 | case 1: LED4_PORT |= _BV(LED4); break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
37 | case 2: LED4_PORT ^= _BV(LED4); break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
38 | } break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
39 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
40 | case 5: switch (state) { |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
41 | case 0: LED5_PORT &= ~_BV(LED5); break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
42 | case 1: LED5_PORT |= _BV(LED5); break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
43 | case 2: LED5_PORT ^= _BV(LED5); break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
44 | } break; |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
45 | } |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
46 | } |
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
47 | |
37
136a79772098
implemented race prepare phase, countdown and jumpstart detection
Malte Bayer <mbayer@neo-soft.org>
parents:
34
diff
changeset
|
48 | void LEDS_OFF(void) { |
136a79772098
implemented race prepare phase, countdown and jumpstart detection
Malte Bayer <mbayer@neo-soft.org>
parents:
34
diff
changeset
|
49 | LED1_PORT &= ~_BV(LED1); |
136a79772098
implemented race prepare phase, countdown and jumpstart detection
Malte Bayer <mbayer@neo-soft.org>
parents:
34
diff
changeset
|
50 | LED2_PORT &= ~_BV(LED1); |
136a79772098
implemented race prepare phase, countdown and jumpstart detection
Malte Bayer <mbayer@neo-soft.org>
parents:
34
diff
changeset
|
51 | LED3_PORT &= ~_BV(LED1); |
136a79772098
implemented race prepare phase, countdown and jumpstart detection
Malte Bayer <mbayer@neo-soft.org>
parents:
34
diff
changeset
|
52 | LED4_PORT &= ~_BV(LED1); |
136a79772098
implemented race prepare phase, countdown and jumpstart detection
Malte Bayer <mbayer@neo-soft.org>
parents:
34
diff
changeset
|
53 | LED5_PORT &= ~_BV(LED1); |
136a79772098
implemented race prepare phase, countdown and jumpstart detection
Malte Bayer <mbayer@neo-soft.org>
parents:
34
diff
changeset
|
54 | } |
136a79772098
implemented race prepare phase, countdown and jumpstart detection
Malte Bayer <mbayer@neo-soft.org>
parents:
34
diff
changeset
|
55 | |
3 | 56 | void init_hardware(void) { |
7
f4e250d5402b
fixes, bound lap counter reset to race start button
Malte Bayer <mbayer@neo-soft.org>
parents:
6
diff
changeset
|
57 | // reset all ports to input, no pullup |
f4e250d5402b
fixes, bound lap counter reset to race start button
Malte Bayer <mbayer@neo-soft.org>
parents:
6
diff
changeset
|
58 | DDRA = 0; PORTA = 0; |
f4e250d5402b
fixes, bound lap counter reset to race start button
Malte Bayer <mbayer@neo-soft.org>
parents:
6
diff
changeset
|
59 | DDRB = 0; PORTB = 0; |
f4e250d5402b
fixes, bound lap counter reset to race start button
Malte Bayer <mbayer@neo-soft.org>
parents:
6
diff
changeset
|
60 | DDRC = 0; PORTC = 0; |
f4e250d5402b
fixes, bound lap counter reset to race start button
Malte Bayer <mbayer@neo-soft.org>
parents:
6
diff
changeset
|
61 | DDRD = 0; PORTD = 0; |
f4e250d5402b
fixes, bound lap counter reset to race start button
Malte Bayer <mbayer@neo-soft.org>
parents:
6
diff
changeset
|
62 | |
f4e250d5402b
fixes, bound lap counter reset to race start button
Malte Bayer <mbayer@neo-soft.org>
parents:
6
diff
changeset
|
63 | |
34 | 64 | RS232_init(); // initialize RS232 interface |
3 | 65 | initADC(); |
7
f4e250d5402b
fixes, bound lap counter reset to race start button
Malte Bayer <mbayer@neo-soft.org>
parents:
6
diff
changeset
|
66 | SFIOR = 0; |
3 | 67 | |
68 | // set LED output | |
69 | DDR(LED1_PORT) |= _BV(LED1); | |
70 | DDR(LED2_PORT) |= _BV(LED2); | |
71 | DDR(LED3_PORT) |= _BV(LED3); | |
72 | DDR(LED4_PORT) |= _BV(LED4); | |
73 | DDR(LED5_PORT) |= _BV(LED5); | |
74 | ||
75 | // set Controller Input Pull-UPs | |
76 | CONTROLLER_PORT |= (_BV(CONTROLLER1_SW) | _BV(CONTROLLER2_SW) | _BV(CONTROLLER3_SW) | _BV(CONTROLLER4_SW)); | |
77 | ||
78 | // switch pull-ups | |
79 | SW_FUEL_PORT |= _BV(SW_FUEL); | |
7
f4e250d5402b
fixes, bound lap counter reset to race start button
Malte Bayer <mbayer@neo-soft.org>
parents:
6
diff
changeset
|
80 | SW_START_PORT |= _BV(SW_START); |
91
e0738355b517
bugfix: ghostcar assignment to slots 5 and 6
Malte Bayer <mbayer@neo-soft.org>
parents:
89
diff
changeset
|
81 | //SW_PACECAR_PORT |= _BV(SW_PACECAR); |
3 | 82 | |
7
f4e250d5402b
fixes, bound lap counter reset to race start button
Malte Bayer <mbayer@neo-soft.org>
parents:
6
diff
changeset
|
83 | // control outputs |
f4e250d5402b
fixes, bound lap counter reset to race start button
Malte Bayer <mbayer@neo-soft.org>
parents:
6
diff
changeset
|
84 | DDR(LAP_COUNTER_PORT) |= _BV(LAP_COUNTER); |
f4e250d5402b
fixes, bound lap counter reset to race start button
Malte Bayer <mbayer@neo-soft.org>
parents:
6
diff
changeset
|
85 | |
f4e250d5402b
fixes, bound lap counter reset to race start button
Malte Bayer <mbayer@neo-soft.org>
parents:
6
diff
changeset
|
86 | // setup rail control |
3 | 87 | //RAIL_DETECT_PORT |= _BV(RAIL_DETECT); // enable internal pull-up |
88 | DDR(RAIL_POWER_PORT) |= _BV(RAIL_POWER); | |
89 | ||
42
018d4d63ad3b
implemented 500ns timer and set jumpstart time
Malte Bayer <mbayer@neo-soft.org>
parents:
41
diff
changeset
|
90 | // setup debut output on i2c pins |
018d4d63ad3b
implemented 500ns timer and set jumpstart time
Malte Bayer <mbayer@neo-soft.org>
parents:
41
diff
changeset
|
91 | DDR(PORTC) |= _BV(PC0) | _BV(PC1); |
018d4d63ad3b
implemented 500ns timer and set jumpstart time
Malte Bayer <mbayer@neo-soft.org>
parents:
41
diff
changeset
|
92 | |
7
f4e250d5402b
fixes, bound lap counter reset to race start button
Malte Bayer <mbayer@neo-soft.org>
parents:
6
diff
changeset
|
93 | // display init sequence on LEDs |
34 | 94 | LED(1, 1); blinkdelay(); |
95 | LED(2, 1); blinkdelay(); | |
96 | LED(3, 1); blinkdelay(); | |
97 | LED(4, 1); blinkdelay(); | |
98 | LED(5, 1); blinkdelay(); | |
99 | LED(1, 0); blinkdelay(); | |
100 | LED(2, 0); blinkdelay(); | |
101 | LED(3, 0); blinkdelay(); | |
102 | LED(4, 0); blinkdelay(); | |
103 | LED(5, 0); | |
3 | 104 | |
6
2405aff29a51
added response receiver timer
Malte Bayer <mbayer@neo-soft.org>
parents:
4
diff
changeset
|
105 | |
2405aff29a51
added response receiver timer
Malte Bayer <mbayer@neo-soft.org>
parents:
4
diff
changeset
|
106 | // setup response receiver timer |
2405aff29a51
added response receiver timer
Malte Bayer <mbayer@neo-soft.org>
parents:
4
diff
changeset
|
107 | TCCR0 = (1<<CS01); //divide by 8 |
2405aff29a51
added response receiver timer
Malte Bayer <mbayer@neo-soft.org>
parents:
4
diff
changeset
|
108 | // interrupt enable + tcnt0 set in timer2 |
3 | 109 | |
110 | ||
41
9857c18c5e64
implemented car detection to cu
Malte Bayer <mbayer@neo-soft.org>
parents:
37
diff
changeset
|
111 | // setup data bit + carid timer |
7
f4e250d5402b
fixes, bound lap counter reset to race start button
Malte Bayer <mbayer@neo-soft.org>
parents:
6
diff
changeset
|
112 | TCCR2 = (1<<CS21) | (1<<WGM21); //divide by 8, set compare match |
3 | 113 | OCR2 = TIMER2_50US; |
69
27c0c0095e26
implemented responsewire in CU firmware
Malte Bayer <mbayer@neo-soft.org>
parents:
42
diff
changeset
|
114 | TIMSK |= _BV(OCIE2); //enable timer2 interrupt |
3 | 115 | |
41
9857c18c5e64
implemented car detection to cu
Malte Bayer <mbayer@neo-soft.org>
parents:
37
diff
changeset
|
116 | // enable carid interrupts |
9857c18c5e64
implemented car detection to cu
Malte Bayer <mbayer@neo-soft.org>
parents:
37
diff
changeset
|
117 | MCUCR = _BV(ISC00) | _BV(ISC01) | _BV(ISC10) | _BV(ISC11); // INT0/1 rising edge |
9857c18c5e64
implemented car detection to cu
Malte Bayer <mbayer@neo-soft.org>
parents:
37
diff
changeset
|
118 | GICR = _BV(INT0) | _BV(INT1) ; // Enable INT0 + INT1 |
9857c18c5e64
implemented car detection to cu
Malte Bayer <mbayer@neo-soft.org>
parents:
37
diff
changeset
|
119 | |
9857c18c5e64
implemented car detection to cu
Malte Bayer <mbayer@neo-soft.org>
parents:
37
diff
changeset
|
120 | |
9857c18c5e64
implemented car detection to cu
Malte Bayer <mbayer@neo-soft.org>
parents:
37
diff
changeset
|
121 | |
3 | 122 | // setup data packet timer |
41
9857c18c5e64
implemented car detection to cu
Malte Bayer <mbayer@neo-soft.org>
parents:
37
diff
changeset
|
123 | TCCR1B = (1<<CS11) | (1<<WGM12); //divide by 8, set compare match (1mhz clock) |
42
018d4d63ad3b
implemented 500ns timer and set jumpstart time
Malte Bayer <mbayer@neo-soft.org>
parents:
41
diff
changeset
|
124 | OCR1A = TIMER1_500NS; |
018d4d63ad3b
implemented 500ns timer and set jumpstart time
Malte Bayer <mbayer@neo-soft.org>
parents:
41
diff
changeset
|
125 | //OCR1A = TIMER1_7500NS; |
69
27c0c0095e26
implemented responsewire in CU firmware
Malte Bayer <mbayer@neo-soft.org>
parents:
42
diff
changeset
|
126 | TIMSK |= _BV(OCIE1A); //enable timer1 interrupt |
3 | 127 | |
37
136a79772098
implemented race prepare phase, countdown and jumpstart detection
Malte Bayer <mbayer@neo-soft.org>
parents:
34
diff
changeset
|
128 | RS232_puts_p(PSTR("FreeSlot Blackbox v")); |
136a79772098
implemented race prepare phase, countdown and jumpstart detection
Malte Bayer <mbayer@neo-soft.org>
parents:
34
diff
changeset
|
129 | RS232_puts(VERSION); |
136a79772098
implemented race prepare phase, countdown and jumpstart detection
Malte Bayer <mbayer@neo-soft.org>
parents:
34
diff
changeset
|
130 | RS232_putc('\n'); |
3 | 131 | |
132 | } | |
133 | ||
89
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
134 | void panic_mode(void) { |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
135 | RAIL_POWER_PORT &= ~_BV(RAIL_POWER); // disable rails power |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
136 | LEDS_OFF(); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
137 | LED(1, 2); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
138 | blinkdelay(); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
139 | LED(1, 2); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
140 | LED(2, 2); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
141 | blinkdelay(); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
142 | LED(2, 2); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
143 | LED(3, 2); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
144 | blinkdelay(); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
145 | LED(3, 2); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
146 | LED(4, 2); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
147 | blinkdelay(); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
148 | LED(4, 2); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
149 | LED(5, 2); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
150 | } |
3 | 151 | |
152 | ||
69
27c0c0095e26
implemented responsewire in CU firmware
Malte Bayer <mbayer@neo-soft.org>
parents:
42
diff
changeset
|
153 | uint8_t check_rails_shortcut(void) { |
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
154 | // check for short circuit on the rails |
10 | 155 | uint8_t i = 100; |
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
156 | if ((PIN(RAIL_DETECT_PORT) & _BV(RAIL_DETECT)) == 0) { |
10 | 157 | while (i>0) { |
158 | if ((PIN(RAIL_DETECT_PORT) & _BV(RAIL_DETECT)) != 0) return 0; | |
159 | _delay_us(20); | |
33 | 160 | i--; |
10 | 161 | } |
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
162 | if ((PIN(RAIL_DETECT_PORT) & _BV(RAIL_DETECT)) == 0) { |
89
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
163 | // set panic mode |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
164 | mode = 0xff; |
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
165 | RAIL_POWER_PORT &= ~_BV(RAIL_POWER); // disable rails power |
89
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
166 | // wait a little to all interrupts complete |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
167 | //cli(); // disable ALL Interrupts |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
168 | _delay_ms(2); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
169 | RAIL_POWER_PORT &= ~_BV(RAIL_POWER); // disable rails power |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
170 | RS232_puts_p(SHORTCUT); |
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
171 | LED(1, 1); |
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
172 | LED(2, 1); |
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
173 | LED(3, 0); |
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
174 | LED(4, 0); |
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
175 | LED(5, 0); |
89
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
176 | while (mode == 0xff) { |
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
177 | LED(1, 2); |
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
178 | LED(2, 2); |
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
179 | LED(4, 2); |
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
180 | LED(5, 2); |
33 | 181 | blinkdelay(); |
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
182 | LED(3, 2); |
33 | 183 | blinkdelay(); |
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
184 | LED(3, 2); |
33 | 185 | blinkdelay(); |
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
186 | LED(3, 2); |
33 | 187 | blinkdelay(); |
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
188 | LED(3, 2); |
89
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
189 | btn_start = (PIN(SW_START_PORT) & _BV(SW_START)); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
190 | if (old_start != btn_start) { |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
191 | // start button changed |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
192 | if (btn_start == 0) { |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
193 | mode = 0; |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
194 | RS232_puts_p(RESUME); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
195 | } |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
196 | old_start = btn_start; |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
197 | } |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
198 | |
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
199 | } |
89
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
200 | LEDS_OFF(); |
4b5b4c7ba03d
added panic mode, shortcircuit can be resumed now
Malte Bayer <mbayer@neo-soft.org>
parents:
69
diff
changeset
|
201 | LED(3, 1); |
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
202 | } |
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
203 | } |
69
27c0c0095e26
implemented responsewire in CU firmware
Malte Bayer <mbayer@neo-soft.org>
parents:
42
diff
changeset
|
204 | return 0; |
2
6c59b4293fa9
finished: rails short circuit check
Malte Bayer <mbayer@neo-soft.org>
parents:
0
diff
changeset
|
205 | } |