summaryrefslogtreecommitdiff
path: root/src/arch/esp8266/driver
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-12-25 18:09:33 +0100
committerDaniel Friesel <derf@finalrewind.org>2021-12-25 18:09:33 +0100
commit35a98377f52caf5ac37c2e932b9f2d4c9196c195 (patch)
treed87920e581a25b3ef30b4cce967cd8842db5c1eb /src/arch/esp8266/driver
parent16b712e0233cfd7b60668927067885f7e3551b92 (diff)
Remove esp8266 support in favor of ESP8266 RTOS SDK
Diffstat (limited to 'src/arch/esp8266/driver')
-rw-r--r--src/arch/esp8266/driver/counter.cc8
-rw-r--r--src/arch/esp8266/driver/gpio.cc199
-rw-r--r--src/arch/esp8266/driver/stdin.cc82
-rw-r--r--src/arch/esp8266/driver/stdout.cc264
-rw-r--r--src/arch/esp8266/driver/uptime.cc8
5 files changed, 0 insertions, 561 deletions
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;