File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
features/FEATURE_COMMON_PAL/nanostack-hal-mbed-cmsis-rtos Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 12
12
13
13
static Timer timer;
14
14
static Timeout timeout;
15
+
16
+ // If critical sections are implemented using mutexes, timers must be called in thread context, and
17
+ // we use the high-priority event queue for this.
18
+ // If critical sections disable interrupts, we can call timers directly from interrupt. Avoiding the
19
+ // event queue can save ~1600B of RAM if the rest of the system is not using the event queue either.
20
+ // Caveats of this tunable are listed on arm_hal_interrupt.c.
21
+ #if !MBED_CONF_NANOSTACK_HAL_CRITICAL_SECTION_USABLE_FROM_INTERRUPT
15
22
static EventQueue *equeue;
23
+ #endif
24
+
16
25
static uint32_t due;
17
26
static void (*arm_hal_callback)(void );
18
27
19
28
// Called once at boot
20
29
void platform_timer_enable (void )
21
30
{
31
+ #if !MBED_CONF_NANOSTACK_HAL_CRITICAL_SECTION_USABLE_FROM_INTERRUPT
22
32
equeue = mbed_highprio_event_queue ();
23
33
MBED_ASSERT (equeue != NULL );
34
+ #endif
24
35
}
25
36
26
37
// Actually cancels a timer, not the opposite of enable
@@ -38,7 +49,14 @@ void platform_timer_set_cb(void (*new_fp)(void))
38
49
static void timer_callback (void )
39
50
{
40
51
due = 0 ;
52
+
53
+ #if MBED_CONF_NANOSTACK_HAL_CRITICAL_SECTION_USABLE_FROM_INTERRUPT
54
+ // Callback is interrupt safe so it can be called directly without
55
+ // bouncing via event queue thread.
56
+ arm_hal_callback ();
57
+ #else
41
58
equeue->call (arm_hal_callback);
59
+ #endif
42
60
}
43
61
44
62
// This is called from inside platform_enter_critical - IRQs can't happen
Original file line number Diff line number Diff line change @@ -41,7 +41,10 @@ static const osThreadAttr_t event_thread_attr = {
41
41
};
42
42
#endif
43
43
44
+ #if !MBED_CONF_NANOSTACK_HAL_EVENT_LOOP_DISPATCH_FROM_APPLICATION
44
45
static osThreadId_t event_thread_id ;
46
+ #endif
47
+
45
48
static mbed_rtos_storage_mutex_t event_mutex ;
46
49
static const osMutexAttr_t event_mutex_attr = {
47
50
.name = "nanostack_event_mutex" ,
You can’t perform that action at this time.
0 commit comments