mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-22 21:23:07 +03:00
* 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
40 lines
1.1 KiB
C
40 lines
1.1 KiB
C
// ROM and blob calls without official headers available
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
// ROM
|
|
|
|
extern void rom_i2c_writeReg_Mask(int, int, int, int, int, int);
|
|
extern int rom_i2c_readReg_Mask(int, int, int, 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);
|
|
|
|
#ifdef __cplusplus
|
|
};
|
|
#endif
|