]> git.tdb.fi Git - model-railway-devices.git/commitdiff
Connect some status leds to port B
authorMikko Rasa <tdb@tdb.fi>
Sat, 2 Nov 2013 11:53:45 +0000 (13:53 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 2 Nov 2013 11:53:45 +0000 (13:53 +0200)
arducontrol/interface.c
arducontrol/monitor.c

index a8ae2a28af9a0fce11cd391b5dd80da3634cf38b..2c55e2af634eca747a7d207db38235a037c24cd3 100644 (file)
@@ -14,6 +14,7 @@ static uint8_t dispatch_command(const uint8_t *, uint8_t);
 
 void interface_init(void)
 {
+       DDRB |= 0x01;
        DDRD = (DDRD&0xFC)|0x02;
 
        serial_init(9600);
@@ -28,6 +29,7 @@ void interface_check(void)
        count = serial_read_available();
        if(count>0)
        {
+               PORTB |= 0x01;
                if(cmd_length==0)
                {
                        uint8_t l = ~serial_read();
@@ -58,6 +60,7 @@ void interface_check(void)
                                cmd_length = 0;
                        }
                }
+               PORTB &= ~0x01;
        }
 }
 
index de00fc1645b9ddc1258326eadcb2a880aaeb23d9..b87e73ed7370413eeed407ff35b8fcd8ffe75c36 100644 (file)
@@ -22,6 +22,7 @@ static uint16_t input_voltage_millivolts(void);
 
 void monitor_init(void)
 {
+       DDRB |= 0x02;
        adc_init();
 }
 
@@ -42,14 +43,18 @@ void monitor_check(void)
                        if(track_current_sum>overcurrent_limit)
                        {
                                output_set_power(0);
+                               PORTB |= 0x02;
                                if(!overcurrent_sent)
                                {
                                        overcurrent_sent = 1;
                                        interface_send1(OVERCURRENT);
                                }
                        }
-                       else
+                       else if(overcurrent_sent && output_is_power_on())
+                       {
+                               PORTB &= ~0x02;
                                overcurrent_sent = 0;
+                       }
                }
                else if(adc_state==4)
                {