Fixed UART RX problems

git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@232 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
mmi
2017-10-04 12:54:11 +00:00
parent 73a391f720
commit 8b315602e9
7 changed files with 115 additions and 51 deletions

View File

@@ -327,6 +327,12 @@ static void loggerTask(void* parameters)
IODevice_write(loggerDevice, str, strlen(str));
#endif
char buffer[5] = {0,};
size_t actualLength = 0;
IODevice_read(loggerDevice, buffer, 5, &actualLength);
snprintf(str, sizeof(str) / sizeof(str[0]), "%d - %x %x %x %x %x", actualLength, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4]);
IODevice_write(loggerDevice, str, strlen(str));
}
}
}

View File

@@ -170,7 +170,7 @@ static void initTask(void* parameters)
xTaskCreate(ledBlinkTask, (const char* const)"ledTask", 40, &ledTaskArguments, 0, &ledTaskHandle);
Logger_construct(&uart1->device);
Logger_construct(&uart3->device);
NHD0420_construct(&nhd0420, &spiDisplay->device);

View File

@@ -142,11 +142,8 @@ void USART1_IRQHandler(void)
//! Transmission register empty interrupt
if(USART_GetITStatus(USART1, USART_IT_TXE) != RESET)
{
//! Receive element from usart transmission queue
struct usartQueueItem usartTxItem;
xQueueReceiveFromISR(uart1->txQueue, &usartTxItem, &higherPriorityTaskWoken);
//! Write one byte to the transmit data register
USART_SendData(USART1, usartTxItem.byte);
@@ -163,11 +160,10 @@ void USART1_IRQHandler(void)
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
{
//! Read one byte from the receive data register
struct usartQueueItem usartRxItem;
//! Reading from reception register automatically clears the RXNE interrupt
usartRxItem.byte = (unsigned char) 0xFF & USART_ReceiveData(USART1);
//! Add the byte to the bluetooth RX queue
usartRxItem.byte = USART_ReceiveData(USART1);
//! Add the byte to the USART RX queue
//! In case of a full queue, the data is dumped
(void)xQueueSendFromISR(uart1->rxQueue, &usartRxItem, &higherPriorityTaskWoken);
}
@@ -195,11 +191,8 @@ void USART3_IRQHandler(void)
//! Transmission register empty interrupt
if(USART_GetITStatus(USART3, USART_IT_TXE) != RESET)
{
//! Receive element from usart transmission queue
struct usartQueueItem usartTxItem;
xQueueReceiveFromISR(uart3->txQueue, &usartTxItem, &higherPriorityTaskWoken);
//! Write one byte to the transmit data register
USART_SendData(USART3, usartTxItem.byte);
@@ -216,11 +209,10 @@ void USART3_IRQHandler(void)
if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET)
{
//! Read one byte from the receive data register
struct usartQueueItem usartRxItem;
//! Reading from reception register automatically clears the RXNE interrupt
usartRxItem.byte = (unsigned char) 0xFF & USART_ReceiveData(USART3);
//! Add the byte to the bluetooth RX queue
usartRxItem.byte = (char)USART_ReceiveData(USART3);
//! Add the byte to the USART RX queue
//! In case of a full queue, the data is dumped
(void)xQueueSendFromISR(uart3->rxQueue, &usartRxItem, &higherPriorityTaskWoken);
}
@@ -387,14 +379,6 @@ void RTC_IRQHandler(void)
xSemaphoreGiveFromISR(rtc->secondSync, &higherPriorityTaskWoken);
Display_feedRefreshCounter(display);
if (ledGreen->status)
{
LED_turnOff(ledGreen);
}
else
{
LED_turnOn(ledGreen);
}
/* Wait until last write operation on RTC registers has finished */
RTC_WaitForLastTask();