hal_dual_tim.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file hal_dual_tim.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of DUAL TIMER HAL 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 HAL_DRIVER HAL Driver
43 * @{
44 */
45
46 /** @defgroup HAL_DUAL_TIMER DUAL TIMER
47 * @brief DUAL TIM HAL module driver.
48 * @{
49 */
50
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef HAL_DUAL_TIMER_H
53 #define HAL_DUAL_TIMER_H
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "hal_def.h"
61 #include "ll_dual_tim.h"
62
63 /* Exported types ------------------------------------------------------------*/
64 /** @addtogroup HAL_DUAL_TIMER_ENUMERATIONS Enumerations
65 * @{
66 */
67
68 /** @defgroup HAL_DUAL_TIMER_state HAL DUAL TIM state
69 * @{
70 */
71
72 /**
73 * @brief HAL DUAL TIMER State Enumerations definition
74 */
75 typedef enum
76 {
77 HAL_DUAL_TIMER_STATE_RESET = 0x00, /**< Peripheral not yet initialized or disabled */
78 HAL_DUAL_TIMER_STATE_READY = 0x01, /**< Peripheral Initialized and ready for use */
79 HAL_DUAL_TIMER_STATE_BUSY = 0x02, /**< An internal process is ongoing */
80 HAL_DUAL_TIMER_STATE_ERROR = 0x04 /**< Reception process is ongoing */
81 } hal_dual_timer_state_t;
82 /** @} */
83
84 /** @defgroup HAL_DUAL_TIMER_channel HAL DUAL TIM channel
85 * @{
86 */
87
88 /**
89 * @brief HAL DUAL TIMER Channel Enumerations definition
90 */
91 typedef enum
92 {
93 HAL_DUAL_TIMER_CHANNEL_A = 0x00, /**< Channel A */
94 HAL_DUAL_TIMER_CHANNEL_B = 0x01, /**< Channel B */
95 HAL_DUAL_TIMER_CHANNEL_C = 0x02, /**< Channel C */
96 } hal_dual_timer_channel_t;
97 /** @} */
98
99 /** @} */
100
101 /** @addtogroup HAL_DUAL_TIMER_STRUCTURES Structures
102 * @{
103 */
104
105 /** @defgroup DUAL_TIMER_Configuration DUAL TIMER Configuration
106 * @{
107 */
108
109 /**
110 * @brief DUAL TIMER init Structure definition
111 */
112 typedef struct _dual_timer_init
113 {
114 uint32_t prescaler; /**< Specifies the prescaler value used to divide the DUAL_TIMER clock.
115 This parameter can be a value of @ref DUAL_TIMER_Prescaler_Div */
116
117 uint32_t counter_mode; /**< Specifies the counter mode.
118 This parameter can be a value of @ref DUAL_TIMER_Counter_Mode */
119
120 uint32_t auto_reload; /**< Specifies the auto-reload value. */
121
122 } dual_timer_init_t;
123
124 /**
125 * @brief DUAL TIMER io crtl config Structure definition
126 */
127 typedef struct _dual_timer_io_ctrl_cfg
128 {
129 hal_dual_timer_channel_t channel; /**< Specifies the channel.
130 This parameter can be a value of @ref HAL_DUAL_TIMER_channel */
131 uint32_t count1_value; /**< Specifies the count1 value.
132 The value is set to 0 to not use this count function */
133 uint32_t count2_value; /**< Specifies the count2 value.
134 The value is set to 0 to not use this count function */
135 uint32_t io_init_state; /**< Specifies the io initial state.
136 This parameter can be a value of @ref DUAL_TIMER_IO_Init_State */
137 uint32_t start_act_mode; /**< Specifies the start action mode.
138 This parameter can be a value of @ref DUAL_TIMER_IO_Act_Mode */
139 uint32_t period_act_mode; /**< Specifies the period action mode.
140 This parameter can be a value of @ref DUAL_TIMER_IO_Act_Mode */
141 uint32_t stop_act_mode; /**< Specifies the stop action mode.
142 This parameter can be a value of @ref DUAL_TIMER_IO_Act_Mode */
143 uint32_t count1_act_mode; /**< Specifies the count1 action mode.
144 This parameter can be a value of @ref DUAL_TIMER_IO_Act_Mode */
145 uint32_t count2_act_mode; /**< Specifies the count2 action mode.
146 This parameter can be a value of @ref DUAL_TIMER_IO_Act_Mode */
147 uint32_t start_act_it; /**< Specifies the start action interrupt config. */
148 uint32_t period_act_it; /**< Specifies the period action interrupt config. */
149 uint32_t stop_act_it; /**< Specifies the stop action interrupt config. */
150 uint32_t count1_act_it; /**< Specifies the count1 action interrupt config. */
151 uint32_t count2_act_it; /**< Specifies the count2 action interrupt config. */
152 } dual_timer_io_ctrl_cfg_t;
153
154 /** @} */
155
156 /** @defgroup DUAL_TIMER_handle DUAL TIMER handle
157 * @{
158 */
159
160 /**
161 * @brief DUAL_TIMER handle Structure definition
162 */
163 typedef struct _dual_timer_handle
164 {
165 dual_timer_regs_t *p_instance; /**< Register base address */
166
167 dual_timer_init_t init; /**< DUAL_TIMER Base required parameters */
168
169 dual_timer_io_ctrl_cfg_t io_crtl_cfg; /**< DUAL_TIMER io crtl required parameters. */
170
171 __IO hal_dual_timer_state_t state; /**< DUAL_TIMER operation state */
172
173 } dual_timer_handle_t;
174 /** @} */
175
176 /** @} */
177
178 /** @addtogroup HAL_DUAL_TIMER_CALLBACK_STRUCTURES Callback Structures
179 * @{
180 */
181
182 /** @defgroup HAL_DUAL_TIMER_Callback Callback
183 * @{
184 */
185
186 /**
187 * @brief HAL_DUAL_TIMER Callback function definition
188 */
189
190 typedef struct _hal_dual_timer_callback
191 {
192 void (*dual_timer_msp_init)(dual_timer_handle_t *p_dual_timer); /**< DUAL_TIMER init MSP callback */
193 void (*dual_timer_msp_deinit)(dual_timer_handle_t *p_dual_timer); /**< DUAL_TIMER de-init MSP callback */
194 void (*dual_timer_period_elapsed_callback)(dual_timer_handle_t *p_dual_timer); /**< DUAL_TIMER period elapsed callback */
195 } hal_dual_timer_callback_t;
196 /** @} */
197
198 /** @} */
199
200 /**
201 * @defgroup HAL_DUAL_TIMER_MACRO Defines
202 * @{
203 */
204
205 /* Exported constants --------------------------------------------------------*/
206 /** @defgroup DUAL_TIMER_Exported_Constants DUAL TIMER Exported Constants
207 * @{
208 */
209
210 /** @defgroup DUAL_TIMER_Prescaler_Div DUAL TIMER Prescaler Division
211 * @{
212 */
213 #define DUAL_TIMER_PRESCALER_DIV0 LL_DUAL_TIMER_PRESCALER_DIV0 /**< 0 stage of prescale, clock is divided by 1. */
214 #define DUAL_TIMER_PRESCALER_DIV16 LL_DUAL_TIMER_PRESCALER_DIV16 /**< 4 stages of prescale, clock is divided by 16. */
215 #define DUAL_TIMER_PRESCALER_DIV256 LL_DUAL_TIMER_PRESCALER_DIV256 /**< 8 stages of prescale, clock is divided by 256. */
216 /** @} */
217
218 /** @defgroup DUAL_TIMER_Counter_Mode DUAL TIMER Counter Mode
219 * @{
220 */
221 #define DUAL_TIMER_COUNTERMODE_LOOP 0x00000000U /**< DUAL TIMER Loop mode.*/
222 #define DUAL_TIMER_COUNTERMODE_ONESHOT DUAL_TIMER_CTRL_ONESHOT /**< DUAL TIMER One-shot mode. */
223 /** @} */
224
225 /** @defgroup DUAL_TIMER_IO_Init_State DUAL TIMER IO Initial State
226 * @{
227 */
228 #define DUAL_TIMER_IO_INIT_RESET LL_DUAL_TIMER_IO_INIT_RESET /**< io init reset */
229 #define DUAL_TIMER_IO_INIT_SET LL_DUAL_TIMER_IO_INIT_SET /**< io init set */
230 /** @} */
231
232 /** @defgroup DUAL_TIMER_IO_Act_Mode DUAL TIMER IO Action Mode
233 * @{
234 */
235 #define DUAL_TIMER_IO_ACTION_NONE LL_DUAL_TIMER_IO_ACTION_NONE /**< io action: do noting */
236 #define DUAL_TIMER_IO_ACTION_SET LL_DUAL_TIMER_IO_ACTION_SET /**< io action: set */
237 #define DUAL_TIMER_IO_ACTION_RESET LL_DUAL_TIMER_IO_ACTION_RESET /**< io action: reset */
238 #define DUAL_TIMER_IO_ACTION_TOGGLE LL_DUAL_TIMER_IO_ACTION_TOGGLE /**< io action: toggle */
239 /** @} */
240
241 /** @} */
242
243 /* Exported macro ------------------------------------------------------------*/
244 /** @defgroup DUAL_TIMER_Exported_Macros DUAL TIMER Exported Macros
245 * @{
246 */
247
248 /** @brief Reset DUAL TIMER handle states.
249 * @param __HANDLE__ DUAL TIMER handle.
250 * @retval None
251 */
252 #define __HAL_DUAL_TIMER_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_DUAL_TIMER_STATE_RESET)
253
254 /** @brief Enable the specified DUAL TIMER peripheral.
255 * @param __HANDLE__ Specifies the DUAL TIMER Handle.
256 * @retval None
257 */
258 #define __HAL_DUAL_TIMER_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL, DUAL_TIMER_CTRL_EN)
259
260 /** @brief Disable the specified DUAL TIMER peripheral.
261 * @param __HANDLE__ Specifies the DUAL TIMER Handle.
262 * @retval None
263 */
264 #define __HAL_DUAL_TIMER_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, DUAL_TIMER_CTRL_EN)
265
266 /** @brief Enable the DUAL TIMER interrupt.
267 * @param __HANDLE__ Specifies the DUAL TIM Handle.
268 * @retval None
269 */
270 #define __HAL_DUAL_TIMER_ENABLE_IT(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL, DUAL_TIMER_CTRL_INTEN)
271
272 /** @brief Disable the DUAL TIMER interrupt.
273 * @param __HANDLE__ Specifies the DUAL TIM Handle.
274 * @retval None
275 */
276 #define __HAL_DUAL_TIMER_DISABLE_IT(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, DUAL_TIMER_CTRL_INTEN)
277
278 /** @brief Check whether the DUAL TIMER interrupt has occurred or not.
279 * @param __HANDLE__ Specifies the DUAL TIMER Handle.
280 * @retval The new state of DUAL TIMER interrupt (SET or RESET).
281 */
282 #define __HAL_DUAL_TIMER_GET_FLAG_IT(__HANDLE__) ll_dual_timer_is_active_flag_it(__HANDLE__->p_instance)
283
284 /** @brief Clear the DUAL TIMER interrupt flag.
285 * @param __HANDLE__ Specifies the DUAL TIMER Handle.
286 * @retval None.
287 */
288 #define __HAL_DUAL_TIMER_CLEAR_FLAG_IT(__HANDLE__) ll_dual_timer_clear_flag_it(__HANDLE__->p_instance)
289
290 /** @} */
291
292 /* Private macros ------------------------------------------------------------*/
293 /** @defgroup DUAL_TIMER_Private_Macros DUAL TIMER Private Macros
294 * @{
295 */
296
297 /** @brief Check if DUAL TIMER prescaler is valid.
298 * @param __PRESCALER__ DUAL TIMER prescaler.
299 * @retval SET (__PRESCALER__ is valid) or RESET (__PRESCALER__ is invalid)
300 */
301 #define IS_DUAL_TIMER_PRESCALER(__PRESCALER__) (((__PRESCALER__) == DUAL_TIMER_PRESCALER_DIV0) || \
302 ((__PRESCALER__) == DUAL_TIMER_PRESCALER_DIV16) || \
303 ((__PRESCALER__) == DUAL_TIMER_PRESCALER_DIV256))
304
305 /** @brief Check if DUAL TIMER counter mode is valid.
306 * @param __MODE__ DUAL TIMER counter mode.
307 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
308 */
309 #define IS_DUAL_TIMER_COUNTERMODE(__MODE__) (((__MODE__) == DUAL_TIMER_COUNTERMODE_LOOP) || \
310 ((__MODE__) == DUAL_TIMER_COUNTERMODE_ONESHOT))
311
312 /** @brief Check if DUAL TIMER io initial state is valid.
313 * @param __MODE__ DUAL TIMER io initial state.
314 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
315 */
316 #define IS_DUAL_TIMER_IO_INIT_STATE(__MODE__) (((__MODE__) == DUAL_TIMER_IO_INIT_RESET) || \
317 ((__MODE__) == DUAL_TIMER_IO_INIT_SET))
318
319 /** @brief Check if DUAL TIMER io action mode is valid.
320 * @param __MODE__ DUAL TIMER io action mode.
321 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
322 */
323 #define IS_DUAL_TIMER_IO_ACT_MODE(__MODE__) (((__MODE__) == DUAL_TIMER_IO_ACTION_NONE) || \
324 ((__MODE__) == DUAL_TIMER_IO_ACTION_SET)) || \
325 ((__MODE__) == DUAL_TIMER_IO_ACTION_RESET)) || \
326 ((__MODE__) == DUAL_TIMER_IO_ACTION_TOGGLE))
327
328 /** @} */
329
330 /** @} */
331
332 /* Exported functions --------------------------------------------------------*/
333 /** @addtogroup HAL_DUAL_TIMER_DRIVER_FUNCTIONS Functions
334 * @{
335 */
336
337 /** @addtogroup DUAL_TIMER_Exported_Functions_Group1 Initialization and de-initialization functions
338 * @brief Initialization and de-initialization functions
339 *
340 * @verbatim
341 ===============================================================================
342 ##### Initialization and de-initialization functions #####
343 ===============================================================================
344 [..]
345 This section provides functions allowing to:
346 (+) Initialize and configure the DUAL TIMER.
347 (+) De-initialize the DUAL TIMER.
348 (+) Start the Timer.
349 (+) Stop the Timer.
350 (+) Start the Timer and enable interrupt.
351 (+) Stop the Timer and disable interrupt.
352
353 @endverbatim
354 * @{
355 */
356
357 /**
358 ****************************************************************************************
359 * @brief Initialize the DUAL TIMER according to the specified parameters
360 * in the dual_timer_init_t and initialize the associated handle.
361 *
362 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
363 *
364 * @retval ::HAL_OK: Operation is OK.
365 * @retval ::HAL_ERROR: Parameter error or operation not supported.
366 * @retval ::HAL_BUSY: Driver is busy.
367 * @retval ::HAL_TIMEOUT: Timeout occurred.
368 ****************************************************************************************
369 */
370 hal_status_t hal_dual_timer_base_init(dual_timer_handle_t *p_dual_timer);
371
372 /**
373 ****************************************************************************************
374 * @brief De-initialize the DUAL TIMER peripheral.
375 *
376 * @param[in] p_dual_timer: Pointer to a DUAL_TIM handle which contains the configuration information for the specified DUAL TIMER.
377 *
378 * @retval ::HAL_OK: Operation is OK.
379 * @retval ::HAL_ERROR: Parameter error or operation not supported.
380 * @retval ::HAL_BUSY: Driver is busy.
381 * @retval ::HAL_TIMEOUT: Timeout occurred.
382 ****************************************************************************************
383 */
384 hal_status_t hal_dual_timer_base_deinit(dual_timer_handle_t *p_dual_timer);
385
386 /**
387 ****************************************************************************************
388 * @brief Initialize the DUAL TIMER MSP.
389 *
390 * @note This function should not be modified. When the callback is needed,
391 * the hal_dual_timer_base_msp_init could be implemented in the user file
392 *
393 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
394 ****************************************************************************************
395 */
396 void hal_dual_timer_base_msp_init(dual_timer_handle_t *p_dual_timer);
397
398 /**
399 ****************************************************************************************
400 * @brief De-initialize the DUAL TIMER MSP.
401 *
402 * @note This function should not be modified. When the callback is needed,
403 * the hal_dual_timer_base_msp_deinit could be implemented in the user file
404 *
405 * @param[in] p_dual_timer: Pointer to a DUAL_TIM handle which contains the configuration information for the specified DUAL TIMER.
406 ****************************************************************************************
407 */
408 void hal_dual_timer_base_msp_deinit(dual_timer_handle_t *p_dual_timer);
409
410 /**
411 ****************************************************************************************
412 * @brief Starts the DUAL TIMER counter.
413 *
414 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
415 *
416 * @retval ::HAL_OK: Operation is OK.
417 * @retval ::HAL_ERROR: Parameter error or operation not supported.
418 * @retval ::HAL_BUSY: Driver is busy.
419 * @retval ::HAL_TIMEOUT: Timeout occurred.
420 ****************************************************************************************
421 */
422 hal_status_t hal_dual_timer_base_start(dual_timer_handle_t *p_dual_timer);
423
424 /**
425 ****************************************************************************************
426 * @brief Stops the DUAL TIMER counter.
427 *
428 * @param[in] p_dual_timer: Pointer to a DUAL_TIM handle which contains the configuration information for the specified DUAL TIMER.
429 *
430 * @retval ::HAL_OK: Operation is OK.
431 * @retval ::HAL_ERROR: Parameter error or operation not supported.
432 * @retval ::HAL_BUSY: Driver is busy.
433 * @retval ::HAL_TIMEOUT: Timeout occurred.
434 ****************************************************************************************
435 */
436 hal_status_t hal_dual_timer_base_stop(dual_timer_handle_t *p_dual_timer);
437
438 /**
439 ****************************************************************************************
440 * @brief Starts the DUAL TIMER counter in interrupt mode.
441 *
442 * @param[in] p_dual_timer: Pointer to a DUAL_TIM handle which contains the configuration information for the specified DUAL TIMER.
443 *
444 * @retval ::HAL_OK: Operation is OK.
445 * @retval ::HAL_ERROR: Parameter error or operation not supported.
446 * @retval ::HAL_BUSY: Driver is busy.
447 * @retval ::HAL_TIMEOUT: Timeout occurred.
448 ****************************************************************************************
449 */
450 hal_status_t hal_dual_timer_base_start_it(dual_timer_handle_t *p_dual_timer);
451
452 /**
453 ****************************************************************************************
454 * @brief Stops the DUAL TIMER counter in interrupt mode.
455 *
456 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
457 *
458 * @retval ::HAL_OK: Operation is OK.
459 * @retval ::HAL_ERROR: Parameter error or operation not supported.
460 * @retval ::HAL_BUSY: Driver is busy.
461 * @retval ::HAL_TIMEOUT: Timeout occurred.
462 ****************************************************************************************
463 */
464 hal_status_t hal_dual_timer_base_stop_it(dual_timer_handle_t *p_dual_timer);
465
466 /** @} */
467
468 /** @addtogroup DUAL_TIMER_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
469 * @brief IRQ Handler and Callbacks functions
470 * @{
471 */
472
473 /**
474 ****************************************************************************************
475 * @brief Handle DUAL TIMER interrupt request.
476 *
477 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
478 ****************************************************************************************
479 */
480 void hal_dual_timer_irq_handler(dual_timer_handle_t *p_dual_timer);
481
482 /**
483 ****************************************************************************************
484 * @brief Period elapsed callback in non-blocking mode.
485 *
486 * @note This function should not be modified. When the callback is needed,
487 * the hal_dual_timer_period_elapsed_callback can be implemented in the user file.
488 *
489 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
490 ****************************************************************************************
491 */
492 void hal_dual_timer_period_elapsed_callback(dual_timer_handle_t *p_dual_timer);
493
494 /**
495 ****************************************************************************************
496 * @brief Action when timer start callback in non-blocking mode.
497 *
498 * @note This function should not be modified. When the callback is needed,
499 * the hal_dual_timer_act_start_event_callback can be implemented in the user file.
500 *
501 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
502 ****************************************************************************************
503 */
504 void hal_dual_timer_act_start_event_callback(dual_timer_handle_t *p_dual_timer);
505
506 /**
507 ****************************************************************************************
508 * @brief Action when timer value meets to COUNT_A1IO callback in non-blocking mode.
509 *
510 * @note This function should not be modified. When the callback is needed,
511 * the hal_dual_timer_ioa_act_c1_event_callback can be implemented in the user file.
512 *
513 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
514 ****************************************************************************************
515 */
516 void hal_dual_timer_ioa_act_c1_event_callback(dual_timer_handle_t *p_dual_timer);
517
518 /**
519 ****************************************************************************************
520 * @brief Action when timer value meets to COUNT_A2IO callback in non-blocking mode.
521 *
522 * @note This function should not be modified. When the callback is needed,
523 * the hal_dual_timer_ioa_act_c1_event_callback can be implemented in the user file.
524 *
525 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
526 ****************************************************************************************
527 */
528 void hal_dual_timer_ioa_act_c2_event_callback(dual_timer_handle_t *p_dual_timer);
529
530 /**
531 ****************************************************************************************
532 * @brief Action when timer value meets to 0 callback in non-blocking mode.
533 *
534 * @note This function should not be modified. When the callback is needed,
535 * the hal_dual_timer_act_period_event_callback can be implemented in the user file.
536 *
537 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
538 ****************************************************************************************
539 */
540 void hal_dual_timer_act_period_event_callback(dual_timer_handle_t *p_dual_timer);
541
542 /**
543 ****************************************************************************************
544 * @brief Action when timer stop callback in non-blocking mode.
545 *
546 * @note This function should not be modified. When the callback is needed,
547 * the hal_dual_timer_act_stop_event_callback can be implemented in the user file.
548 *
549 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
550 ****************************************************************************************
551 */
552 void hal_dual_timer_act_stop_event_callback(dual_timer_handle_t *p_dual_timer);
553
554 /**
555 ****************************************************************************************
556 * @brief Action when timer value meets to COUNT_B1IO callback in non-blocking mode.
557 *
558 * @note This function should not be modified. When the callback is needed,
559 * the hal_dual_timer_iob_act_c1_event_callback can be implemented in the user file.
560 *
561 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
562 ****************************************************************************************
563 */
564 void hal_dual_timer_iob_act_c1_event_callback(dual_timer_handle_t *p_dual_timer);
565
566 /**
567 ****************************************************************************************
568 * @brief Action when timer value meets to COUNT_B2IO callback in non-blocking mode.
569 *
570 * @note This function should not be modified. When the callback is needed,
571 * the hal_dual_timer_iob_act_c1_event_callback can be implemented in the user file.
572 *
573 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
574 ****************************************************************************************
575 */
576 void hal_dual_timer_iob_act_c2_event_callback(dual_timer_handle_t *p_dual_timer);
577
578 /**
579 ****************************************************************************************
580 * @brief Action when timer value meets to COUNT_C1IO callback in non-blocking mode.
581 *
582 * @note This function should not be modified. When the callback is needed,
583 * the hal_dual_timer_ioc_act_c1_event_callback can be implemented in the user file.
584 *
585 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
586 ****************************************************************************************
587 */
588 void hal_dual_timer_ioc_act_c1_event_callback(dual_timer_handle_t *p_dual_timer);
589
590 /**
591 ****************************************************************************************
592 * @brief Action when timer value meets to COUNT_C2IO callback in non-blocking mode.
593 *
594 * @note This function should not be modified. When the callback is needed,
595 * the hal_dual_timer_ioc_act_c1_event_callback can be implemented in the user file.
596 *
597 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
598 ****************************************************************************************
599 */
600 void hal_dual_timer_ioc_act_c2_event_callback(dual_timer_handle_t *p_dual_timer);
601
602 /**
603 ****************************************************************************************
604 * @brief Action when timer value meets to BLE_COUNT1 callback in non-blocking mode.
605 *
606 * @note This function should not be modified. When the callback is needed,
607 * the hal_dual_timer_ioc_act_c1_event_callback can be implemented in the user file.
608 *
609 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
610 ****************************************************************************************
611 */
612 void hal_dual_timer_ble_pulse1_event_callback(dual_timer_handle_t *p_dual_timer);
613
614 /**
615 ****************************************************************************************
616 * @brief Action when timer value meets to BLE_COUNT2 callback in non-blocking mode.
617 *
618 * @note This function should not be modified. When the callback is needed,
619 * the hal_dual_timer_ioc_act_c1_event_callback can be implemented in the user file.
620 *
621 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
622 ****************************************************************************************
623 */
624 void hal_dual_timer_ble_pulse2_event_callback(dual_timer_handle_t *p_dual_timer);
625
626 /** @} */
627
628 /** @addtogroup DUAL_TIMER_Exported_Functions_Group2 Peripheral Control and State functions
629 * @brief DUAL TIMER Peripheral State functions
630 *
631 @verbatim
632 ==============================================================================
633 ##### Peripheral Control and State functions #####
634 ==============================================================================
635 [..]
636 This subsection provides functions allowing to :
637 (+) Return the DUAL TIMER handle state.
638 (+) Configure the DUAL TIMER.
639
640 @endverbatim
641 * @{
642 */
643
644 /**
645 ****************************************************************************************
646 * @brief Return the DUAL TIMER handle state.
647 *
648 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
649 *
650 * @retval ::HAL_DUAL_TIMER_STATE_RESET: Peripheral not yet initialized or disabled.
651 * @retval ::HAL_DUAL_TIMER_STATE_READY: Peripheral Initialized and ready for use.
652 * @retval ::HAL_DUAL_TIMER_STATE_BUSY: An internal process is ongoing.
653 * @retval ::HAL_DUAL_TIMER_STATE_ERROR: Reception process is ongoing.
654 ****************************************************************************************
655 */
656 hal_dual_timer_state_t hal_dual_timer_get_state(const dual_timer_handle_t *p_dual_timer);
657
658 /**
659 ****************************************************************************************
660 * @brief DUAL TIMER configuration
661 *
662 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
663 * @param[in] p_structure: The DUAL TIMER configuration structure
664 *
665 * @retval ::HAL_OK: Operation is OK.
666 * @retval ::HAL_ERROR: Parameter error or operation not supported.
667 * @retval ::HAL_BUSY: Driver is busy.
668 * @retval ::HAL_TIMEOUT: Timeout occurred.
669 ****************************************************************************************
670 */
671 hal_status_t hal_dual_timer_set_config(dual_timer_handle_t *p_dual_timer, const dual_timer_init_t *p_structure);
672
673 /**
674 ****************************************************************************************
675 * @brief DUAL TIMER set background reload value
676 * The background reload value contains the value from which the counter is to decrement.
677 * This is the value used to reload the counter when Periodic mode is enabled, and the current count reaches 0.
678 * The difference is that writes to background reload value do not cause the counter to immediately restart from the new value.
679 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
680 * @param[in] reload_value: Background reload value
681 *
682 * @retval ::HAL_OK: Operation is OK.
683 * @retval ::HAL_ERROR: Parameter error or operation not supported.
684 * @retval ::HAL_BUSY: Driver is busy.
685 ****************************************************************************************
686 */
687 hal_status_t hal_dual_timer_set_background_reload(dual_timer_handle_t *p_dual_timer, uint32_t reload_value);
688
689 /**
690 ****************************************************************************************
691 * @brief DUAL TIMER set one-time reload value
692 * The one-time reload value contains the value from which the counter is to decrement.
693 * This is the value used to reload the counter when Periodic mode is enabled, and the current count reaches 0.
694 * The difference is that writes to one-time reload value do not cause the counter to immediately restart from the new value.
695 * The one-time reload value only takes effect in the next cycle. It has higher priority than background reload.
696 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
697 * @param[in] reload_value: One-time reload value
698 *
699 * @retval ::HAL_OK: Operation is OK.
700 * @retval ::HAL_ERROR: Parameter error or operation not supported.
701 * @retval ::HAL_BUSY: Driver is busy.
702 ****************************************************************************************
703 */
704 hal_status_t hal_dual_timer_set_onetime_reload(const dual_timer_handle_t *p_dual_timer, uint32_t reload_value);
705
706 /**
707 ****************************************************************************************
708 * @brief DUAL TIMER set period count value
709 * The value is valid when the value is greater than 1. This fucntion is only avaliable in Period/Loop mode with IO control.
710 * This function call must be after hal_dual_timer_io_crtl_config.
711 * This function will force the stop action interrupt to be turned on.
712 * If the current count value of the dual timer is not the period value, it may cause the first period to be shortened.
713 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
714 * @param[in] count_value: period count value
715 *
716 * @retval ::HAL_OK: Operation is OK.
717 * @retval ::HAL_ERROR: Parameter error or operation not supported.
718 * @retval ::HAL_BUSY: Driver is busy.
719 ****************************************************************************************
720 */
721 hal_status_t hal_dual_timer_set_period_count(const dual_timer_handle_t *p_dual_timer, uint32_t count_value);
722
723 /**
724 ****************************************************************************************
725 * @brief DUAL TIMER io ctrl configuration
726 * This function call must be after hal_dual_timer_base_init.
727 *
728 * @param[in] p_dual_timer: Pointer to a DUAL_TIMER handle which contains the configuration information for the specified DUAL TIMER.
729 * @param[in] p_structure: The DUAL TIMER io crtl configuration structure
730 *
731 * @retval ::HAL_OK: Operation is OK.
732 * @retval ::HAL_ERROR: Parameter error or operation not supported.
733 * @retval ::HAL_BUSY: Driver is busy.
734 * @retval ::HAL_TIMEOUT: Timeout occurred.
735 ****************************************************************************************
736 */
737 hal_status_t hal_dual_timer_io_crtl_config(const dual_timer_handle_t *p_dual_timer, const dual_timer_io_ctrl_cfg_t *p_structure);
738
739 /** @} */
740
741 /** @} */
742
743 #ifdef __cplusplus
744 }
745 #endif
746
747 #endif /* HAL_DUAL_TIMER_H */
748
749 /** @} */
750
751 /** @} */
752
753 /** @} */
hal_dual_timer_callback_t
struct _hal_dual_timer_callback hal_dual_timer_callback_t
HAL_DUAL_TIMER Callback function definition.
hal_dual_timer_act_stop_event_callback
void hal_dual_timer_act_stop_event_callback(dual_timer_handle_t *p_dual_timer)
Action when timer stop callback in non-blocking mode.
hal_dual_timer_get_state
hal_dual_timer_state_t hal_dual_timer_get_state(const dual_timer_handle_t *p_dual_timer)
Return the DUAL TIMER handle state.
_dual_timer_io_ctrl_cfg::period_act_it
uint32_t period_act_it
Definition: hal_dual_tim.h:148
_hal_dual_timer_callback
HAL_DUAL_TIMER Callback function definition.
Definition: hal_dual_tim.h:191
hal_dual_timer_base_deinit
hal_status_t hal_dual_timer_base_deinit(dual_timer_handle_t *p_dual_timer)
De-initialize the DUAL TIMER peripheral.
HAL_DUAL_TIMER_STATE_RESET
@ HAL_DUAL_TIMER_STATE_RESET
Definition: hal_dual_tim.h:77
HAL_DUAL_TIMER_STATE_BUSY
@ HAL_DUAL_TIMER_STATE_BUSY
Definition: hal_dual_tim.h:79
dual_timer_io_ctrl_cfg_t
struct _dual_timer_io_ctrl_cfg dual_timer_io_ctrl_cfg_t
DUAL TIMER io crtl config Structure definition.
HAL_DUAL_TIMER_STATE_READY
@ HAL_DUAL_TIMER_STATE_READY
Definition: hal_dual_tim.h:78
_dual_timer_io_ctrl_cfg::io_init_state
uint32_t io_init_state
Definition: hal_dual_tim.h:135
_dual_timer_io_ctrl_cfg::period_act_mode
uint32_t period_act_mode
Definition: hal_dual_tim.h:139
_hal_dual_timer_callback::dual_timer_msp_init
void(* dual_timer_msp_init)(dual_timer_handle_t *p_dual_timer)
Definition: hal_dual_tim.h:192
_dual_timer_io_ctrl_cfg::stop_act_mode
uint32_t stop_act_mode
Definition: hal_dual_tim.h:141
hal_dual_timer_channel_t
hal_dual_timer_channel_t
HAL DUAL TIMER Channel Enumerations definition.
Definition: hal_dual_tim.h:92
HAL_DUAL_TIMER_STATE_ERROR
@ HAL_DUAL_TIMER_STATE_ERROR
Definition: hal_dual_tim.h:80
_dual_timer_handle::io_crtl_cfg
dual_timer_io_ctrl_cfg_t io_crtl_cfg
Definition: hal_dual_tim.h:169
hal_dual_timer_set_background_reload
hal_status_t hal_dual_timer_set_background_reload(dual_timer_handle_t *p_dual_timer, uint32_t reload_value)
DUAL TIMER set background reload value The background reload value contains the value from which the ...
ll_dual_tim.h
Header file containing functions prototypes of DUAL TIMER LL library.
HAL_DUAL_TIMER_CHANNEL_B
@ HAL_DUAL_TIMER_CHANNEL_B
Definition: hal_dual_tim.h:94
hal_dual_timer_io_crtl_config
hal_status_t hal_dual_timer_io_crtl_config(const dual_timer_handle_t *p_dual_timer, const dual_timer_io_ctrl_cfg_t *p_structure)
DUAL TIMER io ctrl configuration This function call must be after hal_dual_timer_base_init.
_dual_timer_io_ctrl_cfg::stop_act_it
uint32_t stop_act_it
Definition: hal_dual_tim.h:149
_dual_timer_handle
DUAL_TIMER handle Structure definition.
Definition: hal_dual_tim.h:164
hal_dual_timer_base_stop
hal_status_t hal_dual_timer_base_stop(dual_timer_handle_t *p_dual_timer)
Stops the DUAL TIMER counter.
hal_dual_timer_act_period_event_callback
void hal_dual_timer_act_period_event_callback(dual_timer_handle_t *p_dual_timer)
Action when timer value meets to 0 callback in non-blocking mode.
_dual_timer_init::auto_reload
uint32_t auto_reload
Definition: hal_dual_tim.h:120
_dual_timer_io_ctrl_cfg::count1_act_mode
uint32_t count1_act_mode
Definition: hal_dual_tim.h:143
_dual_timer_io_ctrl_cfg::start_act_mode
uint32_t start_act_mode
Definition: hal_dual_tim.h:137
_dual_timer_io_ctrl_cfg
DUAL TIMER io crtl config Structure definition.
Definition: hal_dual_tim.h:128
hal_dual_timer_ble_pulse2_event_callback
void hal_dual_timer_ble_pulse2_event_callback(dual_timer_handle_t *p_dual_timer)
Action when timer value meets to BLE_COUNT2 callback in non-blocking mode.
_dual_timer_handle::p_instance
dual_timer_regs_t * p_instance
Definition: hal_dual_tim.h:165
_hal_dual_timer_callback::dual_timer_msp_deinit
void(* dual_timer_msp_deinit)(dual_timer_handle_t *p_dual_timer)
Definition: hal_dual_tim.h:193
hal_dual_timer_iob_act_c2_event_callback
void hal_dual_timer_iob_act_c2_event_callback(dual_timer_handle_t *p_dual_timer)
Action when timer value meets to COUNT_B2IO callback in non-blocking mode.
hal_dual_timer_set_onetime_reload
hal_status_t hal_dual_timer_set_onetime_reload(const dual_timer_handle_t *p_dual_timer, uint32_t reload_value)
DUAL TIMER set one-time reload value The one-time reload value contains the value from which the coun...
hal_dual_timer_set_period_count
hal_status_t hal_dual_timer_set_period_count(const dual_timer_handle_t *p_dual_timer, uint32_t count_value)
DUAL TIMER set period count value The value is valid when the value is greater than 1....
hal_dual_timer_set_config
hal_status_t hal_dual_timer_set_config(dual_timer_handle_t *p_dual_timer, const dual_timer_init_t *p_structure)
DUAL TIMER configuration.
_dual_timer_io_ctrl_cfg::count2_value
uint32_t count2_value
Definition: hal_dual_tim.h:133
HAL_DUAL_TIMER_CHANNEL_A
@ HAL_DUAL_TIMER_CHANNEL_A
Definition: hal_dual_tim.h:93
_dual_timer_io_ctrl_cfg::start_act_it
uint32_t start_act_it
Definition: hal_dual_tim.h:147
_dual_timer_init
DUAL TIMER init Structure definition.
Definition: hal_dual_tim.h:113
hal_dual_timer_base_start
hal_status_t hal_dual_timer_base_start(dual_timer_handle_t *p_dual_timer)
Starts the DUAL TIMER counter.
hal_dual_timer_ioc_act_c2_event_callback
void hal_dual_timer_ioc_act_c2_event_callback(dual_timer_handle_t *p_dual_timer)
Action when timer value meets to COUNT_C2IO callback in non-blocking mode.
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr_common.h:140
hal_dual_timer_base_msp_deinit
void hal_dual_timer_base_msp_deinit(dual_timer_handle_t *p_dual_timer)
De-initialize the DUAL TIMER MSP.
hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
hal_dual_timer_base_start_it
hal_status_t hal_dual_timer_base_start_it(dual_timer_handle_t *p_dual_timer)
Starts the DUAL TIMER counter in interrupt mode.
hal_dual_timer_state_t
hal_dual_timer_state_t
HAL DUAL TIMER State Enumerations definition.
Definition: hal_dual_tim.h:76
hal_dual_timer_ioc_act_c1_event_callback
void hal_dual_timer_ioc_act_c1_event_callback(dual_timer_handle_t *p_dual_timer)
Action when timer value meets to COUNT_C1IO callback in non-blocking mode.
dual_timer_handle_t
struct _dual_timer_handle dual_timer_handle_t
DUAL_TIMER handle Structure definition.
_dual_timer_io_ctrl_cfg::channel
hal_dual_timer_channel_t channel
Definition: hal_dual_tim.h:129
_dual_timer_init::counter_mode
uint32_t counter_mode
Definition: hal_dual_tim.h:117
hal_dual_timer_ioa_act_c1_event_callback
void hal_dual_timer_ioa_act_c1_event_callback(dual_timer_handle_t *p_dual_timer)
Action when timer value meets to COUNT_A1IO callback in non-blocking mode.
hal_dual_timer_iob_act_c1_event_callback
void hal_dual_timer_iob_act_c1_event_callback(dual_timer_handle_t *p_dual_timer)
Action when timer value meets to COUNT_B1IO callback in non-blocking mode.
_dual_timer_io_ctrl_cfg::count1_act_it
uint32_t count1_act_it
Definition: hal_dual_tim.h:150
hal_dual_timer_base_init
hal_status_t hal_dual_timer_base_init(dual_timer_handle_t *p_dual_timer)
Initialize the DUAL TIMER according to the specified parameters in the dual_timer_init_t and initiali...
_dual_timer_init::prescaler
uint32_t prescaler
Definition: hal_dual_tim.h:114
dual_timer_init_t
struct _dual_timer_init dual_timer_init_t
DUAL TIMER init Structure definition.
hal_dual_timer_irq_handler
void hal_dual_timer_irq_handler(dual_timer_handle_t *p_dual_timer)
Handle DUAL TIMER interrupt request.
_dual_timer_handle::state
__IO hal_dual_timer_state_t state
Definition: hal_dual_tim.h:171
hal_dual_timer_ioa_act_c2_event_callback
void hal_dual_timer_ioa_act_c2_event_callback(dual_timer_handle_t *p_dual_timer)
Action when timer value meets to COUNT_A2IO callback in non-blocking mode.
hal_dual_timer_period_elapsed_callback
void hal_dual_timer_period_elapsed_callback(dual_timer_handle_t *p_dual_timer)
Period elapsed callback in non-blocking mode.
_hal_dual_timer_callback::dual_timer_period_elapsed_callback
void(* dual_timer_period_elapsed_callback)(dual_timer_handle_t *p_dual_timer)
Definition: hal_dual_tim.h:194
hal_dual_timer_base_stop_it
hal_status_t hal_dual_timer_base_stop_it(dual_timer_handle_t *p_dual_timer)
Stops the DUAL TIMER counter in interrupt mode.
hal_dual_timer_act_start_event_callback
void hal_dual_timer_act_start_event_callback(dual_timer_handle_t *p_dual_timer)
Action when timer start callback in non-blocking mode.
HAL_DUAL_TIMER_CHANNEL_C
@ HAL_DUAL_TIMER_CHANNEL_C
Definition: hal_dual_tim.h:95
_dual_timer_handle::init
dual_timer_init_t init
Definition: hal_dual_tim.h:167
_dual_timer_io_ctrl_cfg::count1_value
uint32_t count1_value
Definition: hal_dual_tim.h:131
_dual_timer_io_ctrl_cfg::count2_act_mode
uint32_t count2_act_mode
Definition: hal_dual_tim.h:145
hal_dual_timer_base_msp_init
void hal_dual_timer_base_msp_init(dual_timer_handle_t *p_dual_timer)
Initialize the DUAL TIMER MSP.
hal_dual_timer_ble_pulse1_event_callback
void hal_dual_timer_ble_pulse1_event_callback(dual_timer_handle_t *p_dual_timer)
Action when timer value meets to BLE_COUNT1 callback in non-blocking mode.
_dual_timer_io_ctrl_cfg::count2_act_it
uint32_t count2_act_it
Definition: hal_dual_tim.h:151