|
STM32 Traffic Control
|
SysTick timer configuration and millisecond utilities. More...
#include "uart.h"#include "systick.h"#include "controller.h"#include <stdio.h>#include <stdint.h>#include "stm32f446xx.h"Macros | |
| #define | SYSTICK_LOAD_VAL 16000 |
| #define | CTRL_ENABLE (1U<<0) |
| #define | CTRL_CLKSRC (1U<<2) |
| #define | CTRL_COUNTFLAG (1U<<16) |
Functions | |
| void | SysTick_Handler (void) |
| SysTick interrupt handler called every 1 millisecond. | |
| void | systick_init (void) |
| Initialize the SysTick timer for 1ms tick interrupts. | |
| uint32_t | systickGetMillis (void) |
| Get the current system uptime in milliseconds. | |
| void | systickDelayMs (int delay) |
| Busy-wait delay for a specified number of milliseconds. | |
Variables | |
| volatile uint32_t | systickMillis = 0 |
SysTick timer configuration and millisecond utilities.
This module configures the Cortex-M4 SysTick timer to generate a 1 ms tick interrupt. It maintains a global millisecond counter ('systickMillis`) and provides functions with time retrieval and busy-wait delays.
| #define CTRL_CLKSRC (1U<<2) |
| #define CTRL_COUNTFLAG (1U<<16) |
| #define CTRL_ENABLE (1U<<0) |
| #define SYSTICK_LOAD_VAL 16000 |
| void SysTick_Handler | ( | void | ) |
SysTick interrupt handler called every 1 millisecond.
Increments the global milliseocnd counter and calls application-specific timeout functions:
| void systick_init | ( | void | ) |
Initialize the SysTick timer for 1ms tick interrupts.
Configures the SysTick LOAD register and control register to generate interrupts every millisecond based on the system clock.
| void systickDelayMs | ( | int | delay | ) |
Busy-wait delay for a specified number of milliseconds.
Uses systickGetMillis() to implement a simple blocking delay.
| delay | Number of milliseconds to wait |
| uint32_t systickGetMillis | ( | void | ) |
Get the current system uptime in milliseconds.
Returns the number of milliseconds elapsed since SysTick initialization.
| volatile uint32_t systickMillis = 0 |