mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Update UART selection for Boot ROM ets_putc, when debug port is selected. (#6489)
* Add code to select the UART for Boot ROM ets_putc which is used by ::printf, ets_printf_P in core_esp_postmortem.cpp and others. ets_putc is a wrapper for uart_tx_one_char. uart_tx_one_char uses the element buff_uart_no in UartDev (A structure in data area of the Boot ROM) to select UART0 or UART1. uart_buff_switch is used to set that entry. The structure for UartDev can be found in uart.h from the ESP8266_NONOS_SDK. As best I can tell the Boot ROM always defaults to UART0. * Fixes debug UART selection for ets_putc This addresses an issue of UART selection for ROM function ets_putc, which is used by ::printf, ets_printf_P in core_esp_postmortem.cpp and others. Currently ets_putc stays on UART0 after Serial1.setDebugOutput(true) is called. ets_putc() is not affected by calls to ets_install_putc1. Its UART selection is controlled by the ROM function uart_buff_switch. Updated uart_set_debug() to call uart_buff_switch whenever debug is enabled on an UART. For the case of disabling, a call to select UART0 is made, because there is no disable option for this print method. * Removed fp_putc_t typedef, save for a later PR
This commit is contained in:
parent
308e131dee
commit
f3ca09006d
@ -11,6 +11,27 @@ extern int rom_i2c_readReg_Mask(int, int, int, int, int);
|
|||||||
|
|
||||||
extern int uart_baudrate_detect(int, int);
|
extern int uart_baudrate_detect(int, int);
|
||||||
|
|
||||||
|
/*
|
||||||
|
ROM function, uart_buff_switch(), is used to switch printing between UART0 and
|
||||||
|
UART1. It updates a structure that only controls a select group of print
|
||||||
|
functions. ets_putc() and ets_uart_printf() are examples and are not affected by
|
||||||
|
calls to ets_install_putc1().
|
||||||
|
|
||||||
|
Use:
|
||||||
|
0 for UART0, also clears RX FIFO
|
||||||
|
1 for UART1
|
||||||
|
*/
|
||||||
|
extern void uart_buff_switch(uint8_t);
|
||||||
|
|
||||||
|
/*
|
||||||
|
ROM function, ets_uart_printf(), prints on the UART selected by
|
||||||
|
uart_buff_switch(). Supported format options are the same as vprintf(). Also
|
||||||
|
has cooked newline behavior. No flash format/string support; however, ISR safe.
|
||||||
|
Also, uses a static function in ROM to print characters which is only
|
||||||
|
controlled by uart_buff_switch().
|
||||||
|
*/
|
||||||
|
extern int ets_uart_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
|
||||||
|
|
||||||
extern void ets_delay_us(uint32_t us);
|
extern void ets_delay_us(uint32_t us);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -904,13 +904,21 @@ uart_set_debug(int uart_nr)
|
|||||||
{
|
{
|
||||||
case UART0:
|
case UART0:
|
||||||
func = &uart0_write_char;
|
func = &uart0_write_char;
|
||||||
|
// This selects the UART for ROM ets_putc which is used by
|
||||||
|
// ::printf, ets_printf_P in core_esp_postmortem.cpp and others.
|
||||||
|
// Has a side effect of clearing RX FIFO for UART0
|
||||||
|
uart_buff_switch(0);
|
||||||
break;
|
break;
|
||||||
case UART1:
|
case UART1:
|
||||||
func = &uart1_write_char;
|
func = &uart1_write_char;
|
||||||
|
uart_buff_switch(1);
|
||||||
break;
|
break;
|
||||||
case UART_NO:
|
case UART_NO:
|
||||||
default:
|
default:
|
||||||
func = &uart_ignore_char;
|
func = &uart_ignore_char;
|
||||||
|
// There is no disable option for ets_putc,
|
||||||
|
// we switch to UART0 for disable case.
|
||||||
|
uart_buff_switch(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(gdbstub_has_putc1_control()) {
|
if(gdbstub_has_putc1_control()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user