feat(bootloader): Add configration for output console UART

This commit is contained in:
Dong Heng
2018-09-06 20:40:02 +08:00
parent 1870ecf943
commit 964e027860
4 changed files with 57 additions and 8 deletions

View File

@ -35,6 +35,23 @@ config SOC_FULL_ICACHE
Enable this option, full 32 KB iram instead of 16 KB iram will be used as icache, so the heap use can use
may reduce a lot.
choice CONSOLE_UART_NUM
prompt "UART peripheral to use for console output (0-1)"
default CONSOLE_UART_CUSTOM_NUM_0
help
Configrate output console UART for "ets_printf", "printf", "ESP_LOGX" and so on.
config CONSOLE_UART_CUSTOM_NUM_0
bool "UART0"
config CONSOLE_UART_CUSTOM_NUM_1
bool "UART1"
endchoice
config CONSOLE_UART_NUM
int
default 0 if CONSOLE_UART_CUSTOM_NUM_0
default 1 if CONSOLE_UART_CUSTOM_NUM_1
endmenu
menu WIFI

View File

@ -14,26 +14,24 @@
#include <stdint.h>
#include "sdkconfig.h"
#include "esp_attr.h"
#include "esp8266/eagle_soc.h"
#include "esp8266/uart_register.h"
#include "esp8266/rom_functions.h"
#ifndef CONFIG_ETS_PUTC_UART
#define CONFIG_ETS_PUTC_UART 0
#endif
int IRAM_ATTR ets_putc(int c)
{
while (1) {
uint32_t fifo_cnt = READ_PERI_REG(UART_STATUS(CONFIG_ETS_PUTC_UART)) & (UART_TXFIFO_CNT << UART_TXFIFO_CNT_S);
uint32_t fifo_cnt = READ_PERI_REG(UART_STATUS(CONFIG_CONSOLE_UART_NUM)) & (UART_TXFIFO_CNT << UART_TXFIFO_CNT_S);
if ((fifo_cnt >> UART_TXFIFO_CNT_S & UART_TXFIFO_CNT) < 126)
break;
}
WRITE_PERI_REG(UART_FIFO(CONFIG_ETS_PUTC_UART) , c);
WRITE_PERI_REG(UART_FIFO(CONFIG_CONSOLE_UART_NUM) , c);
return c;
}