示例#1
0
static int platform_fhss_timer_start(uint32_t slots, void (*callback)(const fhss_api_t *api, uint16_t), const fhss_api_t *callback_param)
{
    int ret_val = -1;
    platform_enter_critical();
    if (timer_initialized == false) {
#if !MBED_CONF_NANOSTACK_HAL_CRITICAL_SECTION_USABLE_FROM_INTERRUPT
        equeue = mbed_highprio_event_queue();
        MBED_ASSERT(equeue != NULL);
#endif
        timer->start();
        timer_initialized = true;
    }
    fhss_timeout_s *fhss_tim = find_timeout(callback);
    if (!fhss_tim) {
        fhss_tim = allocate_timeout();
    }
    if (!fhss_tim) {
        platform_exit_critical();
        tr_error("Failed to allocate timeout");
        return ret_val;
    }
    fhss_tim->fhss_timer_callback = callback;
    fhss_tim->start_time = read_current_time();
    fhss_tim->stop_time = fhss_tim->start_time + slots;
    fhss_tim->active = true;
    fhss_tim->timeout->attach_us(timer_callback, slots);
    fhss_active_handle = callback_param;
    ret_val = 0;
    platform_exit_critical();
    return ret_val;
}
// Called once at boot
void platform_timer_enable(void)
{
#if !MBED_CONF_NANOSTACK_HAL_CRITICAL_SECTION_USABLE_FROM_INTERRUPT
    equeue = mbed_highprio_event_queue();
    MBED_ASSERT(equeue != NULL);
#endif
    timer->start();
    // Prime the SingletonPtr - can't construct from IRQ/critical section
    timeout.get();
}
示例#3
0
static void _rtc_lpticker_init(void)
{
    _rtc_lp_timer->start();
    _rtc_enabled = true;
}