app_dual_tim.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file app_dual_tim.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of DAUL 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 /** @addtogroup PERIPHERAL Peripheral Driver
38 * @{
39 */
40
41 /** @addtogroup APP_DRIVER APP DRIVER
42 * @{
43 */
44
45 /** @defgroup APP_DUAL_TIMER DUAL TIMER
46 * @brief DUAL TIMER APP module driver.
47 * @{
48 */
49
50
51 #ifndef _APP_DUAL_TIM_H_
52 #define _APP_DUAL_TIM_H_
53
54 #include "gr55xx_hal.h"
55 #include "app_drv_error.h"
56
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60
61 #ifdef HAL_DUAL_TIMER_MODULE_ENABLED
62
63 /** @addtogroup APP_TIM_ENUM Enumerations
64 * @{
65 */
66
67 /**
68 * @brief APP_DUAL_TIM module Enumerations definition
69 */
70 typedef enum
71 {
72 APP_DUAL_TIM_ID_0, /**< DUAL TIMER module 0 */
73 APP_DUAL_TIM_ID_1, /**< DUAL TIMER module 1 */
74 APP_DUAL_TIM_ID_MAX /**< Only for check parameter, not used as input parameters. */
75 } app_dual_tim_id_t;
76
77 /**
78 * @brief DUAL_TIM event Enumerations definition
79 */
80 typedef enum
81 {
82 APP_DUAL_TIM_EVT_ERROR, /**< Error reported by DUAL TIMER peripheral. */
83 APP_DUAL_TIM_EVT_DONE /**< Interrupt done by DUAL TIMER peripheral. */
84 } app_dual_tim_evt_t;
85 /** @} */
86
87 /** @addtogroup APP_DUAL_TIM_STRUCTURES Structures
88 * @{
89 */
90
91 /**
92 * @brief DUAL_TIM parameters structure definition
93 */
94 typedef struct
95 {
96 app_dual_tim_id_t id; /**< specified DUAL TIMER module ID. */
97 dual_timer_init_t init; /**< DUAL_TIM Base required parameters. */
98 } app_dual_tim_params_t;
99
100 /**
101 * @brief APP_DUAL_TIM event callback definition
102 */
103 typedef void (*app_dual_tim_evt_handler_t)(app_dual_tim_evt_t *p_evt);
104
105 /** @} */
106
107 /* Exported functions --------------------------------------------------------*/
108 /** @addtogroup APP_DUAL_TIM_DRIVER_FUNCTIONS Functions
109 * @{
110 */
111 /**
112 ****************************************************************************************
113 * @brief Initialize the APP DUAL TIM DRIVER according to the specified parameters
114 * in the app_dual_tim_params_t and app_dual_tim_evt_handler_t.
115 *
116 * @param[in] p_params: Pointer to app_dual_tim_params_t parameter which contains the
117 * configuration information for the specified DUAL TIM module.
118 * @param[in] evt_handler: DUAL TIM user callback function.
119 *
120 * @return Result of initialization.
121 ****************************************************************************************
122 */
123 uint16_t app_dual_tim_init(app_dual_tim_params_t *p_params, app_dual_tim_evt_handler_t evt_handler);
124
125 /**
126 ****************************************************************************************
127 * @brief De-initialize the APP DUAL TIM DRIVER peripheral.
128 *
129 * @param[in] id: De-initialize for a specific ID.
130 *
131 * @return Result of De-initialization.
132 ****************************************************************************************
133 */
134 uint16_t app_dual_tim_deinit(app_dual_tim_id_t id);
135
136 /**
137 ****************************************************************************************
138 * @brief Starts the DUAL TIM counter in interrupt mode.
139 * @param[in] id: which DUAL TIM module want to start.
140 *
141 * @return Result of execution.
142 *
143 ****************************************************************************************
144 */
145 uint16_t app_dual_tim_start(app_dual_tim_id_t id);
146
147 /**
148 ****************************************************************************************
149 * @brief Stops the DUAL TIM counter in interrupt mode.
150 * @param[in] id: which DUAL TIM module want to stop.
151 *
152 * @return Result of execution.
153 *
154 ****************************************************************************************
155 */
156 uint16_t app_dual_tim_stop(app_dual_tim_id_t id);
157
158 /**
159 ****************************************************************************************
160 * @brief Set the APP DUAL TIM according to the specified parameters
161 *
162 * @param[in] p_params: Pointer to app_dual_tim_params_t parameter which contains the
163 * configuration information for the specified DUAL TIM module.
164 * @param[in] id: A specific timer ID which can be APP_DUAL_TIM_ID_0 or APP_DUAL_TIM_ID_1
165 *
166 * @return Result of execution.
167 ****************************************************************************************
168 */
169 uint16_t app_dual_tim_set_params(app_dual_tim_params_t *p_params, app_dual_tim_id_t id);
170
171 /**
172 ****************************************************************************************
173 * @brief Set the APP DUAL TIM background reload value
174 * The background reload value contains the value from which the counter is to decrement.
175 * This is the value used to reload the counter when Periodic mode is enabled, and the current count reaches 0.
176 * @param[in] id: A specific timer ID which can be APP_DUAL_TIM_ID_0 or APP_DUAL_TIM_ID_1
177 * @param[in] reload_value: Background reload value
178 *
179 * @return Result of execution.
180 ****************************************************************************************
181 */
182 uint16_t app_dual_tim_set_background_reload(app_dual_tim_id_t id, uint32_t reload_value);
183
184 /**
185 ****************************************************************************************
186 * @brief Return the DUAL TIM handle.
187 *
188 * @param[in] id: DUAL TIM Channel ID.
189 *
190 * @return Pointer to the specified ID's DUAL TIM handle.
191 ****************************************************************************************
192 */
193 dual_timer_handle_t *app_dual_tim_get_handle(app_dual_tim_id_t id);
194
195 /** @} */
196
197 #endif
198
199 #ifdef __cplusplus
200 }
201 #endif
202
203 #endif
204
205 /** @} */
206 /** @} */
207 /** @} */
APP_DUAL_TIM_EVT_ERROR
@ APP_DUAL_TIM_EVT_ERROR
Error reported by DUAL TIMER peripheral.
Definition: app_dual_tim.h:82
app_dual_tim_params_t
DUAL_TIM parameters structure definition.
Definition: app_dual_tim.h:95
app_dual_tim_evt_t
app_dual_tim_evt_t
DUAL_TIM event Enumerations definition.
Definition: app_dual_tim.h:81
app_dual_tim_set_params
uint16_t app_dual_tim_set_params(app_dual_tim_params_t *p_params, app_dual_tim_id_t id)
Set the APP DUAL TIM according to the specified parameters.
app_dual_tim_params_t::init
dual_timer_init_t init
DUAL_TIM Base required parameters.
Definition: app_dual_tim.h:97
app_dual_tim_get_handle
dual_timer_handle_t * app_dual_tim_get_handle(app_dual_tim_id_t id)
Return the DUAL TIM handle.
app_dual_tim_params_t::id
app_dual_tim_id_t id
specified DUAL TIMER module ID.
Definition: app_dual_tim.h:96
app_dual_tim_set_background_reload
uint16_t app_dual_tim_set_background_reload(app_dual_tim_id_t id, uint32_t reload_value)
Set the APP DUAL TIM background reload value The background reload value contains the value from whic...
app_dual_tim_evt_handler_t
void(* app_dual_tim_evt_handler_t)(app_dual_tim_evt_t *p_evt)
APP_DUAL_TIM event callback definition.
Definition: app_dual_tim.h:103
_dual_timer_handle
DUAL_TIMER handle Structure definition.
Definition: gr55xx_hal_dual_tim.h:119
app_dual_tim_id_t
app_dual_tim_id_t
APP_DUAL_TIM module Enumerations definition.
Definition: app_dual_tim.h:71
APP_DUAL_TIM_ID_1
@ APP_DUAL_TIM_ID_1
DUAL TIMER module 1.
Definition: app_dual_tim.h:73
APP_DUAL_TIM_ID_0
@ APP_DUAL_TIM_ID_0
DUAL TIMER module 0.
Definition: app_dual_tim.h:72
_dual_timer_init
DUAL TIMER init Structure definition.
Definition: gr55xx_hal_dual_tim.h:98
APP_DUAL_TIM_ID_MAX
@ APP_DUAL_TIM_ID_MAX
Only for check parameter, not used as input parameters.
Definition: app_dual_tim.h:74
APP_DUAL_TIM_EVT_DONE
@ APP_DUAL_TIM_EVT_DONE
Interrupt done by DUAL TIMER peripheral.
Definition: app_dual_tim.h:83
app_dual_tim_stop
uint16_t app_dual_tim_stop(app_dual_tim_id_t id)
Stops the DUAL TIM counter in interrupt mode.
gr55xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
app_dual_tim_start
uint16_t app_dual_tim_start(app_dual_tim_id_t id)
Starts the DUAL TIM counter in interrupt mode.
app_dual_tim_deinit
uint16_t app_dual_tim_deinit(app_dual_tim_id_t id)
De-initialize the APP DUAL TIM DRIVER peripheral.
app_drv_error.h
Header file of app driver error code.
app_dual_tim_init
uint16_t app_dual_tim_init(app_dual_tim_params_t *p_params, app_dual_tim_evt_handler_t evt_handler)
Initialize the APP DUAL TIM DRIVER according to the specified parameters in the app_dual_tim_params_t...