static xQueueHandle 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
\r
signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, portTickType 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
/* 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