Procházet zdrojové kódy

RTOS2: Updated Thread and Event Flags (changed flags parameter and return type from int32_t to uint32_t)

Robert Rostohar před 9 roky
rodič
revize
34464dcc7e

+ 1 - 1
CMSIS/DoxyGen/RTOS2/rtos.dxy

@@ -38,7 +38,7 @@ PROJECT_NAME           = CMSIS-RTOS2
 # could be handy for archiving the generated documentation or if some version
 # control system is used.
 
-PROJECT_NUMBER         = "Version 2.0.0"
+PROJECT_NUMBER         = "Version 2.1.0"
 
 # Using the PROJECT_BRIEF tag one can provide an optional one line description
 # for a project that appears at the top of each page and should give viewer a

+ 21 - 1
CMSIS/DoxyGen/RTOS2/src/cmsis_os2.txt

@@ -77,6 +77,16 @@ File/Folder                  | Content
       <th>Version</th>
       <th>Description</th>
     </tr>
+    <tr>
+      <td>V2.1.0</td>
+      <td>
+        Support for critical and uncritical sections (nesting safe): 
+         - updated: osKernelLock, osKernelUnlock
+         - added: osKernelRestoreLock
+        Updated Thread and Event Flags:
+         - changed flags parameter and return type from int32_t to uint32_t
+     </td>
+    </tr>
     <tr>
       <td>V2.0.0</td>
       <td>
@@ -132,6 +142,16 @@ File/Folder                  | Content
       <th>Version</th>
       <th>Description</th>
     </tr>
+    <tr>
+      <td>V5.1.0</td>
+      <td>
+       Based on CMSIS-RTOS API V2.1.\n
+       Added support for Event recording.\n
+       Added support for IAR compiler.\n
+       Configuration file split into .h and .c file.\n
+       osRtx name-space for RTX specific symbols.\n
+      </td>
+    </tr>
     <tr>
       <td>V5.0.0</td>
       <td>
@@ -547,7 +567,7 @@ Examples:
 \section CMSIS_RTOS_ISR_Calls Calls from Interrupt Service Routines 
 
 The following CMSIS-RTOS2 functions can be called from threads and Interrupt Service Routines (ISR):
-  - \ref osKernelGetTickCount, \ref osKernelGetTickFreq
+  - \ref osKernelGetSysTimerCount, \ref osKernelGetSysTimerFreq
   - \ref osThreadFlagsSet
   - \ref osEventFlagsSet, \ref osEventFlagsClear, \ref osEventFlagsGet, \ref osEventFlagsWait
   - \ref osSemaphoreAcquire, \ref osSemaphoreRelease, \ref osSemaphoreGetCount

+ 11 - 11
CMSIS/DoxyGen/RTOS2/src/cmsis_os2_Event.txt

@@ -32,11 +32,11 @@ Here is a simple example that shows how two thread can communicate with each oth
 The following steps are required to use event flags:
 -# In the thread that is supposed to send  a event with id sig1_id, call the wait function:
 \code
-osEventFlagsSet (sig1_id, 0x0001); // 
+osEventFlagsSet (sig1_id, 0x0001U); // 
 \endcode
 -# In another thread (or threads) that are supposed wait for the event:
 \code
-osEventFlagsGet (sig1_id, 0x0001, NULL, osWaitForever);    // set the signal 0x0001 for thread tid_thread1
+osEventFlagsGet (sig1_id, 0x0001U, NULL, osWaitForever);    // set the signal 0x0001U for thread tid_thread1
 osDelay (1000);                       // wait for 1 second
 \endcode
 
