xref: /nrf52832-nimble/packages/NimBLE-latest/porting/npl/freertos/include/nimble/npl_freertos.h (revision 042d53a763ad75cb1465103098bb88c245d95138)
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 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 struct ble_npl_eventq *npl_freertos_eventq_dflt_get(void);
28 
29 struct ble_npl_event *npl_freertos_eventq_get(struct ble_npl_eventq *evq,
30                                               ble_npl_time_t tmo);
31 
32 void npl_freertos_eventq_put(struct ble_npl_eventq *evq,
33                              struct ble_npl_event *ev);
34 
35 void npl_freertos_eventq_remove(struct ble_npl_eventq *evq,
36                                 struct ble_npl_event *ev);
37 
38 ble_npl_error_t npl_freertos_mutex_init(struct ble_npl_mutex *mu);
39 
40 ble_npl_error_t npl_freertos_mutex_pend(struct ble_npl_mutex *mu,
41                                         ble_npl_time_t timeout);
42 
43 ble_npl_error_t npl_freertos_mutex_release(struct ble_npl_mutex *mu);
44 
45 ble_npl_error_t npl_freertos_sem_init(struct ble_npl_sem *sem, uint16_t tokens);
46 
47 ble_npl_error_t npl_freertos_sem_pend(struct ble_npl_sem *sem,
48                                       ble_npl_time_t timeout);
49 
50 ble_npl_error_t npl_freertos_sem_release(struct ble_npl_sem *sem);
51 
52 void npl_freertos_callout_init(struct ble_npl_callout *co,
53                                struct ble_npl_eventq *evq,
54                                ble_npl_event_fn *ev_cb, void *ev_arg);
55 
56 ble_npl_error_t npl_freertos_callout_reset(struct ble_npl_callout *co,
57                                            ble_npl_time_t ticks);
58 
59 ble_npl_time_t npl_freertos_callout_remaining_ticks(struct ble_npl_callout *co,
60 						    ble_npl_time_t now);
61 
62 ble_npl_error_t npl_freertos_time_ms_to_ticks(uint32_t ms,
63                                               ble_npl_time_t *out_ticks);
64 
65 ble_npl_error_t npl_freertos_time_ticks_to_ms(ble_npl_time_t ticks,
66                                               uint32_t *out_ms);
67 
68 void npl_freertos_hw_set_isr(int irqn, void (*addr)(void));
69 
70 uint32_t npl_freertos_hw_enter_critical(void);
71 
72 void npl_freertos_hw_exit_critical(uint32_t ctx);
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 
78 #endif  /* _NPL_FREERTOS_H_ */
79