Skip to content

Commit e39b49c

Browse files
committed
Merge branch 'uart_bug_fixing' into irq_management_revision
2 parents 0521eff + fa7ee2d commit e39b49c

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

cores/arduino/Serial.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,17 @@ void UART::begin(unsigned long baudrate, uint16_t config) {
139139
/* -------------------------------------------------------------------------- */
140140
#if SERIAL_HOWMANY > 0
141141
if (channel == UART1_CHANNEL) {
142-
/* TX pin */
143-
R_IOPORT_PinCfg(&g_ioport_ctrl, BSP_IO_PORT_01_PIN_02, (uint32_t) IOPORT_CFG_PERIPHERAL_PIN | IOPORT_PERIPHERAL_SCI1_3_5_7_9);
144-
/* RX pin */
145-
R_IOPORT_PinCfg(&g_ioport_ctrl, BSP_IO_PORT_03_PIN_01, (uint32_t) IOPORT_CFG_PERIPHERAL_PIN | IOPORT_PERIPHERAL_SCI0_2_4_6_8);
142+
/* configuring PIN */
143+
int pin_count = 0;
144+
bsp_io_port_pin_t serial_pins[4];
145+
for (int i=0; i<PINCOUNT_fn(); i++) {
146+
if (g_APinDescription[i].PeripheralConfig == SERIAL_BUS) {
147+
serial_pins[pin_count] = g_APinDescription[i].name;
148+
pin_count++;
149+
}
150+
if (pin_count == 2) break;
151+
}
152+
setPins(serial_pins[0], serial_pins[1]);
146153

147154
uart_cfg.channel = UART1_CHANNEL;
148155
uart_cfg.p_context = NULL;

0 commit comments

Comments
 (0)