diff --git a/cores/arduino/Serial.cpp b/cores/arduino/Serial.cpp index 325f8fd34..c5808622f 100644 --- a/cores/arduino/Serial.cpp +++ b/cores/arduino/Serial.cpp @@ -126,6 +126,15 @@ void UART::begin(unsigned long baudrate) { } } +void UART::begin(unsigned long baudrate, uint16_t config, bool no_rx_pullup) { + begin(baudrate, config); +#if defined(SET_GPIO_PULL_FUNCTION) + if (no_rx_pullup) { + SET_GPIO_PULL_FUNCTION(_rx, NO_PULL); + } +#endif +} + void UART::on_rx() { #if defined(SERIAL_CDC) if (is_usb) { diff --git a/cores/arduino/Serial.h b/cores/arduino/Serial.h index f20e14060..f511256ad 100644 --- a/cores/arduino/Serial.h +++ b/cores/arduino/Serial.h @@ -45,6 +45,7 @@ class UART : public HardwareSerial { } void begin(unsigned long); void begin(unsigned long baudrate, uint16_t config); + void begin(unsigned long baudrate, uint16_t config, bool no_rx_pullup); void end(); int available(void); int peek(void); diff --git a/variants/OPTA/pins_arduino.h b/variants/OPTA/pins_arduino.h index 698a1ecef..6812a8f56 100644 --- a/variants/OPTA/pins_arduino.h +++ b/variants/OPTA/pins_arduino.h @@ -182,7 +182,7 @@ void _ontouch1200bps_(); #define RS485_DEFAULT_TX_PIN SERIAL2_TX #define RS485_DEFAULT_DE_PIN PB_14 -#define RS485_DEFAULT_RE_PIN RS485_DEFAULT_DE_PIN +#define RS485_DEFAULT_RE_PIN PB_13 #define SerialLoRa Serial3 #define LORA_BOOT0 (PG_7) @@ -193,4 +193,22 @@ void _ontouch1200bps_(); #define USB_MAX_POWER (500) +static GPIO_TypeDef * const GPIO_PORT[] = { + GPIOA, + GPIOB, + GPIOC, + GPIOD, + GPIOE, + GPIOF, + GPIOG, + GPIOH, + GPIOI, + GPIOJ, + GPIOK, +}; + +#include "pin_device.h" +#define SET_GPIO_PULL_FUNCTION(x, y) LL_GPIO_SetPinPull(GPIO_PORT[STM_PORT(x)], ll_pin_defines[STM_PIN(x)], y) +#define NO_PULL LL_GPIO_PULL_NO + #endif //__PINS_ARDUINO__