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;
|
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)
|
void us_delay(uint32_t us)
|
||||||
{
|
{
|
||||||
struct tls_timer_cfg timer_config =
|
struct tls_timer_cfg timer_config =
|
||||||
@ -55,6 +61,11 @@ void ms_delay(uint32_t ms)
|
|||||||
tls_timer_destroy(timer_id);
|
tls_timer_destroy(timer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ms_increment(uint32_t increment)
|
||||||
|
{
|
||||||
|
_elapsed_ms += increment;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t elapsed_ms(void)
|
uint32_t elapsed_ms(void)
|
||||||
{
|
{
|
||||||
return _elapsed_ms;
|
return _elapsed_ms;
|
||||||
|
@ -17,6 +17,13 @@ void us_delay(uint32_t us);
|
|||||||
*/
|
*/
|
||||||
void ms_delay(uint32_t ms);
|
void ms_delay(uint32_t ms);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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.
|
* @brief Returns the current milliseconds count elapsed since the start of the program.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user