From ff2c23e32fc4fdf8427b712a056a9c05f44c76af Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 3 Dec 2018 09:25:51 +0100 Subject: esp8266: add counter driver --- include/arch/esp8266/driver/stdout.h | 2 ++ src/arch/esp8266/Makefile.inc | 6 +++++- src/arch/esp8266/driver/stdout.cc | 16 ++++++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/arch/esp8266/driver/stdout.h b/include/arch/esp8266/driver/stdout.h index 95135ad..8d366d8 100644 --- a/include/arch/esp8266/driver/stdout.h +++ b/include/arch/esp8266/driver/stdout.h @@ -27,6 +27,8 @@ class StandardOutput { StandardOutput & operator<<(long number); StandardOutput & operator<<(unsigned long long number); StandardOutput & operator<<(long long number); + StandardOutput & operator<<(float number); + StandardOutput & operator<<(double number); StandardOutput & operator<<(void *pointer); StandardOutput & operator<<(const char *text); StandardOutput & operator<<(StandardOutput & (*fun) (StandardOutput &)); diff --git a/src/arch/esp8266/Makefile.inc b/src/arch/esp8266/Makefile.inc index 1df3e5a..18547a6 100644 --- a/src/arch/esp8266/Makefile.inc +++ b/src/arch/esp8266/Makefile.inc @@ -33,6 +33,10 @@ ifneq ($(findstring stdin,${arch_drivers}), ) CXX_TARGETS += src/arch/esp8266/driver/stdin.cc endif +ifneq ($(findstring counter,${arch_drivers}), ) + CXX_TARGETS += src/arch/esp8266/driver/counter.cc +endif + .cc.o: ${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc} ${QUIET}${OBJCOPY} --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal $@ @@ -47,7 +51,7 @@ build/system.ar: ${OBJECTS} build/system.elf: build/system.ar ${CC} -L${SDK_BASE}/lib -T${SDK_BASE}/lib/eagle.app.v6-derf.ld ${LDFLAGS} \ -Wl,--start-group -lc -lgcc -lhal -lpp -lphy -lnet80211 -llwip -lwpa \ - -lmain $< -Wl,--end-group -o $@ + -lmain -flto $< -Wl,--end-group -o $@ build/0x00000.bin: build/system.elf ${ESPTOOL} --chip esp8266 elf2image -o build/ $< diff --git a/src/arch/esp8266/driver/stdout.cc b/src/arch/esp8266/driver/stdout.cc index d8e07a8..c4f0abc 100644 --- a/src/arch/esp8266/driver/stdout.cc +++ b/src/arch/esp8266/driver/stdout.cc @@ -67,7 +67,19 @@ StandardOutput & StandardOutput::operator<<(long number) return *this; } -StandardOutput & StandardOutput::operator<<(unsigned long long number) +StandardOutput & StandardOutput::operator<<(float number) +{ + printf_float(number); + return *this; +} + +StandardOutput & StandardOutput::operator<<(double number) +{ + printf_float(number); + return *this; +} + +ICACHE_FLASH_ATTR StandardOutput & StandardOutput::operator<<(unsigned long long number) { switch (base) { case 2: @@ -164,7 +176,7 @@ void StandardOutput::printf_uint8(uint8_t num) put(format_hex_nibble(num % 16)); } -void StandardOutput::printf_float(float num) +ICACHE_FLASH_ATTR void StandardOutput::printf_float(float num) { if (num < 0) { put('-'); -- cgit v1.2.3