@@ -78,7 +78,7 @@ void Thread_EventSender (void *argument)
  
 void Thread_EventReceiver (void *argument)
 {
-  int32_t  flags;
+  uint32_t flags;
   while (1) {
     flags = osEventFlagsWait (evt_id,FLAGS_MSK1,osFlagsWaitAny, osWaitForever);
     //handle event
@@ -131,29 +131,29 @@ void CreateEvent (void)  {
 
 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
 /**
-\fn int32_t osEventFlagsSet (osEventFlagsId_t ef_id, int32_t flags)
+\fn uint32_t osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags)
 \details
 The function \b osEventFlagsSet sets the event flags specified by the parameter \a flags in an event flags object specified
 by parameter \a ef_id. All threads waiting for the flag set will be notified to resume from \em BLOCKED state. The function
-returns the event flags after setting or a negative number representing an error code otherwise (refer to \ref osStatus_t).
+returns the event flags after setting or an error code if highest bit is set (refer to \ref osStatus_t).
 
 \note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
 */
 
 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
 /**
-\fn int32_t osEventFlagsClear (osEventFlagsId_t ef_id, int32_t flags)
+\fn uint32_t osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags)
 \details
 The function \b osEventFlagsClear clears the event flags specified by the parameter \a flags in an event flags object
-specified by parameter \a ef_id. The function returns the event flags before clearing or a negative number representing an
-error code otherwise (refer to \ref osStatus_t).
+specified by parameter \a ef_id. The function returns the event flags before clearing or an error code if highest bit is set
+(refer to \ref osStatus_t).
 
 \note This function may be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
 */
 
 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
 /**
-\fn int32_t osEventFlagsGet (osEventFlagsId_t ef_id)
+\fn uint32_t osEventFlagsGet (osEventFlagsId_t ef_id)
 \details
 The function \b osEventFlagsGet returns the event flags currently set in an event flags object specified by parameter
 \a ef_id or \token{0} in case of an error.
@@ -163,12 +163,12 @@ The function \b osEventFlagsGet returns the event flags currently set in an even
 
 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
 /**
-\fn int32_t osEventFlagsWait (osEventFlagsId_t ef_id, int32_t flags, uint32_t options, uint32_t timeout)
+\fn uint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout)
 \details
 The function \b osEventFlagsWait suspends the execution of the currently \b RUNNING thread until any or all event flags
 specified by the parameter \a flags in the event object specified by parameter \a ef_id are set. When these event flags are
 already set, the function returns instantly. Otherwise, the thread is put into the state \em BLOCKED. The function returns
-the event flags before clearing or a negative number representing an error code otherwise (refer to \ref osStatus_t).
+the event flags before clearing or an error code if highest bit is set (refer to \ref osStatus_t).
 
 The \em options parameter specifies the wait condition:
 |Option              |                                                       |

+ 8 - 8
CMSIS/DoxyGen/RTOS2/src/cmsis_os2_Migration.txt

@@ -282,28 +282,28 @@ New section to synchronize threads using flags. Thread flags and the more flexib
 Refer to \ref CMSIS_RTOS_ThreadFlagsMgmt for details.
 
 \div{new}
-\func{int32_t #osThreadFlagsSet (osThreadId_t thread_id, int32_t flags)}
+\func{uint32_t #osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags)}
 \none
 \copybrief{osThreadFlagsSet}
 New function.
 \enddiv
 
 \div{new}
-\func{int32_t #osThreadFlagsClear (int32_t flags)}
+\func{uint32_t #osThreadFlagsClear (uint32_t flags)}
 \none
 \copybrief{osThreadFlagsClear}
 New function.
 \enddiv
 
 \div{new}
-\func{int32_t #osThreadFlagsGet (void)}
+\func{uint32_t #osThreadFlagsGet (void)}
 \none
 \copybrief{osThreadFlagsGet}
 New function.
 \enddiv
 
 \div{new}
-\func{int32_t #osThreadFlagsWait (int32_t flags, uint32_t options, uint32_t timeout)}
+\func{uint32_t #osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout)}
 \none
 \copybrief{osThreadFlagsWait}
 New function.
@@ -323,7 +323,7 @@ Refer to \ref mig_signalEvents for a list of deprecated functions.
 Refer to \ref CMSIS_RTOS_EventFlags for details about the new function.
 
 \div{new}
-\func{int32_t #osEventFlagsClear (osEventFlagsId_t ef_id, int32_t flags)}
+\func{uint32_t #osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags)}
 \none
 \copybrief{osEventFlagsClear}
 New function.
@@ -344,7 +344,7 @@ New function.
 \enddiv
 
 \div{new}
-\func{int32_t #osEventFlagsGet (osEventFlagsId_t ef_id)}
+\func{uint32_t #osEventFlagsGet (osEventFlagsId_t ef_id)}
 \none
 \copybrief{osEventFlagsGet}
 New function.
@@ -358,14 +358,14 @@ New function.
 \enddiv
 
 \div{new}
-\func{int32_t #osEventFlagsSet (osEventFlagsId_t ef_id, int32_t flags)}
+\func{uint32_t #osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags)}
 \none
 \copybrief{osEventFlagsSet}
 New function.
 \enddiv
 
 \div{new}
-\func{int32_t #osEventFlagsWait (osEventFlagsId_t ef_id, int32_t flags, uint32_t options, uint32_t timeout)}
+\func{uint32_t #osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout)}
 \none
 \copybrief{osEventFlagsWait}
 New function.

+ 9 - 10
CMSIS/DoxyGen/RTOS2/src/cmsis_os2_ThreadFlags.txt

@@ -16,35 +16,34 @@ for \ref osThreadFlagsSet.
 */
 
 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
-/** \fn int32_t osThreadFlagsSet (osThreadId_t thread_id, int32_t flags )
+/** \fn uint32_t osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags )
 The function \b osThreadFlagsSet sets the thread flags for a thread specified by parameter \em thread_id. It returns the
-flags set, or a negative number representing an error code otherwise (refer to \ref osStatus_t). This function may
+flags set, or an error code if highest bit is set (refer to \ref osStatus_t). This function may
 be used also within interrupt service routines. Threads waiting for a flag to be set will resume from \em BLOCKED state.
 */
 
 /*=======0=========1=========2=========3=========4=========5=========6=========7=======osThreadFlagsClear==8=========9=========0=========1====*/
-/** \fn int32_t osThreadFlagsClear (int32_t flags)
+/** \fn uint32_t osThreadFlagsClear (int32_t flags)
 \details
 The function \b osThreadFlagsClear clears the specified flags for the currently running thread. It returns the
-flags before clearing, or a negative number representing an error code otherwise (refer to \ref osStatus_t).
+flags before clearing, or an error code if highest bit is set (refer to \ref osStatus_t).
 
 \note Cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
 */
 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
-/** \fn int32_t osThreadFlagsGet (void)
+/** \fn uint32_t osThreadFlagsGet (void)
 \details
-The function \b osThreadFlagsGet returns the flags currently set for the currently running thread, or a negative number
-representing an error code otherwise (refer to \ref osStatus_t). 
+The function \b osThreadFlagsGet returns the flags currently set for the currently running thread. 
 
 \note Cannot be called from \ref CMSIS_RTOS_ISR_Calls "Interrupt Service Routines".
 */
 
 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
-/** \fn int32_t osThreadFlagsWait (int32_t flags, uint32_t options, uint32_t timeout)
+/** \fn uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout)
 The function \b osThreadFlagsWait suspends the execution of the currently \b RUNNING thread until any or all of the thread
 flags specified with the parameter \a flags are set. When these thread flags are already set, the function returns instantly.
-Otherwise the thread is put into the state \b BLOCKED. The function then returns flags before clearing, or a negative number
-representing an error code otherwise (refer to \ref osStatus_t).
+Otherwise the thread is put into the state \b BLOCKED. The function then returns flags before clearing, or an error code
+if highest bit is set (refer to \ref osStatus_t).
 
 The parameter \em options specifies the wait condition:
 |Option              |                                                       |

+ 18 - 16
CMSIS/RTOS2/Include/cmsis_os2.h

@@ -17,16 +17,18 @@
  *
  * ----------------------------------------------------------------------
  *
- * $Date:        25. November 2016
+ * $Date:        10. January 2017
  * $Revision:    V2.1
  *
  * Project:      CMSIS-RTOS2 API
  * Title:        cmsis_os2.h header file
  *
  * Version 2.1
- *    Support for critical and uncritical sections (nesting safe)
+ *    Support for critical and uncritical sections (nesting safe):
  *    - updated: osKernelLock, osKernelUnlock
  *    - added: osKernelRestoreLock
+ *    Updated Thread and Event Flags:
+ *    - changed flags parameter and return type from int32_t to uint32_t
  * Version 2.0
  *    Initial Release
  *---------------------------------------------------------------------------*/
@@ -432,24 +434,24 @@ uint32_t osThreadEnumerate (osThreadId_t *thread_array, uint32_t array_items);
 /// Set the specified Thread Flags of a thread.
 /// \param[in]     thread_id     thread ID obtained by \ref osThreadNew or \ref osThreadGetId.
 /// \param[in]     flags         specifies the flags of the thread that shall be set.
-/// \return thread flags after setting or error code if negative.
-int32_t osThreadFlagsSet (osThreadId_t thread_id, int32_t flags);
+/// \return thread flags after setting or error code if highest bit set.
+uint32_t osThreadFlagsSet (osThreadId_t thread_id, uint32_t flags);
  
 /// Clear the specified Thread Flags of current running thread.
 /// \param[in]     flags         specifies the flags of the thread that shall be cleared.
-/// \return thread flags before clearing or error code if negative.
-int32_t osThreadFlagsClear (int32_t flags);
+/// \return thread flags before clearing or error code if highest bit set.
+uint32_t osThreadFlagsClear (uint32_t flags);
  
 /// Get the current Thread Flags of current running thread.
 /// \return current thread flags.
-int32_t osThreadFlagsGet (void);
+uint32_t osThreadFlagsGet (void);
  
 /// Wait for one or more Thread Flags of the current running thread to become signaled.
 /// \param[in]     flags         specifies the flags to wait for.
 /// \param[in]     options       specifies flags options (osFlagsXxxx).
 /// \param[in]     timeout       \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
-/// \return thread flags before clearing or error code if negative.
-int32_t osThreadFlagsWait (int32_t flags, uint32_t options, uint32_t timeout);
+/// \return thread flags before clearing or error code if highest bit set.
+uint32_t osThreadFlagsWait (uint32_t flags, uint32_t options, uint32_t timeout);
  
  
 //  ==== Generic Wait Functions ====
@@ -517,27 +519,27 @@ const char *osEventFlagsGetName (osEventFlagsId_t ef_id);
 /// Set the specified Event Flags.
 /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.
 /// \param[in]     flags         specifies the flags that shall be set.
-/// \return event flags after setting or error code if negative.
-int32_t osEventFlagsSet (osEventFlagsId_t ef_id, int32_t flags);
+/// \return event flags after setting or error code if highest bit set.
+uint32_t osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags);
  
 /// Clear the specified Event Flags.
 /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.
 /// \param[in]     flags         specifies the flags that shall be cleared.
-/// \return event flags before clearing or error code if negative.
-int32_t osEventFlagsClear (osEventFlagsId_t ef_id, int32_t flags);
+/// \return event flags before clearing or error code if highest bit set.
+uint32_t osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags);
  
 /// Get the current Event Flags.
 /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.
 /// \return current event flags.
-int32_t osEventFlagsGet (osEventFlagsId_t ef_id);
+uint32_t osEventFlagsGet (osEventFlagsId_t ef_id);
  
 /// Wait for one or more Event Flags to become signaled.
 /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.
 /// \param[in]     flags         specifies the flags to wait for.
 /// \param[in]     options       specifies flags options (osFlagsXxxx).
 /// \param[in]     timeout       \ref CMSIS_RTOS_TimeOutValue or 0 in case of no time-out.
-/// \return event flags before clearing or error code if negative.
-int32_t osEventFlagsWait (osEventFlagsId_t ef_id, int32_t flags, uint32_t options, uint32_t timeout);
+/// \return event flags before clearing or error code if highest bit set.
+uint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout);
  
 /// Delete an Event Flags object.
 /// \param[in]     ef_id         event flags ID obtained by \ref osEventFlagsNew.

