Mynewt-Nimble Porting layer wrappers. More...
Mynewt-Nimble Porting layer wrappers.
Definition in file nimble_npl_os.h.
Go to the source code of this file.
Data Structures | |
struct | ble_npl_event |
ble_npl event wrapper More... | |
struct | ble_npl_eventq |
ble_npl event queue wrapper More... | |
struct | ble_npl_callout |
ble_npl callout wrapper More... | |
struct | ble_npl_mutex |
ble_npl mutex wrapper More... | |
struct | ble_npl_sem |
ble_npl semaphore wrapper More... | |
Typedefs | |
typedef uint32_t | ble_npl_time_t |
time type | |
typedef int32_t | ble_npl_stime_t |
time type | |
Functions | |
static bool | ble_npl_os_started (void) |
Not used in RIOT. | |
static void | ble_npl_event_init (struct ble_npl_event *ev, ble_npl_event_fn *fn, void *arg) |
Init a event. | |
static bool | ble_npl_event_is_queued (struct ble_npl_event *ev) |
Check if event is in queue. | |
static void * | ble_npl_event_get_arg (struct ble_npl_event *ev) |
Runs an event. | |
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 void | ble_npl_eventq_init (struct ble_npl_eventq *evq) |
Initialize the event queue. | |
static int | ble_npl_eventq_inited (struct ble_npl_eventq *evq) |
Check whether the event queue is initialized. | |
static void | ble_npl_eventq_deinit (struct ble_npl_eventq *evq) |
Deinitialize an 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. | |
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_put (struct ble_npl_eventq *evq, struct ble_npl_event *ev) |
Put an event on the event queue. | |
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_eventq_run (struct ble_npl_eventq *evq) |
Gets and runs an event from the queue callback. | |
static bool | ble_npl_eventq_is_empty (struct ble_npl_eventq *evq) |
Check if queue is empty. | |
static ble_npl_error_t | ble_npl_mutex_init (struct ble_npl_mutex *mu) |
Initializes a mutex object. | |
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_mutex_release (struct ble_npl_mutex *mu) |
Release a mutex. | |
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_sem_pend (struct ble_npl_sem *sem, ble_npl_time_t timeout) |
Pend (wait) for a semaphore. | |
static ble_npl_error_t | ble_npl_sem_release (struct ble_npl_sem *sem) |
Release a semaphore. | |
static uint16_t | ble_npl_sem_get_count (struct ble_npl_sem *sem) |
Get current semaphore's count. | |
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_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_stop (struct ble_npl_callout *c) |
Stops the callout from firing. | |
static bool | ble_npl_callout_is_active (struct ble_npl_callout *c) |
Check if callout is active. | |
static ble_npl_time_t | ble_npl_callout_get_ticks (struct ble_npl_callout *co) |
Get the callout set ticks. | |
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 void | ble_npl_callout_set_arg (struct ble_npl_callout *co, void *arg) |
Set the callout event argument. | |
static ble_npl_time_t | ble_npl_time_get (void) |
Returns the low 32 bits of cputime. | |
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 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 ble_npl_time_t | ble_npl_time_ms_to_ticks32 (uint32_t ms) |
Converts the given number of milliseconds into cputime ticks. | |
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 void | ble_npl_time_delay (ble_npl_time_t ticks) |
Wait until the number of ticks has elapsed, BLOICKING. | |
static uint32_t | ble_npl_hw_enter_critical (void) |
Disable ISRs. | |
static void | ble_npl_hw_exit_critical (uint32_t ctx) |
Restores ISR context. | |
static bool | ble_npl_hw_is_in_critical (void) |
Check if is in critical section. | |
static void * | ble_npl_get_current_task_id (void) |
Return current thread PID. | |
static void | ble_npl_hw_set_isr (int irqn, void(*addr)(void)) |
Set nrf5x radio ISR callback. | |
BLE NPL layer macros | |
#define | BLE_NPL_OS_ALIGNMENT (OS_ALIGNMENT) |
#define | BLE_NPL_TIME_FOREVER (OS_WAIT_FOREVER) |
#define BLE_NPL_OS_ALIGNMENT (OS_ALIGNMENT) |
Definition at line 40 of file nimble_npl_os.h.
#define BLE_NPL_TIME_FOREVER (OS_WAIT_FOREVER) |
Definition at line 41 of file nimble_npl_os.h.
typedef int32_t ble_npl_stime_t |
time type
Definition at line 51 of file nimble_npl_os.h.
typedef uint32_t ble_npl_time_t |
time type
Definition at line 47 of file nimble_npl_os.h.
|
inlinestatic |
Get the callout set ticks.
[in] | co | the callout to check |
Definition at line 419 of file nimble_npl_os.h.
|
inlinestatic |
Initialize a callout.
Callouts are used to schedule events in the future onto an event queue. Callout timers are scheduled using the ble_npl_callout_reset() function. When the timer expires, an event is posted to the event queue specified in ble_npl_callout_init(). The event argument given here is posted in the ev_arg field of that event.
[out] | c | callout to initialize |
[in] | q | event queue to queue event in |
[in] | e_cb | callback function |
[in] | e_arg | callback function argument |
Definition at line 368 of file nimble_npl_os.h.
|
inlinestatic |
Check if callout is active.
[in] | c | the callout to check |
Definition at line 409 of file nimble_npl_os.h.
|
inlinestatic |
Get the remaining ticks for callout expire.
[in] | co | the callout to check |
[in] | time | ignored |
Definition at line 432 of file nimble_npl_os.h.
|
inlinestatic |
Reset the callout to fire off in 'ticks' ticks.
[in] | c | callout to reset |
[in] | ticks | number of ticks to wait before posting an event |
Definition at line 382 of file nimble_npl_os.h.
|
inlinestatic |
Set the callout event argument.
[in] | co | the callout |
[in] | arg | callback function argument |
Definition at line 446 of file nimble_npl_os.h.
|
inlinestatic |
Stops the callout from firing.
[in] | c | the callout to stop |
Definition at line 397 of file nimble_npl_os.h.
|
inlinestatic |
|
inlinestatic |
Init a event.
[in] | ev | pointer to event to set |
[in] | fn | event callback function |
[in] | arg | event argument |
Definition at line 106 of file nimble_npl_os.h.
|
inlinestatic |
Check if event is in queue.
[in] | ev | event to check |
Definition at line 119 of file nimble_npl_os.h.
|
inlinestatic |
|
inlinestatic |
Set the vent arg.
[in] | ev | event |
[in] | arg | arg to set event |
Definition at line 140 of file nimble_npl_os.h.
|
inlinestatic |
Deinitialize an event queue.
[in] | evq | the event queue to deinit |
Definition at line 182 of file nimble_npl_os.h.
|
inlinestatic |
Get next event from event queue, blocking.
[in] | evq | the event queue to pull an event from |
[in] | tmo | timeout, NPL_TIME_FOREVER to block, 0 to return immediately |
Definition at line 196 of file nimble_npl_os.h.
|
inlinestatic |
Get next event from event queue, non-blocking.
[in] | evq | the event queue to pull an event from |
Definition at line 209 of file nimble_npl_os.h.
|
inlinestatic |
Initialize the event queue.
[in] | evq | The event queue to initialize |
Definition at line 160 of file nimble_npl_os.h.
|
inlinestatic |
Check whether the event queue is initialized.
[in] | evq | the event queue to check |
Definition at line 170 of file nimble_npl_os.h.
|
inlinestatic |
Check if queue is empty.
[in] | evq | the event queue to check |
Definition at line 253 of file nimble_npl_os.h.
|
inlinestatic |
Put an event on the event queue.
[in] | evq | event queue |
[in] | ev | event to put in queue |
Definition at line 220 of file nimble_npl_os.h.
|
inlinestatic |
Remove an event from the queue.
[in] | evq | event queue to remove the event from |
[in] | ev | event to remove from the queue |
Definition at line 231 of file nimble_npl_os.h.
|
inlinestatic |
Gets and runs an event from the queue callback.
[in] | evq | The event queue to pull the item off. |
Definition at line 241 of file nimble_npl_os.h.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Restores ISR context.
[in] | ctx | ISR context to restore. |
Definition at line 535 of file nimble_npl_os.h.
|
inlinestatic |
Check if is in critical section.
Definition at line 545 of file nimble_npl_os.h.
|
inlinestatic |
Set nrf5x radio ISR callback.
[in] | irqn | IRQ number |
[in] | addr | the ISR callback |
Definition at line 566 of file nimble_npl_os.h.
|
inlinestatic |
Initializes a mutex object.
[out] | mu | pre-allocated mutex structure, must not be NULL. |
Definition at line 263 of file nimble_npl_os.h.
|
inlinestatic |
Pend (wait) for a mutex.
[in] | mu | Pointer to mutex. |
[in] | timeout | Timeout, in os ticks. A timeout of 0 means do not wait if not available. A timeout of OS_TIMEOUT_NEVER means wait forever. |
Definition at line 280 of file nimble_npl_os.h.
|
inlinestatic |
Release a mutex.
Definition at line 293 of file nimble_npl_os.h.
|
inlinestatic |
|
inlinestatic |
Get current semaphore's count.
Definition at line 349 of file nimble_npl_os.h.
|
inlinestatic |
Initialize a semaphore.
[in] | sem | pointer to semaphore |
[in] | tokens | # of tokens the semaphore should contain initially. |
Definition at line 308 of file nimble_npl_os.h.
|
inlinestatic |
Pend (wait) for a semaphore.
[in] | sem | pointer to semaphore. |
[in] | timeout | timeout, in os ticks. A timeout of 0 means do not wait if not available. A timeout of BLE_NPL_TIMEOUT_NEVER means wait forever. |
Definition at line 327 of file nimble_npl_os.h.
|
inlinestatic |
Release a semaphore.
[in] | sem | pointer to the semaphore to be released |
Definition at line 341 of file nimble_npl_os.h.
|
inlinestatic |
Wait until the number of ticks has elapsed, BLOICKING.
[in] | ticks | The number of ticks to wait. |
Definition at line 515 of file nimble_npl_os.h.
|
inlinestatic |
Returns the low 32 bits of cputime.
Definition at line 456 of file nimble_npl_os.h.
|
inlinestatic |
Converts the given number of milliseconds into cputime ticks.
[in] | ms | The number of milliseconds to convert to ticks |
[out] | out_ticks | The number of ticks corresponding to 'ms' |
Definition at line 469 of file nimble_npl_os.h.
|
inlinestatic |
Converts the given number of milliseconds into cputime ticks.
[in] | ms | The number of milliseconds to convert to ticks |
Definition at line 494 of file nimble_npl_os.h.
|
inlinestatic |
Convert the given number of ticks into milliseconds.
[in] | ticks | The number of ticks to convert to milliseconds. |
[out] | out_ms | The converted milliseconds from 'ticks' |
Definition at line 482 of file nimble_npl_os.h.
|
inlinestatic |
Convert the given number of ticks into milliseconds.
[in] | ticks | The number of ticks to convert to milliseconds. |
Definition at line 506 of file nimble_npl_os.h.