gr55xx_hal_tim.h
Go to the documentation of this file.
1
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_TIMER_H__
53 #define __GR55xx_HAL_TIMER_H__
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_hal_def.h"
61 #include "gr55xx_ll_tim.h"
62
63 /* Exported types ------------------------------------------------------------*/
75 typedef enum
76 {
77 HAL_TIMER_STATE_RESET = 0x00,
78 HAL_TIMER_STATE_READY = 0x01,
79 HAL_TIMER_STATE_BUSY = 0x02,
80 HAL_TIMER_STATE_ERROR = 0x04
81 } hal_timer_state_t;
97 typedef struct _timer_init
98 {
99 uint32_t auto_reload;
101 } timer_init_t;
102
112 typedef struct _timer_handle
113 {
114 timer_regs_t *p_instance;
116 timer_init_t init;
118 __IO hal_lock_t lock;
120 __IO hal_timer_state_t state;
122 } timer_handle_t;
139 typedef struct _hal_timer_callback
140 {
141 void (*timer_msp_init)(timer_handle_t *p_timer);
142 void (*timer_msp_deinit)(timer_handle_t *p_timer);
143 void (*timer_period_elapsed_callback)(timer_handle_t *p_timer);
144 } hal_timer_callback_t;
145
155 /* Exported macro ------------------------------------------------------------*/
164 #define __HAL_TIMER_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_TIMER_STATE_RESET)
165
170 #define __HAL_TIMER_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL, TIMER_CTRL_EN)
171
176 #define __HAL_TIMER_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, TIMER_CTRL_EN)
177
182 #define __HAL_TIMER_ENABLE_IT(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL, TIMER_CTRL_INTEN)
183
188 #define __HAL_TIMER_DISABLE_IT(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL, TIMER_CTRL_INTEN)
189
194 #define __HAL_TIMER_GET_FLAG_IT(__HANDLE__) ll_timer_is_active_flag_it(__HANDLE__->p_instance)
195
200 #define __HAL_TIMER_CLEAR_FLAG_IT(__HANDLE__) ll_timer_clear_flag_it(__HANDLE__->p_instance)
201
206 /* Exported functions --------------------------------------------------------*/
243 hal_status_t hal_timer_base_init(timer_handle_t *p_timer);
244
256 hal_status_t hal_timer_base_deinit(timer_handle_t *p_timer);
257
267 void hal_timer_base_msp_init(timer_handle_t *p_timer);
268
278 void hal_timer_base_msp_deinit(timer_handle_t *p_timer);
279
291 hal_status_t hal_timer_base_start(timer_handle_t *p_timer);
292
304 hal_status_t hal_timer_base_stop(timer_handle_t *p_timer);
305
317 hal_status_t hal_timer_base_start_it(timer_handle_t *p_timer);
318
330 hal_status_t hal_timer_base_stop_it(timer_handle_t *p_timer);
331
345 void hal_timer_irq_handler(timer_handle_t *p_timer);
346
356 void hal_timer_period_elapsed_callback(timer_handle_t *p_timer);
357
387 hal_timer_state_t hal_timer_get_state(timer_handle_t *p_timer);
388
401 hal_status_t hal_timer_set_config(timer_handle_t *p_timer, timer_init_t *p_structure);
402
407 #ifdef __cplusplus
408 }
409 #endif
410
411 #endif /* __GR55xx_HAL_TIMER_H__ */
412
hal_timer_base_stop
hal_status_t hal_timer_base_stop(timer_handle_t *p_timer)
Stops the TIMER counter.
hal_timer_base_msp_init
void hal_timer_base_msp_init(timer_handle_t *p_timer)
Initialize the TIMER MSP.
gr55xx_ll_tim.h
Header file containing functions prototypes of TIMER LL library.
hal_timer_base_init
hal_status_t hal_timer_base_init(timer_handle_t *p_timer)
Initialize the TIMER according to the specified parameters in the timer_init_t and initialize the ass...
_hal_timer_callback::timer_msp_init
void(* timer_msp_init)(timer_handle_t *p_timer)
Definition: gr55xx_hal_tim.h:141
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
timer_handle_t
struct _timer_handle timer_handle_t
TIMER handle Structure definition.
HAL_TIMER_STATE_BUSY
@ HAL_TIMER_STATE_BUSY
Definition: gr55xx_hal_tim.h:79
_timer_handle::p_instance
timer_regs_t * p_instance
Definition: gr55xx_hal_tim.h:114
hal_timer_base_start_it
hal_status_t hal_timer_base_start_it(timer_handle_t *p_timer)
Starts the TIMER counter in interrupt mode.
hal_timer_base_stop_it
hal_status_t hal_timer_base_stop_it(timer_handle_t *p_timer)
Stops the TIMER counter in interrupt mode.
HAL_TIMER_STATE_RESET
@ HAL_TIMER_STATE_RESET
Definition: gr55xx_hal_tim.h:77
HAL_TIMER_STATE_READY
@ HAL_TIMER_STATE_READY
Definition: gr55xx_hal_tim.h:78
hal_timer_base_start
hal_status_t hal_timer_base_start(timer_handle_t *p_timer)
Starts the TIMER counter.
_timer_handle::state
__IO hal_timer_state_t state
Definition: gr55xx_hal_tim.h:120
_timer_init
TIMER init Structure definition.
Definition: gr55xx_hal_tim.h:98
_timer_handle::lock
__IO hal_lock_t lock
Definition: gr55xx_hal_tim.h:118
_timer_init::auto_reload
uint32_t auto_reload
Definition: gr55xx_hal_tim.h:99
_hal_timer_callback
HAL_TIMER Callback function definition.
Definition: gr55xx_hal_tim.h:140
hal_timer_callback_t
struct _hal_timer_callback hal_timer_callback_t
HAL_TIMER Callback function definition.
HAL_TIMER_STATE_ERROR
@ HAL_TIMER_STATE_ERROR
Definition: gr55xx_hal_tim.h:80
hal_timer_set_config
hal_status_t hal_timer_set_config(timer_handle_t *p_timer, timer_init_t *p_structure)
TIMER configuration.
_timer_handle::init
timer_init_t init
Definition: gr55xx_hal_tim.h:116
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
hal_timer_irq_handler
void hal_timer_irq_handler(timer_handle_t *p_timer)
Handle TIMER interrupt request.
_hal_timer_callback::timer_period_elapsed_callback
void(* timer_period_elapsed_callback)(timer_handle_t *p_timer)
Definition: gr55xx_hal_tim.h:143
_timer_handle
TIMER handle Structure definition.
Definition: gr55xx_hal_tim.h:113
hal_timer_period_elapsed_callback
void hal_timer_period_elapsed_callback(timer_handle_t *p_timer)
Period elapsed callback in non-blocking mode.
hal_timer_base_deinit
hal_status_t hal_timer_base_deinit(timer_handle_t *p_timer)
De-initialize the TIMER peripheral.
timer_init_t
struct _timer_init timer_init_t
TIMER init Structure definition.
_hal_timer_callback::timer_msp_deinit
void(* timer_msp_deinit)(timer_handle_t *p_timer)
Definition: gr55xx_hal_tim.h:142
hal_timer_state_t
hal_timer_state_t
HAL TIMER State Enumerations definition.
Definition: gr55xx_hal_tim.h:76
hal_timer_get_state
hal_timer_state_t hal_timer_get_state(timer_handle_t *p_timer)
Return the TIMER handle state.
hal_timer_base_msp_deinit
void hal_timer_base_msp_deinit(timer_handle_t *p_timer)
De-initialize the TIMER MSP.
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.