X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=FreeRTOS%2FSource%2Finclude%2Fcroutine.h;h=de66545366a9e1d42cf45a6c774b41069599315f;hb=6a98238fd1b8047c2c2ad925e06fe5bbc70d1988;hp=f2843cde2789fd9ce7ba32b08d8b3434768bde6d;hpb=29ba679b4650a076bdb5d97b6eb578aec31eafc5;p=freertos diff --git a/FreeRTOS/Source/include/croutine.h b/FreeRTOS/Source/include/croutine.h index f2843cde2..de6654536 100644 --- a/FreeRTOS/Source/include/croutine.h +++ b/FreeRTOS/Source/include/croutine.h @@ -1,67 +1,70 @@ /* - FreeRTOS V7.2.0 - Copyright (C) 2012 Real Time Engineers Ltd. - - - *************************************************************************** - * * - * FreeRTOS tutorial books are available in pdf and paperback. * - * Complete, revised, and edited pdf reference manuals are also * - * available. * - * * - * Purchasing FreeRTOS documentation will not only help you, by * - * ensuring you get running as quickly as possible and with an * - * in-depth knowledge of how to use FreeRTOS, it will also help * - * the FreeRTOS project to continue with its mission of providing * - * professional grade, cross platform, de facto standard solutions * - * for microcontrollers - completely free of charge! * - * * - * >>> See http://www.FreeRTOS.org/Documentation for details. <<< * - * * - * Thank you for using FreeRTOS, and thank you for your support! * - * * - *************************************************************************** + FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd. + All rights reserved + VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. 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. 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. See the GNU General Public License for - more details. You should have received a copy of the GNU General Public - License and the FreeRTOS license exception along with FreeRTOS; if not it - can be viewed here: http://www.freertos.org/a00114.html and also obtained - by writing to Richard Barry, contact details for whom are available on the - FreeRTOS WEB site. + 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. !<< + *************************************************************************** + + 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 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, training, latest information, - license and 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. + including FreeRTOS+Trace - an indispensable productivity tool, a DOS + compatible FAT file system, and our tiny thread aware UDP/IP stack. - Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell - the code with commercial support, indemnification, and middleware, under - the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also - provide a safety engineered and independently SIL3 certified version under - the SafeRTOS brand: http://www.SafeRTOS.com. + 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 + mission critical applications that require provable dependability. + + 1 tab == 4 spaces! */ #ifndef CO_ROUTINE_H @@ -80,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 @@ -124,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 ); @@ -139,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 ] ); @@ -152,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. @@ -167,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 ); /** @@ -214,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 ); @@ -240,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 @@ -252,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 ); @@ -277,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. * @@ -296,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 ); @@ -336,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 @@ -373,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 @@ -384,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 ); @@ -435,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 @@ -471,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 @@ -482,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 ); @@ -527,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 @@ -567,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 ); @@ -597,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() ) @@ -624,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 @@ -665,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 ); @@ -713,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() ) { @@ -741,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. @@ -750,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 }