Timer and SysTick register defines and API for STM32F4 (Cortex-M4). More...


Go to the source code of this file.
Macros | |
| #define | RCC_APB1ENR_TIM2_OFFSET 0 |
| #define | RCC_APB1ENR_TIM3_OFFSET 1 |
| #define | RCC_APB1ENR_TIM4_OFFSET 2 |
| #define | RCC_APB1ENR_TIM5_OFFSET 3 |
| #define | RCC_APB2ENR_TIM1_OFFSET 0 |
| #define | RCC_APB2ENR_TIM9_OFFSET 16 |
| #define | RCC_APB2ENR_TIM10_OFFSET 17 |
| #define | RCC_APB2ENR_TIM11_OFFSET 18 |
| #define | SYST_CSR (*(__IO uint32_t *)0xE000E010) |
| #define | SYST_RVR (*(__IO uint32_t *)0xE000E014) |
| #define | SYST_CVR (*(__IO uint32_t *)0xE000E018) |
| #define | SYST_CALIB (*(__IO uint32_t *)0xE000E01C) |
| #define | SYST_CSR_EN_BIT 0 |
| #define | SYST_CSR_TICKINT_BIT 1 |
| #define | SYST_CSR_CLKSOURCE_BIT 2 |
Functions | |
| void | systick_init (uint32_t tick_us) |
| Initialize the SysTick timer. | |
| void | delay_ms (uint32_t ms) |
| Busy-wait delay in milliseconds. | |
| void | delay_us (uint64_t us) |
| Busy-wait delay in microseconds. | |
| uint64_t | hal_get_tick (void) |
| Get current system tick count. | |
| uint32_t | hal_get_tick_duration_us (void) |
| Get configured tick duration. | |
| uint32_t | hal_get_tick_reload_value (void) |
| Get SysTick reload value. | |
| uint32_t | hal_get_millis (void) |
| Get system uptime in milliseconds. | |
| uint32_t | hal_get_micros (void) |
| Get system uptime in microseconds. | |
| void | SysTick_Handler (void) |
| SysTick interrupt handler. | |
| void | hal_systick_set_callback (void(*cb)(void)) |
| void | timer_init (hal_timer_t timer, uint32_t prescaler, uint32_t auto_reload) |
| Initialize timer based on type. | |
| void | timer_start (hal_timer_t timer) |
| void | timer_stop (hal_timer_t timer) |
| void | timer_reset (hal_timer_t timer) |
| uint32_t | timer_get_count (hal_timer_t timer) |
| void | timer_enable_interrupt (hal_timer_t timer) |
| void | timer_disable_interrupt (hal_timer_t timer) |
| void | timer_clear_interrupt_flag (hal_timer_t timer) |
| void | timer_attach_callback (hal_timer_t timer, void(*callback)(void)) |
| void | timer_detach_callback (hal_timer_t timer) |
| void | TIM2_IRQHandler (void) |
| void | TIM3_IRQHandler (void) |
| void | TIM4_IRQHandler (void) |
| void | TIM5_IRQHandler (void) |
| void | TIM9_IRQHandler (void) |
| void | TIM12_IRQHandler (void) |
| void | timer_set_compare (hal_timer_t timer, uint8_t channel, uint32_t compare_value) |
| uint32_t | timer_get_compare (hal_timer_t timer, uint32_t channel) |
| uint32_t | timer_get_arr (hal_timer_t timer, uint32_t channel) |
| void | timer_set_arr (hal_timer_t timer, uint32_t channel, uint32_t arr) |
| void | timer_enable_channel (hal_timer_t timer, uint32_t channel) |
| void | timer_disable_channel (hal_timer_t timer, uint32_t channel) |
| uint32_t | timer_get_frequency (hal_timer_t timer) |
| void | timer_set_prescaler (hal_timer_t timer, uint32_t prescaler) |
| void | timer_set_auto_reload (hal_timer_t timer, uint32_t arr) |
Timer and SysTick register defines and API for STM32F4 (Cortex-M4).
This header contains register offsets, bit definitions, SysTick control, timer base addresses, and the public timer/SysTick API used by the HAL. All defines and function prototypes are intended for the STM32F4 series on a Cortex-M4 core.
| #define RCC_APB1ENR_TIM2_OFFSET 0 |
| #define RCC_APB1ENR_TIM3_OFFSET 1 |
| #define RCC_APB1ENR_TIM4_OFFSET 2 |
| #define RCC_APB1ENR_TIM5_OFFSET 3 |
| #define RCC_APB2ENR_TIM10_OFFSET 17 |
| #define RCC_APB2ENR_TIM11_OFFSET 18 |
| #define RCC_APB2ENR_TIM1_OFFSET 0 |
| #define RCC_APB2ENR_TIM9_OFFSET 16 |
| #define SYST_CALIB (*(__IO uint32_t *)0xE000E01C) |
| #define SYST_CSR (*(__IO uint32_t *)0xE000E010) |
| #define SYST_CSR_CLKSOURCE_BIT 2 |
| #define SYST_CSR_EN_BIT 0 |
| #define SYST_CSR_TICKINT_BIT 1 |
| #define SYST_CVR (*(__IO uint32_t *)0xE000E018) |
| #define SYST_RVR (*(__IO uint32_t *)0xE000E014) |
| void delay_ms | ( | uint32_t | ms | ) |
Busy-wait delay in milliseconds.
| ms | Number of milliseconds to delay |
| void delay_us | ( | uint64_t | us | ) |
Busy-wait delay in microseconds.
| us | Number of microseconds to delay |
| uint32_t hal_get_micros | ( | void | ) |
Get system uptime in microseconds.
| uint32_t hal_get_millis | ( | void | ) |
Get system uptime in milliseconds.
| uint64_t hal_get_tick | ( | void | ) |
Get current system tick count.
| uint32_t hal_get_tick_duration_us | ( | void | ) |
Get configured tick duration.
| uint32_t hal_get_tick_reload_value | ( | void | ) |
Get SysTick reload value.
| void hal_systick_set_callback | ( | void(* | cb )(void) | ) |
| void SysTick_Handler | ( | void | ) |
SysTick interrupt handler.
Increments the global tick counter
| void systick_init | ( | uint32_t | tick_us | ) |
Initialize the SysTick timer.
| tick_us | Tick period in microseconds |
Configures SysTick to:
| void TIM12_IRQHandler | ( | void | ) |
| void TIM2_IRQHandler | ( | void | ) |
| void TIM3_IRQHandler | ( | void | ) |
| void TIM4_IRQHandler | ( | void | ) |
| void TIM5_IRQHandler | ( | void | ) |
| void TIM9_IRQHandler | ( | void | ) |
| void timer_attach_callback | ( | hal_timer_t | timer, |
| void(* | callback )(void) ) |
| void timer_clear_interrupt_flag | ( | hal_timer_t | timer | ) |
| void timer_detach_callback | ( | hal_timer_t | timer | ) |
| void timer_disable_channel | ( | hal_timer_t | timer, |
| uint32_t | channel ) |
| void timer_disable_interrupt | ( | hal_timer_t | timer | ) |
| void timer_enable_channel | ( | hal_timer_t | timer, |
| uint32_t | channel ) |
| void timer_enable_interrupt | ( | hal_timer_t | timer | ) |
| uint32_t timer_get_arr | ( | hal_timer_t | timer, |
| uint32_t | channel ) |
| uint32_t timer_get_compare | ( | hal_timer_t | timer, |
| uint32_t | channel ) |
| uint32_t timer_get_count | ( | hal_timer_t | timer | ) |
| uint32_t timer_get_frequency | ( | hal_timer_t | timer | ) |
| void timer_init | ( | hal_timer_t | timer, |
| uint32_t | prescaler, | ||
| uint32_t | auto_reload ) |
Initialize timer based on type.
| timer | Timer identifier |
| prescaler | Prescaler value |
| auto_reload | Auto-reload value |
Start timer counter
| timer | Timer identifier |
Stop timer counter
| timer | Timer identifier |
Set timer compare value for PWM
| timer | Timer identifier |
| channel | Channel number (1-4) |
| compare_value | CCR register value |
Configures PWM mode 1 and enables the channel output
Enable timer channel output
| timer | Timer identifier |
| channel | Channel number (1-4) |
Reset timer counter to zero.
| timer | Timer identifier. |
Get the current counter value for a timer.
| timer | Timer identifier. |
Calculate the timer's current base frequency using PSC and ARR.
| timer | Timer identifier. |
IRQ handler wrapper for TIM2.
Clears the flag and dispatches to the HAL interrupt handler table.
IRQ handler wrapper for TIM3.
IRQ handler wrapper for TIM4.
IRQ handler wrapper for TIM5.
IRQ handler for TIM1 BRK and TIM9 shared vector.
Enable timer interrupts (NVIC + DIER UIE) for supported timers.
| timer | Timer identifier. |
Attach a callback to the timer's HAL interrupt table.
| timer | Timer identifier. |
| callback | Function pointer to call when the timer IRQ fires. |
Detach a previously attached callback for the given timer.
| timer | Timer identifier. |
Set the compare (CCR) register for a timer channel and configure CCMR.
| timer | Timer identifier. |
| channel | Channel number (1-4). |
| compare_value | Value to write into CCRx. |
Disable timer channel output
| timer | Timer identifier |
| channel | Channel number (1-4) |
| void timer_reset | ( | hal_timer_t | timer | ) |
| void timer_set_arr | ( | hal_timer_t | timer, |
| uint32_t | channel, | ||
| uint32_t | arr ) |
| void timer_set_auto_reload | ( | hal_timer_t | timer, |
| uint32_t | arr ) |
| void timer_set_compare | ( | hal_timer_t | timer, |
| uint8_t | channel, | ||
| uint32_t | compare_value ) |
| void timer_set_prescaler | ( | hal_timer_t | timer, |
| uint32_t | prescaler ) |
| void timer_start | ( | hal_timer_t | timer | ) |
| void timer_stop | ( | hal_timer_t | timer | ) |