+ 5 - 3
CMSIS/RTOS2/Template/cmsis_os.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 @@
  *
  * ----------------------------------------------------------------------
  *
- * $Date:        25. November 2016
+ * $Date:        10. January 2017
  * $Revision:    V2.1
  *
  * Project:      CMSIS-RTOS API
@@ -113,9 +113,11 @@
  *    Mail Queue: 
  *     - deprecated (superseded by extended Message Queue functionality)
  * Version 2.1
- *    Support for critical and uncritical sections (nesting safe)
+ *    Support for critical and uncritical sections (nesting safe):
  *    - updated: osKernelLock, osKernelUnlock
  *    - added: osKernelRestoreLock
+ *    Updated Thread and Event Flags:
+ *    - changed flags parameter and return type from int32_t to uint32_t
  *---------------------------------------------------------------------------*/
  
 #ifndef CMSIS_OS_H_

+ 22 - 22
CMSIS/RTOS2/Template/cmsis_os1.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,8 +17,8 @@
  *
  * ----------------------------------------------------------------------
  *
- * $Date:        25. November 2016
- * $Revision:    V1.1
+ * $Date:        10. January 2017
+ * $Revision:    V1.2
  *
  * Project:      CMSIS-RTOS API V1
  * Title:        cmsis_os_v1.c V1 module file
