13
13
#endif
14
14
#include "pico/stdlib.h"
15
15
#include "pico/test.h"
16
+
17
+ #if LIB_PICO_AON_TIMER
18
+ #include "pico/aon_timer.h"
19
+ #endif
20
+
16
21
// Include sys/types.h before inttypes.h to work around issue with
17
22
// certain versions of GCC and newlib which causes omission of PRIi64
18
23
#include <sys/types.h>
@@ -74,11 +79,12 @@ static bool repeating_timer_callback(struct repeating_timer *t) {
74
79
#define RESOLUTION_ALLOWANCE PICO_HARDWARE_TIMER_RESOLUTION_US
75
80
#endif
76
81
77
- int issue_195_test (void );
78
- int issue_1812_test (void );
79
- int issue_1953_test (void );
80
- int issue_2118_test (void );
81
- int issue_2186_test (void );
82
+ static int issue_195_test (void );
83
+ static int issue_1812_test (void );
84
+ static int issue_1953_test (void );
85
+ static int issue_2118_test (void );
86
+ static int issue_2148_test (void );
87
+ static int issue_2186_test (void );
82
88
83
89
int main () {
84
90
setup_default_uart ();
@@ -253,6 +259,8 @@ int main() {
253
259
254
260
issue_2118_test ();
255
261
262
+ issue_2148_test ();
263
+
256
264
issue_2186_test ();
257
265
258
266
PICOTEST_END_TEST ();
@@ -265,7 +273,7 @@ int64_t issue_195_callback(alarm_id_t id, void *user_data) {
265
273
return - ISSUE_195_TIMER_DELAY ;
266
274
}
267
275
268
- int issue_195_test (void ) {
276
+ static int issue_195_test (void ) {
269
277
PICOTEST_START_SECTION ("Issue #195 race condition - without fix may hang on gcc 10.2.1 release builds" );
270
278
absolute_time_t t1 = get_absolute_time ();
271
279
int id = add_alarm_in_us (ISSUE_195_TIMER_DELAY , issue_195_callback , NULL , true);
@@ -284,7 +292,7 @@ int issue_195_test(void) {
284
292
}
285
293
286
294
// Setting an alarm should not swallow a sev
287
- int issue_1812_test (void ) {
295
+ static int issue_1812_test (void ) {
288
296
PICOTEST_START_SECTION ("Issue #1812 defect - Setting an alarm should not ignore a sev" );
289
297
290
298
__sev (); // Make sure the call below does not ignore this
@@ -308,7 +316,7 @@ static void alarm_pool_stuck_issue_1953(uint alarm) {
308
316
hard_assert (false);
309
317
}
310
318
311
- int issue_1953_test (void ) {
319
+ static int issue_1953_test (void ) {
312
320
PICOTEST_START_SECTION ("Issue #1953 defect - Alarm can be set in the past" );
313
321
int alarm = hardware_alarm_claim_unused (true);
314
322
hardware_alarm_set_callback (alarm , alarm_pool_stuck_issue_1953 );
@@ -341,7 +349,7 @@ static bool timer_callback_issue_2118(repeating_timer_t *rt) {
341
349
return true;
342
350
}
343
351
344
- int issue_2118_test (void ) {
352
+ static int issue_2118_test (void ) {
345
353
PICOTEST_START_SECTION ("Issue #2118 defect - failure to set an alarm" );
346
354
347
355
#if PICO_ON_DEVICE
@@ -373,7 +381,7 @@ int issue_2118_test(void) {
373
381
return 0 ;
374
382
}
375
383
376
- int issue_2186_test (void ) {
384
+ static int issue_2186_test (void ) {
377
385
PICOTEST_START_SECTION ("Issue #2186 defect - ta_wakes_up_on_or_before" );
378
386
379
387
hard_assert (best_effort_wfe_or_timeout (get_absolute_time () - 1 ));
@@ -382,3 +390,34 @@ int issue_2186_test(void) {
382
390
PICOTEST_END_SECTION ();
383
391
return 0 ;
384
392
}
393
+
394
+ static int issue_2148_test (void ) {
395
+ #if HAS_RP2040_RTC
396
+ PICOTEST_START_SECTION ("Issue #2148 defect - get time after rtc start" );
397
+ struct tm tm = { 0 };
398
+ struct tm tm_check = { 0 };
399
+
400
+ tm .tm_sec = 55 ;
401
+ tm .tm_min = 36 ;
402
+ tm .tm_hour = 20 ;
403
+ tm .tm_mday = 21 ;
404
+ tm .tm_mon = 10 ;
405
+ tm .tm_year = 124 ;
406
+ tm .tm_wday = 4 ;
407
+ tm .tm_yday = 325 ;
408
+ tm .tm_isdst = 0 ;
409
+ hard_assert (aon_timer_start_calendar (& tm ));
410
+ hard_assert (aon_timer_get_time_calendar (& tm_check ));
411
+
412
+ PICOTEST_CHECK (tm .tm_sec == tm_check .tm_sec || tm .tm_sec == tm_check .tm_sec - 1 , "failed to get seconds" );
413
+ PICOTEST_CHECK (tm .tm_min == tm_check .tm_min , "failed to get minutes" );
414
+ PICOTEST_CHECK (tm .tm_hour == tm_check .tm_hour , "failed to get hour" );
415
+ PICOTEST_CHECK (tm .tm_mday == tm_check .tm_mday , "failed to get day" );
416
+ PICOTEST_CHECK (tm .tm_mon == tm_check .tm_mon , "failed to get month" );
417
+ PICOTEST_CHECK (tm .tm_year == tm_check .tm_year , "failed to get year" );
418
+
419
+ aon_timer_stop ();
420
+ PICOTEST_END_SECTION ();
421
+ #endif
422
+ return 0 ;
423
+ }
0 commit comments