From 7e69bfd89c9c0b3659035871717d81ad9308a9ba Mon Sep 17 00:00:00 2001 From: Steins7 Date: Sun, 28 Apr 2024 22:10:15 +0200 Subject: [PATCH] Document systick module --- drv/stk.c | 3 +++ drv/stk.h | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/drv/stk.c b/drv/stk.c index 6ac0e5d..d865738 100644 --- a/drv/stk.c +++ b/drv/stk.c @@ -17,6 +17,7 @@ static volatile struct STK* regs = (struct STK*)STK_BASE_ADDRESS; + //--local variables------------------------------------------------------------- static StkCallback callback; @@ -80,5 +81,7 @@ uint32_t stk_read(void) void hdr_sys_tick(void) { + //clearing the pending bit in SCB_ICSR isn't needed, though I don't know why callback(); } + diff --git a/drv/stk.h b/drv/stk.h index 3099ff1..d5c5d1d 100644 --- a/drv/stk.h +++ b/drv/stk.h @@ -20,10 +20,34 @@ typedef void (*StkCallback)(void); //--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); + +/** + * Resets the system timer configuration, restoring the default configuration + * and stopping it + */ void stk_reset(void); + +/** + * Starts the system timer. The timer will run until stopped + */ void stk_start(void); + +/** + * Stops the system timer + */ void stk_stop(void); + +/** + * Read the current value of the timer's counter + */ uint32_t stk_read(void);