@@ -42,45 +42,45 @@ osThreadId osThreadCreate (const osThreadDef_t *thread_def, void *argument) {
 
 // Signals
 
-#define SignalMask (int32_t)((1U<<osFeature_Signals)-1U)
+#define SignalMask ((1U<<osFeature_Signals)-1U)
 
 int32_t osSignalSet (osThreadId thread_id, int32_t signals) {
-  int32_t flags;
+  uint32_t flags;
 
-  flags = osThreadFlagsSet(thread_id, signals);
-  if (flags < 0) {
-    return (int32_t)0x80000000U;
+  flags = osThreadFlagsSet(thread_id, (uint32_t)signals);
+  if ((flags & 0x80000000U) != 0U) {
+    return ((int32_t)0x80000000U);
   }
-  return (flags & ~signals);
+  return ((int32_t)(flags & ~((uint32_t)signals)));
 }
 
 int32_t osSignalClear (osThreadId thread_id, int32_t signals) {
-  int32_t flags;
+  uint32_t flags;
 
   if (thread_id != osThreadGetId()) {
-    return (int32_t)0x80000000U;
+    return ((int32_t)0x80000000U);
   }
-  flags = osThreadFlagsClear(signals);
-  if (flags < 0) {
-    return (int32_t)0x80000000U;
+  flags = osThreadFlagsClear((uint32_t)signals);
+  if ((flags & 0x80000000U) != 0U) {
+    return ((int32_t)0x80000000U);
   }
-  return flags;
+  return ((int32_t)flags);
 }
 
 osEvent osSignalWait (int32_t signals, uint32_t millisec) {
-  osEvent event;
-  int32_t flags;
+  osEvent  event;
+  uint32_t flags;
 
   if (signals != 0) {
-    flags = osThreadFlagsWait(signals,    osFlagsWaitAll, millisec);
+    flags = osThreadFlagsWait((uint32_t)signals, osFlagsWaitAll, millisec);
   } else {
-    flags = osThreadFlagsWait(SignalMask, osFlagsWaitAny, millisec);
+    flags = osThreadFlagsWait(SignalMask,        osFlagsWaitAny, millisec);
   }
-  if (flags > 0) {
+  if ((flags > 0U) && (flags < 0x80000000U)) {
     event.status = osEventSignal;
-    event.value.signals = flags;
+    event.value.signals = (int32_t)flags;
   } else {
-    switch (flags) {
+    switch ((int32_t)flags) {
       case osErrorResource:
         event.status = osOK;
         break;