Ejemplo n.º 1
0
void ExampleProcess(otInstance *aInstance)
{
    static int    aliveLEDcounter = 0;
    otDeviceRole  devRole;
    static int    thrValue;

    devRole = otThreadGetDeviceRole(aInstance);

    if (sBlink == false && otPlatAlarmMilliGetNow() != 0)
    {
        sMsCounterInit = otPlatAlarmMilliGetNow();
        sBlink = true;
    }

    sMsCounter = otPlatAlarmMilliGetNow() - sMsCounterInit;

    switch (devRole)
    {
    case OT_DEVICE_ROLE_LEADER:
        thrValue = LEADER_BLINK_TIME;
        break;

    case OT_DEVICE_ROLE_ROUTER:
        thrValue = ROUTER_BLINK_TIME;
        break;

    case OT_DEVICE_ROLE_CHILD:
        thrValue = CHILD_BLINK_TIME;
        break;

    default:
        thrValue = 0x00;
    }

    if ((thrValue != 0x00) && (sMsCounter >= thrValue))
    {
        hw_gpio_toggle(HW_GPIO_PORT_1, HW_GPIO_PIN_5);
        sMsCounterInit = otPlatAlarmMilliGetNow();
    }

    if (thrValue == 0)
    {
        // No specific role, let's generate 'alive blink'
        // to inform that we are running.
        // Loop counter is used to run even if timers
        // are not initialized yet.
        aliveLEDcounter++;

        if (aliveLEDcounter > ALIVE_LED_PERIOD)
        {
            aliveLEDcounter = 0;
            hw_gpio_set_active(HW_GPIO_PORT_1, HW_GPIO_PIN_5);
        }

        if (aliveLEDcounter > ALIVE_LED_DUTY)
        {
            hw_gpio_set_inactive(HW_GPIO_PORT_1, HW_GPIO_PIN_5);
        }
    }
}
void led_toggle(unsigned char led_nr)
{
    if(led_nr < HW_NUM_LEDS)
    	hw_gpio_toggle(leds[led_nr]);
}
void hw_debug_toggle(uint8_t pin_id)
{
    if(pin_id < DEBUG_PIN_NUM)
        hw_gpio_toggle(debug_pins[pin_id]);
}
void hw_debug_toggle(uint8_t pin_nr)
{
    if(pin_nr < PLATFORM_NUM_DEBUGPINS)
      hw_gpio_toggle(debug_pins[pin_nr]);
}