Skip to content

Fix RS485 RX on Opta #607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cores/arduino/Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions cores/arduino/Serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
20 changes: 19 additions & 1 deletion variants/OPTA/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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__