Skip to content

Commit 1c132c8

Browse files
committed
esp8266: Add configuration option for redirecting the built-in OS output
1 parent 40c6d57 commit 1c132c8

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

esp8266/Makefile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ INC += -I../lib/timeutils
2222
INC += -I$(BUILD)
2323
INC += -I$(ESP_SDK)/include
2424

25+
UART_OS = 1
26+
2527
CFLAGS_XTENSA = -fsingle-precision-constant -Wdouble-promotion \
2628
-D__ets__ -DICACHE_FLASH \
2729
-fno-inline-functions \
2830
-Wl,-EL -mlongcalls -mtext-section-literals \
2931

30-
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -ansi -std=gnu99 -nostdlib $(CFLAGS_XTENSA) $(COPT)
32+
CFLAGS = $(INC) -Wall -Wpointer-arith -Werror -ansi -std=gnu99 -nostdlib -DUART_OS=$(UART_OS) \
33+
$(CFLAGS_XTENSA) $(COPT)
3134

3235
LDFLAGS = -nostdlib -T esp8266.ld -Map=$(@:.elf=.map) --cref
3336
LIBS = -L$(ESP_SDK)/lib -lmain -ljson -llwip -lpp -lnet80211 -lwpa -lphy -lnet80211
@@ -85,16 +88,18 @@ OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
8588

8689
all: $(BUILD)/firmware-combined.bin
8790

88-
SCRIPTDIR_FILE = $(BUILD)/scriptdir
91+
CONFVARS_FILE = $(BUILD)/confvars
8992

90-
ifeq ($(wildcard $(SCRIPTDIR_FILE)),)
93+
ifeq ($(wildcard $(CONFVARS_FILE)),)
9194
$(shell $(MKDIR) -p $(BUILD))
92-
$(shell echo $(SCRIPTDIR) > $(SCRIPTDIR_FILE))
93-
else ifneq ($(shell cat $(SCRIPTDIR_FILE)), $(SCRIPTDIR))
94-
$(shell echo $(SCRIPTDIR) > $(SCRIPTDIR_FILE))
95+
$(shell echo $(SCRIPTDIR) $(UART_OS) > $(CONFVARS_FILE))
96+
else ifneq ($(shell cat $(CONFVARS_FILE)), $(SCRIPTDIR) $(UART_OS))
97+
$(shell echo $(SCRIPTDIR) $(UART_OS) > $(CONFVARS_FILE))
9598
endif
9699

97-
$(BUILD)/frozen.c: $(wildcard $(SCRIPTDIR)/*) $(SCRIPTDIR_FILE)
100+
$(BUILD)/uart.o: $(CONFVARS_FILE)
101+
102+
$(BUILD)/frozen.c: $(wildcard $(SCRIPTDIR)/*) $(CONFVARS_FILE)
98103
$(ECHO) "Generating $@"
99104
$(Q)$(MAKE_FROZEN) $(SCRIPTDIR) > $@
100105

esp8266/uart.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ void uart_tx_one_char(uint8 uart, uint8 TxChar) {
112112
* Returns : NONE
113113
*******************************************************************************/
114114
static void ICACHE_FLASH_ATTR
115-
uart1_write_char(char c) {
115+
uart_os_write_char(char c) {
116116
if (c == '\n') {
117-
uart_tx_one_char(UART1, '\r');
118-
uart_tx_one_char(UART1, '\n');
117+
uart_tx_one_char(UART_OS, '\r');
118+
uart_tx_one_char(UART_OS, '\n');
119119
} else if (c == '\r') {
120120
} else {
121-
uart_tx_one_char(UART1, c);
121+
uart_tx_one_char(UART_OS, c);
122122
}
123123
}
124124

@@ -191,7 +191,7 @@ void ICACHE_FLASH_ATTR uart_init(UartBautRate uart0_br, UartBautRate uart1_br) {
191191
ETS_UART_INTR_ENABLE();
192192

193193
// install uart1 putc callback
194-
os_install_putc1((void *)uart1_write_char);
194+
os_install_putc1((void *)uart_os_write_char);
195195
}
196196

197197
void ICACHE_FLASH_ATTR uart_reattach() {

0 commit comments

Comments
 (0)