RTX5: updated to CMSIS RTOS2 API V2.1.1
diff --git a/CMSIS/RTOS2/RTX/Include/rtx_evr.h b/CMSIS/RTOS2/RTX/Include/rtx_evr.h
index e18c2d7..897d4de 100644
--- a/CMSIS/RTOS2/RTX/Include/rtx_evr.h
+++ b/CMSIS/RTOS2/RTX/Include/rtx_evr.h
@@ -308,7 +308,7 @@
   \param[in]  count         RTOS kernel current tick count.
 */
 #if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_GET_TICK_COUNT_DISABLE))
-extern void EvrRtxKernelGetTickCount (uint64_t count);
+extern void EvrRtxKernelGetTickCount (uint32_t count);
 #else
 #define EvrRtxKernelGetTickCount(count)
 #endif
@@ -760,7 +760,7 @@
   \param[in]  ticks         absolute time in ticks
 */
 #if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_DELAY_UNTIL_DISABLE))
-extern void EvrRtxThreadDelayUntil (uint64_t ticks);
+extern void EvrRtxThreadDelayUntil (uint32_t ticks);
 #else
 #define EvrRtxThreadDelayUntil(ticks)
 #endif
diff --git a/CMSIS/RTOS2/RTX/Include/rtx_os.h b/CMSIS/RTOS2/RTX/Include/rtx_os.h
index 02c3906..2ce7de1 100644
--- a/CMSIS/RTOS2/RTX/Include/rtx_os.h
+++ b/CMSIS/RTOS2/RTX/Include/rtx_os.h
@@ -37,9 +37,9 @@
  
  
 /// Kernel Information
-#define osRtxVersionAPI      20010000   ///< API version (2.1.0)
-#define osRtxVersionKernel   50010001   ///< Kernel version (5.1.1)
-#define osRtxKernelId     "RTX V5.1.1"  ///< Kernel identification string
+#define osRtxVersionAPI      20010001   ///< API version (2.1.1)
+#define osRtxVersionKernel   50020001   ///< Kernel version (5.2.0)
+#define osRtxKernelId     "RTX V5.2.0"  ///< Kernel identification string
  
  
 //  ==== Common definitions ====
@@ -285,7 +285,8 @@
     uint8_t                   pendISR;  ///< Pending ISR (SV and SysTick)
     uint8_t                    pendSV;  ///< Pending SV
     uint32_t                 sys_freq;  ///< System Frequency
