1 /*
2  * Copyright (C) 2015-2017 Alibaba Group Holding Limited
3  */
4 
5 #include <stdint.h>
6 #include <k_api.h>
7 
8 /** @defgroup cpp_aos_timer
9  *  @ingroup cpp_aos_api
10  * @{
11  */
12 namespace AOS {
13 
14 #define Timer_WAIT_FOREVER 0xFFFFFFFFU
15 
16 /**
17  * @brief Timer Class.
18  *
19  */
20 
21     class Timer
22     {
23       public:
24         /**
25          * This function will create a timer
26          * @param[in]  name      name of the timer
27          * @param[in]  cb        callbak of the timer
28          * @param[in]  millisec  millisec of timer period
29          * @param[in]  arg       the argument of the callback
30          * @return  the operation status, RHINO_SUCCESS is OK, others is error
31          */
32         kstat_t create(const name_t *name, timer_cb_t cb, uint32_t millisec,
33                        void *arg);
34 
35         /**
36          * This function will delete a timer
37          * @param[in]  NULL
38          * @return  the operation status, RHINO_SUCCESS is OK, others is error
39          */
40         kstat_t destory(void);
41 
42         /**
43          * This function will start a timer
44          * @param[in]  NULL
45          * @return  the operation status, RHINO_SUCCESS is OK, others is error
46          */
47         kstat_t start(void);
48 
49         /**
50          * This function will stop a timer
51          * @param[in]  NULL
52          * @return  the operation status, RHINO_SUCCESS is OK, others is error
53          */
54         kstat_t stop(void);
55 
56         /**
57          * This function will get a Semaphore struct pointer
58          * @param[in]  none
59          * @return  Semaphore struct pointer
60          */
61         ktimer_t *self(void);
62 
63       private:
64         /**
65          * @brief a Queue buffer
66          */
67         ktimer_t _timer_def;
68     };
69 
70 }
71 /**
72  * @}
73  */
74