4
4
5
5
// Include before mbed.h to properly get UINT*_C()
6
6
#include " ns_types.h"
7
+
7
8
#include " mbed.h"
8
- #include " cmsis_os2.h"
9
- #include " rtx_os.h"
10
9
#include " platform/arm_hal_timer.h"
11
10
#include " platform/arm_hal_interrupt.h"
12
11
#include < mbed_assert.h>
13
12
14
- static osThreadId_t timer_thread_id;
15
- static uint64_t timer_thread_stk[2048 /sizeof (uint64_t )];
16
- static osRtxThread_t timer_thread_tcb;
17
-
18
13
static Timer timer;
19
14
static Timeout timeout;
15
+ static EventQueue *equeue;
20
16
static uint32_t due;
21
17
static void (*arm_hal_callback)(void );
22
18
23
- static void timer_thread (void *arg)
24
- {
25
- (void )arg;
26
- for (;;) {
27
- osThreadFlagsWait (1 , osFlagsWaitAny, osWaitForever);
28
- // !!! We don't do our own enter/exit critical - we rely on callback
29
- // doing it (ns_timer_interrupt_handler does)
30
- // platform_enter_critical();
31
- arm_hal_callback ();
32
- // platform_exit_critical();
33
- }
34
- }
35
-
36
19
// Called once at boot
37
20
void platform_timer_enable (void )
38
21
{
39
- static osThreadAttr_t timer_thread_attr = {0 };
40
- timer_thread_attr.name = " pal_timer_thread" ;
41
- timer_thread_attr.stack_mem = &timer_thread_stk[0 ];
42
- timer_thread_attr.cb_mem = &timer_thread_tcb;
43
- timer_thread_attr.stack_size = sizeof (timer_thread_stk);
44
- timer_thread_attr.cb_size = sizeof (timer_thread_tcb);
45
- timer_thread_attr.priority = osPriorityRealtime;
46
- timer_thread_id = osThreadNew (timer_thread, NULL , &timer_thread_attr);
47
- MBED_ASSERT (timer_thread_id != NULL );
48
- timer.start ();
22
+ equeue = mbed_highprio_event_queue ();
23
+ MBED_ASSERT (equeue != NULL );
49
24
}
50
25
51
26
// Actually cancels a timer, not the opposite of enable
@@ -63,7 +38,7 @@ void platform_timer_set_cb(void (*new_fp)(void))
63
38
static void timer_callback (void )
64
39
{
65
40
due = 0 ;
66
- osThreadFlagsSet (timer_thread_id, 1 );
41
+ equeue-> call (arm_hal_callback );
67
42
}
68
43
69
44
// This is called from inside platform_enter_critical - IRQs can't happen
0 commit comments