Document systick module

This commit is contained in:
Steins7 2024-04-28 22:10:15 +02:00
parent ddd05da6eb
commit 7e69bfd89c
2 changed files with 27 additions and 0 deletions

View File

@ -17,6 +17,7 @@
static volatile struct STK* regs = (struct STK*)STK_BASE_ADDRESS; static volatile struct STK* regs = (struct STK*)STK_BASE_ADDRESS;
//--local variables------------------------------------------------------------- //--local variables-------------------------------------------------------------
static StkCallback callback; static StkCallback callback;
@ -80,5 +81,7 @@ uint32_t stk_read(void)
void hdr_sys_tick(void) void hdr_sys_tick(void)
{ {
//clearing the pending bit in SCB_ICSR isn't needed, though I don't know why
callback(); callback();
} }

View File

@ -20,10 +20,34 @@ typedef void (*StkCallback)(void);
//--functions------------------------------------------------------------------- //--functions-------------------------------------------------------------------
/**
* Configures the system timer to run at the specified period in µs and call the
* given callback when said period is reached. Due to the limited configuration
* options, 1.8s is the maximum period when running in speed preset (see rcc
* module). The maximum period can be substantially increased by reducing the
* core clock
*/
uint32_t stk_configure(uint32_t period_us, StkCallback cb); uint32_t stk_configure(uint32_t period_us, StkCallback cb);
/**
* Resets the system timer configuration, restoring the default configuration
* and stopping it
*/
void stk_reset(void); void stk_reset(void);
/**
* Starts the system timer. The timer will run until stopped
*/
void stk_start(void); void stk_start(void);
/**
* Stops the system timer
*/
void stk_stop(void); void stk_stop(void);
/**
* Read the current value of the timer's counter
*/
uint32_t stk_read(void); uint32_t stk_read(void);