X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=FreeRTOS%2FSource%2Finclude%2Fcroutine.h;h=05658e8fe16687b43b30df2f6f9f2f08f4ff2ba2;hb=48e98aaea6c09bdfdf2c260f1d54069df69cccaa;hp=e96ec87f86d69ee16e8ae1dee8a2d2a665c395ff;hpb=7f682e03ddc9f629d828cb8b61033bba85d9df67;p=freertos diff --git a/FreeRTOS/Source/include/croutine.h b/FreeRTOS/Source/include/croutine.h index e96ec87f8..05658e8fe 100644 --- a/FreeRTOS/Source/include/croutine.h +++ b/FreeRTOS/Source/include/croutine.h @@ -1,59 +1,64 @@ /* - FreeRTOS V7.5.1 - Copyright (C) 2013 Real Time Engineers Ltd. + FreeRTOS V8.2.0 - Copyright (C) 2015 Real Time Engineers Ltd. + All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - *************************************************************************** - * * - * FreeRTOS provides completely free yet professionally developed, * - * robust, strictly quality controlled, supported, and cross * - * platform software that has become a de facto standard. * - * * - * Help yourself get started quickly and support the FreeRTOS * - * project by purchasing a FreeRTOS tutorial book, reference * - * manual, or both from: http://www.FreeRTOS.org/Documentation * - * * - * Thank you! * - * * - *************************************************************************** - This file is part of the FreeRTOS distribution. FreeRTOS is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (version 2) as published by the Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception. - >>! NOTE: The modification to the GPL is included to allow you to distribute - >>! a combined work that includes FreeRTOS without being obliged to provide - >>! the source code for proprietary components outside of the FreeRTOS - >>! kernel. + *************************************************************************** + >>! NOTE: The modification to the GPL is included to allow you to !<< + >>! distribute a combined work that includes FreeRTOS without being !<< + >>! obliged to provide the source code for proprietary components !<< + >>! outside of the FreeRTOS kernel. !<< + *************************************************************************** FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - FOR A PARTICULAR PURPOSE. Full license text is available from the following + FOR A PARTICULAR PURPOSE. Full license text is available on the following link: http://www.freertos.org/a00114.html - 1 tab == 4 spaces! - *************************************************************************** * * - * Having a problem? Start by reading the FAQ "My application does * - * not run, what could be wrong?" * + * FreeRTOS provides completely free yet professionally developed, * + * robust, strictly quality controlled, supported, and cross * + * platform software that is more than just the market leader, it * + * is the industry's de facto standard. * * * - * http://www.FreeRTOS.org/FAQHelp.html * + * Help yourself get started quickly while simultaneously helping * + * to support the FreeRTOS project by purchasing a FreeRTOS * + * tutorial book, reference manual, or both: * + * http://www.FreeRTOS.org/Documentation * * * *************************************************************************** - http://www.FreeRTOS.org - Documentation, books, training, latest versions, - license and Real Time Engineers Ltd. contact details. + http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading + the FAQ page "My application does not run, what could be wrong?". Have you + defined configASSERT()? + + http://www.FreeRTOS.org/support - In return for receiving this top quality + embedded software for free we request you assist our global community by + participating in the support forum. + + http://www.FreeRTOS.org/training - Investing in training allows your team to + be as productive as possible as early as possible. Now you can receive + FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers + Ltd, and the world's leading authority on the world's leading RTOS. http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products, including FreeRTOS+Trace - an indispensable productivity tool, a DOS compatible FAT file system, and our tiny thread aware UDP/IP stack. - http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High - Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS - licenses offer ticketed support, indemnification and middleware. + http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate. + Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS. + + http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High + Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS + licenses offer ticketed support, indemnification and commercial middleware. http://www.SafeRTOS.com - High Integrity Systems also provide a safety engineered and independently SIL3 certified version for use in safety and @@ -78,28 +83,28 @@ extern "C" { /* Used to hide the implementation of the co-routine control block. The control block structure however has to be included in the header due to the macro implementation of the co-routine functionality. */ -typedef void * xCoRoutineHandle; +typedef void * CoRoutineHandle_t; /* Defines the prototype to which co-routine functions must conform. */ -typedef void (*crCOROUTINE_CODE)( xCoRoutineHandle, unsigned portBASE_TYPE ); +typedef void (*crCOROUTINE_CODE)( CoRoutineHandle_t, UBaseType_t ); typedef struct corCoRoutineControlBlock { - crCOROUTINE_CODE pxCoRoutineFunction; - xListItem xGenericListItem; /*< List item used to place the CRCB in ready and blocked queues. */ - xListItem xEventListItem; /*< List item used to place the CRCB in event lists. */ - unsigned portBASE_TYPE uxPriority; /*< The priority of the co-routine in relation to other co-routines. */ - unsigned portBASE_TYPE uxIndex; /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */ - unsigned short uxState; /*< Used internally by the co-routine implementation. */ -} corCRCB; /* Co-routine control block. Note must be identical in size down to uxPriority with tskTCB. */ + crCOROUTINE_CODE pxCoRoutineFunction; + ListItem_t xGenericListItem; /*< List item used to place the CRCB in ready and blocked queues. */ + ListItem_t xEventListItem; /*< List item used to place the CRCB in event lists. */ + UBaseType_t uxPriority; /*< The priority of the co-routine in relation to other co-routines. */ + UBaseType_t uxIndex; /*< Used to distinguish between co-routines when multiple co-routines use the same co-routine function. */ + uint16_t uxState; /*< Used internally by the co-routine implementation. */ +} CRCB_t; /* Co-routine control block. Note must be identical in size down to uxPriority with TCB_t. */ /** * croutine. h *
- portBASE_TYPE xCoRoutineCreate( + BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, - unsigned portBASE_TYPE uxPriority, - unsigned portBASE_TYPE uxIndex + UBaseType_t uxPriority, + UBaseType_t uxIndex );* * Create a new co-routine and add it to the list of co-routines that are @@ -122,12 +127,12 @@ typedef struct corCoRoutineControlBlock * Example usage:
// Co-routine to be created. - void vFlashCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex ) + void vFlashCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) { // Variables in co-routines must be declared static if they must maintain value across a blocking call. // This may not be necessary for const variables. static const char cLedToFlash[ 2 ] = { 5, 6 }; - static const portTickType uxFlashRates[ 2 ] = { 200, 400 }; + static const TickType_t uxFlashRates[ 2 ] = { 200, 400 }; // Must start every co-routine with a call to crSTART(); crSTART( xHandle ); @@ -137,7 +142,7 @@ typedef struct corCoRoutineControlBlock // This co-routine just delays for a fixed period, then toggles // an LED. Two co-routines are created using this function, so // the uxIndex parameter is used to tell the co-routine which - // LED to flash and how long to delay. This assumes xQueue has + // LED to flash and how int32_t to delay. This assumes xQueue has // already been created. vParTestToggleLED( cLedToFlash[ uxIndex ] ); crDELAY( xHandle, uxFlashRates[ uxIndex ] ); @@ -150,9 +155,9 @@ typedef struct corCoRoutineControlBlock // Function that creates two co-routines. void vOtherFunction( void ) { - unsigned char ucParameterToPass; - xTaskHandle xHandle; - + uint8_t ucParameterToPass; + TaskHandle_t xHandle; + // Create two co-routines at priority 0. The first is given index 0 // so (from the code above) toggles LED 5 every 200 ticks. The second // is given index 1 so toggles LED 6 every 400 ticks. @@ -165,7 +170,7 @@ typedef struct corCoRoutineControlBlock * \defgroup xCoRoutineCreate xCoRoutineCreate * \ingroup Tasks */ -signed portBASE_TYPE xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, unsigned portBASE_TYPE uxPriority, unsigned portBASE_TYPE uxIndex ); +BaseType_t xCoRoutineCreate( crCOROUTINE_CODE pxCoRoutineCode, UBaseType_t uxPriority, UBaseType_t uxIndex ); /** @@ -212,17 +217,17 @@ void vCoRoutineSchedule( void ); /** * croutine. h ** * This macro MUST always be called at the start of a co-routine function. * * Example usage:- crSTART( xCoRoutineHandle xHandle );+ crSTART( CoRoutineHandle_t xHandle );
// Co-routine to be created. - void vACoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex ) + void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) { // Variables in co-routines must be declared static if they must maintain value across a blocking call. - static long ulAVariable; + static int32_t ulAVariable; // Must start every co-routine with a call to crSTART(); crSTART( xHandle ); @@ -238,7 +243,7 @@ void vCoRoutineSchedule( void ); * \defgroup crSTART crSTART * \ingroup Tasks */ -#define crSTART( pxCRCB ) switch( ( ( corCRCB * )( pxCRCB ) )->uxState ) { case 0: +#define crSTART( pxCRCB ) switch( ( ( CRCB_t * )( pxCRCB ) )->uxState ) { case 0: /** * croutine. h @@ -250,10 +255,10 @@ void vCoRoutineSchedule( void ); * Example usage:// Co-routine to be created. - void vACoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex ) + void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) { // Variables in co-routines must be declared static if they must maintain value across a blocking call. - static long ulAVariable; + static int32_t ulAVariable; // Must start every co-routine with a call to crSTART(); crSTART( xHandle ); @@ -275,13 +280,13 @@ void vCoRoutineSchedule( void ); * These macros are intended for internal use by the co-routine implementation * only. The macros should not be used directly by application writers. */ -#define crSET_STATE0( xHandle ) ( ( corCRCB * )( xHandle ) )->uxState = (__LINE__ * 2); return; case (__LINE__ * 2): -#define crSET_STATE1( xHandle ) ( ( corCRCB * )( xHandle ) )->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1): +#define crSET_STATE0( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = (__LINE__ * 2); return; case (__LINE__ * 2): +#define crSET_STATE1( xHandle ) ( ( CRCB_t * )( xHandle ) )->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1): /** * croutine. h ** * Delay a co-routine for a fixed period of time. * @@ -294,18 +299,18 @@ void vCoRoutineSchedule( void ); * * @param xTickToDelay The number of ticks that the co-routine should delay * for. The actual amount of time this equates to is defined by - * configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant portTICK_RATE_MS + * configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant portTICK_PERIOD_MS * can be used to convert ticks to milliseconds. * * Example usage:- crDELAY( xCoRoutineHandle xHandle, portTickType xTicksToDelay );+ crDELAY( CoRoutineHandle_t xHandle, TickType_t xTicksToDelay );// Co-routine to be created. - void vACoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex ) + void vACoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) { // Variables in co-routines must be declared static if they must maintain value across a blocking call. // This may not be necessary for const variables. // We are to delay for 200ms. - static const xTickType xDelayTime = 200 / portTICK_RATE_MS; + static const xTickType xDelayTime = 200 / portTICK_PERIOD_MS; // Must start every co-routine with a call to crSTART(); crSTART( xHandle ); @@ -334,11 +339,11 @@ void vCoRoutineSchedule( void ); /** *crQUEUE_SEND( - xCoRoutineHandle xHandle, - xQueueHandle pxQueue, + CoRoutineHandle_t xHandle, + QueueHandle_t pxQueue, void *pvItemToQueue, - portTickType xTicksToWait, - portBASE_TYPE *pxResult + TickType_t xTicksToWait, + BaseType_t *pxResult )* * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine @@ -371,7 +376,7 @@ void vCoRoutineSchedule( void ); * to wait for space to become available on the queue, should space not be * available immediately. The actual amount of time this equates to is defined * by configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant - * portTICK_RATE_MS can be used to convert ticks to milliseconds (see example + * portTICK_PERIOD_MS can be used to convert ticks to milliseconds (see example * below). * * @param pxResult The variable pointed to by pxResult will be set to pdPASS if @@ -382,11 +387,11 @@ void vCoRoutineSchedule( void );// Co-routine function that blocks for a fixed period then posts a number onto // a queue. - static void prvCoRoutineFlashTask( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex ) + static void prvCoRoutineFlashTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) { // Variables in co-routines must be declared static if they must maintain value across a blocking call. - static portBASE_TYPE xNumberToPost = 0; - static portBASE_TYPE xResult; + static BaseType_t xNumberToPost = 0; + static BaseType_t xResult; // Co-routines must begin with a call to crSTART(). crSTART( xHandle ); @@ -433,11 +438,11 @@ void vCoRoutineSchedule( void ); * croutine. h *crQUEUE_RECEIVE( - xCoRoutineHandle xHandle, - xQueueHandle pxQueue, + CoRoutineHandle_t xHandle, + QueueHandle_t pxQueue, void *pvBuffer, - portTickType xTicksToWait, - portBASE_TYPE *pxResult + TickType_t xTicksToWait, + BaseType_t *pxResult )* * The macro's crQUEUE_SEND() and crQUEUE_RECEIVE() are the co-routine @@ -469,7 +474,7 @@ void vCoRoutineSchedule( void ); * to wait for data to become available from the queue, should data not be * available immediately. The actual amount of time this equates to is defined * by configTICK_RATE_HZ (set in FreeRTOSConfig.h). The constant - * portTICK_RATE_MS can be used to convert ticks to milliseconds (see the + * portTICK_PERIOD_MS can be used to convert ticks to milliseconds (see the * crQUEUE_SEND example). * * @param pxResult The variable pointed to by pxResult will be set to pdPASS if @@ -480,11 +485,11 @@ void vCoRoutineSchedule( void );// A co-routine receives the number of an LED to flash from a queue. It // blocks on the queue until the number is received. - static void prvCoRoutineFlashWorkTask( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex ) + static void prvCoRoutineFlashWorkTask( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) { // Variables in co-routines must be declared static if they must maintain value across a blocking call. - static portBASE_TYPE xResult; - static unsigned portBASE_TYPE uxLEDToFlash; + static BaseType_t xResult; + static UBaseType_t uxLEDToFlash; // All co-routines must start with a call to crSTART(). crSTART( xHandle ); @@ -525,9 +530,9 @@ void vCoRoutineSchedule( void ); * croutine. h *crQUEUE_SEND_FROM_ISR( - xQueueHandle pxQueue, + QueueHandle_t pxQueue, void *pvItemToQueue, - portBASE_TYPE xCoRoutinePreviouslyWoken + BaseType_t xCoRoutinePreviouslyWoken )* * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the @@ -565,10 +570,10 @@ void vCoRoutineSchedule( void ); * Example usage:// A co-routine that blocks on a queue waiting for characters to be received. - static void vReceivingCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex ) + static void vReceivingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) { char cRxedChar; - portBASE_TYPE xResult; + BaseType_t xResult; // All co-routines must start with a call to crSTART(). crSTART( xHandle ); @@ -595,7 +600,7 @@ void vCoRoutineSchedule( void ); void vUART_ISR( void ) { char cRxedChar; - portBASE_TYPE xCRWokenByPost = pdFALSE; + BaseType_t xCRWokenByPost = pdFALSE; // We loop around reading characters until there are none left in the UART. while( UART_RX_REG_NOT_EMPTY() ) @@ -622,9 +627,9 @@ void vCoRoutineSchedule( void ); * croutine. h *crQUEUE_SEND_FROM_ISR( - xQueueHandle pxQueue, + QueueHandle_t pxQueue, void *pvBuffer, - portBASE_TYPE * pxCoRoutineWoken + BaseType_t * pxCoRoutineWoken )* * The macro's crQUEUE_SEND_FROM_ISR() and crQUEUE_RECEIVE_FROM_ISR() are the @@ -663,12 +668,12 @@ void vCoRoutineSchedule( void );// A co-routine that posts a character to a queue then blocks for a fixed // period. The character is incremented each time. - static void vSendingCoRoutine( xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex ) + static void vSendingCoRoutine( CoRoutineHandle_t xHandle, UBaseType_t uxIndex ) { // cChar holds its value while this co-routine is blocked and must therefore // be declared static. static char cCharToTx = 'a'; - portBASE_TYPE xResult; + BaseType_t xResult; // All co-routines must start with a call to crSTART(). crSTART( xHandle ); @@ -711,7 +716,7 @@ void vCoRoutineSchedule( void ); void vUART_ISR( void ) { char cCharToTx; - portBASE_TYPE xCRWokenByPost = pdFALSE; + BaseType_t xCRWokenByPost = pdFALSE; while( UART_TX_REG_EMPTY() ) { @@ -739,7 +744,7 @@ void vCoRoutineSchedule( void ); * Removes the current co-routine from its ready list and places it in the * appropriate delayed list. */ -void vCoRoutineAddToDelayedList( portTickType xTicksToDelay, xList *pxEventList ); +void vCoRoutineAddToDelayedList( TickType_t xTicksToDelay, List_t *pxEventList ); /* * This function is intended for internal use by the queue implementation only. @@ -748,7 +753,7 @@ void vCoRoutineAddToDelayedList( portTickType xTicksToDelay, xList *pxEventList * Removes the highest priority co-routine from the event list and places it in * the pending ready list. */ -signed portBASE_TYPE xCoRoutineRemoveFromEventList( const xList *pxEventList ); +BaseType_t xCoRoutineRemoveFromEventList( const List_t *pxEventList ); #ifdef __cplusplus }