Skip to content

Commit a1e9e52

Browse files
committed
fixup! cpu/esp32: uart API function uart_mode added
1 parent 901b177 commit a1e9e52

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

cpu/esp32/periph/uart.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,29 @@ static int _uart_set_mode(uart_t uart, uart_data_bits_t data_bits,
395395
_uarts[uart].data = data_bits;
396396

397397
/* set number of stop bits */
398+
#ifdef MCU_ESP32
399+
/* workaround for hardware bug when stop bits are set to 2-bit mode. */
400+
switch (stop_bits) {
401+
case UART_STOP_BITS_1: _uarts[uart].regs->conf0.stop_bit_num = 1;
402+
_uarts[uart].regs->rs485_conf.dl1_en = 1;
403+
break;
404+
case UART_STOP_BITS_2: _uarts[uart].regs->conf0.stop_bit_num = 1;
405+
_uarts[uart].regs->rs485_conf.dl1_en = 1;
406+
break;
407+
default: LOG_TAG_ERROR("uart", "invalid number of stop bits\n");
408+
critical_exit();
409+
return UART_NOMODE;
410+
}
411+
#else
398412
switch (stop_bits) {
399413
case UART_STOP_BITS_1: _uarts[uart].regs->conf0.stop_bit_num = 1; break;
400414
case UART_STOP_BITS_2: _uarts[uart].regs->conf0.stop_bit_num = 3; break;
401415
default: LOG_TAG_ERROR("uart", "invalid number of stop bits\n");
402416
critical_exit();
403417
return UART_NOMODE;
404418
}
419+
#endif
420+
405421
/* store changed number of stop bits in configuration */
406422
_uarts[uart].stop = stop_bits;
407423

0 commit comments

Comments
 (0)