20#ifndef NIMBLE_NIMBLE_NPL_OS_H
21#define NIMBLE_NIMBLE_NPL_OS_H
28#if defined(CPU_FAM_NRF51) || defined(CPU_FAM_NRF52)
40#define BLE_NPL_OS_ALIGNMENT (OS_ALIGNMENT)
41#define BLE_NPL_TIME_FOREVER (OS_WAIT_FOREVER)
265 return (ble_npl_error_t)os_mutex_init(&mu->
mu);
282 return (ble_npl_error_t)os_mutex_pend(&mu->
mu, timeout);
295 return (ble_npl_error_t)os_mutex_release(&mu->
mu);
310 return (ble_npl_error_t)os_sem_init(&sem->
sem, tokens);
329 return (ble_npl_error_t)os_sem_pend(&sem->
sem, timeout);
343 return (ble_npl_error_t)os_sem_release(&sem->
sem);
351 return os_sem_get_count(&sem->
sem);
369 ble_npl_event_fn *e_cb,
void *e_arg)
387 os_callout_reset(&c->
co, ticks);
399 os_callout_stop(&c->
co);
448 co->
co.c_ev.arg = arg;
573#if defined(CPU_FAM_NRF51) || defined(CPU_FAM_NRF52)
575nrf52_clock_hfxo_request(
void)
581nrf52_clock_hfxo_release(
void)
void clock_hfxo_request(void)
Request the external high frequency crystal (HFXO) as HF clock source.
void clock_hfxo_release(void)
Release the use of the HFXO.
static kernel_pid_t thread_getpid(void)
Returns the process ID of the currently running thread.
uint32_t ztimer_now_t
type for ztimer_now() result
static ztimer_now_t ztimer_now(ztimer_clock_t *clock)
Get the current time from a clock.
unsigned ztimer_is_set(const ztimer_clock_t *clock, const ztimer_t *timer)
Check if a timer is currently active.
ztimer_clock_t *const ZTIMER_MSEC
Default ztimer millisecond clock.
Abstraction layer for RIOT adaption.
void nrf5x_hw_set_isr(int irqn, void(*addr)(void))
Set nrf5x radio ISR callback.
static bool ble_npl_os_started(void)
Not used in RIOT.
static void ble_npl_hw_exit_critical(uint32_t ctx)
Restores ISR context.
static void ble_npl_eventq_deinit(struct ble_npl_eventq *evq)
Deinitialize an event queue.
static void ble_npl_event_set_arg(struct ble_npl_event *ev, void *arg)
Set the vent arg.
static void ble_npl_event_run(struct ble_npl_event *ev)
Runs an event.
static uint16_t ble_npl_sem_get_count(struct ble_npl_sem *sem)
Get current semaphore's count.
static void ble_npl_eventq_init(struct ble_npl_eventq *evq)
Initialize the event queue.
static struct ble_npl_event * ble_npl_eventq_get(struct ble_npl_eventq *evq, ble_npl_time_t tmo)
Get next event from event queue, blocking.
int32_t ble_npl_stime_t
time type
static ble_npl_time_t ble_npl_time_ms_to_ticks32(uint32_t ms)
Converts the given number of milliseconds into cputime ticks.
static void * ble_npl_get_current_task_id(void)
Return current thread PID.
static void ble_npl_event_init(struct ble_npl_event *ev, ble_npl_event_fn *fn, void *arg)
Init a event.
static uint32_t ble_npl_hw_enter_critical(void)
Disable ISRs.
static void ble_npl_eventq_remove(struct ble_npl_eventq *evq, struct ble_npl_event *ev)
Remove an event from the queue.
static void ble_npl_hw_set_isr(int irqn, void(*addr)(void))
Set nrf5x radio ISR callback.
static void ble_npl_callout_stop(struct ble_npl_callout *c)
Stops the callout from firing.
static void ble_npl_eventq_put(struct ble_npl_eventq *evq, struct ble_npl_event *ev)
Put an event on the event queue.
static bool ble_npl_callout_is_active(struct ble_npl_callout *c)
Check if callout is active.
static ble_npl_time_t ble_npl_time_get(void)
Returns the low 32 bits of cputime.
uint32_t ble_npl_time_t
time type
static ble_npl_time_t ble_npl_callout_remaining_ticks(struct ble_npl_callout *co, ble_npl_time_t time)
Get the remaining ticks for callout expire.
static bool ble_npl_hw_is_in_critical(void)
Check if is in critical section.
static ble_npl_error_t ble_npl_sem_release(struct ble_npl_sem *sem)
Release a semaphore.
static ble_npl_error_t ble_npl_sem_init(struct ble_npl_sem *sem, uint16_t tokens)
Initialize a semaphore.
static ble_npl_error_t ble_npl_callout_reset(struct ble_npl_callout *c, ble_npl_time_t ticks)
Reset the callout to fire off in 'ticks' ticks.
static void ble_npl_callout_init(struct ble_npl_callout *c, struct ble_npl_eventq *q, ble_npl_event_fn *e_cb, void *e_arg)
Initialize a callout.
static ble_npl_error_t ble_npl_time_ms_to_ticks(uint32_t ms, ble_npl_time_t *out_ticks)
Converts the given number of milliseconds into cputime ticks.
static int ble_npl_eventq_inited(struct ble_npl_eventq *evq)
Check whether the event queue is initialized.
static ble_npl_error_t ble_npl_mutex_release(struct ble_npl_mutex *mu)
Release a mutex.
static bool ble_npl_event_is_queued(struct ble_npl_event *ev)
Check if event is in queue.
static void ble_npl_callout_set_arg(struct ble_npl_callout *co, void *arg)
Set the callout event argument.
static ble_npl_error_t ble_npl_time_ticks_to_ms(ble_npl_time_t ticks, uint32_t *out_ms)
Convert the given number of ticks into milliseconds.
static void ble_npl_time_delay(ble_npl_time_t ticks)
Wait until the number of ticks has elapsed, BLOICKING.
static struct ble_npl_event * ble_npl_eventq_get_no_wait(struct ble_npl_eventq *evq)
Get next event from event queue, non-blocking.
static void ble_npl_eventq_run(struct ble_npl_eventq *evq)
Gets and runs an event from the queue callback.
static void * ble_npl_event_get_arg(struct ble_npl_event *ev)
Runs an event.
static ble_npl_time_t ble_npl_time_ticks_to_ms32(ble_npl_time_t ticks)
Convert the given number of ticks into milliseconds.
static ble_npl_error_t ble_npl_mutex_init(struct ble_npl_mutex *mu)
Initializes a mutex object.
static ble_npl_time_t ble_npl_callout_get_ticks(struct ble_npl_callout *co)
Get the callout set ticks.
static ble_npl_error_t ble_npl_mutex_pend(struct ble_npl_mutex *mu, ble_npl_time_t timeout)
Pend (wait) for a mutex.
static ble_npl_error_t ble_npl_sem_pend(struct ble_npl_sem *sem, ble_npl_time_t timeout)
Pend (wait) for a semaphore.
static bool ble_npl_eventq_is_empty(struct ble_npl_eventq *evq)
Check if queue is empty.
Apache Mynewt Copyright 2015-2021 The Apache Software Foundation.
static bool os_hw_is_in_critical(void)
Check if is in critical section.
static void os_hw_exit_critical(uint32_t ctx)
Restores ISR context.
static uint32_t os_hw_enter_critical(void)
Disable ISRs.
static bool os_eventq_is_empty(struct os_eventq *evq)
Check if queue is empty.
static struct os_event * os_eventq_get_no_wait(struct os_eventq *evq)
Get next event from event queue, non-blocking.
static void os_event_init(struct os_event *ev, os_event_fn *fn, void *arg)
Init a event.
static void os_event_set_arg(struct os_event *ev, void *arg)
Set the event argument.
static int os_eventq_inited(struct os_eventq *evq)
Check whether the event queue is initialized.
static struct os_event * os_eventq_get(struct os_eventq *evq, os_time_t tmo)
Get next event from event queue.
static void os_eventq_remove(struct os_eventq *evq, struct os_event *ev)
Remove an event from the queue.
static bool os_event_is_queued(struct os_event *ev)
Check if event is in queue.
void os_event_fn(struct os_event *ev)
Event callback function.
static void os_event_run(struct os_event *ev)
Runs an event.
static void os_eventq_init(struct os_eventq *evq)
Initialize the event queue.
static void os_eventq_put(struct os_eventq *evq, struct os_event *ev)
Put an event on the event queue.
static void * os_event_get_arg(struct os_event *ev)
Returns event argument.
static void os_eventq_run(struct os_eventq *evq)
Gets and runs an event from the queue callback.
static os_time_t os_time_ms_to_ticks32(uint32_t ms)
Converts the given number of milliseconds into cputime ticks.
static os_time_t os_time_get(void)
Returns the low 32 bits of cputime.
static void os_time_delay(os_time_t ticks)
Wait until the number of ticks has elapsed, BLOICKING.
static os_time_t os_time_ticks_to_ms32(os_time_t ticks)
Convert the given number of ticks into milliseconds.
static os_error_t os_time_ticks_to_ms(os_time_t ticks, uint32_t *out_ms)
Convert the given number of ticks into milliseconds.
static os_error_t os_time_ms_to_ticks(uint32_t ms, os_time_t *out_ticks)
Converts the given number of milliseconds into cputime ticks.
uint32_t ticks
the callout set timeout
struct os_callout co
the callout
struct os_event ev
the event
ble_npl event queue wrapper
struct os_eventq evq
the event queue
ble_npl semaphore wrapper
struct os_sem sem
semaphore