From 03f86ea4834b5f42229fe221a47f0cba03b9fade Mon Sep 17 00:00:00 2001 From: anschrammh Date: Thu, 20 Apr 2023 13:01:50 +0200 Subject: [PATCH] Finished to implement the millis api? It uses the FreeRTOS tick hook function to keep track of running time. --- src/W800_SDK_v1.00.10/app/app_utils/app_utils.c | 11 +++++++++++ src/W800_SDK_v1.00.10/app/app_utils/app_utils.h | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/W800_SDK_v1.00.10/app/app_utils/app_utils.c b/src/W800_SDK_v1.00.10/app/app_utils/app_utils.c index 158317a..8863202 100644 --- a/src/W800_SDK_v1.00.10/app/app_utils/app_utils.c +++ b/src/W800_SDK_v1.00.10/app/app_utils/app_utils.c @@ -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; diff --git a/src/W800_SDK_v1.00.10/app/app_utils/app_utils.h b/src/W800_SDK_v1.00.10/app/app_utils/app_utils.h index 08b8144..c4f178b 100644 --- a/src/W800_SDK_v1.00.10/app/app_utils/app_utils.h +++ b/src/W800_SDK_v1.00.10/app/app_utils/app_utils.h @@ -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 */