Skip to content

Commit ced27ee

Browse files
committed
Add support for RX pull-up management
1 parent d0b865c commit ced27ee

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

Diff for: cores/arduino/Serial.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ void UART::begin(unsigned long baudrate) {
126126
}
127127
}
128128

129+
void UART::begin(unsigned long baudrate, uint16_t config, bool no_rx_pullup) {
130+
begin(baudrate, config);
131+
#if defined(SET_GPIO_PULL_FUNCTION)
132+
if (no_rx_pullup) {
133+
SET_GPIO_PULL_FUNCTION(_rx, NO_PULL);
134+
}
135+
#endif
136+
}
137+
129138
void UART::on_rx() {
130139
#if defined(SERIAL_CDC)
131140
if (is_usb) {

Diff for: cores/arduino/Serial.h

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class UART : public HardwareSerial {
4545
}
4646
void begin(unsigned long);
4747
void begin(unsigned long baudrate, uint16_t config);
48+
void begin(unsigned long baudrate, uint16_t config, bool no_rx_pullup);
4849
void end();
4950
int available(void);
5051
int peek(void);

Diff for: variants/OPTA/pins_arduino.h

+18
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,22 @@ void _ontouch1200bps_();
193193

194194
#define USB_MAX_POWER (500)
195195

196+
static GPIO_TypeDef * const GPIO_PORT[] = {
197+
GPIOA,
198+
GPIOB,
199+
GPIOC,
200+
GPIOD,
201+
GPIOE,
202+
GPIOF,
203+
GPIOG,
204+
GPIOH,
205+
GPIOI,
206+
GPIOJ,
207+
GPIOK,
208+
};
209+
210+
#include "pin_device.h"
211+
#define SET_GPIO_PULL_FUNCTION(x, y) LL_GPIO_SetPinPull(GPIO_PORT[STM_PORT(x)], ll_pin_defines[STM_PIN(x)], y)
212+
#define NO_PULL LL_GPIO_PULL_NO
213+
196214
#endif //__PINS_ARDUINO__

0 commit comments

Comments
 (0)