106 //TCCR1B = (1<<CS11) | (1<<CS10); //divide by 64 |
104 //TCCR1B = (1<<CS11) | (1<<CS10); //divide by 64 |
107 //TCNT1 = TIMER_7500NS; |
105 //TCNT1 = TIMER_7500NS; |
108 OCR1A = TIMER1_7500NS; |
106 OCR1A = TIMER1_7500NS; |
109 TIMSK |= 1<<OCIE1A; //enable timer1 interrupt |
107 TIMSK |= 1<<OCIE1A; //enable timer1 interrupt |
110 |
108 |
111 RS232_puts_p(PSTR("INIT OK\n")); |
109 RS232_puts_p(PSTR("FreeSlot Blackbox v1.0\n")); |
112 |
110 |
113 } |
111 } |
114 |
112 |
115 |
113 |
|
114 void blinkdelay(void) { |
|
115 _delay_ms(100); |
|
116 } |
116 |
117 |
117 void check_rails_shortcut(void) { |
118 void check_rails_shortcut(void) { |
118 // check for short circuit on the rails |
119 // check for short circuit on the rails |
119 uint8_t i = 100; |
120 uint8_t i = 100; |
120 if ((PIN(RAIL_DETECT_PORT) & _BV(RAIL_DETECT)) == 0) { |
121 if ((PIN(RAIL_DETECT_PORT) & _BV(RAIL_DETECT)) == 0) { |
121 while (i>0) { |
122 while (i>0) { |
122 if ((PIN(RAIL_DETECT_PORT) & _BV(RAIL_DETECT)) != 0) return 0; |
123 if ((PIN(RAIL_DETECT_PORT) & _BV(RAIL_DETECT)) != 0) return 0; |
123 _delay_us(20); |
124 _delay_us(20); |
|
125 i--; |
124 } |
126 } |
125 if ((PIN(RAIL_DETECT_PORT) & _BV(RAIL_DETECT)) == 0) { |
127 if ((PIN(RAIL_DETECT_PORT) & _BV(RAIL_DETECT)) == 0) { |
126 cli(); // disable ALL Interrupts |
128 cli(); // disable ALL Interrupts |
127 RAIL_POWER_PORT &= ~_BV(RAIL_POWER); // disable rails power |
129 RAIL_POWER_PORT &= ~_BV(RAIL_POWER); // disable rails power |
128 RS232_puts_p(PSTR("!!! SHORT CIRCUIT ON RAILS, POWERED OFF !!!\n")); |
130 RS232_puts_p(PSTR("!!! SHORT CIRCUIT ON RAILS, POWERED OFF !!!\n")); |