app_tim.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file app_tim.h
5  * @author BLE Driver Team
6  * @brief Header file containing functions prototypes of TIM app library.
7  *
8  ****************************************************************************************
9  * @attention
10  #####Copyright (c) 2019 GOODIX
11  All rights reserved.
12 
13  Redistribution and use in source and binary forms, with or without
14  modification, are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20  * Neither the name of GOODIX nor the names of its contributors may be used
21  to endorse or promote products derived from this software without
22  specific prior written permission.
23 
24  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35  ****************************************************************************************
36  */
37 
38 /** @addtogroup PERIPHERAL Peripheral Driver
39  * @{
40  */
41 
42 /** @addtogroup APP_DRIVER APP DRIVER
43  * @{
44  */
45 
46 /** @defgroup APP_TIMER TIMER
47  * @brief TIMER APP module driver.
48  * @{
49  */
50 
51 
52 #ifndef _APP_TIM_H_
53 #define _APP_TIM_H_
54 
55 #include "gr55xx_hal.h"
56 #include "app_drv_error.h"
57 
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 #ifdef HAL_TIMER_MODULE_ENABLED
63 
64 /** @addtogroup APP_TIM_ENUM Enumerations
65  * @{
66  */
67 
68 /**
69  * @brief TIM module Enumerations definition
70  */
71 typedef enum
72 {
73  APP_TIM_ID_0, /**< TIMER module 0 */
74  APP_TIM_ID_1, /**< TIMER module 1 */
75  APP_TIM_ID_MAX /**< Only for check parameter, not used as input parameters. */
77 
78 /**
79  * @brief TIM event Enumerations definition
80  */
81 typedef enum
82 {
83  APP_TIM_EVT_ERROR, /**< Error reported by TIMER peripheral. */
84  APP_TIM_EVT_DONE /**< Interrupt done by TIMER peripheral. */
86 /** @} */
87 
88 /** @addtogroup APP_TIM_STRUCTURES Structures
89  * @{
90  */
91 
92 /**
93  * @brief TIM parameters structure definition
94  */
95 typedef struct
96 {
97  app_tim_id_t id; /**< specified TIMER module ID. */
98  timer_init_t init; /**< TIMER Base required parameters. */
100 
101 /**
102  * @brief TIM event callback definition
103  */
104 typedef void (*app_tim_evt_handler_t)(app_tim_evt_t *p_evt);
105 
106 /** @} */
107 
108 /* Exported functions --------------------------------------------------------*/
109 /** @addtogroup APP_TIM_DRIVER_FUNCTIONS Functions
110  * @{
111  */
112 /**
113  ****************************************************************************************
114  * @brief Initialize the APP TIM DRIVER according to the specified parameters
115  * in the app_tim_params_t and app_tim_evt_handler_t.
116  *
117  * @param[in] p_params: Pointer to app_tim_params_t parameter which contains the
118  * configuration information for the specified TIM module.
119  * @param[in] evt_handler: TIM user callback function.
120  *
121  * @return Result of initialization.
122  ****************************************************************************************
123  */
124 uint16_t app_tim_init(app_tim_params_t *p_params, app_tim_evt_handler_t evt_handler);
125 
126 /**
127  ****************************************************************************************
128  * @brief De-initialize the APP TIM DRIVER peripheral.
129  *
130  * @param[in] id: De-initialize for a specific ID.
131  *
132  * @return Result of De-initialization.
133  ****************************************************************************************
134  */
136 
137 /**
138  ****************************************************************************************
139  * @brief Starts the TIM counter in interrupt mode.
140  * @param[in] id: which TIM module want to start.
141  *
142  * @return Result of initialization.
143  *
144  ****************************************************************************************
145  */
147 
148 /**
149  ****************************************************************************************
150  * @brief Stops the TIM counter in interrupt mode.
151  * @param[in] id: which TIM module want to stop.
152  *
153  * @return Result of initialization.
154  *
155  ****************************************************************************************
156  */
158 
159 /**
160  ****************************************************************************************
161  * @brief Return the TIM handle.
162  *
163  * @param[in] id: TIM Channel ID.
164  *
165  * @return Pointer to the specified ID's TIM handle.
166  ****************************************************************************************
167  */
169 
170 /** @} */
171 
172 #endif
173 
174 #ifdef __cplusplus
175 }
176 #endif
177 
178 #endif
179 
180 /** @} */
181 /** @} */
182 /** @} */
183 
app_tim_id_t
app_tim_id_t
TIM module Enumerations definition.
Definition: app_tim.h:72
APP_TIM_ID_MAX
@ APP_TIM_ID_MAX
Only for check parameter, not used as input parameters.
Definition: app_tim.h:75
app_tim_stop
uint16_t app_tim_stop(app_tim_id_t id)
Stops the TIM counter in interrupt mode.
app_tim_params_t::init
timer_init_t init
TIMER Base required parameters.
Definition: app_tim.h:98
app_tim_params_t::id
app_tim_id_t id
specified TIMER module ID.
Definition: app_tim.h:97
_timer_init
TIMER init Structure definition.
Definition: gr55xx_hal_tim.h:98
APP_TIM_ID_1
@ APP_TIM_ID_1
TIMER module 1.
Definition: app_tim.h:74
APP_TIM_EVT_ERROR
@ APP_TIM_EVT_ERROR
Error reported by TIMER peripheral.
Definition: app_tim.h:83
app_tim_evt_t
app_tim_evt_t
TIM event Enumerations definition.
Definition: app_tim.h:82
app_tim_params_t
TIM parameters structure definition.
Definition: app_tim.h:96
APP_TIM_ID_0
@ APP_TIM_ID_0
TIMER module 0.
Definition: app_tim.h:73
app_tim_start
uint16_t app_tim_start(app_tim_id_t id)
Starts the TIM counter in interrupt mode.
app_tim_deinit
uint16_t app_tim_deinit(app_tim_id_t id)
De-initialize the APP TIM DRIVER peripheral.
gr55xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
app_tim_init
uint16_t app_tim_init(app_tim_params_t *p_params, app_tim_evt_handler_t evt_handler)
Initialize the APP TIM DRIVER according to the specified parameters in the app_tim_params_t and app_t...
_timer_handle
TIMER handle Structure definition.
Definition: gr55xx_hal_tim.h:113
app_tim_evt_handler_t
void(* app_tim_evt_handler_t)(app_tim_evt_t *p_evt)
TIM event callback definition.
Definition: app_tim.h:104
app_tim_get_handle
timer_handle_t * app_tim_get_handle(app_tim_id_t id)
Return the TIM handle.
app_drv_error.h
Header file of app driver error code.
APP_TIM_EVT_DONE
@ APP_TIM_EVT_DONE
Interrupt done by TIMER peripheral.
Definition: app_tim.h:84