Update PIC32 serial.c slightly to add volatile qualifier and update to coding standard.

pull/4/head
Richard Barry 12 years ago
parent 1e17924fa8
commit 14a190e79e

@ -99,7 +99,7 @@ static xQueueHandle xRxedChars;
static xQueueHandle xCharsForTx; static xQueueHandle xCharsForTx;
/* Flag used to indicate the tx status. */ /* Flag used to indicate the tx status. */
static portBASE_TYPE xTxHasEnded; static volatile portBASE_TYPE xTxHasEnded;
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -151,22 +151,31 @@ signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedC
signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, portTickType xBlockTime ) signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, portTickType xBlockTime )
{ {
signed portBASE_TYPE xReturn;
/* Only one port is supported. */ /* Only one port is supported. */
( void ) pxPort; ( void ) pxPort;
/* Return false if after the block time there is no room on the Tx queue. */ /* Return false if after the block time there is no room on the Tx queue. */
if( xQueueSend( xCharsForTx, &cOutChar, xBlockTime ) != pdPASS ) if( xQueueSend( xCharsForTx, &cOutChar, xBlockTime ) != pdPASS )
{ {
return pdFAIL; xReturn = pdFAIL;
}
else
{
xReturn = pdPASS;
} }
if( xReturn != pdFAIL )
{
/* A critical section should not be required as xTxHasEnded will not be /* 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?). */ written to by the ISR if it is already 0. */
if( xTxHasEnded ) if( xTxHasEnded == pdTRUE )
{ {
xTxHasEnded = pdFALSE; xTxHasEnded = pdFALSE;
IFS1SET = _IFS1_U2TXIF_MASK; IFS1SET = _IFS1_U2TXIF_MASK;
} }
}
return pdPASS; return pdPASS;
} }
@ -201,7 +210,7 @@ static portBASE_TYPE xHigherPriorityTaskWoken;
/* Are any Tx interrupts pending? */ /* Are any Tx interrupts pending? */
if( IFS1bits.U2TXIF == 1 ) if( IFS1bits.U2TXIF == 1 )
{ {
while( !( U2STAbits.UTXBF ) ) while( ( U2STAbits.UTXBF ) == 0 )
{ {
if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE ) if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE )
{ {

Loading…
Cancel
Save