mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-23 15:01:56 -04:00
Change to use UART1.
This commit is contained in:
parent
9157e9cfef
commit
4c8a5cfdad
|
@ -79,9 +79,9 @@
|
||||||
#define serWANTED_CLOCK_SCALING ( ( unsigned portLONG ) 16 )
|
#define serWANTED_CLOCK_SCALING ( ( unsigned portLONG ) 16 )
|
||||||
|
|
||||||
/* Constants to setup and access the VIC. */
|
/* Constants to setup and access the VIC. */
|
||||||
#define serU0VIC_CHANNEL ( ( unsigned portLONG ) 0x0006 )
|
#define serU1VIC_CHANNEL ( ( unsigned portLONG ) 0x0007 )
|
||||||
#define serU0VIC_CHANNEL_BIT ( ( unsigned portLONG ) 0x0040 )
|
#define serU1VIC_CHANNEL_BIT ( ( unsigned portLONG ) 0x0080 )
|
||||||
#define serU0VIC_ENABLE ( ( unsigned portLONG ) 0x0020 )
|
#define serU1VIC_ENABLE ( ( unsigned portLONG ) 0x0020 )
|
||||||
|
|
||||||
/* Misc. */
|
/* Misc. */
|
||||||
#define serINVALID_QUEUE ( ( xQueueHandle ) 0 )
|
#define serINVALID_QUEUE ( ( xQueueHandle ) 0 )
|
||||||
|
@ -97,6 +97,7 @@
|
||||||
#define serSOURCE_ERROR ( ( unsigned portCHAR ) 0x06 )
|
#define serSOURCE_ERROR ( ( unsigned portCHAR ) 0x06 )
|
||||||
#define serSOURCE_RX ( ( unsigned portCHAR ) 0x04 )
|
#define serSOURCE_RX ( ( unsigned portCHAR ) 0x04 )
|
||||||
#define serINTERRUPT_SOURCE_MASK ( ( unsigned portCHAR ) 0x0f )
|
#define serINTERRUPT_SOURCE_MASK ( ( unsigned portCHAR ) 0x0f )
|
||||||
|
#define serINTERRUPT_IS_PENDING ( ( unsigned portCHAR ) 0x01 )
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -147,27 +148,27 @@ xComPortHandle xReturn = serHANDLE;
|
||||||
ulDivisor = configCPU_CLOCK_HZ / ulWantedClock;
|
ulDivisor = configCPU_CLOCK_HZ / ulWantedClock;
|
||||||
|
|
||||||
/* Set the DLAB bit so we can access the divisor. */
|
/* Set the DLAB bit so we can access the divisor. */
|
||||||
U0LCR |= serDLAB;
|
U1LCR |= serDLAB;
|
||||||
|
|
||||||
/* Setup the divisor. */
|
/* Setup the divisor. */
|
||||||
U0DLL = ( unsigned portCHAR ) ( ulDivisor & ( unsigned portLONG ) 0xff );
|
U1DLL = ( unsigned portCHAR ) ( ulDivisor & ( unsigned portLONG ) 0xff );
|
||||||
ulDivisor >>= 8;
|
ulDivisor >>= 8;
|
||||||
U0DLM = ( unsigned portCHAR ) ( ulDivisor & ( unsigned portLONG ) 0xff );
|
U1DLM = ( unsigned portCHAR ) ( ulDivisor & ( unsigned portLONG ) 0xff );
|
||||||
|
|
||||||
/* Turn on the FIFO's and clear the buffers. */
|
/* Turn on the FIFO's and clear the buffers. */
|
||||||
U0FCR = ( serFIFO_ON | serCLEAR_FIFO );
|
U1FCR = ( serFIFO_ON | serCLEAR_FIFO );
|
||||||
|
|
||||||
/* Setup transmission format. */
|
/* Setup transmission format. */
|
||||||
U0LCR = serNO_PARITY | ser1_STOP_BIT | ser8_BIT_CHARS;
|
U1LCR = serNO_PARITY | ser1_STOP_BIT | ser8_BIT_CHARS;
|
||||||
|
|
||||||
/* Setup the VIC for the UART. */
|
/* Setup the VIC for the UART. */
|
||||||
VICIntSelect &= ~( serU0VIC_CHANNEL_BIT );
|
VICIntSelect &= ~( serU1VIC_CHANNEL_BIT );
|
||||||
VICIntEnable |= serU0VIC_CHANNEL_BIT;
|
VICIntEnable |= serU1VIC_CHANNEL_BIT;
|
||||||
VICVectAddr1 = ( unsigned portLONG ) vUART_ISREntry;
|
VICVectAddr1 = ( unsigned portLONG ) vUART_ISREntry;
|
||||||
VICVectCntl1 = serU0VIC_CHANNEL | serU0VIC_ENABLE;
|
VICVectCntl1 = serU1VIC_CHANNEL | serU1VIC_ENABLE;
|
||||||
|
|
||||||
/* Enable UART0 interrupts. */
|
/* Enable UART0 interrupts. */
|
||||||
U0IER |= serENABLE_INTERRUPTS;
|
U1IER |= serENABLE_INTERRUPTS;
|
||||||
}
|
}
|
||||||
portEXIT_CRITICAL();
|
portEXIT_CRITICAL();
|
||||||
}
|
}
|
||||||
|
@ -234,7 +235,7 @@ signed portBASE_TYPE xReturn;
|
||||||
/* We wrote the character directly to the UART, so was
|
/* We wrote the character directly to the UART, so was
|
||||||
successful. */
|
successful. */
|
||||||
lTHREEmpty = pdFALSE;
|
lTHREEmpty = pdFALSE;
|
||||||
U0THR = cOutChar;
|
U1THR = cOutChar;
|
||||||
xReturn = pdPASS;
|
xReturn = pdPASS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -253,7 +254,7 @@ signed portBASE_TYPE xReturn;
|
||||||
{
|
{
|
||||||
xQueueReceive( xCharsForTx, &cOutChar, serNO_BLOCK );
|
xQueueReceive( xCharsForTx, &cOutChar, serNO_BLOCK );
|
||||||
lTHREEmpty = pdFALSE;
|
lTHREEmpty = pdFALSE;
|
||||||
U0THR = cOutChar;
|
U1THR = cOutChar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -266,23 +267,26 @@ signed portBASE_TYPE xReturn;
|
||||||
void vUART_ISRHandler( void )
|
void vUART_ISRHandler( void )
|
||||||
{
|
{
|
||||||
signed portCHAR cChar;
|
signed portCHAR cChar;
|
||||||
portBASE_TYPE xTaskWokenByRx, xTaskWokenByTx;
|
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||||
|
unsigned portCHAR ucInterrupt;
|
||||||
|
|
||||||
xTaskWokenByTx = pdFALSE;
|
ucInterrupt = U1IIR;
|
||||||
xTaskWokenByRx = pdFALSE;
|
|
||||||
|
|
||||||
|
/* The interrupt pending bit is active low. */
|
||||||
|
while( ( ucInterrupt & serINTERRUPT_IS_PENDING ) == 0 )
|
||||||
|
{
|
||||||
/* What caused the interrupt? */
|
/* What caused the interrupt? */
|
||||||
switch( U0IIR & serINTERRUPT_SOURCE_MASK )
|
switch( ucInterrupt & serINTERRUPT_SOURCE_MASK )
|
||||||
{
|
{
|
||||||
case serSOURCE_ERROR : /* Not handling this, but clear the interrupt. */
|
case serSOURCE_ERROR : /* Not handling this, but clear the interrupt. */
|
||||||
cChar = U0LSR;
|
cChar = U1LSR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case serSOURCE_THRE : /* The THRE is empty. If there is another
|
case serSOURCE_THRE : /* The THRE is empty. If there is another
|
||||||
character in the Tx queue, send it now. */
|
character in the Tx queue, send it now. */
|
||||||
if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xTaskWokenByTx ) == pdTRUE )
|
if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE )
|
||||||
{
|
{
|
||||||
U0THR = cChar;
|
U1THR = cChar;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -296,23 +300,23 @@ portBASE_TYPE xTaskWokenByRx, xTaskWokenByTx;
|
||||||
case serSOURCE_RX_TIMEOUT :
|
case serSOURCE_RX_TIMEOUT :
|
||||||
case serSOURCE_RX : /* A character was received. Place it in
|
case serSOURCE_RX : /* A character was received. Place it in
|
||||||
the queue of received characters. */
|
the queue of received characters. */
|
||||||
cChar = U0RBR;
|
cChar = U1RBR;
|
||||||
if( xQueueSendFromISR( xRxedChars, &cChar, pdFALSE ) )
|
xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken );
|
||||||
{
|
|
||||||
xTaskWokenByRx = pdTRUE;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default : /* There is nothing to do, leave the ISR. */
|
default : /* There is nothing to do, leave the ISR. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ucInterrupt = U1IIR;
|
||||||
|
}
|
||||||
|
|
||||||
/* Clear the ISR in the VIC. */
|
/* Clear the ISR in the VIC. */
|
||||||
VICVectAddr = serCLEAR_VIC_INTERRUPT;
|
VICVectAddr = serCLEAR_VIC_INTERRUPT;
|
||||||
|
|
||||||
/* Exit the ISR. If a task was woken by either a character being received
|
/* Exit the ISR. If a task was woken by either a character being received
|
||||||
or transmitted then a context switch will occur. */
|
or transmitted then a context switch will occur. */
|
||||||
portEXIT_SWITCHING_ISR( ( xTaskWokenByTx || xTaskWokenByRx ) );
|
portEXIT_SWITCHING_ISR( xHigherPriorityTaskWoken );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue