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, ble_npl_time_t tmo); 30 31 void npl_freertos_eventq_put(struct ble_npl_eventq *evq, 32 struct ble_npl_event *ev); 33 34 void npl_freertos_eventq_remove(struct ble_npl_eventq *evq, 35 struct ble_npl_event *ev); 36 37 ble_npl_error_t npl_freertos_mutex_init(struct ble_npl_mutex *mu); 38 ble_npl_error_t npl_freertos_mutex_deinit(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 ble_npl_error_t npl_freertos_sem_deinit(struct ble_npl_sem *sem); 47 48 ble_npl_error_t npl_freertos_sem_pend(struct ble_npl_sem *sem, 49 ble_npl_time_t timeout); 50 51 ble_npl_error_t npl_freertos_sem_release(struct ble_npl_sem *sem); 52 uint16_t npl_freertos_get_sem_count(struct ble_npl_sem *sem); 53 54 void npl_freertos_callout_init(struct ble_npl_callout *co, 55 struct ble_npl_eventq *evq, 56 ble_npl_event_fn *ev_cb, void *ev_arg); 57 58 ble_npl_error_t npl_freertos_callout_reset(struct ble_npl_callout *co, ble_npl_time_t ticks); 59 60 ble_npl_time_t npl_freertos_callout_remaining_ticks(struct ble_npl_callout *co, ble_npl_time_t now); 61 62 ble_npl_error_t npl_freertos_time_ms_to_ticks(uint32_t ms, ble_npl_time_t *out_ticks); 63 64 ble_npl_error_t npl_freertos_time_ticks_to_ms(ble_npl_time_t ticks, uint32_t *out_ms); 65 66 void npl_freertos_hw_set_isr(int irqn, void (*addr)(void)); 67 68 uint32_t npl_freertos_hw_enter_critical(void); 69 70 void npl_freertos_hw_exit_critical(uint32_t ctx); 71 72 #ifdef __cplusplus 73 } 74 #endif 75 76 #endif /* _NPL_FREERTOS_H_ */