]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/include/croutine.h
Tidy up comments only.
[freertos] / FreeRTOS / Source / include / croutine.h
index 725c5db61380550110da7f085f34359b9d9c83b7..97366e1a3f9ca675a8904225c0c1fa3cc93ebaaf 100644 (file)
@@ -1,68 +1,29 @@
 /*\r
-    FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.\r
-\r
-\r
-    ***************************************************************************\r
-     *                                                                       *\r
-     *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
-     *    Complete, revised, and edited pdf reference manuals are also       *\r
-     *    available.                                                         *\r
-     *                                                                       *\r
-     *    Purchasing FreeRTOS documentation will not only help you, by       *\r
-     *    ensuring you get running as quickly as possible and with an        *\r
-     *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
-     *    the FreeRTOS project to continue with its mission of providing     *\r
-     *    professional grade, cross platform, de facto standard solutions    *\r
-     *    for microcontrollers - completely free of charge!                  *\r
-     *                                                                       *\r
-     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
-     *                                                                       *\r
-     *    Thank you for using FreeRTOS, and thank you for your support!      *\r
-     *                                                                       *\r
-    ***************************************************************************\r
-\r
-\r
-    This file is part of the FreeRTOS distribution.\r
-\r
-    FreeRTOS is free software; you can redistribute it and/or modify it under\r
-    the terms of the GNU General Public License (version 2) as published by the\r
-    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
-    >>>NOTE<<< The modification to the GPL is included to allow you to\r
-    distribute a combined work that includes FreeRTOS without being obliged to\r
-    provide the source code for proprietary components outside of the FreeRTOS\r
-    kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
-    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
-    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
-    more details. You should have received a copy of the GNU General Public\r
-    License and the FreeRTOS license exception along with FreeRTOS; if not it\r
-    can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
-    by writing to Richard Barry, contact details for whom are available on the\r
-    FreeRTOS WEB site.\r
-\r
-    1 tab == 4 spaces!\r
-    \r
-    ***************************************************************************\r
-     *                                                                       *\r
-     *    Having a problem?  Start by reading the FAQ "My application does   *\r
-     *    not run, what could be wrong?                                      *\r
-     *                                                                       *\r
-     *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
-     *                                                                       *\r
-    ***************************************************************************\r
-\r
-    \r
-    http://www.FreeRTOS.org - Documentation, training, latest information, \r
-    license and contact details.\r
-    \r
-    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
-    including FreeRTOS+Trace - an indispensable productivity tool.\r
-\r
-    Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
-    the code with commercial support, indemnification, and middleware, under \r
-    the OpenRTOS brand: http://www.OpenRTOS.com.  High Integrity Systems also\r
-    provide a safety engineered and independently SIL3 certified version under \r
-    the SafeRTOS brand: http://www.SafeRTOS.com.\r
-*/\r
+ * FreeRTOS Kernel V10.2.1\r
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+ * this software and associated documentation files (the "Software"), to deal in\r
+ * the Software without restriction, including without limitation the rights to\r
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
+ * the Software, and to permit persons to whom the Software is furnished to do so,\r
+ * subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included in all\r
+ * copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ *\r
+ * http://www.FreeRTOS.org\r
+ * http://aws.amazon.com/freertos\r
+ *\r
+ * 1 tab == 4 spaces!\r
+ */\r
 \r
 #ifndef CO_ROUTINE_H\r
 #define CO_ROUTINE_H\r