-    uint64_t                     tick;  ///< Tick counter
+    uint32_t                     tick;  ///< Tick counter
+    uint32_t                 reserved;
   } kernel;
   int32_t                   tick_irqn;  ///< Tick Timer IRQ Number
   struct {                              ///< Thread Info
diff --git a/CMSIS/RTOS2/RTX/Include1/cmsis_os.h b/CMSIS/RTOS2/RTX/Include1/cmsis_os.h
index 9a7ab76..a560162 100644
--- a/CMSIS/RTOS2/RTX/Include1/cmsis_os.h
+++ b/CMSIS/RTOS2/RTX/Include1/cmsis_os.h
@@ -17,8 +17,8 @@
  *
  * ----------------------------------------------------------------------
  *
- * $Date:        10. January 2017
- * $Revision:    V2.1.0
+ * $Date:        9. June 2017
+ * $Revision:    V2.1.1
  *
  * Project:      CMSIS-RTOS API
  * Title:        cmsis_os.h RTX header file
@@ -118,6 +118,11 @@
  *    - added: osKernelRestoreLock
  *    Updated Thread and Event Flags:
  *    - changed flags parameter and return type from int32_t to uint32_t
+ * Version 2.1.1
+ *    Additional functions allowed to be called from Interrupt Service Routines:
+ *    - osKernelGetTickCount, osKernelGetTickFreq
+ *    Changed Kernel Tick type to uint32_t:
+ *    - updated: osKernelGetTickCount, osDelayUntil
  *---------------------------------------------------------------------------*/
  
 #ifndef CMSIS_OS_H_
diff --git a/CMSIS/RTOS2/RTX/RTX5.scvd b/CMSIS/RTOS2/RTX/RTX5.scvd
index 9451235..b75b9a2 100644
--- a/CMSIS/RTOS2/RTX/RTX5.scvd
+++ b/CMSIS/RTOS2/RTX/RTX5.scvd
@@ -357,7 +357,7 @@
       <member name="kernel_pendISR"             type="uint8_t"              offset="10" info="Kernel pending ISR"/>
       <member name="kernel_pendSV"              type="uint8_t"              offset="11" info="Kernel pending SV"/>
       <member name="kernel_sys_freq"            type="uint32_t"             offset="12" info="Kernel system frequency"/>
-      <member name="kernel_tick"                type="uint64_t"             offset="16" info="Kernel tick counter"/>
+      <member name="kernel_tick"                type="uint32_t"             offset="16" info="Kernel tick counter"/>
       <member name="tick_irqn"                  type="int32_t"              offset="24" info="Tick timer IRQ number"/>
       <member name="thread_run_curr"            type="*osRtxThread_t"       offset="28" info="Current running thread"/>
       <member name="thread_run_next"            type="*osRtxThread_t"       offset="32" info="Next thread to run"/>
@@ -1482,7 +1482,7 @@
     <event id="0xF100 + 0x10" level="Op"     property="KernelSuspended"           value="sleep_ticks=%d[val1]" info="Kernel execution was suspended."/>
     <event id="0xF100 + 0x11" level="API"    property="KernelResume"              value="sleep_ticks=%d[val1]" info="osKernelResume function was called."/>
     <event id="0xF100 + 0x12" level="Op"     property="KernelResumed"             value="" info="Kernel execution was resumed."/>
-    <event id="0xF100 + 0x13" level="API"    property="KernelGetTickCount"        value="count=%d[((uint64_t)val2 &lt;&lt; 32) | val1]" info="osKernelGetTickCount function was called."/>
+    <event id="0xF100 + 0x13" level="API"    property="KernelGetTickCount"        value="count=%d[val1]" info="osKernelGetTickCount function was called."/>
     <event id="0xF100 + 0x14" level="API"    property="KernelGetTickFreq"         value="freq=%d[val1]" info="osKernelGetTickFreq function was called."/>
     <event id="0xF100 + 0x15" level="API"    property="KernelGetSysTimerCount"    value="count=%d[val1]" info="osKernelGetSysTimerCount function was called."/>
     <event id="0xF100 + 0x16" level="API"    property="KernelGetSysTimerFreq"     value="freq=%d[val1]" info="osKernelGetSysTimerFreq function was called."/>
@@ -1528,7 +1528,7 @@
     <event id="0xF200 + 0x26" level="Op"     property="ThreadFlagsWaitCompleted"    value="flags=%x[val1], options=%x[val2], thread_flags=%x[val3]" info="Wait for thread flags completed."/>
     <event id="0xF200 + 0x27" level="Op"     property="ThreadFlagsWaitNotCompleted" value="flags=%x[val1], options=%x[val2]" info="Wait for thread flags not completed."/>
     <event id="0xF200 + 0x28" level="API"    property="ThreadDelay"                 value="ticks=%d[val1]" info="osDelay function was called."/>
-    <event id="0xF200 + 0x29" level="API"    property="ThreadDelayUntil"            value="ticks=%d[((uint64_t)val2 &lt;&lt; 32) | val1]" info="osDelayUntil function was called."/>
+    <event id="0xF200 + 0x29" level="API"    property="ThreadDelayUntil"            value="ticks=%d[val1]" info="osDelayUntil function was called."/>
     <event id="0xF200 + 0x2A" level="Op"     property="ThreadDelayCompleted"        value="" info="osDelay/osDelayUntil completed."/>
 
     <event id="0xF300 + 0x00" level="Error"  property="TimerError"     value="timer_id=%x[val1], status=%E[val2, rtx_t:status]" info="Timer error occurred."/>
diff --git a/CMSIS/RTOS2/RTX/Source/rtx_core_ca.h b/CMSIS/RTOS2/RTX/Source/rtx_core_ca.h
index 2e8cb1d..10731ae 100644
--- a/CMSIS/RTOS2/RTX/Source/rtx_core_ca.h
+++ b/CMSIS/RTOS2/RTX/Source/rtx_core_ca.h
@@ -108,8 +108,6 @@
   return svc##f(svcRtx##f);                                                    \
 }
 
