Finished to implement the millis api? It uses the FreeRTOS tick hook function to keep track of running time.
This commit is contained in:
parent
2df2f332bf
commit
03f86ea483
@ -3,6 +3,12 @@
|
||||
|
||||
static uint32_t _elapsed_ms = 0;
|
||||
|
||||
void vApplicationTickHook(void)
|
||||
{
|
||||
/* One tick is 2 ms because configTICK_RATE_HZ = 500. */
|
||||
_elapsed_ms += 2;
|
||||
}
|
||||
|
||||
void us_delay(uint32_t us)
|
||||
{
|
||||
struct tls_timer_cfg timer_config =
|
||||
@ -55,6 +61,11 @@ void ms_delay(uint32_t ms)
|
||||
tls_timer_destroy(timer_id);
|
||||
}
|
||||
|
||||
void ms_increment(uint32_t increment)
|
||||
{
|
||||
_elapsed_ms += increment;
|
||||
}
|
||||
|
||||
uint32_t elapsed_ms(void)
|
||||
{
|
||||
return _elapsed_ms;
|
||||
|
@ -18,7 +18,14 @@ void us_delay(uint32_t us);
|
||||
void ms_delay(uint32_t ms);
|
||||
|
||||
/**
|
||||
* @brief Returns the current milli seconds count elapsed since the start of the program.
|
||||
* @brief Manually increment the millisecond counter.
|
||||
*
|
||||
* @param increment amount of milliseconds to add to the current @ref elapsed_ms count.
|
||||
*/
|
||||
void ms_increment(uint32_t increment);
|
||||
|
||||
/**
|
||||
* @brief Returns the current milliseconds count elapsed since the start of the program.
|
||||
*
|
||||
* @return uint32_t the elapsed time in ms
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user