]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/PIC32MX_MPLAB/serial/serial.c
Update version number in readiness for V10.3.0 release. Sync SVN with reviewed releas...
[freertos] / FreeRTOS / Demo / PIC32MX_MPLAB / serial / serial.c
index 458cc8054218a67747551a75a9af9471818db82a..1702512594cbf6f23d4f306ebed77e00e3de3de4 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.3.0\r
+ * Copyright (C) 2020 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
 \r
 /* BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER. \r
@@ -87,11 +48,11 @@ an example of an efficient driver. */
 #define serSET_FLAG                                            ( 1 )\r
 \r
 /* The queues used to communicate between tasks and ISR's. */\r
-static xQueueHandle xRxedChars; \r
-static xQueueHandle xCharsForTx; \r
+static QueueHandle_t xRxedChars; \r
+static QueueHandle_t xCharsForTx; \r
 \r
 /* Flag used to indicate the tx status. */\r
-static portBASE_TYPE xTxHasEnded;\r
+static volatile portBASE_TYPE xTxHasEnded;\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -99,7 +60,7 @@ static portBASE_TYPE xTxHasEnded;
 entry point the IPL setting in the following prototype has no effect.  The\r
 interrupt priority is set by the call to  ConfigIntUART2() in \r
 xSerialPortInitMinimal(). */\r
-void __attribute__( (interrupt(ipl0), vector(_UART2_VECTOR))) vU2InterruptWrapper( void );\r
+void __attribute__( (interrupt(IPL0AUTO), vector(_UART2_VECTOR))) vU2InterruptWrapper( void );\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -123,7 +84,7 @@ unsigned short usBRG;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime )\r
+signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, TickType_t xBlockTime )\r
 {\r
        /* Only one port is supported. */\r
        ( void ) pxPort;\r
@@ -141,23 +102,32 @@ signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedC
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, portTickType xBlockTime )\r
+signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, TickType_t xBlockTime )\r
 {\r
+signed portBASE_TYPE xReturn;\r
+\r
        /* Only one port is supported. */\r
        ( void ) pxPort;\r
 \r
        /* Return false if after the block time there is no room on the Tx queue. */\r
        if( xQueueSend( xCharsForTx, &cOutChar, xBlockTime ) != pdPASS )\r
        {\r
-               return pdFAIL;\r
+               xReturn = pdFAIL;\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdPASS;\r
        }\r
 \r
-       /* A critical section should not be required as xTxHasEnded will not be\r
-       written to by the ISR if it is already 0 (is this correct?). */\r
-       if( xTxHasEnded )\r
+       if( xReturn != pdFAIL )\r
        {\r
-               xTxHasEnded = pdFALSE;\r
-               IFS1SET = _IFS1_U2TXIF_MASK;\r
+               /* A critical section should not be required as xTxHasEnded will not be\r
+               written to by the ISR if it is already 0. */\r
+               if(  xTxHasEnded == pdTRUE )\r
+               {\r
+                       xTxHasEnded = pdFALSE;\r
+                       IFS1SET = _IFS1_U2TXIF_MASK;\r
+               }\r
        }\r
 \r
        return pdPASS;\r
@@ -193,7 +163,7 @@ static portBASE_TYPE xHigherPriorityTaskWoken;
        /* Are any Tx interrupts pending? */\r
        if( IFS1bits.U2TXIF == 1 )\r
        {\r
-               while( !( U2STAbits.UTXBF ) )\r
+               while( ( U2STAbits.UTXBF ) == 0 )\r
                {\r
                        if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE )\r
                        {\r