mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
b283b7784c
pkg, nordic_softdevice_ble: disable CFLAGS to omit compiler error sys, pm_layered: fix casting nonscalar to the same type cpu, stm32_common: fix type-limits, remove always true assert cpu, stm32f4: fix pointer arithmetic in periph/i2c drivers, at86rf2xx: fix type-limits where condition always true saul, gpio: fix if no gpio configured for saul cpu, saml21: add frequency check to periph/timer driver, cc110x: fix unused param and type-limts errors boards, wsn430-common: fix old-style-declaration make: fix old style definition drivers, sdcard_spi: fix old style typedef driver, at30tse: remove unnecessary check driver, nrf24: fix type-limit driver, pn532: change buffer from char to uint8_t tests/driver_sdcard: fix type limits boards, feather-m0: add missing field inits driver, tcs37727: fix type limits pkg, emb6: disable some compiler warnings tests/emb6: disable some compiler warings pkg, openthread: fix sign compare and unused params tests/trickle: fix struct init tests/pthread_cooperation: fix type limits board, mips-malta: remove feature periph_uart shell: fix var size for netif command gnrc, netif: fix sign-compare gnrc, nib: fix sign-compare shell: fix output in netif command posix: fix type-limits in pthread_cond
73 lines
1.8 KiB
C
73 lines
1.8 KiB
C
/*
|
|
* Copyright (C) 2017 Fundacion Inria Chile
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
/**
|
|
* @{
|
|
* @ingroup net
|
|
* @file
|
|
* @brief Implementation of OpenThread alarm platform abstraction
|
|
*
|
|
* @author Jose Ignacio Alamos <jialamos@uc.cl>
|
|
* @}
|
|
*/
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "msg.h"
|
|
#include "openthread/platform/alarm.h"
|
|
#include "ot.h"
|
|
#include "thread.h"
|
|
#include "xtimer.h"
|
|
#include "timex.h"
|
|
|
|
#define ENABLE_DEBUG (0)
|
|
#include "debug.h"
|
|
|
|
static xtimer_t ot_timer;
|
|
static msg_t ot_alarm_msg;
|
|
|
|
/**
|
|
* Set the alarm to fire at @p aDt milliseconds after @p aT0.
|
|
*
|
|
* @param[in] aInstance The OpenThread instance structure.
|
|
* @param[in] aT0 The reference time.
|
|
* @param[in] aDt The time delay in milliseconds from @p aT0.
|
|
*/
|
|
void otPlatAlarmStartAt(otInstance *aInstance, uint32_t aT0, uint32_t aDt)
|
|
{
|
|
(void)aInstance;
|
|
(void)aT0;
|
|
|
|
DEBUG("openthread: otPlatAlarmStartAt: aT0: %" PRIu32 ", aDT: %" PRIu32 "\n", aT0, aDt);
|
|
ot_alarm_msg.type = OPENTHREAD_XTIMER_MSG_TYPE_EVENT;
|
|
|
|
if (aDt == 0) {
|
|
msg_send(&ot_alarm_msg, thread_getpid());
|
|
}
|
|
else {
|
|
int dt = aDt * US_PER_MS;
|
|
xtimer_set_msg(&ot_timer, dt, &ot_alarm_msg, thread_getpid());
|
|
}
|
|
}
|
|
|
|
/* OpenThread will call this to stop alarms */
|
|
void otPlatAlarmStop(otInstance *aInstance)
|
|
{
|
|
(void)aInstance;
|
|
DEBUG("openthread: otPlatAlarmStop\n");
|
|
xtimer_remove(&ot_timer);
|
|
}
|
|
|
|
/* OpenThread will call this for getting running time in millisecs */
|
|
uint32_t otPlatAlarmGetNow(void)
|
|
{
|
|
uint32_t now = xtimer_now_usec() / US_PER_MS;
|
|
DEBUG("openthread: otPlatAlarmGetNow: %" PRIu32 "\n", now);
|
|
return now;
|
|
}
|