20#ifndef _NPL_FREERTOS_H_
21#define _NPL_FREERTOS_H_
23#include "nimble/porting/nimble/include/syscfg/syscfg.h"
29#if CONFIG_NIMBLE_STACK_USE_MEM_POOLS
30typedef void ble_npl_event_fn(
struct ble_npl_event *ev);
32struct ble_npl_event_freertos {
38struct ble_npl_eventq_freertos {
42struct ble_npl_callout_freertos {
43#if CONFIG_BT_NIMBLE_USE_ESP_TIMER
44 esp_timer_handle_t handle;
48 struct ble_npl_eventq *evq;
49 struct ble_npl_event ev;
52struct ble_npl_mutex_freertos {
53 SemaphoreHandle_t handle;
56struct ble_npl_sem_freertos {
57 SemaphoreHandle_t handle;
60typedef void ble_npl_event_fn_freertos(
struct ble_npl_event_freertos *ev);
63struct ble_npl_eventq *npl_freertos_eventq_dflt_get(
void);
65struct ble_npl_event *npl_freertos_eventq_get(
struct ble_npl_eventq *evq,
68void npl_freertos_eventq_put(
struct ble_npl_eventq *evq,
69 struct ble_npl_event *ev);
71void npl_freertos_eventq_remove(
struct ble_npl_eventq *evq,
72 struct ble_npl_event *ev);
74ble_npl_error_t npl_freertos_mutex_init(
struct ble_npl_mutex *mu);
75ble_npl_error_t npl_freertos_mutex_deinit(
struct ble_npl_mutex *mu);
77ble_npl_error_t npl_freertos_mutex_pend(
struct ble_npl_mutex *mu,
78 ble_npl_time_t timeout);
80ble_npl_error_t npl_freertos_mutex_release(
struct ble_npl_mutex *mu);
82ble_npl_error_t npl_freertos_sem_init(
struct ble_npl_sem *sem, uint16_t tokens);
83ble_npl_error_t npl_freertos_sem_deinit(
struct ble_npl_sem *sem);
85ble_npl_error_t npl_freertos_sem_pend(
struct ble_npl_sem *sem,
86 ble_npl_time_t timeout);
88ble_npl_error_t npl_freertos_sem_release(
struct ble_npl_sem *sem);
90int npl_freertos_callout_init(
struct ble_npl_callout *co,
91 struct ble_npl_eventq *evq,
92 ble_npl_event_fn *ev_cb,
void *ev_arg);
94void npl_freertos_callout_deinit(
struct ble_npl_callout *co);
96void npl_freertos_callout_stop(
struct ble_npl_callout *co);
98bool npl_freertos_callout_is_active(
struct ble_npl_callout *co);
100ble_npl_time_t npl_freertos_callout_get_ticks(
struct ble_npl_callout *co);
102ble_npl_error_t npl_freertos_callout_reset(
struct ble_npl_callout *co,
103 ble_npl_time_t ticks);
105ble_npl_time_t npl_freertos_callout_remaining_ticks(
struct ble_npl_callout *co,
108ble_npl_error_t npl_freertos_time_ms_to_ticks(uint32_t ms,
109 ble_npl_time_t *out_ticks);
111ble_npl_error_t npl_freertos_time_ticks_to_ms(ble_npl_time_t ticks,
114void npl_freertos_hw_set_isr(
int irqn,
void (*addr)(
void));
116uint32_t npl_freertos_hw_enter_critical(
void);
118void npl_freertos_hw_exit_critical(uint32_t ctx);