NimBLE-Arduino 2.1.3
Loading...
Searching...
No Matches
npl_freertos.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef _NPL_FREERTOS_H_
21#define _NPL_FREERTOS_H_
22
23#include "nimble/porting/nimble/include/syscfg/syscfg.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#if CONFIG_NIMBLE_STACK_USE_MEM_POOLS
30typedef void ble_npl_event_fn(struct ble_npl_event *ev);
31
32struct ble_npl_event_freertos {
33 bool queued;
34 ble_npl_event_fn *fn;
35 void *arg;
36};
37
38struct ble_npl_eventq_freertos {
39 QueueHandle_t q;
40};
41
42struct ble_npl_callout_freertos {
43#if CONFIG_BT_NIMBLE_USE_ESP_TIMER
44 esp_timer_handle_t handle;
45#else
46 TimerHandle_t handle;
47#endif
48 struct ble_npl_eventq *evq;
49 struct ble_npl_event ev;
50};
51
52struct ble_npl_mutex_freertos {
53 SemaphoreHandle_t handle;
54};
55
56struct ble_npl_sem_freertos {
57 SemaphoreHandle_t handle;
58};
59
60typedef void ble_npl_event_fn_freertos(struct ble_npl_event_freertos *ev);
61#endif
62
63struct ble_npl_eventq *npl_freertos_eventq_dflt_get(void);
64
65struct ble_npl_event *npl_freertos_eventq_get(struct ble_npl_eventq *evq,
66 ble_npl_time_t tmo);
67
68void npl_freertos_eventq_put(struct ble_npl_eventq *evq,
69 struct ble_npl_event *ev);
70
71void npl_freertos_eventq_remove(struct ble_npl_eventq *evq,
72 struct ble_npl_event *ev);
73
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);
76
77ble_npl_error_t npl_freertos_mutex_pend(struct ble_npl_mutex *mu,
78 ble_npl_time_t timeout);
79
80ble_npl_error_t npl_freertos_mutex_release(struct ble_npl_mutex *mu);
81
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);
84
85ble_npl_error_t npl_freertos_sem_pend(struct ble_npl_sem *sem,
86 ble_npl_time_t timeout);
87
88ble_npl_error_t npl_freertos_sem_release(struct ble_npl_sem *sem);
89
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);
93
94void npl_freertos_callout_deinit(struct ble_npl_callout *co);
95
96void npl_freertos_callout_stop(struct ble_npl_callout *co);
97
98bool npl_freertos_callout_is_active(struct ble_npl_callout *co);
99
100ble_npl_time_t npl_freertos_callout_get_ticks(struct ble_npl_callout *co);
101
102ble_npl_error_t npl_freertos_callout_reset(struct ble_npl_callout *co,
103 ble_npl_time_t ticks);
104
105ble_npl_time_t npl_freertos_callout_remaining_ticks(struct ble_npl_callout *co,
106 ble_npl_time_t now);
107
108ble_npl_error_t npl_freertos_time_ms_to_ticks(uint32_t ms,
109 ble_npl_time_t *out_ticks);
110
111ble_npl_error_t npl_freertos_time_ticks_to_ms(ble_npl_time_t ticks,
112 uint32_t *out_ms);
113
114void npl_freertos_hw_set_isr(int irqn, void (*addr)(void));
115
116uint32_t npl_freertos_hw_enter_critical(void);
117
118void npl_freertos_hw_exit_critical(uint32_t ctx);
119
120#ifdef __cplusplus
121}
122#endif
123
124#endif /* _NPL_FREERTOS_H_ */