114 |
114 |
115 |
115 |
116 |
116 |
117 void check_rails_shortcut(void) { |
117 void check_rails_shortcut(void) { |
118 // check for short circuit on the rails |
118 // check for short circuit on the rails |
|
119 uint8_t i = 100; |
119 if ((PIN(RAIL_DETECT_PORT) & _BV(RAIL_DETECT)) == 0) { |
120 if ((PIN(RAIL_DETECT_PORT) & _BV(RAIL_DETECT)) == 0) { |
120 _delay_ms(2); |
121 while (i>0) { |
|
122 if ((PIN(RAIL_DETECT_PORT) & _BV(RAIL_DETECT)) != 0) return 0; |
|
123 _delay_us(20); |
|
124 } |
121 if ((PIN(RAIL_DETECT_PORT) & _BV(RAIL_DETECT)) == 0) { |
125 if ((PIN(RAIL_DETECT_PORT) & _BV(RAIL_DETECT)) == 0) { |
122 cli(); // disable ALL Interrupts |
126 cli(); // disable ALL Interrupts |
123 RAIL_POWER_PORT &= ~_BV(RAIL_POWER); // disable rails power |
127 RAIL_POWER_PORT &= ~_BV(RAIL_POWER); // disable rails power |
124 RS232_puts_p(PSTR("!!! SHORT CIRCUIT ON RAILS, POWERED OFF !!!\n")); |
128 RS232_puts_p(PSTR("!!! SHORT CIRCUIT ON RAILS, POWERED OFF !!!\n")); |
125 LED(1, 1); |
129 LED(1, 1); |