File tree Expand file tree Collapse file tree 4 files changed +22
-9
lines changed Expand file tree Collapse file tree 4 files changed +22
-9
lines changed Original file line number Diff line number Diff line change 35
35
#include "rt_TypeDef.h"
36
36
#include "RTX_Config.h"
37
37
#include "rt_HAL_CM.h"
38
-
38
+ #include "cmsis_os.h"
39
39
40
40
/*----------------------------------------------------------------------------
41
41
* Global Variables
@@ -93,12 +93,12 @@ void rt_init_stack (P_TCB p_TCB, FUNCP task_body) {
93
93
94
94
#ifdef __MBED_CMSIS_RTOS_CM
95
95
/* Set a magic word for checking of stack overflow.
96
- For the main thread (ID: 0x02 ) the stack is in a memory area shared with the
96
+ For the main thread (ID: MAIN_THREAD_ID ) the stack is in a memory area shared with the
97
97
heap, therefore the last word of the stack is a moving target.
98
98
We want to do stack/heap collision detection instead.
99
99
Similar applies to stack filling for the magic pattern.
100
100
*/
101
- if (p_TCB -> task_id != 0x02 ) {
101
+ if (p_TCB -> task_id != MAIN_THREAD_ID ) {
102
102
p_TCB -> stack [0 ] = MAGIC_WORD ;
103
103
104
104
/* Initialize stack with magic pattern. */
Original file line number Diff line number Diff line change 39
39
* RTX User configuration part BEGIN
40
40
*---------------------------------------------------------------------------*/
41
41
42
- #if defined(MBED_RTOS_SINGLE_THREAD )
43
- #define OS_TASKCNT 1
44
- #define OS_TIMERS 0
45
- #endif
46
-
47
42
//-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
48
43
//
49
44
// <h>Thread Configuration
Original file line number Diff line number Diff line change 72
72
# define WORDS_STACK_SIZE 128
73
73
#endif
74
74
75
+ #ifdef __MBED_CMSIS_RTOS_CM
76
+
77
+ /* Single thread - disable timers and set task count to one */
78
+ #if defined(MBED_RTOS_SINGLE_THREAD )
79
+ #define OS_TASKCNT 1
80
+ #define OS_TIMERS 0
81
+ #endif
82
+
83
+ /* If os timers macro is set to 0, there's no timer thread created, therefore
84
+ * main thread has tid 0x01
85
+ */
86
+ #if (OS_TIMERS != 0 )
87
+ #define MAIN_THREAD_ID 0x02
88
+ #else
89
+ #define MAIN_THREAD_ID 0x01
90
+ #endif
91
+ #endif
92
+
75
93
#define DEFAULT_STACK_SIZE (WORDS_STACK_SIZE*4)
76
94
77
95
#define osCMSIS 0x10002U ///< CMSIS-RTOS API version (main [31:16] .sub [15:0])
Original file line number Diff line number Diff line change @@ -315,7 +315,7 @@ void rt_systick (void) {
315
315
__weak void rt_stk_check (void ) {
316
316
#ifdef __MBED_CMSIS_RTOS_CM
317
317
/* Check for stack overflow. */
318
- if (os_tsk .run -> task_id == 0x02 ) {
318
+ if (os_tsk .run -> task_id == MAIN_THREAD_ID ) {
319
319
// TODO: For the main thread the check should be done against the main heap pointer
320
320
} else {
321
321
if ((os_tsk .run -> tsk_stack < (U32 )os_tsk .run -> stack ) ||
You can’t perform that action at this time.
0 commit comments