Fixes for TX16S

This commit is contained in:
Raphael Coeffic
2022-03-20 16:22:14 +01:00
parent 74effd7c14
commit 74f19371ae
5 changed files with 26 additions and 23 deletions
+4
View File
@@ -1963,6 +1963,10 @@ static int luaSerialRead(lua_State * L)
int num = luaL_optunsigned(L, 1, 0); int num = luaL_optunsigned(L, 1, 0);
if (!luaRxFifo) { if (!luaRxFifo) {
// TODO:
// - check which serial port has been assigned this function
// - set the receive callback on that serial port
//
luaRxFifo = new Fifo<uint8_t, LUA_FIFO_SIZE>(); luaRxFifo = new Fifo<uint8_t, LUA_FIFO_SIZE>();
if (!luaRxFifo) { if (!luaRxFifo) {
lua_pushlstring(L, "", 0); lua_pushlstring(L, "", 0);
@@ -65,12 +65,12 @@ const stm32_usart_t auxUSART = {
#endif #endif
}; };
static void auxSerialOnSend(uint8_t& data) static bool auxSerialOnSend(uint8_t& data)
{ {
return auxSerialTxFifo.pop(data); return auxSerialTxFifo.pop(data);
} }
static etx_serial_callbacks auxSerialCb = { static etx_serial_callbacks_t auxSerialCb = {
.on_send = auxSerialOnSend, .on_send = auxSerialOnSend,
.on_receive = nullptr, .on_receive = nullptr,
.on_error = nullptr, .on_error = nullptr,
@@ -133,7 +133,7 @@ extern "C" void AUX_SERIAL_USART_IRQHandler(void)
stm32_usart_isr(&auxUSART, &auxSerialCb); stm32_usart_isr(&auxUSART, &auxSerialCb);
} }
void auxSerialPutc(char c) void auxSerialPutc(uint8_t c)
{ {
if (auxSerialTxFifo.isFull()) return; if (auxSerialTxFifo.isFull()) return;
auxSerialTxFifo.push(c); auxSerialTxFifo.push(c);
@@ -147,8 +147,11 @@ void auxSerialStop()
static void serialPushLua(uint8_t data) static void serialPushLua(uint8_t data)
{ {
if (luaRxFifo) // TODO: this should be set by LUA instead of
luaRxFifo->push(data); // including some LUA header here.
//
// if (luaRxFifo)
// luaRxFifo->push(data);
} }
void auxSerialInit(unsigned int mode, unsigned int protocol) void auxSerialInit(unsigned int mode, unsigned int protocol)
@@ -224,7 +227,7 @@ uint8_t aux2SerialMode = UART_MODE_COUNT; // Prevent debug output before port i
Fifo<uint8_t, 512> aux2SerialTxFifo; Fifo<uint8_t, 512> aux2SerialTxFifo;
AuxSerialRxFifo aux2SerialRxFifo __DMA (AUX2_SERIAL_DMA_Stream_RX); AuxSerialRxFifo aux2SerialRxFifo __DMA (AUX2_SERIAL_DMA_Stream_RX);
const LL_GPIO_InitTypeDef auxUSARTPinInit = { const LL_GPIO_InitTypeDef aux2USARTPinInit = {
.Pin = AUX2_SERIAL_GPIO_PIN_TX | AUX2_SERIAL_GPIO_PIN_RX, .Pin = AUX2_SERIAL_GPIO_PIN_TX | AUX2_SERIAL_GPIO_PIN_RX,
.Mode = LL_GPIO_MODE_ALTERNATE, .Mode = LL_GPIO_MODE_ALTERNATE,
.Speed = LL_GPIO_SPEED_FREQ_LOW, .Speed = LL_GPIO_SPEED_FREQ_LOW,
@@ -236,7 +239,7 @@ const LL_GPIO_InitTypeDef auxUSARTPinInit = {
const stm32_usart_t aux2USART = { const stm32_usart_t aux2USART = {
.USARTx = AUX2_SERIAL_USART, .USARTx = AUX2_SERIAL_USART,
.GPIOx = AUX2_SERIAL_GPIO, .GPIOx = AUX2_SERIAL_GPIO,
.pinInit = &auxUSARTPinInit, .pinInit = &aux2USARTPinInit,
.IRQn = AUX2_SERIAL_USART_IRQn, .IRQn = AUX2_SERIAL_USART_IRQn,
.IRQ_Prio = 7, // TODO: define constant .IRQ_Prio = 7, // TODO: define constant
.txDMA = nullptr, .txDMA = nullptr,
@@ -247,12 +250,12 @@ const stm32_usart_t aux2USART = {
.rxDMA_Channel = AUX2_SERIAL_DMA_Channel_RX, .rxDMA_Channel = AUX2_SERIAL_DMA_Channel_RX,
}; };
static void aux2SerialOnSend(uint8_t& data) static bool aux2SerialOnSend(uint8_t& data)
{ {
return aux2SerialTxFifo.pop(data); return aux2SerialTxFifo.pop(data);
} }
static etx_serial_callbacks aux2SerialCb = { static etx_serial_callbacks_t aux2SerialCb = {
.on_send = aux2SerialOnSend, .on_send = aux2SerialOnSend,
.on_receive = nullptr, .on_receive = nullptr,
.on_error = nullptr, .on_error = nullptr,
@@ -281,12 +284,12 @@ void aux2SerialSetup(unsigned int baudrate, bool rx_enable, uint8_t word_length,
stm32_usart_init(&aux2USART, &serialInit); stm32_usart_init(&aux2USART, &serialInit);
#if defined(AUX2_SERIAL_PWR_GPIO) // #if defined(AUX2_SERIAL_PWR_GPIO)
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; // GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_InitStructure.GPIO_Pin = AUX2_SERIAL_PWR_GPIO_PIN; // GPIO_InitStructure.GPIO_Pin = AUX2_SERIAL_PWR_GPIO_PIN;
GPIO_Init(AUX2_SERIAL_PWR_GPIO, &GPIO_InitStructure); // GPIO_Init(AUX2_SERIAL_PWR_GPIO, &GPIO_InitStructure);
#endif // #endif
} }
extern "C" void AUX2_SERIAL_USART_IRQHandler(void) extern "C" void AUX2_SERIAL_USART_IRQHandler(void)
@@ -295,7 +298,7 @@ extern "C" void AUX2_SERIAL_USART_IRQHandler(void)
stm32_usart_isr(&aux2USART, &aux2SerialCb); stm32_usart_isr(&aux2USART, &aux2SerialCb);
} }
void aux2SerialPutc(char c) void aux2SerialPutc(uint8_t c)
{ {
if (aux2SerialTxFifo.isFull()) return; if (aux2SerialTxFifo.isFull()) return;
aux2SerialTxFifo.push(c); aux2SerialTxFifo.push(c);
@@ -30,7 +30,7 @@ void auxSerialSetup(unsigned int baudrate, bool rx_enable,
uint8_t parity = ETX_Parity_None, uint8_t parity = ETX_Parity_None,
uint8_t stop_bits = ETX_StopBits_One); uint8_t stop_bits = ETX_StopBits_One);
void auxSerialInit(unsigned int mode, unsigned int protocol); void auxSerialInit(unsigned int mode, unsigned int protocol);
void auxSerialPutc(char c); void auxSerialPutc(uint8_t c);
void auxSerialSbusInit(); void auxSerialSbusInit();
void auxSerialStop(); void auxSerialStop();
uint8_t auxSerialTracesEnabled(); uint8_t auxSerialTracesEnabled();
@@ -43,7 +43,7 @@ void aux2SerialSetup(unsigned int baudrate, bool rx_enable,
uint8_t parity = ETX_Parity_None, uint8_t parity = ETX_Parity_None,
uint8_t stop_bits = ETX_StopBits_One); uint8_t stop_bits = ETX_StopBits_One);
void aux2SerialInit(unsigned int mode, unsigned int protocol); void aux2SerialInit(unsigned int mode, unsigned int protocol);
void aux2SerialPutc(char c); void aux2SerialPutc(uint8_t c);
void aux2SerialSbusInit(); void aux2SerialSbusInit();
void aux2SerialStop(); void aux2SerialStop();
uint8_t aux2SerialTracesEnabled(); uint8_t aux2SerialTracesEnabled();
-4
View File
@@ -158,10 +158,6 @@ set(RADIO_DEPENDENCIES
truetype_fonts truetype_fonts
) )
if(HARDWARE_EXTERNAL_MODULE)
set(TARGET_SRC ${TARGET_SRC} extmodule_driver.cpp)
endif()
set(FIRMWARE_DEPENDENCIES datacopy) set(FIRMWARE_DEPENDENCIES datacopy)
add_definitions(-DPCBHORUS -DSTM32F429_439xx -DSTM32F429xx -DSDRAM -DCCMRAM -DCOLORLCD -DHARDWARE_KEYS) add_definitions(-DPCBHORUS -DSTM32F429_439xx -DSTM32F429xx -DSDRAM -DCCMRAM -DCOLORLCD -DHARDWARE_KEYS)
+1 -1
View File
@@ -458,7 +458,7 @@
#define AUX2_SERIAL_DMA_RX DMA2 #define AUX2_SERIAL_DMA_RX DMA2
#define AUX2_SERIAL_DMA_Stream_RX DMA2_Stream1 // or DMA2_Stream2 #define AUX2_SERIAL_DMA_Stream_RX DMA2_Stream1 // or DMA2_Stream2
#define AUX2_SERIAL_DMA_Channel_RX DMA_Channel_5 #define AUX2_SERIAL_DMA_Channel_RX DMA_Channel_5
#define AUX_SERIAL_DMA_Stream_RX_LL LL_DMA_STREAM_1 #define AUX2_SERIAL_DMA_Stream_RX_LL LL_DMA_STREAM_1
#define AUX2_SERIAL_PWR_GPIO GPIOB #define AUX2_SERIAL_PWR_GPIO GPIOB
#define AUX2_SERIAL_PWR_GPIO_PIN GPIO_Pin_0 // PB.00 #define AUX2_SERIAL_PWR_GPIO_PIN GPIO_Pin_0 // PB.00
#if defined(RADIO_TX16S) #if defined(RADIO_TX16S)