@@ -80,28 +41,28 @@ extern "C" {
 /* Used to hide the implementation of the co-routine control block.  The\r
 control block structure however has to be included in the header due to\r
 the macro implementation of the co-routine functionality. */\r
-typedef void * xCoRoutineHandle;\r
+typedef void * CoRoutineHandle_t;\r
 \r
 /* Defines the prototype to which co-routine functions must conform. */\r
-typedef void (*crCOROUTINE_CODE)( xCoRoutineHandle, unsigned portBASE_TYPE );\r
+typedef void (*crCOROUTINE_CODE)( CoRoutineHandle_t, UBaseType_t );\r
 \r
 typedef struct corCoRoutineControlBlock\r
 {\r
-       crCOROUTINE_CODE                pxCoRoutineFunction;\r
-       xListItem                               xGenericListItem;       /*< List item used to place the CRCB in ready and blocked queues. */\r
-       xListItem                               xEventListItem;         /*< List item used to place the CRCB in event lists. */\r
-       unsigned portBASE_TYPE  uxPriority;                     /*< The priority of the co-routine in relation to other co-routines. */\r
-       unsigned portBASE_TYPE  uxIndex;                        /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */\r
-       unsigned short          uxState;                        /*< Used internally by the co-routine implementation. */\r
-} corCRCB; /* Co-routine control block.  Note must be identical in size down to uxPriority with tskTCB. */\r
+       crCOROUTINE_CODE        pxCoRoutineFunction;\r
+       ListItem_t                      xGenericListItem;       /*< List item used to place the CRCB in ready and blocked queues. */\r
+       ListItem_t                      xEventListItem;         /*< List item used to place the CRCB in event lists. */\r
+       UBaseType_t             uxPriority;                     /*< The priority of the co-routine in relation to other co-routines. */\r
+       UBaseType_t             uxIndex;                        /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */\r
+       uint16_t                        uxState;                        /*< Used internally by the co-routine implementation. */\r
+} CRCB_t; /* Co-routine control block.  Note must be identical in size down to uxPriority with TCB_t. */\r
 \r
 /**\r
  * croutine. h\r
  *<pre>\r
portBASE_TYPE xCoRoutineCreate(\r
BaseType_t xCoRoutineCreate(\r
                                  crCOROUTINE_CODE pxCoRoutineCode,\r
-                                 unsigned portBASE_TYPE uxPriority,\r
-                                 unsigned portBASE_TYPE uxIndex\r
+                                 UBaseType_t uxPriority,\r
+                                 UBaseType_t uxIndex\r
                                );</pre>\r
  *\r
  * Create a new co-routine and add it to the list of co-routines that are\r
@@ -124,12 +85,12 @@ typedef struct corCoRoutineControlBlock
  * Example usage:\r
    <pre>\r
  // Co-routine to be created.\r
- void vFlashCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )\r
+ void vFlashCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
  {\r
  // Variables in co-routines must be declared static if they must maintain value across a blocking call.\r
  // This may not be necessary for const variables.\r
  static const char cLedToFlash[ 2 ] = { 5, 6 };\r
- static const portTickType uxFlashRates[ 2 ] = { 200, 400 };\r
+ static const TickType_t uxFlashRates[ 2 ] = { 200, 400 };\r
 \r
      // Must start every co-routine with a call to crSTART();\r
      crSTART( xHandle );\r
@@ -139,7 +100,7 @@ typedef struct corCoRoutineControlBlock
          // This co-routine just delays for a fixed period, then toggles\r
          // an LED.  Two co-routines are created using this function, so\r
          // the uxIndex parameter is used to tell the co-routine which\r
-         // LED to flash and how long to delay.  This assumes xQueue has\r
+         // LED to flash and how int32_t to delay.  This assumes xQueue has\r
          // already been created.\r
          vParTestToggleLED( cLedToFlash[ uxIndex ] );\r
          crDELAY( xHandle, uxFlashRates[ uxIndex ] );\r
@@ -152,9 +113,9 @@ typedef struct corCoRoutineControlBlock
  // Function that creates two co-routines.\r
  void vOtherFunction( void )\r
  {\r
- unsigned char ucParameterToPass;\r
xTaskHandle xHandle;\r
-               \r
+ uint8_t ucParameterToPass;\r
TaskHandle_t xHandle;\r
+\r
      // Create two co-routines at priority 0.  The first is given index 0\r
      // so (from the code above) toggles LED 5 every 200 ticks.  The second\r
      // is given index 1 so toggles LED 6 every 400 ticks.\r
@@ -167,7 +128,7 @@ typedef struct corCoRoutineControlBlock
  * \defgroup xCoRoutineCreate xCoRoutineCreate\r
  * \ingroup Tasks\r
  */\r
