Skip to content
Prev Previous commit
Next Next commit
Add method to uart so debug can be reassigned after apb frequency switch
  • Loading branch information
me-no-dev committed Dec 19, 2018
commit 2c8df88546e6675b8e4b2baacae903cf1c24866d
25 changes: 15 additions & 10 deletions cores/esp32/esp32-hal-uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,17 +386,8 @@ static void IRAM_ATTR uart2_write_char(char c)
ESP_REG(DR_REG_UART2_BASE) = c;
}

void uartSetDebug(uart_t* uart)
void uart_install_putc()
{
if(uart == NULL || uart->num > 2) {
s_uart_debug_nr = -1;
ets_install_putc1(NULL);
return;
}
if(s_uart_debug_nr == uart->num) {
return;
}
s_uart_debug_nr = uart->num;
switch(s_uart_debug_nr) {
case 0:
ets_install_putc1((void (*)(char)) &uart0_write_char);
Expand All @@ -413,6 +404,20 @@ void uartSetDebug(uart_t* uart)
}
}

void uartSetDebug(uart_t* uart)
{
if(uart == NULL || uart->num > 2) {
s_uart_debug_nr = -1;
//ets_install_putc1(NULL);
//return;
} else
if(s_uart_debug_nr == uart->num) {
return;
} else
s_uart_debug_nr = uart->num;
uart_install_putc();
}

int uartGetDebug()
{
return s_uart_debug_nr;
Expand Down