-#define SVC0_0D SVC0_0
-
 #define SVC0_1N(f,t,t1)                                                        \
 __SVC_INDIRECT(0) t    svc##f (t(*)(t1),t1);                                   \
                   t svcRtx##f (t1 a1);                                         \
@@ -185,8 +183,6 @@
   return svc##f();                                                             \
 }
 
-#define SVC0_0D SVC0_0
-
 #define SVC0_1N(f,t,t1)                                                        \
 __SVC_INDIRECT(0) t    svc##f (t1 a1);                                         \
                   t svcRtx##f (t1 a1);                                         \
@@ -284,16 +280,6 @@
   return (t) __r0;                                                             \
 }
 
-#define SVC0_0D(f,t)                                                           \
-__attribute__((always_inline))                                                 \
-__STATIC_INLINE t __svc##f (void) {                                            \
-  SVC_ArgN(0);                                                                 \
-  SVC_ArgN(1);                                                                 \
-  SVC_ArgF(svcRtx##f);                                                         \
-  SVC_Call0(SVC_In0, SVC_Out2, SVC_CL0);                                       \
-  return (((t) __r0) | (((t) __r1) << 32));                                    \
-}
-
 #define SVC0_1N(f,t,t1)                                                        \
 __attribute__((always_inline))                                                 \
 __STATIC_INLINE t __svc##f (t1 a1) {                                           \
diff --git a/CMSIS/RTOS2/RTX/Source/rtx_core_cm.h b/CMSIS/RTOS2/RTX/Source/rtx_core_cm.h
index 5cab82a..759f90f 100644
--- a/CMSIS/RTOS2/RTX/Source/rtx_core_cm.h
+++ b/CMSIS/RTOS2/RTX/Source/rtx_core_cm.h
@@ -129,8 +129,6 @@
   return svc##f(svcRtx##f);                                                    \
 }
 
-#define SVC0_0D SVC0_0
-
 #define SVC0_1N(f,t,t1)                                                        \
 __SVC_INDIRECT(0) t    svc##f (t(*)(t1),t1);                                   \
                   t svcRtx##f (t1 a1);                                         \
@@ -271,8 +269,6 @@
   return svc##f();                                                             \
 }
 
-#define SVC0_0D SVC0_0
-
 #define SVC0_1N(f,t,t1)                                                        \
 __SVC_INDIRECT(0) t    svc##f (t1 a1);                                         \
                   t svcRtx##f (t1 a1);                                         \
@@ -476,16 +472,6 @@
   return (t) __r0;                                                             \
 }
 
-#define SVC0_0D(f,t)                                                           \
-__attribute__((always_inline))                                                 \
-__STATIC_INLINE t __svc##f (void) {                                            \
-  SVC_ArgN(0);                                                                 \
-  SVC_ArgN(1);                                                                 \
-  SVC_ArgF(svcRtx##f);                                                         \
-  SVC_Call0(SVC_In0, SVC_Out2, SVC_CL0);                                       \
-  return (((t) __r0) | (((t) __r1) << 32));                                    \
-}
-
 #define SVC0_1N(f,t,t1)                                                        \
 __attribute__((always_inline))                                                 \
 __STATIC_INLINE t __svc##f (t1 a1) {                                           \
diff --git a/CMSIS/RTOS2/RTX/Source/rtx_delay.c b/CMSIS/RTOS2/RTX/Source/rtx_delay.c
index a7e71b7..17e90c2 100644
--- a/CMSIS/RTOS2/RTX/Source/rtx_delay.c
+++ b/CMSIS/RTOS2/RTX/Source/rtx_delay.c
@@ -30,7 +30,7 @@
 
 //  Service Calls definitions
 SVC0_1(Delay,      osStatus_t, uint32_t)
