Beispiel #1
0
void tdma_error(void)
{
    static uint16_t debounce;

    debounce++;
    if(debounce>50) debounce=50;
    if(debounce==50 )
    {
        if((PIND & 0x1) == 0 )
        {
            debounce=0;
            if(socket_0_active==1)
            {
                plug_led_green_clr();
                power_socket_disable(0);
            }
            else
            {
                plug_led_green_set();
                power_socket_enable(0);
            }

        }

    }
    if(tdma_sync_ok()==0) plug_led_red_set();
    else plug_led_red_clr();


}
Beispiel #2
0
// This function gets called in a loop if sync is lost.
// It is passed a counter indicating how long it has gone since the last synchronization.
int8_t tdma_error(uint16_t cons_error_cnt)
{

// TDMA error handler just controls the LED in this case.
// Button is still handled by interrupt
    if(tdma_sync_ok()==0) plug_led_red_set();
    else plug_led_red_clr();
// Return NRK_OK to force the error counter to be reset
    return NRK_ERROR;
}
Beispiel #3
0
void io_task()
{

    DDRD=0;
    while(cal_done==0) nrk_wait_until_next_period();

    // Crappy polling IO task that reads the button to toggle the outlet
    while(1) {
        if(tdma_sync_ok()==0) plug_led_red_set();
        else plug_led_red_clr();

        if((PIND & 0x1) == 0 )
        {

            if(socket_0_active==1)
            {
                plug_led_green_clr();
                power_socket_disable(0);
            }
            else
            {
                plug_led_green_set();
                power_socket_enable(0);
            }

            // After press, wait until user lets go
            do {
                nrk_wait_until_next_period();
            } while((PIND & 0x1) == 0 );

        }
        nrk_wait_until_next_period();

    }



}