18
18
19
19
#include " utest/shim.h"
20
20
21
-
22
21
#if UTEST_SHIM_SCHEDULER_USE_MINAR
23
22
#include " minar/minar.h"
24
23
@@ -40,20 +39,26 @@ static int32_t utest_minar_run()
40
39
{
41
40
return 0 ;
42
41
}
43
- extern " C" const utest_v1_scheduler_t utest_v1_scheduler =
42
+ extern " C" {
43
+ static const utest_v1_scheduler_t utest_v1_scheduler =
44
44
{
45
45
utest_minar_init,
46
46
utest_minar_post,
47
47
utest_minar_cancel,
48
48
utest_minar_run
49
49
};
50
+ utest_v1_scheduler_t utest_v1_get_scheduler ()
51
+ {
52
+ return utest_v1_scheduler;
53
+ }
54
+ }
50
55
51
56
#elif UTEST_SHIM_SCHEDULER_USE_US_TICKER
52
57
// only one callback is active at any given time
53
- volatile utest_v1_harness_callback_t minimal_callback;
54
- volatile utest_v1_harness_callback_t ticker_callback;
55
- const ticker_data_t *ticker_data;
56
- ticker_event_t ticker_event;
58
+ static volatile utest_v1_harness_callback_t minimal_callback;
59
+ static volatile utest_v1_harness_callback_t ticker_callback;
60
+ static const ticker_data_t *ticker_data;
61
+ static ticker_event_t ticker_event;
57
62
58
63
static void ticker_handler (uint32_t )
59
64
{
@@ -64,15 +69,14 @@ static void ticker_handler(uint32_t)
64
69
static int32_t utest_us_ticker_init ()
65
70
{
66
71
ticker_data = get_us_ticker_data ();
72
+ ticker_set_handler (ticker_data, ticker_handler);
67
73
return 0 ;
68
74
}
69
75
static void *utest_us_ticker_post (const utest_v1_harness_callback_t callback, const uint32_t delay_ms)
70
76
{
71
77
// printf("\t\t>>> Schedule %p with %ums delay => %p.\n", callback, (unsigned int)delay_ms, (void*)1);
72
78
if (delay_ms) {
73
79
ticker_callback = callback;
74
- // setup ticker to call the handler manually
75
- ticker_set_handler (ticker_data, ticker_handler);
76
80
// fire the interrupt in 1000us * delay_ms
77
81
ticker_insert_event (ticker_data, &ticker_event, ticker_read (ticker_data) + delay_ms * 1000 , 0 );
78
82
} else {
@@ -107,19 +111,23 @@ static int32_t utest_us_ticker_run()
107
111
}
108
112
return 0 ;
109
113
}
110
- const utest_v1_scheduler_t utest_v1_scheduler =
114
+ extern " C" {
115
+ static const utest_v1_scheduler_t utest_v1_scheduler =
111
116
{
112
117
utest_us_ticker_init,
113
118
utest_us_ticker_post,
114
119
utest_us_ticker_cancel,
115
120
utest_us_ticker_run
116
121
};
117
- #else
118
- const utest_v1_scheduler_t utest_v1_scheduler =
122
+ utest_v1_scheduler_t utest_v1_get_scheduler ()
119
123
{
120
- NULL ,
121
- NULL ,
122
- NULL ,
123
- NULL
124
- };
124
+ return utest_v1_scheduler;
125
+ }
126
+ }
127
+ #endif
128
+
129
+ #ifdef YOTTA_CORE_UTIL_VERSION_STRING
130
+ // their functionality is implemented using the CriticalSectionLock class
131
+ void utest_v1_enter_critical_section (void ) {}
132
+ void utest_v1_leave_critical_section (void ) {}
125
133
#endif
0 commit comments