-signed portBASE_TYPE xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, unsigned portBASE_TYPE uxPriority, unsigned portBASE_TYPE uxIndex );\r
+BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex );\r
 \r
 \r
 /**\r
@@ -196,7 +157,7 @@ signed portBASE_TYPE xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, unsigne
  }\r
 \r
  // Alternatively, if you do not require any other part of the idle task to\r
- // execute, the idle task hook can call vCoRoutineScheduler() within an\r
+ // execute, the idle task hook can call vCoRoutineSchedule() within an\r
  // infinite loop.\r
  void vApplicationIdleHook( void )\r
  {\r
@@ -214,17 +175,17 @@ void vCoRoutineSchedule( void );
 /**\r
  * croutine. h\r
  * <pre>\r
- crSTART( xCoRoutineHandle xHandle );</pre>\r
+ crSTART( CoRoutineHandle_t xHandle );</pre>\r
  *\r
  * This macro MUST always be called at the start of a co-routine function.\r
  *\r
  * Example usage:\r
    <pre>\r
  // Co-routine to be created.\r
- void vACoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )\r
+ void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
  {\r
  // Variables in co-routines must be declared static if they must maintain value across a blocking call.\r
- static long ulAVariable;\r
+ static int32_t ulAVariable;\r
 \r
      // Must start every co-routine with a call to crSTART();\r
      crSTART( xHandle );\r
@@ -240,7 +201,7 @@ void vCoRoutineSchedule( void );
  * \defgroup crSTART crSTART\r
  * \ingroup Tasks\r
  */\r
-#define crSTART( pxCRCB ) switch( ( ( corCRCB * )( pxCRCB ) )->uxState ) { case 0:\r
+#define crSTART( pxCRCB ) switch( ( ( CRCB_t * )( pxCRCB ) )->uxState ) { case 0:\r
 \r
 /**\r
  * croutine. h\r
@@ -252,10 +213,10 @@ void vCoRoutineSchedule( void );
  * Example usage:\r
    <pre>\r
  // Co-routine to be created.\r
- void vACoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )\r
+ void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
  {\r
  // Variables in co-routines must be declared static if they must maintain value across a blocking call.\r
- static long ulAVariable;\r
+ static int32_t ulAVariable;\r
 \r
      // Must start every co-routine with a call to crSTART();\r
      crSTART( xHandle );\r
@@ -277,13 +238,13 @@ void vCoRoutineSchedule( void );
  * These macros are intended for internal use by the co-routine implementation\r
  * only.  The macros should not be used directly by application writers.\r
  */\r
