stm32f1xx_HBL/drv/stk.h
Steins7 34fb4dac76 Make stk_read function usable
This function used to return the raw current value, but that exposes the
prescaling used internaly
2024-04-30 20:17:58 +02:00

56 lines
1.3 KiB
C

/** @file stk.h
* Module handling the system timer (systick or STK for short)
*
* The module provides functions to configure and use the system timer embedded
* in the cortex m core
*/
#ifndef _STK_H_
#define _STK_H_
//--includes--------------------------------------------------------------------
#include <stdint.h>
//--type definitions------------------------------------------------------------
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 in µs
*/
uint32_t stk_read_us(void);
#endif //_STK_H_