@@ -55,6 +55,18 @@ extern uint32_t SystemCoreClock;
55
55
#define DELTA_MS (delay_ms ) (1 + ((delay_ms) * US_PER_MSEC / 20 / US_PER_MSEC))
56
56
#define DELTA_S (delay_ms ) (0 .000500f + (((float )(delay_ms)) / MSEC_PER_SEC / 20 ))
57
57
58
+ void busy_wait_us (int us)
59
+ {
60
+ const ticker_data_t *const ticker = get_us_ticker_data ();
61
+ uint32_t start = ticker_read (ticker);
62
+ while ((ticker_read (ticker) - start) < (uint32_t )us);
63
+ }
64
+
65
+ void busy_wait_ms (int ms)
66
+ {
67
+ busy_wait_us (ms * US_PER_MSEC);
68
+ }
69
+
58
70
/* This test verifies if low power timer is stopped after
59
71
* creation.
60
72
*
@@ -74,7 +86,7 @@ void test_lptimer_creation()
74
86
75
87
/* Wait 10 ms.
76
88
* After that operation timer read routines should still return 0. */
77
- wait_ms (10 );
89
+ busy_wait_ms (10 );
78
90
79
91
/* Check results. */
80
92
TEST_ASSERT_EQUAL_FLOAT (0 , lp_timer.read ());
@@ -102,7 +114,7 @@ void test_lptimer_time_accumulation()
102
114
lp_timer.start ();
103
115
104
116
/* Wait 10 ms. */
105
- wait_ms (10 );
117
+ busy_wait_ms (10 );
106
118
107
119
/* Stop the timer. */
108
120
lp_timer.stop ();
@@ -116,15 +128,15 @@ void test_lptimer_time_accumulation()
116
128
/* Wait 50 ms - this is done to show that time elapsed when
117
129
* the timer is stopped does not have influence on the
118
130
* timer counted time. */
119
- wait_ms (50 );
131
+ busy_wait_ms (50 );
120
132
121
133
/* ------ */
122
134
123
135
/* Start the timer. */
124
136
lp_timer.start ();
125
137
126
138
/* Wait 20 ms. */
127
- wait_ms (20 );
139
+ busy_wait_ms (20 );
128
140
129
141
/* Stop the timer. */
130
142
lp_timer.stop ();
@@ -145,7 +157,7 @@ void test_lptimer_time_accumulation()
145
157
lp_timer.start ();
146
158
147
159
/* Wait 30 ms. */
148
- wait_ms (30 );
160
+ busy_wait_ms (30 );
149
161
150
162
/* Stop the timer. */
151
163
lp_timer.stop ();
@@ -159,15 +171,15 @@ void test_lptimer_time_accumulation()
159
171
/* Wait 50 ms - this is done to show that time elapsed when
160
172
* the timer is stopped does not have influence on the
161
173
* timer time. */
162
- wait_ms (50 );
174
+ busy_wait_ms (50 );
163
175
164
176
/* ------ */
165
177
166
178
/* Start the timer. */
167
179
lp_timer.start ();
168
180
169
181
/* Wait 1 sec. */
170
- wait_ms (1000 );
182
+ busy_wait_ms (1000 );
171
183
172
184
/* Stop the timer. */
173
185
lp_timer.stop ();
@@ -196,7 +208,7 @@ void test_lptimer_reset()
196
208
lp_timer.start ();
197
209
198
210
/* Wait 10 ms. */
199
- wait_ms (10 );
211
+ busy_wait_ms (10 );
200
212
201
213
/* Stop the timer. */
202
214
lp_timer.stop ();
@@ -214,7 +226,7 @@ void test_lptimer_reset()
214
226
lp_timer.start ();
215
227
216
228
/* Wait 20 ms. */
217
- wait_ms (20 );
229
+ busy_wait_ms (20 );
218
230
219
231
/* Stop the timer. */
220
232
lp_timer.stop ();
@@ -241,13 +253,13 @@ void test_lptimer_start_started_timer()
241
253
lp_timer.start ();
242
254
243
255
/* Wait 10 ms. */
244
- wait_ms (10 );
256
+ busy_wait_ms (10 );
245
257
246
258
/* Now start timer again. */
247
259
lp_timer.start ();
248
260
249
261
/* Wait 20 ms. */
250
- wait_ms (20 );
262
+ busy_wait_ms (20 );
251
263
252
264
/* Stop the timer. */
253
265
lp_timer.stop ();
@@ -274,7 +286,7 @@ void test_lptimer_float_operator()
274
286
lp_timer.start ();
275
287
276
288
/* Wait 10 ms. */
277
- wait_ms (10 );
289
+ busy_wait_ms (10 );
278
290
279
291
/* Stop the timer. */
280
292
lp_timer.stop ();
@@ -302,7 +314,7 @@ void test_lptimer_time_measurement()
302
314
lp_timer.start ();
303
315
304
316
/* Wait <wait_val_us> us. */
305
- wait_us (wait_val_us);
317
+ busy_wait_us (wait_val_us);
306
318
307
319
/* Stop the timer. */
308
320
lp_timer.stop ();
0 commit comments