wiced_result_t wiced_rtos_register_timed_event( wiced_timed_event_t* event_object, wiced_worker_thread_t* worker_thread, event_handler_t function, uint32_t time_ms, void* arg )
{
    if ( wiced_rtos_init_timer( &event_object->timer, time_ms, timed_event_handler, (void*) event_object ) != WICED_SUCCESS )
    {
        return WICED_ERROR;
    }

    event_object->function = function;
    event_object->thread = worker_thread;
    event_object->arg = arg;

    if ( wiced_rtos_start_timer( &event_object->timer ) != WICED_SUCCESS )
    {
        wiced_rtos_deinit_timer( &event_object->timer );
        return WICED_ERROR;
    }

    return WICED_SUCCESS;
}
Example #2
0
static wiced_result_t key_pressed_event_handler( void* arg )
{
    gpio_key_internal_t* key = (gpio_key_internal_t*)arg;

    if ( key != NULL )
    {
        gpio_keypad_internal_t* keypad = key->owner;

        if ( keypad->current_key_pressed == NULL )
        {
            keypad->current_key_pressed = key;

            wiced_rtos_start_timer( &keypad->check_state_timer );

            keypad->function( key->key->code, KEY_EVENT_PRESSED );

            return WICED_SUCCESS;
        }
    }

    return WICED_ERROR;
}