Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-rtos by
Diff: rtx/TARGET_CORTEX_M/RTX_Conf_CM.c
- Revision:
- 112:53ace74b190c
- Parent:
- 111:162b12aea5f2
- Child:
- 113:d9366c711a75
--- a/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c	Tue May 03 00:15:52 2016 +0100
+++ b/rtx/TARGET_CORTEX_M/RTX_Conf_CM.c	Thu May 05 20:45:13 2016 +0100
@@ -1,12 +1,12 @@
 /*----------------------------------------------------------------------------
- *      RL-ARM - RTX
+ *      CMSIS-RTOS  -  RTX
  *----------------------------------------------------------------------------
  *      Name:    RTX_Conf_CM.C
  *      Purpose: Configuration of CMSIS RTX Kernel for Cortex-M
- *      Rev.:    V4.60
+ *      Rev.:    V4.70.1
  *----------------------------------------------------------------------------
  *
- * Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH
+ * Copyright (c) 1999-2009 KEIL, 2009-2015 ARM Germany GmbH
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -44,9 +44,8 @@
 // <h>Thread Configuration
 // =======================
 //
-//   <o>Number of concurrent running threads <0-250>
-//   <i> Defines max. number of threads that will run at the same time.
-//       counting "main", but not counting "osTimerThread"
+//   <o>Number of concurrent running user threads <1-250>
+//   <i> Defines max. number of user threads that will run at the same time.
 //   <i> Default: 6
 #ifndef OS_TASKCNT
 #  if   defined(TARGET_LPC1768) || defined(TARGET_LPC2368)   || defined(TARGET_LPC4088) || defined(TARGET_LPC4088_DM) || defined(TARGET_LPC4330) || defined(TARGET_LPC4337) || defined(TARGET_LPC1347) || defined(TARGET_K64F) || defined(TARGET_STM32F401RE)\
@@ -65,60 +64,93 @@
 #  endif
 #endif
 
-//   <o>Scheduler (+ interrupts) stack size [bytes] <64-4096:8><#/4>
-#ifndef OS_SCHEDULERSTKSIZE
+#ifdef __MBED_CMSIS_RTOS_CM
+//   <o>Idle stack size [bytes] <64-4096:8><#/4>
+//   <i> Defines default stack size for the Idle thread.
+#ifndef OS_IDLESTKSIZE
+ #define OS_IDLESTKSIZE 128
+#endif
+#else // __MBED_CMSIS_RTOS_CM
+//   <o>Default Thread stack size [bytes] <64-4096:8><#/4>
+//   <i> Defines default stack size for threads with osThreadDef stacksz = 0
+//   <i> Default: 200
+#ifndef OS_STKSIZE
+ #define OS_STKSIZE     200
+#endif
+#endif // __MBED_CMSIS_RTOS_CM
+
+//   <o>Main Thread stack size [bytes] <64-32768:8><#/4>
+#ifndef OS_MAINSTKSIZE
 #  if   defined(TARGET_LPC1768) || defined(TARGET_LPC2368)   || defined(TARGET_LPC4088) || defined(TARGET_LPC4088_DM) || defined(TARGET_LPC4330) || defined(TARGET_LPC4337) || defined(TARGET_LPC1347)  || defined(TARGET_K64F) || defined(TARGET_STM32F401RE)\
    || defined(TARGET_STM32F410RB) || defined(TARGET_KL46Z) || defined(TARGET_KL43Z) || defined(TARGET_STM32F407) || defined(TARGET_F407VG)  || defined(TARGET_STM32F303VC) || defined(TARGET_LPC1549) || defined(TARGET_LPC11U68) \
    || defined(TARGET_STM32F411RE) || defined(TARGET_STM32F405RG) || defined(TARGET_K22F) || defined(TARGET_STM32F429ZI) || defined(TARGET_STM32F401VC) || defined(TARGET_MAX32610) || defined(TARGET_MAX32600) || defined(TARGET_TEENSY3_1) \
    || defined(TARGET_STM32L152RE) || defined(TARGET_STM32F446RE) || defined(TARGET_STM32F446VE) || defined(TARGET_STM32L476VG) || defined(TARGET_STM32L476RG) || defined(TARGET_STM32F469NI) || defined(TARGET_STM32F746NG) || defined(TARGET_STM32F746ZG) || defined(TARGET_STM32L152RC)
-#      define OS_SCHEDULERSTKSIZE    256
+#      define OS_MAINSTKSIZE    256
 #  elif defined(TARGET_LPC11U24) || defined(TARGET_LPC11U35_401)  || defined(TARGET_LPC11U35_501) || defined(TARGET_LPCCAPPUCCINO)  || defined(TARGET_LPC1114) \
    || defined(TARGET_LPC812)   || defined(TARGET_KL25Z)         || defined(TARGET_KL26Z)        || defined(TARGET_KL27Z)        || defined(TARGET_KL05Z)        || defined(TARGET_STM32F100RB)  || defined(TARGET_STM32F051R8) \
    || defined(TARGET_STM32F103RB) || defined(TARGET_LPC824) || defined(TARGET_STM32F302R8) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F091RC) || defined(TARGET_NZ32_SC151) \
    || defined(TARGET_SSCI824) || defined(TARGET_STM32F030R8) || defined(TARGET_STM32F070RB)
-#      define OS_SCHEDULERSTKSIZE    128
+#      define OS_MAINSTKSIZE    128
 #  elif defined(TARGET_STM32F334R8) || defined(TARGET_STM32F303RE) ||  defined(TARGET_STM32F303K8) ||  defined(TARGET_STM32F334C8) || defined(TARGET_STM32L031K6) || defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8) || defined(TARGET_STM32L073RZ)
-#      define OS_SCHEDULERSTKSIZE    112
+#      define OS_MAINSTKSIZE    112
 #  else
 #    error "no target defined"
 #  endif
 #endif
 
-//   <o>Idle stack size [bytes] <64-4096:8><#/4>
-//   <i> Defines default stack size for the Idle thread.
-#ifndef OS_IDLESTKSIZE
- #define OS_IDLESTKSIZE         128
+#ifndef __MBED_CMSIS_RTOS_CM
+//   <o>Number of threads with user-provided stack size <0-250>
+//   <i> Defines the number of threads with user-provided stack size.
+//   <i> Default: 0
+#ifndef OS_PRIVCNT
+ #define OS_PRIVCNT     0
 #endif
+ 
+//   <o>Total stack size [bytes] for threads with user-provided stack size <0-1048576:8><#/4>
+//   <i> Defines the combined stack size for threads with user-provided stack size.
+//   <i> Default: 0
+#ifndef OS_PRIVSTKSIZE
+ #define OS_PRIVSTKSIZE 0       // this stack size value is in words
+#endif
+#endif // __MBED_CMSIS_RTOS_CM
 
-//   <o>Timer Thread stack size [bytes] <64-4096:8><#/4>
-//   <i> Defines stack size for Timer thread.
-//   <i> Default: 200
-#ifndef OS_TIMERSTKSZ
- #define OS_TIMERSTKSZ  WORDS_STACK_SIZE
-#endif
-
-// <q>Check for stack overflow
-// <i> Includes the stack checking code for stack overflow.
-// <i> Note that additional code reduces the Kernel performance.
+//   <q>Stack overflow checking
+//   <i> Enable stack overflow checks at thread switch.
+//   <i> Enabling this option increases slightly the execution time of a thread switch.
 #ifndef OS_STKCHECK
  #define OS_STKCHECK    1
 #endif
-
-// <o>Processor mode for thread execution
-//   <0=> Unprivileged mode
-//   <1=> Privileged mode
-// <i> Default: Privileged mode
+ 
+//   <q>Stack usage watermark
+//   <i> Initialize thread stack with watermark pattern for analyzing stack usage (current/maximum) in System and Thread Viewer.
+//   <i> Enabling this option increases significantly the execution time of osThreadCreate.
+#ifndef OS_STKINIT
+#define OS_STKINIT      0
+#endif
+ 
+//   <o>Processor mode for thread execution 
+//     <0=> Unprivileged mode 
+//     <1=> Privileged mode
+//   <i> Default: Privileged mode
 #ifndef OS_RUNPRIV
  #define OS_RUNPRIV     1
 #endif
 
 // </h>
-// <h>SysTick Timer Configuration
-// ==============================
+ 
+// <h>RTX Kernel Timer Tick Configuration
+// ======================================
+//   <q> Use Cortex-M SysTick timer as RTX Kernel Timer
+//   <i> Cortex-M processors provide in most cases a SysTick timer that can be used as 
+//   <i> as time-base for RTX.
+#ifndef OS_SYSTICK
+ #define OS_SYSTICK     1
+#endif
 //
-//   <o>Timer clock value [Hz] <1-1000000000>
-//   <i> Defines the timer clock value.
-//   <i> Default: 6000000  (6MHz)
+//   <o>RTOS Kernel Timer input clock frequency [Hz] <1-1000000000>
+//   <i> Defines the input frequency of the RTOS Kernel Timer.  
+//   <i> When the Cortex-M SysTick timer is used, the input clock 
+//   <i> is on most systems identical with the core clock.
 #ifndef OS_CLOCK
 #  if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_TEENSY3_1)
 #    define OS_CLOCK       96000000
@@ -212,9 +244,10 @@
 #    error "no target defined"
 #  endif
 #endif
-
-//   <o>Timer tick value [us] <1-1000000>
-//   <i> Defines the timer tick value.
+ 
+//   <o>RTX Timer tick interval value [us] <1-1000000>
+//   <i> The RTX Timer tick interval value is used to calculate timeout values.
+//   <i> When the Cortex-M SysTick timer is enabled, the value also configures the SysTick timer.
 //   <i> Default: 1000  (1ms)
 #ifndef OS_TICK
  #define OS_TICK        1000
@@ -251,9 +284,7 @@
 
 //   <o>Timer Thread Priority
 //                        <1=> Low
-//                        <2=> Below Normal
-//                        <3=> Normal
-//                        <4=> Above Normal
+//     <2=> Below Normal  <3=> Normal  <4=> Above Normal
 //                        <5=> High
 //                        <6=> Realtime (highest)
 //   <i> Defines priority for Timer Thread
@@ -261,11 +292,18 @@
 #ifndef OS_TIMERPRIO
  #define OS_TIMERPRIO   5
 #endif
-
+ 
+//   <o>Timer Thread stack size [bytes] <64-4096:8><#/4>
+//   <i> Defines stack size for Timer thread.
+//   <i> Default: 200
+#ifndef OS_TIMERSTKSZ
+ #define OS_TIMERSTKSZ  200
+#endif
+ 
 //   <o>Timer Callback Queue size <1-32>
 //   <i> Number of concurrent active timer callback functions.
 //   <i> Default: 4
-#ifndef OS_TIMERCBQSZ
+#ifndef OS_TIMERCBQS
  #define OS_TIMERCBQS   4
 #endif
 
@@ -316,12 +354,16 @@
 /*----------------------------------------------------------------------------
  *      RTX Errors
  *---------------------------------------------------------------------------*/
-extern void mbed_die(void);
+extern void error(const char* format, ...);
+extern osThreadId svcThreadGetId (void);
+
+#include "stdio.h"
 
 void os_error (uint32_t err_code) {
     /* This function is called when a runtime error is detected. Parameter     */
-    /* 'err_code' holds the runtime error code (defined in RTX_Conf.h).      */
-    mbed_die();
+    /* 'err_code' holds the runtime error code (defined in RTX_Config.h).      */
+    osThreadId err_task = svcThreadGetId();
+    error("CMSIS RTX error code: 0x%08X, task ID: 0x%08X\n", err_code, (uint32_t)err_task);
 }
 
 void sysThreadError(osStatus status) {
    