-#define crSET_STATE0( xHandle ) ( ( corCRCB * )( xHandle ) )->uxState = (__LINE__ * 2); return; case (__LINE__ * 2):\r
-#define crSET_STATE1( xHandle ) ( ( corCRCB * )( xHandle ) )->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1):\r
+#define crSET_STATE0( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = (__LINE__ * 2); return; case (__LINE__ * 2):\r
+#define crSET_STATE1( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1):\r
 \r
 /**\r
  * croutine. h\r
  *<pre>\r
- crDELAY( xCoRoutineHandle xHandle, portTickType xTicksToDelay );</pre>\r
+ crDELAY( CoRoutineHandle_t xHandle, TickType_t xTicksToDelay );</pre>\r
  *\r
  * Delay a co-routine for a fixed period of time.\r
  *\r
@@ -296,18 +257,18 @@ void vCoRoutineSchedule( void );
  *\r
  * @param xTickToDelay The number of ticks that the co-routine should delay\r
  * for.  The actual amount of time this equates to is defined by\r
- * configTICK_RATE_HZ (set in FreeRTOSConfig.h).  The constant portTICK_RATE_MS\r
+ * configTICK_RATE_HZ (set in FreeRTOSConfig.h).  The constant portTICK_PERIOD_MS\r
  * can be used to convert ticks to milliseconds.\r
  *\r
  * Example usage:\r
    <pre>\r
  // Co-routine to be created.\r
- void vACoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )\r
+ void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
  {\r
  // Variables in co-routines must be declared static if they must maintain value across a blocking call.\r
  // This may not be necessary for const variables.\r
  // We are to delay for 200ms.\r
- static const xTickType xDelayTime = 200 / portTICK_RATE_MS;\r
+ static const xTickType xDelayTime = 200 / portTICK_PERIOD_MS;\r
 \r
      // Must start every co-routine with a call to crSTART();\r
      crSTART( xHandle );\r
@@ -336,11 +297,11 @@ void vCoRoutineSchedule( void );
 /**\r
  * <pre>\r
  crQUEUE_SEND(\r
-                  xCoRoutineHandle xHandle,\r
-                  xQueueHandle pxQueue,\r
+                  CoRoutineHandle_t xHandle,\r
+                  QueueHandle_t pxQueue,\r
                   void *pvItemToQueue,\r
-                  portTickType xTicksToWait,\r
-                  portBASE_TYPE *pxResult\r
+                  TickType_t xTicksToWait,\r
+                  BaseType_t *pxResult\r
              )</pre>\r
  *\r
  * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine\r
@@ -373,7 +334,7 @@ void vCoRoutineSchedule( void );
  * to wait for space to become available on the queue, should space not be\r
  * available immediately. The actual amount of time this equates to is defined\r
  * by configTICK_RATE_HZ (set in FreeRTOSConfig.h).  The constant\r
- * portTICK_RATE_MS can be used to convert ticks to milliseconds (see example\r
+ * portTICK_PERIOD_MS can be used to convert ticks to milliseconds (see example\r
  * below).\r
  *\r
  * @param pxResult The variable pointed to by pxResult will be set to pdPASS if\r
@@ -384,11 +345,11 @@ void vCoRoutineSchedule( void );
    <pre>\r
  // Co-routine function that blocks for a fixed period then posts a number onto\r
  // a queue.\r
- static void prvCoRoutineFlashTask( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )\r
+ static void prvCoRoutineFlashTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
  {\r
  // Variables in co-routines must be declared static if they must maintain value across a blocking call.\r
- static portBASE_TYPE xNumberToPost = 0;\r
- static portBASE_TYPE xResult;\r
+ static BaseType_t xNumberToPost = 0;\r
+ static BaseType_t xResult;\r
 \r
     // Co-routines must begin with a call to crSTART().\r
     crSTART( xHandle );\r
@@ -435,11 +396,11 @@ void vCoRoutineSchedule( void );
  * croutine. h\r
  * <pre>\r
   crQUEUE_RECEIVE(\r
-                     xCoRoutineHandle xHandle,\r
-                     xQueueHandle pxQueue,\r
+                     CoRoutineHandle_t xHandle,\r
+                     QueueHandle_t pxQueue,\r
                      void *pvBuffer,\r
-                     portTickType xTicksToWait,\r
-                     portBASE_TYPE *pxResult\r
+                     TickType_t xTicksToWait,\r
+                     BaseType_t *pxResult\r
                  )</pre>\r
  *\r
  * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine\r
@@ -471,7 +432,7 @@ void vCoRoutineSchedule( void );
  * to wait for data to become available from the queue, should data not be\r
  * available immediately. The actual amount of time this equates to is defined\r
  * by configTICK_RATE_HZ (set in FreeRTOSConfig.h).  The constant\r
- * portTICK_RATE_MS can be used to convert ticks to milliseconds (see the\r
+ * portTICK_PERIOD_MS can be used to convert ticks to milliseconds (see the\r
  * crQUEUE_SEND example).\r
  *\r
  * @param pxResult The variable pointed to by pxResult will be set to pdPASS if\r
@@ -482,11 +443,11 @@ void vCoRoutineSchedule( void );
  <pre>\r
  // A co-routine receives the number of an LED to flash from a queue.  It\r
  // blocks on the queue until the number is received.\r
- static void prvCoRoutineFlashWorkTask( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )\r
+ static void prvCoRoutineFlashWorkTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
  {\r
  // Variables in co-routines must be declared static if they must maintain value across a blocking call.\r
- static portBASE_TYPE xResult;\r
- static unsigned portBASE_TYPE uxLEDToFlash;\r
+ static BaseType_t xResult;\r
+ static UBaseType_t uxLEDToFlash;\r
 \r
     // All co-routines must start with a call to crSTART().\r
     crSTART( xHandle );\r
@@ -527,9 +488,9 @@ void vCoRoutineSchedule( void );
  * croutine. h\r
  * <pre>\r
   crQUEUE_SEND_FROM_ISR(\r
-                            xQueueHandle pxQueue,\r
+                            QueueHandle_t pxQueue,\r
                             void *pvItemToQueue,\r
-                            portBASE_TYPE xCoRoutinePreviouslyWoken\r
+                            BaseType_t xCoRoutinePreviouslyWoken\r
                        )</pre>\r
  *\r
  * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the\r
@@ -567,10 +528,10 @@ void vCoRoutineSchedule( void );
  * Example usage:\r
  <pre>\r
  // A co-routine that blocks on a queue waiting for characters to be received.\r
- static void vReceivingCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )\r
+ static void vReceivingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
  {\r
  char cRxedChar;\r
portBASE_TYPE xResult;\r
BaseType_t xResult;\r
 \r
      // All co-routines must start with a call to crSTART().\r
      crSTART( xHandle );\r
@@ -597,7 +558,7 @@ void vCoRoutineSchedule( void );
  void vUART_ISR( void )\r
  {\r
  char cRxedChar;\r
portBASE_TYPE xCRWokenByPost = pdFALSE;\r
BaseType_t xCRWokenByPost = pdFALSE;\r
 \r
      // We loop around reading characters until there are none left in the UART.\r
      while( UART_RX_REG_NOT_EMPTY() )\r
@@ -624,9 +585,9 @@ void vCoRoutineSchedule( void );
  * croutine. h\r
  * <pre>\r
   crQUEUE_SEND_FROM_ISR(\r
-                            xQueueHandle pxQueue,\r
+                            QueueHandle_t pxQueue,\r
                             void *pvBuffer,\r
-                            portBASE_TYPE * pxCoRoutineWoken\r
+                            BaseType_t * pxCoRoutineWoken\r
                        )</pre>\r
  *\r
  * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the\r
@@ -665,12 +626,12 @@ void vCoRoutineSchedule( void );
  <pre>\r
  // A co-routine that posts a character to a queue then blocks for a fixed\r
  // period.  The character is incremented each time.\r
- static void vSendingCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex )\r
+ static void vSendingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex )\r
  {\r
  // cChar holds its value while this co-routine is blocked and must therefore\r
  // be declared static.\r
  static char cCharToTx = 'a';\r
portBASE_TYPE xResult;\r
BaseType_t xResult;\r
 \r
      // All co-routines must start with a call to crSTART().\r
      crSTART( xHandle );\r
@@ -713,7 +674,7 @@ void vCoRoutineSchedule( void );
  void vUART_ISR( void )\r
  {\r
  char cCharToTx;\r
portBASE_TYPE xCRWokenByPost = pdFALSE;\r
BaseType_t xCRWokenByPost = pdFALSE;\r
 \r
      while( UART_TX_REG_EMPTY() )\r
      {\r
@@ -741,7 +702,7 @@ void vCoRoutineSchedule( void );
  * Removes the current co-routine from its ready list and places it in the\r
  * appropriate delayed list.\r
  */\r
-void vCoRoutineAddToDelayedList( portTickType xTicksToDelay, xList *pxEventList );\r
+void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList );\r
 \r
 /*\r
  * This function is intended for internal use by the queue implementation only.\r
@@ -750,7 +711,7 @@ void vCoRoutineAddToDelayedList( portTickType xTicksToDelay, xList *pxEventList
  * Removes the highest priority co-routine from the event list and places it in\r
  * the pending ready list.\r
  */\r
-signed portBASE_TYPE xCoRoutineRemoveFromEventList( const xList *pxEventList );\r
+BaseType_t xCoRoutineRemoveFromEventList( const List_t *pxEventList );\r
 \r
 #ifdef __cplusplus\r
 }\r