2017-10-22 13:54:43 +02:00
|
|
|
/*
|
2019-05-02 11:22:56 +02:00
|
|
|
* Copyright (C) 2017 Inria
|
|
|
|
* 2017 Freie Universität Berlin
|
|
|
|
* 2017 Kaspar Schleiser <kaspar@schleiser.de>
|
2017-10-22 13:54:43 +02:00
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "event/timeout.h"
|
|
|
|
|
|
|
|
static void _event_timeout_callback(void *arg)
|
|
|
|
{
|
|
|
|
event_timeout_t *event_timeout = (event_timeout_t *)arg;
|
|
|
|
event_post(event_timeout->queue, event_timeout->event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void event_timeout_init(event_timeout_t *event_timeout, event_queue_t *queue, event_t *event)
|
|
|
|
{
|
|
|
|
event_timeout->timer.callback = _event_timeout_callback;
|
|
|
|
event_timeout->timer.arg = event_timeout;
|
|
|
|
event_timeout->queue = queue;
|
|
|
|
event_timeout->event = event;
|
|
|
|
}
|
|
|
|
|
|
|
|
void event_timeout_set(event_timeout_t *event_timeout, uint32_t timeout)
|
|
|
|
{
|
|
|
|
xtimer_set(&event_timeout->timer, timeout);
|
|
|
|
}
|
2018-01-09 14:37:45 +01:00
|
|
|
|
|
|
|
void event_timeout_clear(event_timeout_t *event_timeout)
|
|
|
|
{
|
|
|
|
xtimer_remove(&event_timeout->timer);
|
|
|
|
}
|