-SVC0_2(DelayUntil, osStatus_t, uint32_t, uint32_t)
+SVC0_1(DelayUntil, osStatus_t, uint32_t)
 
 /// Wait for Timeout (Time Delay).
 /// \note API identical to osDelay
@@ -47,11 +47,10 @@
 
 /// Wait until specified time.
 /// \note API identical to osDelayUntil
-osStatus_t svcRtxDelayUntil (uint32_t ticks_l, uint32_t ticks_h) {
-  uint64_t ticks = ((uint64_t)ticks_l) | ((uint64_t)ticks_h << 32);
+osStatus_t svcRtxDelayUntil (uint32_t ticks) {
 
   ticks -= osRtxInfo.kernel.tick;
-  if (ticks >= 0xFFFFFFFFU) {
+  if (ticks == 0xFFFFFFFFU) {
     EvrRtxThreadError(NULL, osErrorParameter);
     return osErrorParameter;
   }
@@ -59,7 +58,7 @@
     return osOK;
   }
 
-  osRtxThreadWaitEnter(osRtxThreadWaitingDelay, (uint32_t)ticks);
+  osRtxThreadWaitEnter(osRtxThreadWaitingDelay, ticks);
 
   return osOK;
 }
@@ -78,11 +77,11 @@
 }
 
 /// Wait until specified time.
