11#ifndef CORTEX_M4_TIMER_H
12#define CORTEX_M4_TIMER_H
18#define RCC_APB1ENR_TIM2_OFFSET 0
19#define RCC_APB1ENR_TIM3_OFFSET 1
20#define RCC_APB1ENR_TIM4_OFFSET 2
21#define RCC_APB1ENR_TIM5_OFFSET 3
23#define RCC_APB2ENR_TIM1_OFFSET 0
24#define RCC_APB2ENR_TIM9_OFFSET 16
25#define RCC_APB2ENR_TIM10_OFFSET 17
26#define RCC_APB2ENR_TIM11_OFFSET 18
29#define SYST_CSR (*(__IO uint32_t *)0xE000E010)
31#define SYST_RVR (*(__IO uint32_t *)0xE000E014)
33#define SYST_CVR (*(__IO uint32_t *)0xE000E018)
35#define SYST_CALIB (*(__IO uint32_t *)0xE000E01C)
36#define SYST_CSR_EN_BIT 0
37#define SYST_CSR_TICKINT_BIT 1
38#define SYST_CSR_CLKSOURCE_BIT 2
68 void (*callback)(
void));
82 uint32_t compare_value);
Hardware Abstraction Layer (HAL) common type definitions.
void delay_us(uint64_t us)
Busy-wait delay in microseconds.
Definition timer.c:79
uint32_t timer_get_compare(hal_timer_t timer, uint32_t channel)
void timer_set_arr(hal_timer_t timer, uint32_t channel, uint32_t arr)
void timer_disable_channel(hal_timer_t timer, uint32_t channel)
void timer_set_auto_reload(hal_timer_t timer, uint32_t arr)
void timer_stop(hal_timer_t timer)
uint32_t timer_get_count(hal_timer_t timer)
void TIM2_IRQHandler(void)
void timer_set_compare(hal_timer_t timer, uint8_t channel, uint32_t compare_value)
uint32_t hal_get_tick_reload_value(void)
Get SysTick reload value.
Definition timer.c:109
void timer_attach_callback(hal_timer_t timer, void(*callback)(void))
void timer_disable_interrupt(hal_timer_t timer)
void timer_start(hal_timer_t timer)
void timer_enable_interrupt(hal_timer_t timer)
void systick_init(uint32_t tick_us)
Initialize the SysTick timer.
Definition timer.c:61
uint32_t timer_get_arr(hal_timer_t timer, uint32_t channel)
void TIM5_IRQHandler(void)
void timer_clear_interrupt_flag(hal_timer_t timer)
uint32_t timer_get_frequency(hal_timer_t timer)
void TIM4_IRQHandler(void)
uint32_t hal_get_millis(void)
Get system uptime in milliseconds.
Definition timer.c:115
void timer_detach_callback(hal_timer_t timer)
uint64_t hal_get_tick(void)
Get current system tick count.
Definition timer.c:97
void TIM9_IRQHandler(void)
void TIM12_IRQHandler(void)
void timer_reset(hal_timer_t timer)
void SysTick_Handler(void)
SysTick interrupt handler.
Definition timer.c:129
void timer_enable_channel(hal_timer_t timer, uint32_t channel)
void delay_ms(uint32_t ms)
Busy-wait delay in milliseconds.
Definition timer.c:91
uint32_t hal_get_tick_duration_us(void)
Get configured tick duration.
Definition timer.c:103
void hal_systick_set_callback(void(*cb)(void))
void TIM3_IRQHandler(void)
void timer_set_prescaler(hal_timer_t timer, uint32_t prescaler)
uint32_t hal_get_micros(void)
Get system uptime in microseconds.
Definition timer.c:121
void timer_init(hal_timer_t timer, uint32_t prescaler, uint32_t auto_reload)
Initialize timer based on type.
Definition timer.c:215
hal_timer_t
Definition timer_types.h:5