RTX5: updated configuration (added "ifndef" guards before macro defines)
diff --git a/CMSIS/RTOS2/RTX/Config/RTX_Config.c b/CMSIS/RTOS2/RTX/Config/RTX_Config.c
index ed28a08..f1493fe 100644
--- a/CMSIS/RTOS2/RTX/Config/RTX_Config.c
+++ b/CMSIS/RTOS2/RTX/Config/RTX_Config.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2016 ARM Limited. All rights reserved.
+ * Copyright (c) 2013-2017 ARM Limited. All rights reserved.
  *
  * SPDX-License-Identifier: Apache-2.0
  *
@@ -17,7 +17,7 @@
  *
  * -----------------------------------------------------------------------------
  *
- * $Revision:   V5.1.0
+ * $Revision:   V5.1.1
  *
  * Project:     CMSIS-RTOS RTX
  * Title:       RTX Configuration
@@ -25,17 +25,18 @@
  * -----------------------------------------------------------------------------
  */
  
+#include "cmsis_compiler.h"
 #include "rtx_os.h"
  
 // OS Idle Thread
-__NO_RETURN void osRtxIdleThread (void *argument) {
+__WEAK __NO_RETURN void osRtxIdleThread (void *argument) {
   (void)argument;
 
   for (;;) {}
 }
  
 // OS Error Callback function
-uint32_t osRtxErrorNotify (uint32_t code, void *object_id) {
+__WEAK uint32_t osRtxErrorNotify (uint32_t code, void *object_id) {
   (void)object_id;
 
   switch (code) {
diff --git a/CMSIS/RTOS2/RTX/Config/RTX_Config.h b/CMSIS/RTOS2/RTX/Config/RTX_Config.h
index 669476d..25657c5 100644
--- a/CMSIS/RTOS2/RTX/Config/RTX_Config.h
+++ b/CMSIS/RTOS2/RTX/Config/RTX_Config.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2016 ARM Limited. All rights reserved.
+ * Copyright (c) 2013-2017 ARM Limited. All rights reserved.
  *
  * SPDX-License-Identifier: Apache-2.0
  *
@@ -17,7 +17,7 @@
  *
  * -----------------------------------------------------------------------------
  *
- * $Revision:   V5.1.0
+ * $Revision:   V5.1.1
  *
  * Project:     CMSIS-RTOS RTX
  * Title:       RTX Configuration definitions
@@ -36,21 +36,29 @@
 //     <o>Global Dynamic Memory size [bytes] <0-1073741824:8>
 //     <i> Defines the combined global dynamic memory size.
 //     <i> Default: 4096
+#ifndef OS_DYNAMIC_MEM_SIZE
 #define OS_DYNAMIC_MEM_SIZE         4096
+#endif
  
 //   <o>Kernel Tick Frequency [Hz] <1-1000000>
 //   <i> Defines base time unit for delays and timeouts.
 //   <i> Default: 1000 (1ms tick)
+#ifndef OS_TICK_FREQ
 #define OS_TICK_FREQ                1000
+#endif
  
 //   <e>Round-Robin Thread switching
 //   <i> Enables Round-Robin Thread switching.
+#ifndef OS_ROBIN_ENABLE
 #define OS_ROBIN_ENABLE             1
+#endif
  
 //     <o>Round-Robin Timeout <1-1000>
 //     <i> Defines how many ticks a thread will execute before a thread switch.
 //     <i> Default: 5
+#ifndef OS_ROBIN_TIMEOUT
 #define OS_ROBIN_TIMEOUT            5
+#endif
  
 //   </e>
  
@@ -58,39 +66,57 @@
  
 //     <q>Memory Management
 //     <i> Enables Memory Management events recording.
+#ifndef OS_EVR_MEMORY
 #define OS_EVR_MEMORY               1
+#endif
  
 //     <q>Kernel
 //     <i> Enables Kernel events recording.
+#ifndef OS_EVR_KERNEL
 #define OS_EVR_KERNEL               1
+#endif
  
 //     <q>Thread
 //     <i> Enables Thread events recording.
+#ifndef OS_EVR_THREAD
 #define OS_EVR_THREAD               1
+#endif
  
 //     <q>Timer
 //     <i> Enables Timer events recording.
+#ifndef OS_EVR_TIMER
 #define OS_EVR_TIMER                1
+#endif
  
 //     <q>Event Flags
 //     <i> Enables Event Flags events recording.
+#ifndef OS_EVR_EVFLAGS
 #define OS_EVR_EVFLAGS              1
+#endif
  
 //     <q>Mutex
 //     <i> Enables Mutex events recording.
+#ifndef OS_EVR_MUTEX
 #define OS_EVR_MUTEX                1
+#endif
  
 //     <q>Semaphore
 //     <i> Enables Semaphore events recording.
+#ifndef OS_EVR_SEMAPHORE
 #define OS_EVR_SEMAPHORE            1
+#endif
  
 //     <q>Memory Pool
 //     <i> Enables Memory Pool events recording.
+#ifndef OS_EVR_MEMPOOL
 #define OS_EVR_MEMPOOL              1
+#endif
  
 //     <q>Message Queue
 //     <i> Enables Message Queue events recording.
+#ifndef OS_EVR_MSGQUEUE
 #define OS_EVR_MSGQUEUE             1
+#endif
  
 //   </h>
  
@@ -100,7 +126,9 @@
 //     <96=> 96 entries  <128=> 128 entries  <196=> 196 entries  <256=> 256 entries
 //   <i> RTOS Functions called from ISR store requests to this buffer.
 //   <i> Default: 16 entries
+#ifndef OS_ISR_FIFO_QUEUE
 #define OS_ISR_FIFO_QUEUE           16
+#endif
  
 // </h>
  
@@ -109,51 +137,69 @@
  
 //   <e>Object specific Memory allocation
 //   <i> Enables object specific memory allocation.
+#ifndef OS_THREAD_OBJ_MEM
 #define OS_THREAD_OBJ_MEM           0
+#endif
  
 //     <o>Number of user Threads <1-1000>
 //     <i> Defines maximum number of user threads that can be active at the same time.
 //     <i> Applies to user threads with system provided memory for control blocks.
+#ifndef OS_THREAD_NUM
 #define OS_THREAD_NUM               1
+#endif
  
 //     <o>Number of user Threads with default Stack size <0-1000>
 //     <i> Defines maximum number of user threads with default stack size.
 //     <i> Applies to user threads with zero stack size specified.
+#ifndef OS_THREAD_DEF_STACK_NUM
 #define OS_THREAD_DEF_STACK_NUM     0
+#endif
  
 //     <o>Total Stack size [bytes] for user Threads with user-provided Stack size <0-1073741824:8>
 //     <i> Defines the combined stack size for user threads with user-provided stack size.
 //     <i> Applies to user threads with user-provided stack size and system provided memory for stack.
 //     <i> Default: 0
+#ifndef OS_THREAD_USER_STACK_SIZE
 #define OS_THREAD_USER_STACK_SIZE   0
+#endif
  
 //   </e>
  
 //   <o>Default Thread Stack size [bytes] <96-1073741824:8>
 //   <i> Defines stack size for threads with zero stack size specified.
 //   <i> Default: 200
+#ifndef OS_STACK_SIZE
 #define OS_STACK_SIZE               200
+#endif
  
 //   <o>Idle Thread Stack size [bytes] <72-1073741824:8>
 //   <i> Defines stack size for Idle thread.
 //   <i> Default: 200
+#ifndef OS_IDLE_THREAD_STACK_SIZE
 #define OS_IDLE_THREAD_STACK_SIZE   200
+#endif
  
 //   <q>Stack overrun checking
 //   <i> Enable stack overrun checks at thread switch.
 //   <i> Enabling this option increases slightly the execution time of a thread switch.
+#ifndef OS_STACK_CHECK
 #define OS_STACK_CHECK              1
+#endif
  
 //   <q>Stack usage watermark
 //   <i> Initialize thread stack with watermark pattern for analyzing stack usage.
 //   <i> Enabling this option increases significantly the execution time of thread creation.
+#ifndef OS_STACK_WATERMARK
 #define OS_STACK_WATERMARK          0
+#endif
  
 //   <o>Processor mode for Thread execution 
 //     <0=> Unprivileged mode 
 //     <1=> Privileged mode
 //   <i> Default: Privileged mode
+#ifndef OS_PRIVILEGE_MODE
 #define OS_PRIVILEGE_MODE           1
+#endif
  
 // </h>
  
@@ -162,12 +208,16 @@
  
 //   <e>Object specific Memory allocation
 //   <i> Enables object specific memory allocation.
+#ifndef OS_TIMER_OBJ_MEM
 #define OS_TIMER_OBJ_MEM            0
+#endif
  
 //     <o>Number of Timer objects <1-1000>
 //     <i> Defines maximum number of objects that can be active at the same time.
 //     <i> Applies to objects with system provided memory for control blocks.
+#ifndef OS_TIMER_NUM
 #define OS_TIMER_NUM                1
+#endif
  
 //   </e>
  
@@ -178,19 +228,25 @@
 //     <48=> Realtime
 //   <i> Defines priority for timer thread
 //   <i> Default: High
+#ifndef OS_TIMER_THREAD_PRIO
 #define OS_TIMER_THREAD_PRIO        40
+#endif
  
 //   <o>Timer Thread Stack size [bytes] <0-1073741824:8>
 //   <i> Defines stack size for Timer thread.
 //   <i> May be set to 0 when timers are not used.
 //   <i> Default: 200
+#ifndef OS_TIMER_THREAD_STACK_SIZE
 #define OS_TIMER_THREAD_STACK_SIZE  200
+#endif
  
 //   <o>Timer Callback Queue entries <0-256>
 //   <i> Number of concurrent active timer callback functions.
 //   <i> May be set to 0 when timers are not used.
 //   <i> Default: 4
+#ifndef OS_TIMER_CB_QUEUE
 #define OS_TIMER_CB_QUEUE           4
+#endif
  
 // </h>
  
@@ -199,12 +255,16 @@
  
 //   <e>Object specific Memory allocation
 //   <i> Enables object specific memory allocation.
+#ifndef OS_EVFLAGS_OBJ_MEM
 #define OS_EVFLAGS_OBJ_MEM          0
+#endif
  
 //     <o>Number of Event Flags objects <1-1000>
 //     <i> Defines maximum number of objects that can be active at the same time.
 //     <i> Applies to objects with system provided memory for control blocks.
+#ifndef OS_EVFLAGS_NUM
 #define OS_EVFLAGS_NUM              1
+#endif
  
 //   </e>
  
@@ -215,12 +275,16 @@
  
 //   <e>Object specific Memory allocation
 //   <i> Enables object specific memory allocation.
+#ifndef OS_MUTEX_OBJ_MEM
 #define OS_MUTEX_OBJ_MEM            0
+#endif
  
 //     <o>Number of Mutex objects <1-1000>
 //     <i> Defines maximum number of objects that can be active at the same time.
 //     <i> Applies to objects with system provided memory for control blocks.
+#ifndef OS_MUTEX_NUM
 #define OS_MUTEX_NUM                1
+#endif
  
 //   </e>
  
@@ -231,12 +295,16 @@
  
 //   <e>Object specific Memory allocation
 //   <i> Enables object specific memory allocation.
+#ifndef OS_SEMAPHORE_OBJ_MEM
 #define OS_SEMAPHORE_OBJ_MEM        0
+#endif
  
 //     <o>Number of Semaphore objects <1-1000>
 //     <i> Defines maximum number of objects that can be active at the same time.
 //     <i> Applies to objects with system provided memory for control blocks.
+#ifndef OS_SEMAPHORE_NUM
 #define OS_SEMAPHORE_NUM            1
+#endif
  
 //   </e>
  
@@ -247,18 +315,24 @@
  
 //   <e>Object specific Memory allocation
 //   <i> Enables object specific memory allocation.
+#ifndef OS_MEMPOOL_OBJ_MEM
 #define OS_MEMPOOL_OBJ_MEM          0
+#endif
  
 //     <o>Number of Memory Pool objects <1-1000>
 //     <i> Defines maximum number of objects that can be active at the same time.
 //     <i> Applies to objects with system provided memory for control blocks.
+#ifndef OS_MEMPOOL_NUM
 #define OS_MEMPOOL_NUM              1
+#endif
  
 //     <o>Data Storage Memory size [bytes] <0-1073741824:8>
 //     <i> Defines the combined data storage memory size.
 //     <i> Applies to objects with system provided memory for data storage.
 //     <i> Default: 0
+#ifndef OS_MEMPOOL_DATA_SIZE
 #define OS_MEMPOOL_DATA_SIZE        0
+#endif
  
 //   </e>
  
@@ -269,18 +343,24 @@
  
 //   <e>Object specific Memory allocation
 //   <i> Enables object specific memory allocation.
+#ifndef OS_MSGQUEUE_OBJ_MEM
 #define OS_MSGQUEUE_OBJ_MEM         0
+#endif
  
 //     <o>Number of Message Queue objects <1-1000>
 //     <i> Defines maximum number of objects that can be active at the same time.
 //     <i> Applies to objects with system provided memory for control blocks.
+#ifndef OS_MSGQUEUE_NUM
 #define OS_MSGQUEUE_NUM             1
+#endif
  
 //     <o>Data Storage Memory size [bytes] <0-1073741824:8>
 //     <i> Defines the combined data storage memory size.
 //     <i> Applies to objects with system provided memory for data storage.
 //     <i> Default: 0
+#ifndef OS_MSGQUEUE_DATA_SIZE
 #define OS_MSGQUEUE_DATA_SIZE       0
+#endif
  
 //   </e>