zephyr/subsys/net/lib/openthread/platform/alarm.c
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00

75 lines
1.3 KiB
C

/*
* Copyright (c) 2018 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#define LOG_MODULE_NAME net_openthread_alarm
#define LOG_LEVEL CONFIG_OPENTHREAD_LOG_LEVEL
#include <logging/log.h>
LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <kernel.h>
#include <string.h>
#include <inttypes.h>
#include <openthread/platform/alarm-milli.h>
#include <openthread-system.h>
#include <stdio.h>
#include "platform-zephyr.h"
static bool timer_fired;
static void ot_timer_fired(struct k_timer *timer)
{
ARG_UNUSED(timer);
timer_fired = true;
otSysEventSignalPending();
}
K_TIMER_DEFINE(ot_timer, ot_timer_fired, NULL);
void platformAlarmInit(void)
{
/* Intentionally empty */
}
uint32_t otPlatAlarmMilliGetNow(void)
{
return k_uptime_get_32();
}
void otPlatAlarmMilliStartAt(otInstance *aInstance, uint32_t t0, uint32_t dt)
{
ARG_UNUSED(aInstance);
int64_t reftime = (int64_t)t0 + (int64_t)dt;
int64_t delta = -k_uptime_delta(&reftime);
if (delta > 0) {
k_timer_start(&ot_timer, K_MSEC(delta), K_NO_WAIT);
} else {
ot_timer_fired(NULL);
}
}
void otPlatAlarmMilliStop(otInstance *aInstance)
{
ARG_UNUSED(aInstance);
k_timer_stop(&ot_timer);
}
void platformAlarmProcess(otInstance *aInstance)
{
if (timer_fired) {
timer_fired = false;
otPlatAlarmMilliFired(aInstance);
}
}