From 35a98377f52caf5ac37c2e932b9f2d4c9196c195 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 25 Dec 2021 18:09:33 +0100 Subject: Remove esp8266 support in favor of ESP8266 RTOS SDK --- src/arch/esp8266/Kconfig | 14 -- src/arch/esp8266/Makefile.inc | 127 ------------------ src/arch/esp8266/arch.cc | 74 ----------- src/arch/esp8266/driver/counter.cc | 8 -- src/arch/esp8266/driver/gpio.cc | 199 ---------------------------- src/arch/esp8266/driver/stdin.cc | 82 ------------ src/arch/esp8266/driver/stdout.cc | 264 ------------------------------------- src/arch/esp8266/driver/uptime.cc | 8 -- src/arch/esp8266/prompt | 1 - 9 files changed, 777 deletions(-) delete mode 100644 src/arch/esp8266/Kconfig delete mode 100644 src/arch/esp8266/Makefile.inc delete mode 100644 src/arch/esp8266/arch.cc delete mode 100644 src/arch/esp8266/driver/counter.cc delete mode 100644 src/arch/esp8266/driver/gpio.cc delete mode 100644 src/arch/esp8266/driver/stdin.cc delete mode 100644 src/arch/esp8266/driver/stdout.cc delete mode 100644 src/arch/esp8266/driver/uptime.cc delete mode 100644 src/arch/esp8266/prompt (limited to 'src/arch') diff --git a/src/arch/esp8266/Kconfig b/src/arch/esp8266/Kconfig deleted file mode 100644 index 5c2137c..0000000 --- a/src/arch/esp8266/Kconfig +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2020 Daniel Friesel -# -# SPDX-License-Identifier: CC0-1.0 -config arch_esp8266_driver_counter -bool "Cycle Counter" -select meta_driver_counter - -config arch_esp8266_driver_stdin -bool "UART Input" -select meta_driver_stdin - -config arch_esp8266_driver_uptime -bool "Uptime Counter" -select meta_driver_uptime diff --git a/src/arch/esp8266/Makefile.inc b/src/arch/esp8266/Makefile.inc deleted file mode 100644 index 51106b1..0000000 --- a/src/arch/esp8266/Makefile.inc +++ /dev/null @@ -1,127 +0,0 @@ -# vim:ft=make -# -# Copyright 2020 Daniel Friesel -# -# SPDX-License-Identifier: BSD-2-Clause - -TOOLCHAIN_BASE ?= /home/derf/var/projects/esp8266/toolchain/xtensa-lx106-elf/bin -SDK_BASE ?= /home/derf/var/projects/esp8266/toolchain/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr -ESPTOOL ?= esptool -SERIAL_PORT ?= /dev/ttyUSB0 - -CC = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-gcc -CXX = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-g++ -AR = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-ar -LD = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-gcc -OBJCOPY = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-objcopy -OBJDUMP = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-objdump -SIZE = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-size - -ifdef CONFIG_aspectc - CXX = ag++ -r build/repo.acp -v 0 --c_compiler ${TOOLCHAIN_BASE}/xtensa-lx106-elf-g++ -p . --Xcompiler -endif - -INCLUDES += -I${SDK_BASE}/include -COMMON_FLAGS += -nostdlib -mlongcalls -flto -D__ets__ -DICACHE_FLASH -DMULTIPASS_ARCH_esp8266 -CXXFLAGS = -std=c++11 -fno-rtti -fno-threadsafe-statics -LDFLAGS += -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static - -CXX_TARGETS += src/arch/esp8266/arch.cc src/arch/esp8266/driver/gpio.cc -CXX_TARGETS += src/arch/esp8266/driver/stdout.cc - -OBJECTS = ${CXX_TARGETS:.cc=.o} ${C_TARGETS:.c=.o} - -ifeq (${esp8266_led2}, 1) - COMMON_FLAGS += -DLED_ON_GPIO16 -endif - -# Commandline - -ifneq ($(findstring counter,${arch_drivers}), ) - CONFIG_arch_esp8266_driver_counter = y -endif - -ifneq ($(findstring stdin,${arch_drivers}), ) - CONFIG_arch_esp8266_driver_stdin = y -endif - -ifeq (${timer_s}, 1) - CONFIG_arch_esp8266_driver_uptime = y -endif - -# Kconfig - -ifdef CONFIG_arch_esp8266_driver_counter - CXX_TARGETS += src/arch/esp8266/driver/counter.cc -endif - -ifdef CONFIG_arch_esp8266_driver_stdin - CXX_TARGETS += src/arch/esp8266/driver/stdin.cc -endif - -ifdef CONFIG_arch_esp8266_driver_uptime - COMMON_FLAGS += -DTIMER_S - CXX_TARGETS += src/arch/esp8266/driver/uptime.cc -endif - -%.o : %.cc | include/config.h - ${QUIET}${CXX} ${INCLUDES} ${COMMON_FLAGS} ${CXXFLAGS} -c -o $@ ${@:.o=.cc} - ${QUIET}${OBJCOPY} --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal $@ - -%.o : %.c | include/config.h - ${QUIET}${CC} ${INCLUDES} ${COMMON_FLAGS} ${CFLAGS} -c -o $@ ${@:.o=.c} - ${QUIET}${OBJCOPY} --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal $@ - -build/system.elf: build/system.ar - ${QUIET}${CC} -L${SDK_BASE}/lib -T${SDK_BASE}/lib/eagle.app.v6-derf.ld ${LDFLAGS} \ - -Wl,--gc-sections \ - -Wl,--start-group -lc -lgcc -lhal -lpp -lphy -lnet80211 -llwip -lwpa \ - -lmain $< -Wl,--end-group -o $@ - ${QUIET}${SIZE} build/system.elf | tail -n1 | awk '{ print " ROM: " ($$1+$$2) " (" int(($$1+$$2)*100/4194304) "%) RAM: " ($$2 + $$3) " (" int(($$2+$$3)*100/81920) "%)" }' - -build/system.ar: ${OBJECTS} - ${QUIET}mkdir -p build - ${QUIET}${AR} cru $@ ${OBJECTS} - -build/0x00000.bin: build/system.elf - ${ESPTOOL} --chip esp8266 elf2image -o build/ $< - -build/0x40000.bin: build/0x00000.bin - # also created by commandline for 0x00000.bin - -program: build/0x00000.bin build/0x40000.bin - ${ESPTOOL} -p ${SERIAL_PORT} write_flash 0x00000 build/0x00000.bin 0x40000 build/0x40000.bin #-fm dout - -arch_clean: - ${QUIET}rm -f ${OBJECTS} build/system.ar - -monitor: - screen ${SERIAL_PORT} 115200 - -cat: - ${QUIET}script/cat.py ${SERIAL_PORT} 115200 80000000 0 - -arch_help: - @echo "esp8266 coding advice:" - @echo " The ESP8266 SDK does not give full hardware control." - @echo " Applications must release control every hundred or so milliseconds." - @echo " It is strongly recommended to only use loop=1" - @echo - @echo "esp8266 specific flags:" - @echo " esp8266_led2 = 0 (enable if you are using a NodeMCU dev board with two LEDs)" - @echo " TOOLCHAIN_BASE = /home/derf/var/projects/esp8266/toolchain/xtensa-lx106-elf/bin" - @echo " SDK_BASE = /home/derf/var/projects/esp8266/toolchain/xtensa-lx106-elf/xtensa-lx106-elf/sysroot/usr" - @echo " ESPTOOL = esptool" - @echo " SERIAL_PORT = /dev/ttyUSB0" - -arch_info: - @echo "Counter Overflow: 4294967296/0" - @echo "Monitor: ${SERIAL_PORT} 115200" - -attributes: build/system.elf - ${QUIET}script/size.py ${SIZE} text,irom0.text data,bss - -nfpvalues: build/system.elf - ${QUIET}script/nfpvalues.py ${SIZE} text,irom0.text data,bss - -.PHONY: arch_clean arch_help arch_info attributes cat monitor program diff --git a/src/arch/esp8266/arch.cc b/src/arch/esp8266/arch.cc deleted file mode 100644 index 656a700..0000000 --- a/src/arch/esp8266/arch.cc +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2020 Daniel Friesel - * - * SPDX-License-Identifier: BSD-2-Clause - */ -#include "arch.h" - -extern "C" { -#include "ets_sys.h" -#include "osapi.h" -#include "os_type.h" -#include "user_interface.h" -#include "gpio.h" -#include "mem.h" -void ets_timer_arm_new(os_timer_t *ptimer, uint32_t milliseconds, bool repeat_flag, bool us_flag); -void ets_timer_disarm(os_timer_t *ptimer); -void ets_timer_setfn(os_timer_t *ptimer, os_timer_func_t *pfunction, void *parg); -extern void (*__init_array_start)(); -extern void (*__init_array_end)(); -} - -#define user_procTaskPrio 0 -#define user_procTaskQueueLen 1 - -#ifdef CONFIG_loop -LOCAL os_timer_t loop_timer; - -extern void loop(void); -static void ICACHE_FLASH_ATTR jump_to_loop(void *arg) -{ - loop(); -} - -#endif - -extern int main(void); - -void ICACHE_FLASH_ATTR jump_to_main(void) -{ - for (void (**p)() = &__init_array_start; p != &__init_array_start; p++) { - (*p)(); - } -#ifdef CONFIG_loop - os_timer_disarm(&loop_timer); - os_timer_setfn(&loop_timer, (os_timer_func_t *)jump_to_loop, (void *)0); - os_timer_arm(&loop_timer, 1000, 1); -#endif - // Disable Wi-Fi - wifi_station_disconnect(); - wifi_set_opmode_current(NULL_MODE); - wifi_fpm_set_sleep_type(MODEM_SLEEP_T); - wifi_fpm_open(); - wifi_fpm_do_sleep(0xFFFFFFF); - main(); -} - -void Arch::setup(void) -{ -} - -void Arch::idle_loop(void) -{ -} - -void Arch::idle(void) -{ -} - -extern "C" void user_init(void) -{ - system_init_done_cb(jump_to_main); -} - -Arch arch; diff --git a/src/arch/esp8266/driver/counter.cc b/src/arch/esp8266/driver/counter.cc deleted file mode 100644 index dd6196a..0000000 --- a/src/arch/esp8266/driver/counter.cc +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright 2020 Daniel Friesel - * - * SPDX-License-Identifier: BSD-2-Clause - */ -#include "driver/counter.h" - -Counter counter; diff --git a/src/arch/esp8266/driver/gpio.cc b/src/arch/esp8266/driver/gpio.cc deleted file mode 100644 index d6c92a4..0000000 --- a/src/arch/esp8266/driver/gpio.cc +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright 2020 Daniel Friesel - * - * SPDX-License-Identifier: BSD-2-Clause - */ -#include "driver/gpio.h" -extern "C" { -#include "osapi.h" -#include "user_interface.h" -#include "gpio.h" -} - -void ICACHE_FLASH_ATTR GPIO::setup() -{ - gpio_init(); - - // Enable GPIO2 (ESP8266 on-board LED) as output - PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2); - -#ifdef LED_ON_GPIO16 - // Enable GPIO16 (RTC out / NodeMCU on-board LED) as output - WRITE_PERI_REG(PAD_XPD_DCDC_CONF, (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1); - WRITE_PERI_REG(RTC_GPIO_CONF, (READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0); - WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe) | (uint32)0x1); - // Turn the GPIO on to make sure the LED is off by default - WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) & (uint32)0xfffffffe) | (uint32)(1)); -#endif -} - -void ICACHE_FLASH_ATTR GPIO::led_on(unsigned char const id) -{ -#ifdef LED_ON_GPIO16 - if (id == 0) { - gpio_output_set(0, BIT2, BIT2, 0); - } else { - WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) & (uint32)0xfffffffe) | (uint32)(0)); - } -#else - gpio_output_set(0, BIT2, BIT2, 0); -#endif -} - -void ICACHE_FLASH_ATTR GPIO::led_off(unsigned char const id) -{ -#ifdef LED_ON_GPIO16 - if (id == 0) { - gpio_output_set(BIT2, 0, BIT2, 0); - } else { - WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) & (uint32)0xfffffffe) | (uint32)(0)); - } -#else - gpio_output_set(BIT2, 0, BIT2, 0); -#endif -} - -void ICACHE_FLASH_ATTR GPIO::led_toggle(unsigned char const id) -{ -#ifdef LED_ON_GPIO16 - if (id == 0) { - if (gpio_input_get() & BIT2) { - led_on(0); - } else { - led_off(0); - } - } else { - WRITE_PERI_REG(RTC_GPIO_OUT, (READ_PERI_REG(RTC_GPIO_OUT) ^ BIT0)); - } -#else - if (gpio_input_get() & BIT2) { - led_on(0); - } else { - led_off(0); - } -#endif -} - -void ICACHE_FLASH_ATTR GPIO::input(unsigned char const pin) -{ - if (pin == d0) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0); - } else if (pin == tx) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_GPIO1); - } else if (pin == d4) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2); - } else if (pin == rx) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_GPIO3); - } else if (pin == d2) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U, FUNC_GPIO4); - } else if (pin == d1) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5); - } else if (pin == d6) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12); - } else if (pin == d7) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13); - } else if (pin == d5) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14); - } else if (pin == d8) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15); - } else if (pin == d0) { - // TODO this sets it as output, not input - WRITE_PERI_REG(PAD_XPD_DCDC_CONF, (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1); - WRITE_PERI_REG(RTC_GPIO_CONF, (READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0); - WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe) | (uint32)0x1); - } - if (pin < d0) { - gpio_output_set(0, 0, 0, (1 << pin)); - } -} - -void ICACHE_FLASH_ATTR GPIO::input(unsigned char const pin, bool pullup) -{ - if (pin == d0) { - if (pullup) { - PIN_PULLUP_EN(PERIPHS_IO_MUX_GPIO0_U); - } else { - PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO0_U); - } - } else if (pin == tx) { - if (pullup) { - PIN_PULLUP_EN(PERIPHS_IO_MUX_U0TXD_U); - } else { - PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U); - } - } else if (pin == d4) { - if (pullup) { - PIN_PULLUP_EN(PERIPHS_IO_MUX_GPIO2_U); - } else { - PIN_PULLUP_DIS(PERIPHS_IO_MUX_GPIO2_U); - } - } else if (pin == rx) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_GPIO3); - } else if (pin == d2) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U, FUNC_GPIO4); - } else if (pin == d1) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5); - } else if (pin == d6) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12); - } else if (pin == d7) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13); - } else if (pin == d5) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14); - } else if (pin == d8) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15); - } else if (pin == d0) { - // TODO this sets it as output, not input - WRITE_PERI_REG(PAD_XPD_DCDC_CONF, (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1); - WRITE_PERI_REG(RTC_GPIO_CONF, (READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0); - WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe) | (uint32)0x1); - } - input(pin); -} - -void ICACHE_FLASH_ATTR GPIO::output(unsigned char const pin) -{ - if (pin == d0) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0); - } else if (pin == tx) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_GPIO1); - } else if (pin == d4) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2); - } else if (pin == rx) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_GPIO3); - } else if (pin == d2) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO4_U, FUNC_GPIO4); - } else if (pin == d1) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO5_U, FUNC_GPIO5); - } else if (pin == d6) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, FUNC_GPIO12); - } else if (pin == d7) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_GPIO13); - } else if (pin == d5) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, FUNC_GPIO14); - } else if (pin == d8) { - PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_GPIO15); - } else if (pin == d0) { - WRITE_PERI_REG(PAD_XPD_DCDC_CONF, (READ_PERI_REG(PAD_XPD_DCDC_CONF) & 0xffffffbc) | (uint32)0x1); - WRITE_PERI_REG(RTC_GPIO_CONF, (READ_PERI_REG(RTC_GPIO_CONF) & (uint32)0xfffffffe) | (uint32)0x0); - WRITE_PERI_REG(RTC_GPIO_ENABLE, (READ_PERI_REG(RTC_GPIO_ENABLE) & (uint32)0xfffffffe) | (uint32)0x1); - } - if (pin < d0) { - gpio_output_set(0, 0, (1 << pin), 0); - } -} - -unsigned char ICACHE_FLASH_ATTR GPIO::read(unsigned char const pin) -{ - return (gpio_input_get() & (1 << pin)); -} - -void ICACHE_FLASH_ATTR GPIO::write(unsigned char const pin, unsigned char value) -{ - if (value) { - gpio_output_set(1 << pin, 0, 0, 0); - } else { - gpio_output_set(0, 1 << pin, 0, 0); - } -} - -GPIO gpio; diff --git a/src/arch/esp8266/driver/stdin.cc b/src/arch/esp8266/driver/stdin.cc deleted file mode 100644 index 7032d81..0000000 --- a/src/arch/esp8266/driver/stdin.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2020 Daniel Friesel - * - * SPDX-License-Identifier: BSD-2-Clause - */ -#include "driver/stdin.h" -#include "driver/gpio.h" -extern "C" { -#include "osapi.h" -#include "user_interface.h" -#include "gpio.h" -#include "ets_sys.h" -void ets_isr_attach(uint16_t idx, void func(), void *arg); -void ets_isr_unmask(uint16_t idx); -} - -#define USF *((volatile uint32_t *)(0x60000000)) -#define USIR *((volatile uint32_t *)(0x60000004)) -#define USIS *((volatile uint32_t *)(0x60000008)) -#define USIE *((volatile uint32_t *)(0x6000000c)) -#define USIC *((volatile uint32_t *)(0x60000010)) -#define USS *((volatile uint32_t *)(0x6000001c)) -#define USC1 *((volatile uint32_t *)(0x60000024)) - -#define UIFF 0 -#define UIFE 1 -#define UIPE 2 -#define UIFR 3 -#define UIOF 4 -#define UIDSR 5 -#define UICTS 6 -#define UIBD 7 -#define UITO 8 - -#define USRXC 0 -#define UCFFT 0 -#define UCTOT 24 -#define UCTOE 31 - - -#ifdef CONFIG_wakeup -void wakeup(); -#endif - -void uart_isr() -{ - if (USIS & ((1 << UIFF) | (1 << UITO))) { - while ((USS >> USRXC) & 0x7f) { - kin.addKey(USF); - } - } - USIC = USIS; -#ifdef CONFIG_wakeup - wakeup(); -#endif -} - -void StandardInput::setup() -{ - //USC1 = (0x7f << UCFFT) | (0x02 << UCTOT) | (1 << UCTOE ); - USIC = 0xffff; - USIE = (1 << UIFF) | (1 << UIFR) | (1 << UITO); - ETS_UART_INTR_ATTACH(&uart_isr, NULL); - ETS_UART_INTR_ENABLE(); -} - -bool StandardInput::hasKey() -{ - if (write_pos != read_pos) { - return true; - } - return false; -} - -char StandardInput::getKey() -{ - char ret = buffer[read_pos++]; - read_pos %= 8; - return ret; -} - -StandardInput kin; diff --git a/src/arch/esp8266/driver/stdout.cc b/src/arch/esp8266/driver/stdout.cc deleted file mode 100644 index 09a893f..0000000 --- a/src/arch/esp8266/driver/stdout.cc +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright 2020 Daniel Friesel - * - * SPDX-License-Identifier: BSD-2-Clause - */ -#include "driver/stdout.h" -extern "C" { -#include "osapi.h" -#include "user_interface.h" -#include "gpio.h" -void uart_div_modify(uint8_t uart_no, uint32 DivLatchValue); -void os_printf_plus(const char *s, ...); -} - -StandardOutput & StandardOutput::operator<<(unsigned char c) -{ - if (base == 16) { - os_printf("%02x", c); - } else { - os_printf("%d", c); - } - return *this; -} - -StandardOutput & StandardOutput::operator<<(char c) -{ - put(c); - return *this; -} - -StandardOutput & StandardOutput::operator<<(unsigned short number) -{ - os_printf("%u", number); - return *this; -} - -StandardOutput & StandardOutput::operator<<(short number) -{ - os_printf("%d", number); - return *this; -} - -StandardOutput & StandardOutput::operator<<(unsigned int number) -{ - if (base == 16) { - os_printf("%08x", number); - } else { - os_printf("%u", number); - } - return *this; -} - -StandardOutput & StandardOutput::operator<<(int number) -{ - if (base == 16) { - os_printf("%08x", number); - } else { - os_printf("%d", number); - } - return *this; -} - -StandardOutput & StandardOutput::operator<<(unsigned long number) -{ - os_printf("%lu", number); - return *this; -} - -StandardOutput & StandardOutput::operator<<(long number) -{ - os_printf("%ld", number); - return *this; -} - -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: - put('0'); - put('b'); - break; - case 8: - put('0'); - break; - case 16: - put('0'); - put('x'); - break; - } - - if (number == 0) { - put('0'); - return *this; - } - - signed int i = 0; - while (number > 0) { - if (base == 16 && number % base > 9) { - digit_buffer[i] = 'a' + (number % base) - 10; - } else { - digit_buffer[i] = '0' + (number % base); - } - number /= base; - i++; - } - i--; - for (; i >= 0; i--) { - put(digit_buffer[i]); - } - return *this; - -} - -StandardOutput & StandardOutput::operator<<(long long number) -{ - if (number < 0) { - put('-'); - number *= -1; - } - *this << (unsigned long long)number; - - return *this; -} - -StandardOutput & StandardOutput::operator<<(void *pointer) -{ - unsigned short temp_base = base; - *this << hex << (long)pointer; - switch (temp_base) { - case 2: - *this << bin; break; - case 8: - *this << oct; break; - case 10: - *this << dec; break; - } - return *this; -} - -StandardOutput & StandardOutput::operator<<(const char *text) -{ - write(text); - return *this; -} - -StandardOutput & StandardOutput::operator<<(StandardOutput & (*fkt) (StandardOutput &)) -{ - return fkt(*this); -} - -void StandardOutput::setBase(uint8_t b) -{ - if (b == 2 || b == 8 || b == 10 || b == 16) { - base = b; - } -} - -static inline char format_hex_nibble(uint8_t num) -{ - if (num > 9) { - return 'a' + num - 10; - } - return '0' + num; -} - -void StandardOutput::printf_uint8(uint8_t num) -{ - put(format_hex_nibble(num / 16)); - put(format_hex_nibble(num % 16)); -} - -ICACHE_FLASH_ATTR void StandardOutput::printf_float(float num) -{ - if (num < 0) { - put('-'); - num *= -1; - } - if (num > 1000) { - put('0' + (((int)num % 10000) / 1000)); - } - if (num > 100) { - put('0' + (((int)num % 1000) / 100)); - } - if (num > 10) { - put('0' + (((int)num % 100) / 10)); - } - put('0' + ((int)num % 10)); - put('.'); - put('0' + ((int)(num * 10) % 10)); - put('0' + ((int)(num * 100) % 10)); -} - -StandardOutput & flush(StandardOutput & os) -{ - os.flush(); - return os; -} - -StandardOutput & endl(StandardOutput & os) -{ - os.put('\n'); - os.flush(); - return os; -} - -StandardOutput & bin(StandardOutput & os) -{ - os.setBase(2); - return os; -} - -StandardOutput & oct(StandardOutput & os) -{ - os.setBase(8); - return os; -} - -StandardOutput & dec(StandardOutput & os) -{ - os.setBase(10); - return os; -} - -StandardOutput & hex(StandardOutput & os) -{ - os.setBase(16); - return os; -} - -StandardOutput & term(StandardOutput & os) -{ - os.put('\0'); - os.flush(); - return os; -} - -void StandardOutput::setup() -{ - uart_div_modify(0, UART_CLK_FREQ / 115200); -} - -void StandardOutput::put(char c) -{ - os_printf("%c", c); -} - -void StandardOutput::write(const char *s) -{ - os_printf("%s", s); -} - -StandardOutput kout; diff --git a/src/arch/esp8266/driver/uptime.cc b/src/arch/esp8266/driver/uptime.cc deleted file mode 100644 index 621ec91..0000000 --- a/src/arch/esp8266/driver/uptime.cc +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright 2020 Daniel Friesel - * - * SPDX-License-Identifier: BSD-2-Clause - */ -#include "driver/uptime.h" - -Uptime uptime; diff --git a/src/arch/esp8266/prompt b/src/arch/esp8266/prompt deleted file mode 100644 index 3428bc3..0000000 --- a/src/arch/esp8266/prompt +++ /dev/null @@ -1 +0,0 @@ -ESP8266 -- cgit v1.2.3