Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.

Dependents:   LEDFun NetTester

Fork of mbed-rtos by mbed official

Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.

Revision:
12:58b30ac3f00e
Parent:
10:fcb1f103f7a1
diff -r db1fc233faa9 -r 58b30ac3f00e rtx/RTX_CM_lib.h
--- a/rtx/RTX_CM_lib.h	Tue Apr 30 10:51:19 2013 +0000
+++ b/rtx/RTX_CM_lib.h	Thu May 30 17:08:58 2013 +0100
@@ -198,8 +198,6 @@
 extern int main (void);
 osThreadDef_t os_thread_def_main = {(os_pthread)main, osPriorityNormal, 0, NULL};
 
-#if defined (__CC_ARM)
-
 // This define should be probably moved to the CMSIS layer
 #ifdef TARGET_LPC1768
 #define INITIAL_SP            (0x10008000UL)
@@ -210,16 +208,28 @@
 #elif TARGET_KL25Z
 #define INITIAL_SP            (0x20003000UL)
 
+#elif TARGET_LPC4088
+#define INITIAL_SP            (0x10010000UL)
+
 #endif
 
-extern unsigned char Image$$RW_IRAM1$$ZI$$Limit[];
+#ifdef __CC_ARM
+extern unsigned char     Image$$RW_IRAM1$$ZI$$Limit[];
+#define HEAP_START      (Image$$RW_IRAM1$$ZI$$Limit)
+#elif defined(__GNUC__)
+extern unsigned char     __HeapLimit[];
+#define HEAP_START      (__HeapLimit)
+#endif
 
 void set_main_stack(void) {
+    // That is the bottom of the main stack block: no collision detection
+    os_thread_def_main.stack_pointer = HEAP_START;
+    
     // Leave OS_SCHEDULERSTKSIZE words for the scheduler and interrupts
-    os_thread_def_main.stack_pointer = Image$$RW_IRAM1$$ZI$$Limit;
-    os_thread_def_main.stacksize = (INITIAL_SP - (unsigned int)Image$$RW_IRAM1$$ZI$$Limit) - (OS_SCHEDULERSTKSIZE * 4);
+    os_thread_def_main.stacksize = (INITIAL_SP - (unsigned int)HEAP_START) - (OS_SCHEDULERSTKSIZE * 4);
 }
 
+#if defined (__CC_ARM)
 #ifdef __MICROLIB
 void _main_init (void) __attribute__((section(".ARM.Collect$$$$000000FF")));
 void _main_init (void) {
@@ -313,6 +323,7 @@
   __libc_init_array ();
 
   osKernelInitialize();
+  set_main_stack();
   osThreadCreate(&os_thread_def_main, NULL);
   osKernelStart();
   for (;;);
@@ -334,6 +345,7 @@
     "mov  r0,r4\n"
     "mov  r1,r5\n"
     "bl   osKernelInitialize\n"
+    "bl   set_main_stack\n"
     "ldr  r0,=os_thread_def_main\n"
     "movs r1,#0\n"
     "bl   osThreadCreate\n"