|
|
@ -92,6 +92,7 @@ xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned port
|
|
|
|
void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )
|
|
|
|
void vSerialPutString( xComPortHandle pxPort, const signed char * const pcString, unsigned short usStringLength )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
unsigned short usIndex = 0;
|
|
|
|
unsigned short usIndex = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for( usIndex = 0; usIndex < usStringLength; usIndex++ )
|
|
|
|
for( usIndex = 0; usIndex < usStringLength; usIndex++ )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Check for pre-mature end of line. */
|
|
|
|
/* Check for pre-mature end of line. */
|
|
|
@ -112,6 +113,7 @@ unsigned short usIndex = 0;
|
|
|
|
signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime )
|
|
|
|
signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
portBASE_TYPE xReturn = pdFALSE;
|
|
|
|
portBASE_TYPE xReturn = pdFALSE;
|
|
|
|
|
|
|
|
|
|
|
|
if( pdTRUE == xQueueReceive( xSerialRxQueue, pcRxedChar, xBlockTime ) )
|
|
|
|
if( pdTRUE == xQueueReceive( xSerialRxQueue, pcRxedChar, xBlockTime ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Picked up a character. */
|
|
|
|
/* Picked up a character. */
|
|
|
@ -137,9 +139,8 @@ portBASE_TYPE xReturn = pdFALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Make sure that the interrupt will fire in the case where:
|
|
|
|
/* Make sure that the interrupt will fire in the case where:
|
|
|
|
* Currently sending so the Tx Complete will fire.
|
|
|
|
Currently sending so the Tx Complete will fire.
|
|
|
|
* Not sending so the Empty will fire.
|
|
|
|
Not sending so the Empty will fire. */
|
|
|
|
*/
|
|
|
|
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
taskENTER_CRITICAL();
|
|
|
|
UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE | UART_1_TX_STS_FIFO_EMPTY );
|
|
|
|
UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE | UART_1_TX_STS_FIFO_EMPTY );
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
@ -150,7 +151,7 @@ portBASE_TYPE xReturn = pdFALSE;
|
|
|
|
|
|
|
|
|
|
|
|
CY_ISR(vUartRxISR)
|
|
|
|
CY_ISR(vUartRxISR)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
portBASE_TYPE xTaskWoken = pdFALSE;
|
|
|
|
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
|
|
|
volatile unsigned char ucStatus = 0;
|
|
|
|
volatile unsigned char ucStatus = 0;
|
|
|
|
signed char cInChar = 0;
|
|
|
|
signed char cInChar = 0;
|
|
|
|
unsigned long ulMask = 0;
|
|
|
|
unsigned long ulMask = 0;
|
|
|
@ -168,7 +169,7 @@ unsigned long ulMask = 0;
|
|
|
|
ulMask = portSET_INTERRUPT_MASK_FROM_ISR();
|
|
|
|
ulMask = portSET_INTERRUPT_MASK_FROM_ISR();
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Try to deliver the character. */
|
|
|
|
/* Try to deliver the character. */
|
|
|
|
if ( pdTRUE != xQueueSendFromISR( xSerialRxQueue, &cInChar, &xTaskWoken ) )
|
|
|
|
if( pdTRUE != xQueueSendFromISR( xSerialRxQueue, &cInChar, &xHigherPriorityTaskWoken ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Run out of space. */
|
|
|
|
/* Run out of space. */
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -176,14 +177,20 @@ unsigned long ulMask = 0;
|
|
|
|
portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask );
|
|
|
|
portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* If we delivered the character then a context switch might be required. */
|
|
|
|
/* If we delivered the character then a context switch might be required.
|
|
|
|
portEND_SWITCHING_ISR( xTaskWoken );
|
|
|
|
xHigherPriorityTaskWoken was set to pdFALSE on interrupt entry. If calling
|
|
|
|
|
|
|
|
xQueueSendFromISR() caused a task to unblock, and the unblocked task has
|
|
|
|
|
|
|
|
a priority equal to or higher than the currently running task (the task this
|
|
|
|
|
|
|
|
ISR interrupted), then xHigherPriorityTaskWoken will have been set to pdTRUE and
|
|
|
|
|
|
|
|
portEND_SWITCHING_ISR() will request a context switch to the newly unblocked
|
|
|
|
|
|
|
|
task. */
|
|
|
|
|
|
|
|
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
CY_ISR(vUartTxISR)
|
|
|
|
CY_ISR(vUartTxISR)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
portBASE_TYPE xTaskWoken = pdFALSE;
|
|
|
|
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
|
|
|
volatile unsigned char ucStatus = 0;
|
|
|
|
volatile unsigned char ucStatus = 0;
|
|
|
|
signed char cOutChar = 0;
|
|
|
|
signed char cOutChar = 0;
|
|
|
|
unsigned long ulMask = 0;
|
|
|
|
unsigned long ulMask = 0;
|
|
|
@ -192,35 +199,38 @@ unsigned long ulMask = 0;
|
|
|
|
ucStatus = UART_1_ReadTxStatus();
|
|
|
|
ucStatus = UART_1_ReadTxStatus();
|
|
|
|
|
|
|
|
|
|
|
|
/* Check to see whether this is a genuine interrupt. */
|
|
|
|
/* Check to see whether this is a genuine interrupt. */
|
|
|
|
if ( ( 0 != ( ucStatus & UART_1_TX_STS_COMPLETE ) )
|
|
|
|
if( ( 0 != ( ucStatus & UART_1_TX_STS_COMPLETE ) ) || ( 0 != ( ucStatus & UART_1_TX_STS_FIFO_EMPTY ) ) )
|
|
|
|
|| ( 0 != ( ucStatus & UART_1_TX_STS_FIFO_EMPTY ) ) )
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Mask off the other RTOS interrupts to interact with the queue. */
|
|
|
|
/* Mask off the other RTOS interrupts to interact with the queue. */
|
|
|
|
ulMask = portSET_INTERRUPT_MASK_FROM_ISR();
|
|
|
|
ulMask = portSET_INTERRUPT_MASK_FROM_ISR();
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ( pdTRUE == xQueueReceiveFromISR( xSerialTxQueue, &cOutChar, &xTaskWoken ) )
|
|
|
|
if( pdTRUE == xQueueReceiveFromISR( xSerialTxQueue, &cOutChar, &xHigherPriorityTaskWoken ) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Send the next character. */
|
|
|
|
/* Send the next character. */
|
|
|
|
UART_1_PutChar( cOutChar );
|
|
|
|
UART_1_PutChar( cOutChar );
|
|
|
|
|
|
|
|
|
|
|
|
/* If we are firing, then the only interrupt we are interested in
|
|
|
|
/* If we are firing, then the only interrupt we are interested in
|
|
|
|
* is the Complete. The application code will add the Empty interrupt
|
|
|
|
is the Complete. The application code will add the Empty interrupt
|
|
|
|
* when there is something else to be done.
|
|
|
|
when there is something else to be done. */
|
|
|
|
*/
|
|
|
|
|
|
|
|
UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE );
|
|
|
|
UART_1_SetTxInterruptMode( UART_1_TX_STS_COMPLETE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* There is no work left so disable the interrupt
|
|
|
|
/* There is no work left so disable the interrupt until the application
|
|
|
|
* until the application puts more into the queue.
|
|
|
|
puts more into the queue. */
|
|
|
|
*/
|
|
|
|
|
|
|
|
UART_1_SetTxInterruptMode( 0 );
|
|
|
|
UART_1_SetTxInterruptMode( 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask );
|
|
|
|
portCLEAR_INTERRUPT_MASK_FROM_ISR( ulMask );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* If we delivered the character then a context switch might be required. */
|
|
|
|
/* If we delivered the character then a context switch might be required.
|
|
|
|
portEND_SWITCHING_ISR( xTaskWoken );
|
|
|
|
xHigherPriorityTaskWoken was set to pdFALSE on interrupt entry. If calling
|
|
|
|
|
|
|
|
xQueueSendFromISR() caused a task to unblock, and the unblocked task has
|
|
|
|
|
|
|
|
a priority equal to or higher than the currently running task (the task this
|
|
|
|
|
|
|
|
ISR interrupted), then xHigherPriorityTaskWoken will have been set to pdTRUE and
|
|
|
|
|
|
|
|
portEND_SWITCHING_ISR() will request a context switch to the newly unblocked
|
|
|
|
|
|
|
|
task. */
|
|
|
|
|
|
|
|
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|