Skip to content

Commit

Permalink
fix at32 serial bidir pp od init and smart audio (betaflight#13764)
Browse files Browse the repository at this point in the history
include fix for F4 and G4 as well

Co-authored-by: Eike Ahmels <[email protected]>
  • Loading branch information
Benedikt Kleiner and Eike Ahmels authored Jul 15, 2024
1 parent 1bcde73 commit ee9172f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/drivers/mcu/at32/serial_uart_at32f43x.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ uartPort_t *serialUART(UARTDevice_e device, uint32_t baudRate, portMode_e mode,
GPIO_MODE_MUX,
GPIO_DRIVE_STRENGTH_STRONGER,
((options & SERIAL_INVERTED) || (options & SERIAL_BIDIR_PP) || (options & SERIAL_BIDIR_PP_PD)) ? GPIO_OUTPUT_PUSH_PULL : GPIO_OUTPUT_OPEN_DRAIN,
(options & SERIAL_INVERTED) ? GPIO_PULL_DOWN : GPIO_PULL_UP
((options & SERIAL_INVERTED) || (options & SERIAL_BIDIR_PP_PD)) ? GPIO_PULL_DOWN : GPIO_PULL_UP
);
IOInit(txIO, OWNER_SERIAL_TX, RESOURCE_INDEX(device));
IOConfigGPIOAF(txIO, ioCfg, uartdev->tx.af);
Expand Down
4 changes: 3 additions & 1 deletion src/main/drivers/mcu/stm32/serial_uart_stm32f4xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,9 @@ uartPort_t *serialUART(UARTDevice_e device, uint32_t baudRate, portMode_e mode,

if (options & SERIAL_BIDIR) {
IOInit(txIO, OWNER_SERIAL_TX, RESOURCE_INDEX(device));
IOConfigGPIOAF(txIO, ((options & SERIAL_BIDIR_PP) || (options & SERIAL_BIDIR_PP_PD)) ? IOCFG_AF_PP : IOCFG_AF_OD, hardware->af);
IOConfigGPIOAF(txIO, (options & SERIAL_BIDIR_PP_PD) ? IOCFG_AF_PP_PD
: (options & SERIAL_BIDIR_PP) ? IOCFG_AF_PP
: IOCFG_AF_OD, hardware->af);
} else {
if ((mode & MODE_TX) && txIO) {
IOInit(txIO, OWNER_SERIAL_TX, RESOURCE_INDEX(device));
Expand Down
2 changes: 1 addition & 1 deletion src/main/drivers/mcu/stm32/serial_uart_stm32g4xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ uartPort_t *serialUART(UARTDevice_e device, uint32_t baudRate, portMode_e mode,
ioConfig_t ioCfg = IO_CONFIG(
((options & SERIAL_INVERTED) || (options & SERIAL_BIDIR_PP) || (options & SERIAL_BIDIR_PP_PD)) ? GPIO_MODE_AF_PP : GPIO_MODE_AF_OD,
GPIO_SPEED_FREQ_HIGH,
(options & SERIAL_INVERTED) ? GPIO_PULLDOWN : GPIO_PULLUP
((options & SERIAL_INVERTED) || (options & SERIAL_BIDIR_PP_PD)) ? GPIO_PULLDOWN : GPIO_PULLUP
);

IOInit(txIO, OWNER_SERIAL_TX, RESOURCE_INDEX(device));
Expand Down
2 changes: 2 additions & 0 deletions src/main/io/vtx_smartaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ static void saReceiveFrame(uint8_t c)
static void saSendFrame(uint8_t *buf, int len)
{
if (!IS_RC_MODE_ACTIVE(BOXVTXCONTROLDISABLE)) {
#ifndef AT32F4
switch (smartAudioSerialPort->identifier) {
case SERIAL_PORT_SOFTSERIAL1:
case SERIAL_PORT_SOFTSERIAL2:
Expand All @@ -508,6 +509,7 @@ static void saSendFrame(uint8_t *buf, int len)
serialWrite(smartAudioSerialPort, 0x00); // Generate 1st start byte
break;
}
#endif //AT32F4

for (int i = 0 ; i < len ; i++) {
serialWrite(smartAudioSerialPort, buf[i]);
Expand Down

0 comments on commit ee9172f

Please sign in to comment.