gr55xx_hal_dual_tim.h
Go to the documentation of this file.
1
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_DUAL_TIMER_H__
53 #define __GR55xx_HAL_DUAL_TIMER_H__
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_hal_def.h"
61 #include "gr55xx_ll_dual_tim.h"
62
63 /* Exported types ------------------------------------------------------------*/
75 typedef enum
76 {
77 HAL_DUAL_TIMER_STATE_RESET = 0x00,
78 HAL_DUAL_TIMER_STATE_READY = 0x01,
79 HAL_DUAL_TIMER_STATE_BUSY = 0x02,
80 HAL_DUAL_TIMER_STATE_ERROR = 0x04
81 } hal_dual_timer_state_t;
97 typedef struct _dual_timer_init
98 {
99 uint32_t prescaler;
102 uint32_t counter_mode;
105 uint32_t auto_reload;
107 } dual_timer_init_t;
108
118 typedef struct _dual_timer_handle
119 {
120 dual_timer_regs_t *p_instance;
122 dual_timer_init_t init;
124 __IO hal_lock_t lock;
126 __IO hal_dual_timer_state_t state;
128 } dual_timer_handle_t;
145 typedef struct _hal_dual_timer_callback
146 {
147 void (*dual_timer_msp_init)(dual_timer_handle_t *p_dual_timer);
148 void (*dual_timer_msp_deinit)(dual_timer_handle_t *p_dual_timer);
149 void (*dual_timer_period_elapsed_callback)(dual_timer_handle_t *p_dual_timer);
150 } hal_dual_timer_callback_t;
160 /* Exported constants --------------------------------------------------------*/
168 #define DUAL_TIMER_PRESCALER_DIV0 LL_DUAL_TIMER_PRESCALER_DIV0
169 #define DUAL_TIMER_PRESCALER_DIV16 LL_DUAL_TIMER_PRESCALER_DIV16
170 #define DUAL_TIMER_PRESCALER_DIV256 LL_DUAL_TIMER_PRESCALER_DIV256
176 #define DUAL_TIMER_COUNTERMODE_LOOP 0x00000000U
177 #define DUAL_TIMER_COUNTERMODE_ONESHOT DUAL_TIMER_CTRL_ONESHOT
182 /* Exported macro ------------------------------------------------------------*/
183
191 #define __HAL_DUAL_TIMER_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_DUAL_TIMER_STATE_RESET)
192
197 #define __HAL_DUAL_TIMER_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL, DUAL_TIMER_CTRL_EN)
198
203 #define __HAL_DUAL_TIMER_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, DUAL_TIMER_CTRL_EN)
204
209 #define __HAL_DUAL_TIMER_ENABLE_IT(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL, DUAL_TIMER_CTRL_INTEN)
210
215 #define __HAL_DUAL_TIMER_DISABLE_IT(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, DUAL_TIMER_CTRL_INTEN)
216
221 #define __HAL_DUAL_TIMER_GET_FLAG_IT(__HANDLE__) ll_dual_timer_is_active_flag_it(__HANDLE__->p_instance)
222
227 #define __HAL_DUAL_TIMER_CLEAR_FLAG_IT(__HANDLE__) ll_dual_timer_clear_flag_it(__HANDLE__->p_instance)
228
231 /* Private macros ------------------------------------------------------------*/
240 #define IS_DUAL_TIMER_PRESCALER(__PRESCALER__) (((__PRESCALER__) == DUAL_TIMER_PRESCALER_DIV0) || \
241 ((__PRESCALER__) == DUAL_TIMER_PRESCALER_DIV16) || \
242 ((__PRESCALER__) == DUAL_TIMER_PRESCALER_DIV256))
243
248 #define IS_DUAL_TIMER_COUNTERMODE(__MODE__) (((__MODE__) == DUAL_TIMER_COUNTERMODE_LOOP) || \
249 ((__MODE__) == DUAL_TIMER_COUNTERMODE_ONESHOT))
250
254 /* Exported functions --------------------------------------------------------*/
292 hal_status_t hal_dual_timer_base_init(dual_timer_handle_t *p_dual_timer);
293
306 hal_status_t hal_dual_timer_base_deinit(dual_timer_handle_t *p_dual_timer);
307
318 void hal_dual_timer_base_msp_init(dual_timer_handle_t *p_dual_timer);
319
330 void hal_dual_timer_base_msp_deinit(dual_timer_handle_t *p_dual_timer);
331
344 hal_status_t hal_dual_timer_base_start(dual_timer_handle_t *p_dual_timer);
345
358 hal_status_t hal_dual_timer_base_stop(dual_timer_handle_t *p_dual_timer);
359
372 hal_status_t hal_dual_timer_base_start_it(dual_timer_handle_t *p_dual_timer);
373
386 hal_status_t hal_dual_timer_base_stop_it(dual_timer_handle_t *p_dual_timer);
387
402 void hal_dual_timer_irq_handler(dual_timer_handle_t *p_dual_timer);
403
414 void hal_dual_timer_period_elapsed_callback(dual_timer_handle_t *p_dual_timer);
415
446 hal_dual_timer_state_t hal_dual_timer_get_state(dual_timer_handle_t *p_dual_timer);
447
461 hal_status_t hal_dual_timer_set_config(dual_timer_handle_t *p_dual_timer, dual_timer_init_t *p_structure);
462
477 hal_status_t hal_dual_timer_set_background_reload(dual_timer_handle_t *p_dual_timer, uint32_t reload_value);
478
483 #ifdef __cplusplus
484 }
485 #endif
486
487 #endif /* __GR55xx_HAL_DUAL_TIMER_H__ */
488
hal_dual_timer_callback_t
struct _hal_dual_timer_callback hal_dual_timer_callback_t
HAL_DUAL_TIMER Callback function definition.
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
_hal_dual_timer_callback
HAL_DUAL_TIMER Callback function definition.
Definition: gr55xx_hal_dual_tim.h:146
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_get_state
hal_dual_timer_state_t hal_dual_timer_get_state(dual_timer_handle_t *p_dual_timer)
Return the DUAL TIMER handle state.
HAL_DUAL_TIMER_STATE_RESET
@ HAL_DUAL_TIMER_STATE_RESET
Definition: gr55xx_hal_dual_tim.h:77
HAL_DUAL_TIMER_STATE_BUSY
@ HAL_DUAL_TIMER_STATE_BUSY
Definition: gr55xx_hal_dual_tim.h:79
HAL_DUAL_TIMER_STATE_READY
@ HAL_DUAL_TIMER_STATE_READY
Definition: gr55xx_hal_dual_tim.h:78
_hal_dual_timer_callback::dual_timer_msp_init
void(* dual_timer_msp_init)(dual_timer_handle_t *p_dual_timer)
Definition: gr55xx_hal_dual_tim.h:147
HAL_DUAL_TIMER_STATE_ERROR
@ HAL_DUAL_TIMER_STATE_ERROR
Definition: gr55xx_hal_dual_tim.h:80
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 ...
_dual_timer_handle
DUAL_TIMER handle Structure definition.
Definition: gr55xx_hal_dual_tim.h:119
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.
_dual_timer_init::auto_reload
uint32_t auto_reload
Definition: gr55xx_hal_dual_tim.h:105
_dual_timer_handle::p_instance
dual_timer_regs_t * p_instance
Definition: gr55xx_hal_dual_tim.h:120
_hal_dual_timer_callback::dual_timer_msp_deinit
void(* dual_timer_msp_deinit)(dual_timer_handle_t *p_dual_timer)
Definition: gr55xx_hal_dual_tim.h:148
gr55xx_ll_dual_tim.h
Header file containing functions prototypes of DUAL TIMER LL library.
_dual_timer_init
DUAL TIMER init Structure definition.
Definition: gr55xx_hal_dual_tim.h:98
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_base_msp_deinit
void hal_dual_timer_base_msp_deinit(dual_timer_handle_t *p_dual_timer)
De-initialize the DUAL TIMER MSP.
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: gr55xx_hal_dual_tim.h:76
dual_timer_handle_t
struct _dual_timer_handle dual_timer_handle_t
DUAL_TIMER handle Structure definition.
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
_dual_timer_init::counter_mode
uint32_t counter_mode
Definition: gr55xx_hal_dual_tim.h:102
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: gr55xx_hal_dual_tim.h:99
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: gr55xx_hal_dual_tim.h:126
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: gr55xx_hal_dual_tim.h:149
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_set_config
hal_status_t hal_dual_timer_set_config(dual_timer_handle_t *p_dual_timer, dual_timer_init_t *p_structure)
DUAL TIMER configuration.
_dual_timer_handle::init
dual_timer_init_t init
Definition: gr55xx_hal_dual_tim.h:122
_dual_timer_handle::lock
__IO hal_lock_t lock
Definition: gr55xx_hal_dual_tim.h:124
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.
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.