Skip to content

Commit 51f0c44

Browse files
author
Liyou Zhou
committed
Instead of printing the data, store data in array, and expose test api.
1 parent cfaf41a commit 51f0c44

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

minar-platform/minar_platform_types.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ typedef uint32_t irqstate_t;
4242
// Internal time type
4343
typedef uint32_t tick_t;
4444

45+
namespace test {
46+
#if YOTTA_CFG_MINAR_TEST_CLOCK_OVERFLOW
47+
uint32_t *get_sleep_until_buf(void);
48+
uint32_t get_sleep_until_buf_tail(void);
49+
#endif
50+
}; // namespace test
51+
4552
}; // namespace platform
4653
}; // namespace minar
4754

source/mbed_platform.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,26 @@ static bool timeIsInPeriod(minar::platform::tick_t start, minar::platform::tick_
3636
namespace minar {
3737
namespace platform {
3838

39+
namespace test {
40+
#if YOTTA_CFG_MINAR_TEST_CLOCK_OVERFLOW
41+
#define BUFFER_SIZE 128
42+
static uint32_t sleep_until_buf[BUFFER_SIZE];
43+
static uint32_t sleep_until_buf_tail = 0;
44+
45+
uint32_t *get_sleep_until_buf(void) {
46+
return (uint32_t *) &sleep_until_buf;
47+
}
48+
49+
uint32_t get_sleep_until_buf_tail(void) {
50+
return sleep_until_buf_tail;
51+
}
52+
53+
uint32_t inc_sleep_until_buf_tail(void) {
54+
return ++sleep_until_buf_tail;
55+
}
56+
#endif
57+
}; // namespace test
58+
3959
irqstate_t pushDisableIRQState(){
4060
uint32_t ret = __get_PRIMASK();
4161
__disable_irq();
@@ -85,7 +105,10 @@ void sleepFromUntil(tick_t now, tick_t until){
85105

86106
const tick_t real_now = timer_top_bits + getTime();
87107

88-
printf("sleep From %lx Until %lx real_now %lx\r\n", now, until, real_now);
108+
uint32_t *buf = test::get_sleep_until_buf();
109+
uint32_t tail = test::get_sleep_until_buf_tail();
110+
buf[tail] = until;
111+
test::inc_sleep_until_buf_tail();
89112
#else
90113
// use real-now for front-most end of do-not-sleep range check
91114
const tick_t real_now = getTime();

0 commit comments

Comments
 (0)