summaryrefslogtreecommitdiff
path: root/platforms
diff options
context:
space:
mode:
authorAndre Brait <andrebrait@gmail.com>2023-09-25 04:48:55 +0200
committerGitHub <noreply@github.com>2023-09-25 12:48:55 +1000
commit960d6e0d7d8007ee826184967dc1edc5ab7b2755 (patch)
treee6c429f3086e0c51ad84e25e16c5c5fd1c937425 /platforms
parentdd94877ec6d2ee5c4cdb0e71287abd76585b0268 (diff)
[Enhancement] Improvements for debounce test coverage + bug fixes for sym_defer_g and sym_eager_pr (#21667)
Co-authored-by: Nebuleon <2391500+Nebuleon@users.noreply.github.com>
Diffstat (limited to 'platforms')
-rw-r--r--platforms/test/timer.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/platforms/test/timer.c b/platforms/test/timer.c
index 320cc57782..eb929d7dac 100644
--- a/platforms/test/timer.c
+++ b/platforms/test/timer.c
@@ -17,34 +17,65 @@
#include "timer.h"
#include <stdatomic.h>
-static atomic_uint_least32_t current_time = 0;
+static atomic_uint_least32_t current_time = 0;
+static atomic_uint_least32_t async_tick_amount = 0;
+static atomic_uint_least32_t access_counter = 0;
+
+void simulate_async_tick(uint32_t t) {
+ async_tick_amount = t;
+}
+
+uint32_t timer_read_internal(void) {
+ return current_time;
+}
+
+uint32_t current_access_counter(void) {
+ return access_counter;
+}
+
+void reset_access_counter(void) {
+ access_counter = 0;
+}
void timer_init(void) {
- current_time = 0;
+ current_time = 0;
+ async_tick_amount = 0;
+ access_counter = 0;
}
void timer_clear(void) {
- current_time = 0;
+ current_time = 0;
+ async_tick_amount = 0;
+ access_counter = 0;
}
uint16_t timer_read(void) {
- return current_time & 0xFFFF;
+ return (uint16_t)timer_read32();
}
+
uint32_t timer_read32(void) {
+ if (access_counter++ > 0) {
+ current_time += async_tick_amount;
+ }
return current_time;
}
+
uint16_t timer_elapsed(uint16_t last) {
return TIMER_DIFF_16(timer_read(), last);
}
+
uint32_t timer_elapsed32(uint32_t last) {
return TIMER_DIFF_32(timer_read32(), last);
}
void set_time(uint32_t t) {
- current_time = t;
+ current_time = t;
+ access_counter = 0;
}
+
void advance_time(uint32_t ms) {
current_time += ms;
+ access_counter = 0;
}
void wait_ms(uint32_t ms) {