From: richardbarry Date: Sun, 14 Jul 2013 08:46:15 +0000 (+0000) Subject: Update PIC32 serial.c slightly to add volatile qualifier and update to coding standard. X-Git-Tag: V7.5.0~11 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=af22c2b1b3aa45204b94d03aee671c56124025f2;p=freertos Update PIC32 serial.c slightly to add volatile qualifier and update to coding standard. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1979 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS/Demo/PIC32MX_MPLAB/serial/serial.c b/FreeRTOS/Demo/PIC32MX_MPLAB/serial/serial.c index cdb34f30f..12a36d382 100644 --- a/FreeRTOS/Demo/PIC32MX_MPLAB/serial/serial.c +++ b/FreeRTOS/Demo/PIC32MX_MPLAB/serial/serial.c @@ -99,7 +99,7 @@ static xQueueHandle xRxedChars; static xQueueHandle xCharsForTx; /* Flag used to indicate the tx status. */ -static portBASE_TYPE xTxHasEnded; +static volatile portBASE_TYPE xTxHasEnded; /*-----------------------------------------------------------*/ @@ -151,21 +151,30 @@ signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedC signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, portTickType xBlockTime ) { +signed portBASE_TYPE xReturn; + /* Only one port is supported. */ ( void ) pxPort; /* Return false if after the block time there is no room on the Tx queue. */ if( xQueueSend( xCharsForTx, &cOutChar, xBlockTime ) != pdPASS ) { - return pdFAIL; + xReturn = pdFAIL; + } + else + { + xReturn = pdPASS; } - /* A critical section should not be required as xTxHasEnded will not be - written to by the ISR if it is already 0 (is this correct?). */ - if( xTxHasEnded ) + if( xReturn != pdFAIL ) { - xTxHasEnded = pdFALSE; - IFS1SET = _IFS1_U2TXIF_MASK; + /* A critical section should not be required as xTxHasEnded will not be + written to by the ISR if it is already 0. */ + if( xTxHasEnded == pdTRUE ) + { + xTxHasEnded = pdFALSE; + IFS1SET = _IFS1_U2TXIF_MASK; + } } return pdPASS; @@ -201,7 +210,7 @@ static portBASE_TYPE xHigherPriorityTaskWoken; /* Are any Tx interrupts pending? */ if( IFS1bits.U2TXIF == 1 ) { - while( !( U2STAbits.UTXBF ) ) + while( ( U2STAbits.UTXBF ) == 0 ) { if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE ) {