Skip to content

Commit

Permalink
fixup! cpu/esp32: uart API function uart_mode added
Browse files Browse the repository at this point in the history
  • Loading branch information
gschorcht committed Mar 26, 2019
1 parent 901b177 commit a1e9e52
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions cpu/esp32/periph/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,29 @@ static int _uart_set_mode(uart_t uart, uart_data_bits_t data_bits,
_uarts[uart].data = data_bits;

/* set number of stop bits */
#ifdef MCU_ESP32
/* workaround for hardware bug when stop bits are set to 2-bit mode. */
switch (stop_bits) {
case UART_STOP_BITS_1: _uarts[uart].regs->conf0.stop_bit_num = 1;
_uarts[uart].regs->rs485_conf.dl1_en = 1;
break;
case UART_STOP_BITS_2: _uarts[uart].regs->conf0.stop_bit_num = 1;
_uarts[uart].regs->rs485_conf.dl1_en = 1;
break;
default: LOG_TAG_ERROR("uart", "invalid number of stop bits\n");
critical_exit();
return UART_NOMODE;
}
#else
switch (stop_bits) {
case UART_STOP_BITS_1: _uarts[uart].regs->conf0.stop_bit_num = 1; break;
case UART_STOP_BITS_2: _uarts[uart].regs->conf0.stop_bit_num = 3; break;
default: LOG_TAG_ERROR("uart", "invalid number of stop bits\n");
critical_exit();
return UART_NOMODE;
}
#endif

/* store changed number of stop bits in configuration */
_uarts[uart].stop = stop_bits;

Expand Down

0 comments on commit a1e9e52

Please sign in to comment.