1 /* 2 * Copyright (c) 2022 Winner Microelectronics Co., Ltd. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @file wm_wl_timers.h 18 * 19 * @brief task APIs 20 * 21 * @author dave 22 * 23 * Copyright (c) 2015 Winner Microelectronics Co., Ltd. 24 */ 25 #ifndef __TLS_WL_TIMERS_H__ 26 #define __TLS_WL_TIMERS_H__ 27 28 #include "wm_type_def.h" 29 #include "wm_wl_mbox.h" 30 31 /** callback function of time out */ 32 typedef void (* tls_timeout_handler)(void *arg); 33 34 /** 35 * @brief Create a one-shot timer (aka timeout) 36 * 37 * @param[in] timeo_assigned timer NO. by assigned 38 * @param[in] msecs time in milliseconds after that the timer should expire 39 * @param[in] handler callback function that would be called by the timeout 40 * @param[in] *arg callback argument that would be passed to handler 41 * 42 * @return None 43 * 44 * @note While waiting for a message using sys_timeouts_mbox_fetch() 45 */ 46 void tls_timeout_p(u8 timeo_assigned, u32 msecs, tls_timeout_handler handler, void *arg); 47 48 /** 49 * @brief Go through timeout list (for this task only) and remove the first 50 * matching entry, even though the timeout has not been triggered yet 51 * 52 * @param[in] timeo_assigned timer NO. by assigned 53 * @param[in] handler callback function that would be called by the timeout 54 * @param[in] *arg callback argument that would be passed to handler 55 * 56 * @return None 57 * 58 * @note None 59 */ 60 void tls_untimeout_p(u8 timeo_assigned, tls_timeout_handler handler, void *arg); 61 62 /** 63 * @brief Wait (forever) for a message to arrive in an mbox. 64 * While waiting, timeouts are processed 65 * 66 * @param[in] timeo_assigned timer NO. by assigned 67 * @param[in] mbox the mbox to fetch the message from 68 * @param[out] **msg the place to store the message 69 * 70 * @return None 71 * 72 * @note None 73 */ 74 void tls_timeouts_mbox_fetch_p(u8 timeo_assigned, tls_mbox_t mbox, void **msg); 75 76 /** 77 * @brief Initialize the timer 78 * 79 * @param None 80 * 81 * @retval 0 success 82 * @retval other failed 83 * 84 * @note None 85 */ 86 s8 tls_wl_timer_init(void); 87 88 #endif 89 90