task #5
@ -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();
|
||||
}
|
||||
|
||||
|
||||
24
drv/stk.h
24
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);
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user