I'm trying to enable and use UART1, and more specifically, the Rx interrupt.
I have created a deck and connected a sensor I've built to the CF2 UART1 Rx pin (PC11). My sensor does transmit data over the UART as I'm seeing the expected signal using a scope.
While the CF2 UART1 initializing and testing functions do seem to work (I changed the uart1Test function to flash some LEDs), I cannot seem to use the Rx interrupt (USART_IT_RXNE).
Of course I have enabled UART1 in the config file with
Code: Select all
ENABLE_UART1
The IRQ handler in uart1.c is as following:
Code: Select all
void __attribute__((used)) USART3_IRQHandler(void)
{
uint8_t rxData;
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
if (USART_GetITStatus(UART1_TYPE, USART_IT_RXNE))
{
rxData = USART_ReceiveData(UART1_TYPE) & 0x00FF;
xQueueSendFromISR(uart1queue, &rxData, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
}
Code: Select all
int uart1Getchar(char * ch)
{
xQueueReceive(uart1queue, ch, portMAX_DELAY); // Should be blocked on queue until USART3_IRQHandler is executed
return 1;
}
Code: Select all
static void spinTask()
{
int i = 0;
char angle[] = "000\n\r";
systemWaitStart();
while (1)
{
i = uart1Getchar(angle); // Will be set to 1 if uart1Getchar function executes
while (i)
{
ledSet(1, 0);
vTaskDelay(M2T(100));
ledSet(1, 1);
vTaskDelay(M2T(100));
}
}
}
Is there anything I need to do in order to enable the use of the Rx interrupt?
I did see that the uart1Init function includes these two lines:
Code: Select all
USART_ITConfig(UART1_TYPE, USART_IT_RXNE, ENABLE);
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
Thanks