PoC: connect USB/serial ISR directly to the respective serial send
This assumes that USB IRQ has a lower logical prio as the UART IRQ so that it can be pre-empted by the USART ISR.
This commit is contained in:
committed by
Raphael Coeffic
parent
3e390bd582
commit
96743a9fc4
@@ -22,10 +22,6 @@
|
||||
#include "opentx.h"
|
||||
#include "targets/horus/board.h"
|
||||
|
||||
#if defined(AUX_SERIAL) || defined(AUX2_SERIAL)
|
||||
#include <FreeRTOS.h>
|
||||
#endif
|
||||
|
||||
#if defined(AUX_SERIAL)
|
||||
uint8_t auxSerialMode = UART_MODE_COUNT; // Prevent debug output before port is setup
|
||||
Fifo<uint8_t, 512> auxSerialTxFifo;
|
||||
@@ -196,7 +192,6 @@ uint8_t auxSerialTracesEnabled()
|
||||
extern "C" void AUX_SERIAL_USART_IRQHandler(void)
|
||||
{
|
||||
DEBUG_INTERRUPT(INT_SER2);
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
// Send
|
||||
if (USART_GetITStatus(AUX_SERIAL_USART, USART_IT_TXE) != RESET) {
|
||||
@@ -219,8 +214,7 @@ extern "C" void AUX_SERIAL_USART_IRQHandler(void)
|
||||
if (!(status & USART_FLAG_ERRORS)) {
|
||||
switch (auxSerialMode) {
|
||||
case UART_MODE_DEBUG:
|
||||
xStreamBufferSendFromISR(cliRxBuffer, &data, 1,
|
||||
&xHigherPriorityTaskWoken);
|
||||
cliReceiveData(&data, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -242,9 +236,6 @@ extern "C" void AUX_SERIAL_USART_IRQHandler(void)
|
||||
}
|
||||
status = AUX_SERIAL_USART->SR;
|
||||
}
|
||||
|
||||
// might effect a context switch on ISR exit
|
||||
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
#endif // AUX_SERIAL
|
||||
|
||||
@@ -393,7 +384,6 @@ uint8_t aux2SerialTracesEnabled()
|
||||
extern "C" void AUX2_SERIAL_USART_IRQHandler(void)
|
||||
{
|
||||
DEBUG_INTERRUPT(INT_SER2);
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
// Send
|
||||
if (USART_GetITStatus(AUX2_SERIAL_USART, USART_IT_TXE) != RESET) {
|
||||
@@ -416,8 +406,7 @@ extern "C" void AUX2_SERIAL_USART_IRQHandler(void)
|
||||
if (!(status & USART_FLAG_ERRORS)) {
|
||||
switch (aux2SerialMode) {
|
||||
case UART_MODE_DEBUG:
|
||||
xStreamBufferSendFromISR(cliRxBuffer, &data, 1,
|
||||
&xHigherPriorityTaskWoken);
|
||||
cliReceiveData(&data, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -440,8 +429,5 @@ extern "C" void AUX2_SERIAL_USART_IRQHandler(void)
|
||||
}
|
||||
status = AUX2_SERIAL_USART->SR;
|
||||
}
|
||||
|
||||
// might effect a context switch on ISR exit
|
||||
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
}
|
||||
#endif // AUX2_SERIAL
|
||||
|
||||
@@ -149,6 +149,7 @@ static uint16_t VCP_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len)
|
||||
// some debug vars
|
||||
uint16_t usbWraps = 0;
|
||||
uint16_t charsWritten = 0;
|
||||
uint16_t usbTxErrors = 0;
|
||||
|
||||
void usbSerialPutc(uint8_t c)
|
||||
{
|
||||
@@ -172,7 +173,10 @@ void usbSerialPutc(uint8_t c)
|
||||
}
|
||||
|
||||
// buffer is too full, skip this write
|
||||
if (txDataLen > (APP_RX_DATA_SIZE - CDC_DATA_MAX_PACKET_SIZE)) return;
|
||||
if (txDataLen > (APP_RX_DATA_SIZE - CDC_DATA_MAX_PACKET_SIZE)) {
|
||||
usbTxErrors++;
|
||||
return;
|
||||
}
|
||||
|
||||
++charsWritten;
|
||||
|
||||
@@ -217,17 +221,11 @@ static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len)
|
||||
// if the cliRxFifo does not have enough free space to receive all
|
||||
// available characters, return VCP_FAIL. Maybe that will throttle down
|
||||
// the sender and we will receive the same packet at a later time.
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
#if defined(CLI)
|
||||
|
||||
//copy data to the application FIFO
|
||||
xStreamBufferSendFromISR(cliRxBuffer, Buf, Len, &xHigherPriorityTaskWoken);
|
||||
xTaskNotifyFromISR(cliTaskId.rtos_handle, 0, eNoAction,
|
||||
&xHigherPriorityTaskWoken);
|
||||
// Please note that we don't try to yield to the task that has
|
||||
// potentially been woken up, as this might effect a context switch
|
||||
// in place, whereby the ISR is not done yet handling the USB request
|
||||
// pass data to CLI
|
||||
cliReceiveData(Buf, Len);
|
||||
|
||||
#elif defined(LUA)
|
||||
// TODO: find a better implementation to allow
|
||||
@@ -243,8 +241,6 @@ static uint16_t VCP_DataRx (uint8_t* Buf, uint32_t Len)
|
||||
|
||||
#endif
|
||||
|
||||
// might effect a context switch on ISR exit
|
||||
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user