wm_osal.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. /**
  2. * @file wm_osal.h
  3. *
  4. * @brief WM OS adapter layer
  5. *
  6. * @author winnermicro
  7. *
  8. * Copyright (c) 2015 Winner Microelectronics Co., Ltd.
  9. */
  10. #ifndef WM_OSAL_H
  11. #define WM_OSAL_H
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include "wm_config.h"
  15. #include <core_804.h>
  16. #include "wm_type_def.h"
  17. /** OS TICK Frequency ,this value needs to keep the same as OS self-defined tick value*/
  18. extern const unsigned int HZ;
  19. /** Type definition of os_time_t */
  20. typedef long os_time_t;
  21. /** Structure definition of os_time */
  22. struct os_time {
  23. os_time_t sec;
  24. os_time_t usec;
  25. };
  26. /** ENUMERATION of OS */
  27. enum TLS_OS_TYPE{
  28. OS_UCOSII = 0,
  29. OS_FREERTOS = 1,
  30. OS_MAX_NUM
  31. };
  32. /** TYPE definition of OS_STK */
  33. #ifdef OS_STK
  34. #undef OS_STK
  35. #endif
  36. typedef unsigned int OS_STK;
  37. /** TYPE definition of OS_CPU_SR */
  38. #ifdef OS_CPU_SR
  39. #undef OS_CPU_SR
  40. #endif
  41. typedef unsigned int OS_CPU_SR;
  42. /** TYPE definition of tls_os_task_t */
  43. typedef void * tls_os_task_t;
  44. /** TYPE definition of tls_os_timer_t */
  45. typedef void tls_os_timer_t;
  46. /** TYPE definition of tls_os_sem_t */
  47. typedef void tls_os_sem_t;
  48. /** TYPE definition of tls_os_queue_t */
  49. typedef void tls_os_queue_t;
  50. /** TYPE definition of tls_os_mailbox_t */
  51. typedef void tls_os_mailbox_t;
  52. /** TYPE definition of tls_os_mutex_t */
  53. typedef void tls_os_mutex_t;
  54. /** TYPE definition of TLS_OS_TIMER_CALLBACK */
  55. typedef void (*TLS_OS_TIMER_CALLBACK)(void *ptmr, void *parg);
  56. /** MACRO definition of TIMER ONE times */
  57. #define TLS_OS_TIMER_OPT_ONE_SHORT 1u
  58. /** MACRO definition of TIMER PERIOD */
  59. #define TLS_OS_TIMER_OPT_PERIOD 2u
  60. /** ENUMERATION definition of OS STATUS */
  61. typedef enum tls_os_status {
  62. TLS_OS_SUCCESS = 0,
  63. TLS_OS_ERROR,
  64. TLS_OS_ERR_TIMEOUT,
  65. } tls_os_status_t;
  66. /**
  67. * @defgroup System_APIs System APIs
  68. * @brief System APIs
  69. */
  70. /**
  71. * @addtogroup System_APIs
  72. * @{
  73. */
  74. /**
  75. * @defgroup OS_APIs OS APIs
  76. * @brief Operate system APIs
  77. */
  78. /**
  79. * @addtogroup OS_APIs
  80. * @{
  81. */
  82. /**
  83. * @brief This function is used to register OS tick timer irq
  84. *
  85. * @param[in] None
  86. *
  87. * @return None
  88. *
  89. * @note None
  90. */
  91. void tls_os_timer_init(void);
  92. /**
  93. * @brief This function is used to tick handler
  94. *
  95. * @param[in] *p argument
  96. *
  97. * @return None
  98. *
  99. * @note None
  100. */
  101. void tls_os_time_tick(void *p);
  102. /**
  103. * @brief This function is used to initialize OS common resource
  104. *
  105. * @param[in] *arg
  106. *
  107. * @return None
  108. *
  109. * @note None
  110. */
  111. void tls_os_init(void *arg);
  112. /**
  113. * @brief This function is used to start task scheduler
  114. *
  115. * @param[in] None
  116. *
  117. * @return None
  118. *
  119. * @note None
  120. */
  121. void tls_os_start_scheduler(void);
  122. /**
  123. * @brief This function is used to get OS type
  124. *
  125. * @param[in] None
  126. *
  127. * @retval 0 OS_UCOSII
  128. * @retval 1 OS_FREERTOS
  129. *
  130. * @note May not be used by now.
  131. */
  132. int tls_os_get_type(void);
  133. /**
  134. * @brief This function is used to create a task. Tasks can either be created prior to
  135. the start of multitasking or by a running task.
  136. A task cannot be created in an ISR.
  137. *
  138. * @param[in] *task pointer to the task
  139. * @param[in] name the task's name
  140. * @param[in] entry the task's entry function
  141. * @param[in] param pointer to an optional data area which can be
  142. used to pass parameters to the task when the
  143. task first executes. Where the task is
  144. concerned it thinks it was invoked and passed
  145. the argument 'param' as follows:
  146. void Task (void *param)
  147. {
  148. for (;;) {
  149. Task code;
  150. }
  151. }
  152. * @param[in] *stk_start pointer to the task's bottom of stack. Address must be between 0x20000000 and 0x20028000
  153. * @param[in] stk_size the size of the stack in number of elements.
  154. If OS_STK is set to INT8U,
  155. 'stk_size' corresponds to the number of bytes
  156. available.
  157. If OS_STK is set to INT16U, 'stk_size' contains
  158. the number of 16-bit entries available.
  159. Finally, if OS_STK is set to INT32U,
  160. 'stk_size' contains the number of 32-bit entries
  161. available on the stack.
  162. * @param[in] prio the task's priority. A unique priority MUST be
  163. assigned to each task and the lower the number,
  164. the higher the priority.
  165. * @param[in] flag contains additional information about the behavior of the task
  166. *
  167. * @retval TLS_OS_SUCCESS the call was successful.
  168. * @retval TLS_OS_ERROR failed
  169. *
  170. * @note 1) Stack Range: [stk_start, stk_start + stk_size) must be between 0x20000000 and 0x20028000
  171. * 2) task stack: Using static memory like array, not using dynamic memory.
  172. * 3) And if you use static memory like array (large size) as data storage in your application,
  173. * we suggest you change it to dynamic memory by tls_mem_alloc.
  174. */
  175. tls_os_status_t tls_os_task_create(tls_os_task_t *task,
  176. const char* name,
  177. void (*entry)(void* param),
  178. void* param,
  179. u8 *stk_start,
  180. u32 stk_size,
  181. u32 prio,
  182. u32 flag);
  183. /**
  184. * @brief This function allows you to delete a task. The calling
  185. task can delete itself by its own priority number.
  186. The deleted task is returned to the dormant state
  187. and can be re-activated by creating the deleted task
  188. again.
  189. *
  190. * @param[in] prio task priority to delete
  191. * @param[in] (*freefun)(void) function to free resource
  192. *
  193. * @retval TLS_OS_SUCCESS the call is successful
  194. * @retval TLS_OS_ERROR failed
  195. *
  196. * @note Generally, you do not need to call this function in your application.
  197. */
  198. tls_os_status_t tls_os_task_del(u8 prio, void (*freefun)(void));
  199. /**
  200. * @brief This function allows you to delete a task. The calling
  201. task can delete itself by taks's handler.
  202. The deleted task is returned to the dormant state
  203. and can be re-activated by creating the deleted task
  204. again.
  205. *
  206. * @param[in] prio task handler to delete
  207. * @param[in] (*freefun)(void) function to free resource
  208. *
  209. * @retval TLS_OS_SUCCESS the call is successful
  210. * @retval TLS_OS_ERROR failed
  211. *
  212. */
  213. tls_os_status_t tls_os_task_del_by_task_handle(void *handle, void (*freefun)(void));
  214. tls_os_task_t tls_os_task_id();
  215. u8 tls_os_task_schedule_state();
  216. /**
  217. * @brief This function creates a mutual exclusion semaphore
  218. *
  219. * @param[in] prio the priority to use when accessing the mutual
  220. exclusion semaphore. In other words, when the
  221. semaphore is acquired and a higher priority task
  222. attempts to obtain the semaphore then the
  223. priority of the task owning the semaphore is
  224. raised to this priority. It is assumed that
  225. you will specify a priority that is LOWER in
  226. value than ANY of the tasks competing for the
  227. mutex.
  228. * @param[in] **mutex pointer to the event control clock (OS_EVENT)
  229. associated with the created mutex.
  230. *
  231. * @retval TLS_OS_SUCCESS the call was successful
  232. * @retval TLS_OS_ERROR failed
  233. *
  234. * @note 1) The LEAST significant 8 bits of '.OSEventCnt' are used
  235. to hold the priority number of the task owning the mutex
  236. or 0xFF if no task owns the mutex.
  237. 2) The MOST significant 8 bits of '.OSEventCnt' are used to
  238. hold the priority number to use to reduce priority
  239. inversion.
  240. */
  241. tls_os_status_t tls_os_mutex_create(u8 prio, tls_os_mutex_t **mutex);
  242. /**
  243. * @brief This function deletes a mutual exclusion semaphore and
  244. readies all tasks pending on the it
  245. *
  246. * @param[in] *mutex pointer to the event control block associated
  247. with the desired mutex
  248. *
  249. * @retval TLS_OS_SUCCESS The call was successful and the mutex
  250. was deleted
  251. * @retval TLS_OS_ERROR failed
  252. *
  253. * @note 1) This function must be used with care. Tasks that would
  254. normally expect the presence of the mutex MUST check the
  255. return code of OSMutexPend().
  256. 2) This call can potentially disable interrupts for a long
  257. time. The interrupt disable time is directly
  258. proportional to the number of tasks waiting on the mutex.
  259. 3) Because ALL tasks pending on the mutex will be readied,
  260. you MUST be careful because the resource(s) will no
  261. longer be guarded by the mutex.
  262. 4) IMPORTANT: In the 'OS_DEL_ALWAYS' case, we assume that
  263. the owner of the Mutex (if there is one) is ready-to-run
  264. and is thus NOT pending on another kernel object or has
  265. delayed itself.In other words, if a task owns the mutex
  266. being deleted,that task will be made ready-to-run at
  267. its original priority.
  268. */
  269. tls_os_status_t tls_os_mutex_delete(tls_os_mutex_t *mutex);
  270. /**
  271. * @brief This function waits for a mutual exclusion semaphore
  272. *
  273. * @param[in] *mutex pointer to the event control block
  274. associated with the desired mutex
  275. * @param[in] wait_time an optional timeout period (in clock ticks).
  276. If non-zero, your task will wait for the resource
  277. up to the amount of time specified by
  278. this argument.
  279. If you specify 0, however, your task will wait
  280. forever at the specified mutex or,
  281. until the resource becomes available.
  282. *
  283. * @retval TLS_OS_SUCCESS The call was successful and your task
  284. owns the mutex
  285. * @retval TLS_OS_ERROR failed
  286. *
  287. * @note 1) The task that owns the Mutex MUST NOT pend on
  288. any other event while it owns the mutex.
  289. 2) You MUST NOT change the priority of the task
  290. that owns the mutex
  291. */
  292. tls_os_status_t tls_os_mutex_acquire(tls_os_mutex_t *mutex,
  293. u32 wait_time);
  294. /**
  295. * @brief This function releases a mutual exclusion semaphore
  296. *
  297. * @param[in] *mutex pointer to the event control block
  298. associated with the desired mutex
  299. *
  300. * @retval TLS_OS_SUCCESS The call was successful and the mutex was signaled.
  301. * @retval TLS_OS_ERROR failed
  302. *
  303. * @note None
  304. */
  305. tls_os_status_t tls_os_mutex_release(tls_os_mutex_t *mutex);
  306. /**
  307. * @brief This function creates a semaphore
  308. *
  309. * @param[in] **sem pointer to the event control block (OS_EVENT)
  310. associated with the created semaphore
  311. * @param[in] cnt the initial value for the semaphore.
  312. If the value is 0, no resource is available
  313. (or no event has occurred).
  314. You initialize the semaphore to a non-zero value
  315. to specify how many resources are available
  316. (e.g. if you have 10 resources, you would
  317. initialize the semaphore to 10).
  318. *
  319. * @retval TLS_OS_SUCCESS success,The call was successful
  320. * @retval TLS_OS_ERROR failed
  321. *
  322. * @note None
  323. */
  324. tls_os_status_t tls_os_sem_create(tls_os_sem_t **sem, u32 cnt);
  325. /**
  326. * @brief This function deletes a semaphore and readies all tasks
  327. pending on this semaphore.
  328. *
  329. * @param[in] *sem pointer to the event control block associated
  330. with the desired semaphore
  331. *
  332. * @retval TLS_OS_SUCCESS success
  333. * @retval TLS_OS_ERROR failed
  334. *
  335. * @note None
  336. */
  337. tls_os_status_t tls_os_sem_delete(tls_os_sem_t *sem);
  338. /**
  339. * @brief This function waits for a semaphore
  340. *
  341. * @param[in] *sem pointer to the event control block
  342. associated with the desired semaphore
  343. * @param[in] wait_time an optional timeout period (in clock ticks).
  344. If non-zero, your task will wait for the
  345. resource up to the amount of time specified
  346. by this argument.If you specify 0, however,
  347. your task will wait forever at the specified
  348. semaphore or, until the resource becomes
  349. available (or the event occurs).
  350. *
  351. * @retval TLS_OS_SUCCESS success
  352. * @retval TLS_OS_ERROR failed
  353. *
  354. * @note None
  355. */
  356. tls_os_status_t tls_os_sem_acquire(tls_os_sem_t *sem,
  357. u32 wait_time);
  358. /**
  359. * @brief This function signals a semaphore
  360. *
  361. * @param[in] *sem pointer to the event control block associated
  362. with the desired semaphore
  363. *
  364. * @retval TLS_OS_SUCCESS success
  365. * @retval TLS_OS_ERROR failed
  366. *
  367. * @note None
  368. */
  369. tls_os_status_t tls_os_sem_release(tls_os_sem_t *sem);
  370. /**
  371. * @brief This function sets the semaphore count to the value specified
  372. as an argument.Typically,this value would be 0.You
  373. would typically use this function when a semaphore is
  374. used as a signaling mechanism and, you want to reset
  375. the count value.
  376. *
  377. * @param[in] *sem pointer to the event control block
  378. * @param[in] cnt the new value for the semaphore count. You would
  379. pass 0 to reset the semaphore count.
  380. *
  381. * @retval TLS_OS_SUCCESS success
  382. * @retval TLS_OS_ERROR failed
  383. *
  384. * @note None
  385. */
  386. tls_os_status_t tls_os_sem_set(tls_os_sem_t *sem, u16 cnt);
  387. u16 tls_os_sem_get_count(tls_os_sem_t *sem);
  388. /**
  389. * @brief This function creates a message queue if free event cont
  390. rol blocks are available
  391. *
  392. * @param[in] **queue pointer to the event control clock (OS_EVENT)
  393. associated with the created queue
  394. * @param[in] queue_size the number of elements in the storage area
  395. *
  396. * @retval TLS_OS_SUCCESS success
  397. * @retval TLS_OS_ERROR failed
  398. *
  399. * @note None
  400. */
  401. tls_os_status_t tls_os_queue_create(tls_os_queue_t **queue, u32 queue_size);
  402. /**
  403. * @brief This function deletes a message queue and readies all
  404. tasks pending on the queue
  405. *
  406. * @param[in] *queue pointer to the event control block associated
  407. with the desired queue
  408. *
  409. * @retval TLS_OS_SUCCESS success
  410. * @retval TLS_OS_ERROR failed
  411. *
  412. * @note None
  413. */
  414. tls_os_status_t tls_os_queue_delete(tls_os_queue_t *queue);
  415. /**
  416. * @brief This function sends a message to a queue
  417. *
  418. * @param[in] *queue pointer to the event control block
  419. associated with the desired queue
  420. * @param[in] *msg pointer to the message to send.
  421. * @param[in] msg_size message size
  422. *
  423. * @retval 0 success
  424. * @retval other failed
  425. *
  426. * @note None
  427. */
  428. tls_os_status_t tls_os_queue_send(tls_os_queue_t *queue,
  429. void *msg,
  430. u32 msg_size);
  431. /**
  432. * @brief This function sends a message to a head of the queue
  433. *
  434. * @param[in] *queue pointer to the event control block
  435. associated with the desired queue
  436. * @param[in] *msg pointer to the message to send.
  437. * @param[in] msg_size message size
  438. *
  439. * @retval 0 success
  440. * @retval other failed
  441. *
  442. * @note None
  443. */
  444. tls_os_status_t tls_os_queue_send_to_front(tls_os_queue_t *queue,
  445. void *msg,
  446. u32 msg_size);
  447. /**
  448. * @brief This function sends a message to a tail of the queue
  449. *
  450. * @param[in] *queue pointer to the event control block
  451. associated with the desired queue
  452. * @param[in] *msg pointer to the message to send.
  453. * @param[in] msg_size message size
  454. *
  455. * @retval 0 success
  456. * @retval other failed
  457. *
  458. * @note None
  459. */
  460. tls_os_status_t tls_os_queue_send_to_back(tls_os_queue_t *queue,
  461. void *msg,
  462. u32 msg_size);
  463. /**
  464. * @brief This function is used to flush the contents of the message
  465. queue.
  466. *
  467. * @param[in] *queue
  468. *
  469. * @retval TLS_OS_SUCCESS success
  470. * @retval TLS_OS_ERROR failed
  471. *
  472. * @note None
  473. */
  474. tls_os_status_t tls_os_queue_flush(tls_os_queue_t *queue);
  475. /**
  476. * @brief This function waits for a message to be sent to a queue
  477. *
  478. * @param[in] *queue pointer to the event control block associated
  479. with the desired queue
  480. * @param[in] **msg pointer to the message received
  481. * @param[in] msg_size message size
  482. * @param[in] wait_time an optional timeout period (in clock ticks).
  483. If non-zero, your task will wait for a message
  484. to arrive at the queue up to the amount of time
  485. specified by this argument. If you specify 0,
  486. however, your task will wait forever at the
  487. specified queue or, until a message arrives.
  488. *
  489. * @retval TLS_OS_SUCCESS success
  490. * @retval TLS_OS_ERROR failed
  491. *
  492. * @note None
  493. */
  494. tls_os_status_t tls_os_queue_receive(tls_os_queue_t *queue,void **msg,
  495. u32 msg_size,
  496. u32 wait_time);
  497. u8 tls_os_queue_is_empty(tls_os_queue_t *queue);
  498. /**
  499. * @brief Return the number of free spaces available in a queue. This is equal to the
  500. * number of items that can be sent to the queue before the queue becomes full
  501. * if no items are removed.
  502. *
  503. * @param *queue pointer to the event control block associated
  504. with the desired queue
  505. * @return The number of spaces available in the queue.
  506. * @note None
  507. */
  508. u32 tls_os_queue_space_available(tls_os_queue_t *queue);
  509. tls_os_status_t tls_os_queue_remove(tls_os_queue_t *queue, void* msg, u32 msg_size);
  510. /**
  511. * @brief This function creates a message mailbox if free event
  512. control blocks are available.
  513. *
  514. * @param[in] **mailbox pointer to the event control clock (OS_EVENT)
  515. associated with the created mailbox
  516. * @param[in] mailbox_size size
  517. *
  518. * @retval TLS_OS_SUCCESS success
  519. * @retval TLS_OS_ERROR failed
  520. *
  521. * @note None
  522. */
  523. tls_os_status_t tls_os_mailbox_create(tls_os_mailbox_t **mailbox, u32 mailbox_size);
  524. /**
  525. * @brief This function deletes a mailbox and readies all of the tasks
  526. pending on the this mailbox.
  527. *
  528. * @param[in] *mailbox pointer to the event control block
  529. associated with the desired mailbox.
  530. *
  531. * @retval TLS_OS_SUCCESS success
  532. * @retval TLS_OS_ERROR failed
  533. *
  534. * @note None
  535. */
  536. tls_os_status_t tls_os_mailbox_delete(tls_os_mailbox_t *mailbox);
  537. /**
  538. * @brief This function sends a message to a mailbox
  539. *
  540. * @param[in] *mailbox pointer to the event control block associated
  541. with the desired mailbox
  542. * @param[in] *msg pointer to the message to send.
  543. You MUST NOT send a NULL pointer
  544. *
  545. * @retval TLS_OS_SUCCESS success
  546. * @retval TLS_OS_ERROR failed
  547. *
  548. * @note None
  549. */
  550. tls_os_status_t tls_os_mailbox_send(tls_os_mailbox_t *mailbox,void *msg);
  551. /**
  552. * @brief This function waits for a message to be sent to a mailbox
  553. *
  554. * @param[in] *mailbox pointer to the event control block associated
  555. with the desired mailbox
  556. * @param[in] **msg pointer to the message received
  557. * @param[in] wait_time an optional timeout period (in clock ticks).
  558. If non-zero, your task will wait for a message
  559. to arrive at the mailbox up to the amount of
  560. time specified by this argument.
  561. If you specify 0, however, your task will wait
  562. forever at the specified mailbox or,
  563. until a message arrives.
  564. *
  565. *
  566. * @retval TLS_OS_SUCCESS success
  567. * @retval TLS_OS_ERROR failed
  568. *
  569. * @note None
  570. */
  571. tls_os_status_t tls_os_mailbox_receive(tls_os_mailbox_t *mailbox,
  572. void **msg,
  573. u32 wait_time);
  574. /**
  575. * @brief This function is used by your application to obtain the
  576. current value of the 32-bit counter which keeps track
  577. of the number of clock ticks since the system starts.
  578. *
  579. * @param[in] None
  580. *
  581. * @retval current value of OSTime
  582. *
  583. * @note None
  584. */
  585. u32 tls_os_get_time(void);
  586. /**
  587. * @brief This function is used to disable interrupts by preserving
  588. the state of interrupts
  589. *
  590. * @param[in] None
  591. *
  592. * @retval cpu_sr
  593. *
  594. * @note None
  595. */
  596. u32 tls_os_set_critical(void);
  597. /**
  598. * @brief This function is used to enable interrupts by preserving
  599. the state of interrupts
  600. *
  601. * @param[in] cpu_sr
  602. *
  603. * @return None
  604. *
  605. * @note None
  606. */
  607. void tls_os_release_critical(u32 cpu_sr);
  608. /**
  609. * @brief This function is called by your application code to create
  610. a timer
  611. *
  612. * @param[in] **timer pointer to an OS_TMR data structure.
  613. This is the 'handle' that your application will
  614. use to reference the timer created
  615. * @param[in] callback pointer to a callback function that will
  616. be called when the timer expires. The callback
  617. function must be declared as follows
  618. void MyCallback (OS_TMR *ptmr, void *p_arg);
  619. * @param[in] *callback_arg argument (a pointer) that is passed to
  620. the callback function when it is called
  621. * @param[in] period The 'period' being repeated for the timer.
  622. If you specified 'OS_TMR_OPT_PERIODIC' as
  623. an option, when the timer expires, it will
  624. automatically restart with the same period.
  625. * @param[in] repeat if repeat
  626. * @param[in] *name pointer to an ASCII string that is used to
  627. name the timer. Names are useful for
  628. debugging.
  629. *
  630. * @retval TLS_OS_SUCCESS success
  631. * @retval TLS_OS_ERROR failed
  632. *
  633. * @note None
  634. */
  635. tls_os_status_t tls_os_timer_create(tls_os_timer_t **timer,
  636. TLS_OS_TIMER_CALLBACK callback,
  637. void *callback_arg,
  638. u32 period,
  639. bool repeat,
  640. u8 *name);
  641. /**
  642. * @brief This function is called by your application code to start
  643. a timer.
  644. *
  645. * @param[in] *timer pointer to an OS_TMR
  646. *
  647. * @return None
  648. *
  649. * @note None
  650. */
  651. void tls_os_timer_start(tls_os_timer_t *timer);
  652. /*
  653. ************************************************************************************************************************
  654. * CHANGE A TIMER WAIT TIME
  655. *
  656. * Description: This function is called by your application code to change a timer wait time.
  657. *
  658. * Arguments : timer Is a pointer to an OS_TMR
  659. *
  660. * ticks is the wait time
  661. ************************************************************************************************************************
  662. */
  663. void tls_os_timer_change(tls_os_timer_t *timer, u32 ticks);
  664. /**
  665. * @brief This function is called by your application code to stop
  666. a timer
  667. *
  668. * @param[in] *timer pointer to the timer to stop.
  669. *
  670. * @return None
  671. *
  672. * @note None
  673. */
  674. void tls_os_timer_stop(tls_os_timer_t *timer);
  675. /**
  676. * @brief This function is called by your application code to delete
  677. a timer
  678. *
  679. * @param[in] *timer pointer to the timer to delete
  680. *
  681. * @retval TLS_OS_SUCCESS success
  682. * @retval TLS_OS_ERROR failed
  683. *
  684. * @note None
  685. */
  686. tls_os_status_t tls_os_timer_delete(tls_os_timer_t *timer);
  687. /**
  688. * @brief This function is called to delay execution of the currently
  689. running task until the specified number of system
  690. ticks expires. This, of course, directly equates to
  691. delaying the current task for some time to expire.
  692. There will be no delay if the specified delay is 0.
  693. If the specified delay is greater than 0 then,
  694. a context switch will executed.
  695. *
  696. * @param[in] ticks the time delay that the task will be suspended
  697. in number of clock 'ticks'.Note that by specifying 0,
  698. the task will not be delayed.
  699. *
  700. * @return None
  701. *
  702. * @note None
  703. */
  704. void tls_os_time_delay(u32 ticks);
  705. u8 tls_os_timer_active(tls_os_timer_t *timer);
  706. u32 tls_os_timer_expirytime(tls_os_timer_t *timer);
  707. /**
  708. * @brief This function is used to display all the tasks' detail status.
  709. *
  710. * @param[in] None
  711. *
  712. * @return None
  713. *
  714. * @note None
  715. */
  716. void tls_os_disp_task_stat_info(void);
  717. u8 tls_get_isr_count(void);
  718. /**
  719. * @}
  720. */
  721. /**
  722. * @}
  723. */
  724. #endif /* end of WM_OSAL_H */