X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=FreeRTOS%2FDemo%2FCommon%2FMinimal%2Fcomtest_strings.c;h=d23beb85005cbd3c611a85baee212e5d6ed8e9c5;hb=refs%2Ftags%2FV9.0.0rc2;hp=6a4d4cb4b1a1aa3c3d13003edd48bb78f52ea23c;hpb=69644b6878075d157a1dcface6a6136d1fce91c2;p=freertos diff --git a/FreeRTOS/Demo/Common/Minimal/comtest_strings.c b/FreeRTOS/Demo/Common/Minimal/comtest_strings.c index 6a4d4cb4b..d23beb850 100644 --- a/FreeRTOS/Demo/Common/Minimal/comtest_strings.c +++ b/FreeRTOS/Demo/Common/Minimal/comtest_strings.c @@ -1,75 +1,70 @@ /* - FreeRTOS V7.4.0 - Copyright (C) 2013 Real Time Engineers Ltd. - - FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT - http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. - - *************************************************************************** - * * - * 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.0rc2 - 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. + 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. 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 itcan be - viewed here: http://www.freertos.org/a00114.html and also obtained by - writing to Real Time Engineers Ltd., contact details for whom are available - on the FreeRTOS WEB site. - - 1 tab == 4 spaces! + FOR A PARTICULAR PURPOSE. Full license text is available on the following + link: http://www.freertos.org/a00114.html *************************************************************************** * * - * 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/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 - Documentation, books, training, latest versions, - license and Real Time Engineers Ltd. contact details. + 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, and our new - fully thread aware and reentrant UDP/IP stack. - - http://www.OpenRTOS.com - 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.SafeRTOS.com - High Integrity Systems also provide a safety - engineered and independently SIL3 certified version for use in safety and + including FreeRTOS+Trace - an indispensable productivity tool, a DOS + compatible FAT file system, and our tiny thread aware UDP/IP stack. + + 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! */ @@ -81,18 +76,18 @@ * See http://www.serialporttool.com/CommEcho.htm for a suitable echo server * for Windows hosts. * - * The timer sends a string to the UART, toggles an LED, then resets itself by - * changing its own period. The period is calculated as a pseudo random number + * The timer sends a string to the UART, toggles an LED, then resets itself by + * changing its own period. The period is calculated as a pseudo random number * between comTX_MAX_BLOCK_TIME and comTX_MIN_BLOCK_TIME. * - * The task blocks on an Rx queue waiting for a character to become available. - * Received characters are checked to ensure they match those transmitted by the - * Tx timer. An error is latched if characters are missing, incorrect, or + * The task blocks on an Rx queue waiting for a character to become available. + * Received characters are checked to ensure they match those transmitted by the + * Tx timer. An error is latched if characters are missing, incorrect, or * arrive too slowly. * * How characters are actually transmitted and received is port specific. Demos * that include this test/demo file will provide example drivers. The Tx timer - * executes in the context of the timer service (daemon) task, and must + * executes in the context of the timer service (daemon) task, and must * therefore never attempt to block. * */ @@ -128,9 +123,9 @@ /* The Tx timer transmits the sequence of characters at a pseudo random interval that is capped between comTX_MAX_BLOCK_TIME and comTX_MIN_BLOCK_TIME. */ -#define comTX_MAX_BLOCK_TIME ( ( portTickType ) 0x96 ) -#define comTX_MIN_BLOCK_TIME ( ( portTickType ) 0x32 ) -#define comOFFSET_TIME ( ( portTickType ) 3 ) +#define comTX_MAX_BLOCK_TIME ( ( TickType_t ) 0x96 ) +#define comTX_MIN_BLOCK_TIME ( ( TickType_t ) 0x32 ) +#define comOFFSET_TIME ( ( TickType_t ) 3 ) /* States for the simple state machine implemented in the Rx task. */ #define comtstWAITING_START_OF_STRING 0 @@ -141,36 +136,36 @@ a bit so more than one character can be processed at a time. This is relative to comTX_MIN_BLOCK_TIME to ensure it is never longer than the shortest gap between transmissions. It could be worked out more scientifically from the baud rate being used. */ -#define comSHORT_DELAY ( comTX_MIN_BLOCK_TIME >> ( portTickType ) 2 ) +#define comSHORT_DELAY ( comTX_MIN_BLOCK_TIME >> ( TickType_t ) 2 ) /* The string that is transmitted and received. */ #define comTRANSACTED_STRING "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" /* A block time of 0 simply means "don't block". */ -#define comtstDONT_BLOCK ( portTickType ) 0 +#define comtstDONT_BLOCK ( TickType_t ) 0 /* Handle to the com port used by both tasks. */ static xComPortHandle xPort = NULL; /* The callback function allocated to the transmit timer, as described in the comments at the top of this file. */ -static void prvComTxTimerCallback( xTimerHandle xTimer ); +static void prvComTxTimerCallback( TimerHandle_t xTimer ); /* The receive task as described in the comments at the top of this file. */ static void vComRxTask( void *pvParameters ); /* The Rx task will toggle LED ( uxBaseLED + comRX_LED_OFFSET). The Tx task will toggle LED ( uxBaseLED + comTX_LED_OFFSET ). */ -static unsigned portBASE_TYPE uxBaseLED = 0; +static UBaseType_t uxBaseLED = 0; /* The Rx task toggles uxRxLoops on each successful iteration of its defined function - provided no errors have ever been latched. If this variable stops incrementing, then an error has occurred. */ -static volatile unsigned portBASE_TYPE uxRxLoops = 0UL; +static volatile UBaseType_t uxRxLoops = 0UL; /* The timer used to periodically transmit the string. This is the timer that has prvComTxTimerCallback allocated to it as its callback function. */ -static xTimerHandle xTxTimer = NULL; +static TimerHandle_t xTxTimer = NULL; /* The string length is held at file scope so the Tx timer does not need to calculate it each time it executes. */ @@ -178,7 +173,7 @@ static size_t xStringLength = 0U; /*-----------------------------------------------------------*/ -void vStartComTestStringsTasks( unsigned portBASE_TYPE uxPriority, unsigned long ulBaudRate, unsigned portBASE_TYPE uxLED ) +void vStartComTestStringsTasks( UBaseType_t uxPriority, uint32_t ulBaudRate, UBaseType_t uxLED ) { /* Store values that are used at run time. */ uxBaseLED = uxLED; @@ -197,15 +192,15 @@ void vStartComTestStringsTasks( unsigned portBASE_TYPE uxPriority, unsigned long /* Create the Rx task and the Tx timer. The timer is started from the Rx task. */ - xTaskCreate( vComRxTask, ( signed char * ) "COMRx", comSTACK_SIZE, NULL, uxPriority, ( xTaskHandle * ) NULL ); - xTxTimer = xTimerCreate( ( const signed char * ) "TxTimer", comTX_MIN_BLOCK_TIME, pdFALSE, NULL, prvComTxTimerCallback ); + xTaskCreate( vComRxTask, "COMRx", comSTACK_SIZE, NULL, uxPriority, ( TaskHandle_t * ) NULL ); + xTxTimer = xTimerCreate( "TxTimer", comTX_MIN_BLOCK_TIME, pdFALSE, NULL, prvComTxTimerCallback ); configASSERT( xTxTimer ); } /*-----------------------------------------------------------*/ -static void prvComTxTimerCallback( xTimerHandle xTimer ) +static void prvComTxTimerCallback( TimerHandle_t xTimer ) { -portTickType xTimeToWait; +TickType_t xTimeToWait; /* The parameter is not used in this case. */ ( void ) xTimer; @@ -214,7 +209,7 @@ portTickType xTimeToWait; sample driver provided with this demo. However - as this is a timer, it executes in the context of the timer task and therefore must not block. */ - vSerialPutString( xPort, ( const signed char * const ) comTRANSACTED_STRING, xStringLength ); + vSerialPutString( xPort, comTRANSACTED_STRING, xStringLength ); /* Toggle an LED to give a visible indication that another transmission has been performed. */ @@ -241,8 +236,8 @@ portTickType xTimeToWait; static void vComRxTask( void *pvParameters ) { -portBASE_TYPE xState = comtstWAITING_START_OF_STRING, xErrorOccurred = pdFALSE; -signed char *pcExpectedByte, cRxedChar; +BaseType_t xState = comtstWAITING_START_OF_STRING, xErrorOccurred = pdFALSE; +char *pcExpectedByte, cRxedChar; const xComPortHandle xPort = NULL; /* The parameter is not used in this example. */ @@ -254,7 +249,7 @@ const xComPortHandle xPort = NULL; /* The first expected Rx character is the first in the string that is transmitted. */ - pcExpectedByte = ( signed char * ) comTRANSACTED_STRING; + pcExpectedByte = comTRANSACTED_STRING; for( ;; ) { @@ -278,9 +273,9 @@ const xComPortHandle xPort = NULL; xState = comtstWAITING_END_OF_STRING; pcExpectedByte++; - /* Block for a short period. This just allows the Rx queue + /* Block for a short period. This just allows the Rx queue to contain more than one character, and therefore prevent - thrashing reads to the queue, and repetitive context + thrashing reads to the queue, and repetitive context switches as each character is received. */ vTaskDelay( comSHORT_DELAY ); } @@ -307,7 +302,7 @@ const xComPortHandle xPort = NULL; } /* Go back to wait for the start of the next string. */ - pcExpectedByte = ( signed char * ) comTRANSACTED_STRING; + pcExpectedByte = comTRANSACTED_STRING; xState = comtstWAITING_START_OF_STRING; } else @@ -333,9 +328,9 @@ const xComPortHandle xPort = NULL; } /*-----------------------------------------------------------*/ -portBASE_TYPE xAreComTestTasksStillRunning( void ) +BaseType_t xAreComTestTasksStillRunning( void ) { -portBASE_TYPE xReturn; +BaseType_t xReturn; /* If the count of successful reception loops has not changed than at some time an error occurred (i.e. a character was received out of sequence)