-osStatus_t osDelayUntil (uint64_t ticks) {
+osStatus_t osDelayUntil (uint32_t ticks) {
   EvrRtxThreadDelayUntil(ticks);
   if (IS_IRQ_MODE() || IS_IRQ_MASKED()) {
     EvrRtxThreadError(NULL, osErrorISR);
     return osErrorISR;
   }
-  return __svcDelayUntil((uint32_t)ticks, (uint32_t)(ticks >> 32));
+  return __svcDelayUntil(ticks);
 }
diff --git a/CMSIS/RTOS2/RTX/Source/rtx_evr.c b/CMSIS/RTOS2/RTX/Source/rtx_evr.c
index 8785e26..f81b927 100644
--- a/CMSIS/RTOS2/RTX/Source/rtx_evr.c
+++ b/CMSIS/RTOS2/RTX/Source/rtx_evr.c
@@ -503,9 +503,9 @@
 #endif
 
 #if (!defined(EVR_RTX_DISABLE) && (OS_EVR_KERNEL != 0) && !defined(EVR_RTX_KERNEL_GET_TICK_COUNT_DISABLE))
-__WEAK void EvrRtxKernelGetTickCount (uint64_t count) {
+__WEAK void EvrRtxKernelGetTickCount (uint32_t count) {
 #if defined(RTE_Compiler_EventRecorder)
-  EventRecord2(EvtRtxKernelGetTickCount, (uint32_t)count, (uint32_t)(count>>32));
+  EventRecord2(EvtRtxKernelGetTickCount, count, 0U);
 #else
   (void)count;
 #endif
@@ -960,9 +960,9 @@
 #endif
 
 #if (!defined(EVR_RTX_DISABLE) && (OS_EVR_THREAD != 0) && !defined(EVR_RTX_THREAD_DELAY_UNTIL_DISABLE))
-__WEAK void EvrRtxThreadDelayUntil (uint64_t ticks) {
+__WEAK void EvrRtxThreadDelayUntil (uint32_t ticks) {
 #if defined(RTE_Compiler_EventRecorder)
-  EventRecord2(EvtRtxThreadDelayUntil, (uint32_t)ticks, (uint32_t)(ticks >> 32));
+  EventRecord2(EvtRtxThreadDelayUntil, ticks, 0U);
 #else
   (void)ticks;
 #endif
diff --git a/CMSIS/RTOS2/RTX/Source/rtx_kernel.c b/CMSIS/RTOS2/RTX/Source/rtx_kernel.c
index d06f883..24883ad 100644
--- a/CMSIS/RTOS2/RTX/Source/rtx_kernel.c
+++ b/CMSIS/RTOS2/RTX/Source/rtx_kernel.c
@@ -82,7 +82,7 @@
 SVC0_0 (KernelSuspend,          uint32_t)
 SVC0_1N(KernelResume,           void, uint32_t)
 SVC0_0 (KernelGetState,         osKernelState_t)
-SVC0_0D(KernelGetTickCount,     uint64_t)
+SVC0_0 (KernelGetTickCount,     uint32_t)
 SVC0_0 (KernelGetTickFreq,      uint32_t)
 SVC0_0 (KernelGetSysTimerCount, uint32_t)
 SVC0_0 (KernelGetSysTimerFreq,  uint32_t)
@@ -468,7 +468,7 @@
 
 /// Get the RTOS kernel tick count.
 /// \note API identical to osKernelGetTickCount
-uint64_t svcRtxKernelGetTickCount (void) {
+uint32_t svcRtxKernelGetTickCount (void) {
   EvrRtxKernelGetTickCount(osRtxInfo.kernel.tick);
   return osRtxInfo.kernel.tick;
 }
@@ -597,10 +597,9 @@
 }
 
 /// Get the RTOS kernel tick count.
-uint64_t osKernelGetTickCount (void) {
+uint32_t osKernelGetTickCount (void) {
   if (IS_IRQ_MODE() || IS_IRQ_MASKED()) {
-    EvrRtxKernelGetTickCount(0U);
-    return  0U;
+    return svcRtxKernelGetTickCount();
   } else {
     return  __svcKernelGetTickCount();
   }
@@ -609,8 +608,7 @@
 /// Get the RTOS kernel tick frequency.
 uint32_t osKernelGetTickFreq (void) {
   if (IS_IRQ_MODE() || IS_IRQ_MASKED()) {
-    EvrRtxKernelGetTickFreq(0U);
-    return  0U;
+    return svcRtxKernelGetTickFreq();
   } else {
     return  __svcKernelGetTickFreq();
   }
diff --git a/CMSIS/RTOS2/RTX/Source/rtx_lib.h b/CMSIS/RTOS2/RTX/Source/rtx_lib.h
index a2835e9..5c5f81b 100644
--- a/CMSIS/RTOS2/RTX/Source/rtx_lib.h
+++ b/CMSIS/RTOS2/RTX/Source/rtx_lib.h
@@ -124,7 +124,7 @@
 extern int32_t          svcRtxKernelRestoreLock      (int32_t lock);
 extern uint32_t         svcRtxKernelSuspend          (void);
 extern void             svcRtxKernelResume           (uint32_t sleep_ticks);
-extern uint64_t         svcRtxKernelGetTickCount     (void);
+extern uint32_t         svcRtxKernelGetTickCount     (void);
 extern uint32_t         svcRtxKernelGetTickFreq      (void);
 extern uint32_t         svcRtxKernelGetSysTimerCount (void);
 extern uint32_t         svcRtxKernelGetSysTimerFreq  (void);
@@ -154,7 +154,7 @@
 
 // Delay Service Calls
 extern osStatus_t       svcRtxDelay      (uint32_t ticks);
-extern osStatus_t       svcRtxDelayUntil (uint32_t ticks_l, uint32_t ticks_h);
+extern osStatus_t       svcRtxDelayUntil (uint32_t ticks);
 
 // Timer Service Calls
 extern osTimerId_t      svcRtxTimerNew       (osTimerFunc_t func, osTimerType_t type, void *argument, const osTimerAttr_t *attr);
diff --git a/CMSIS/RTOS2/RTX/Source/rtx_system.c b/CMSIS/RTOS2/RTX/Source/rtx_system.c
index a4483fd..f92b30b 100644
--- a/CMSIS/RTOS2/RTX/Source/rtx_system.c
+++ b/CMSIS/RTOS2/RTX/Source/rtx_system.c
@@ -250,7 +250,7 @@
   uint32_t tick;
   uint32_t val;
 
-  tick = (uint32_t)osRtxInfo.kernel.tick;
+  tick = osRtxInfo.kernel.tick;
   val  = SysTick_GetVal();
   if (SysTick_GetOvf()) {
     val = SysTick_GetVal();