From f087a578953866f3056bf6312f09f571b0b3c7ab Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Mon, 24 Oct 2016 23:01:19 -0500 Subject: [PATCH] Added support for ESP8266 Fixes #262 --- .travis.yml | 2 +- avrpins.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ library.json | 3 ++- usbhost.h | 2 ++ 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c9351a50..f8ffbecd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -74,4 +74,4 @@ install: - platformio lib install 62 416 417 script: - - platformio ci --board=uno --board=teensy31 --board=due --lib="." + - platformio ci --board=uno --board=teensy31 --board=due --board=esp12e --board=nodemcu --lib="." diff --git a/avrpins.h b/avrpins.h index b73a6bc6..4b0d37a4 100644 --- a/avrpins.h +++ b/avrpins.h @@ -1242,6 +1242,52 @@ MAKE_PIN(P13, 13); // #undef MAKE_PIN +#elif defined(ESP8266) + +#define pgm_read_pointer(p) pgm_read_ptr(p) + +#define MAKE_PIN(className, pin) \ +class className { \ +public: \ + static void Set() { \ + digitalWrite(pin, HIGH);\ + } \ + static void Clear() { \ + digitalWrite(pin, LOW); \ + } \ + static void SetDirRead() { \ + pinMode(pin, INPUT); \ + } \ + static void SetDirWrite() { \ + pinMode(pin, OUTPUT); \ + } \ + static uint8_t IsSet() { \ + return digitalRead(pin); \ + } \ +}; + +// Pinout for ESP-12 module +// 0 .. 16 - Digital pins +MAKE_PIN(P0, 0); +MAKE_PIN(P1, 1); // TX0 +MAKE_PIN(P2, 2); // TX1 +MAKE_PIN(P3, 3); // RX0 +MAKE_PIN(P4, 4); // SDA +MAKE_PIN(P5, 5); // SCL +MAKE_PIN(P6, 6); +MAKE_PIN(P7, 7); +MAKE_PIN(P8, 8); +MAKE_PIN(P9, 9); +MAKE_PIN(P10, 10); +MAKE_PIN(P11, 11); +MAKE_PIN(P12, 12); // MISO +MAKE_PIN(P13, 13); // MOSI +MAKE_PIN(P14, 14); // SCK +MAKE_PIN(P15, 15); // SS +MAKE_PIN(P16, 16); + +#undef MAKE_PIN + #else #error "Please define board in avrpins.h" diff --git a/library.json b/library.json index a26311d1..7251409b 100644 --- a/library.json +++ b/library.json @@ -49,6 +49,7 @@ "teensy", "atmelsam", "nordicnrf51", - "ststm32" + "ststm32", + "espressif8266" ] } diff --git a/usbhost.h b/usbhost.h index 15a57bd1..b655f44b 100644 --- a/usbhost.h +++ b/usbhost.h @@ -97,6 +97,8 @@ typedef SPi< P13, P11, P12, P10 > spi; typedef SPi< P76, P75, P74, P10 > spi; #elif defined(RBL_NRF51822) typedef SPi< P16, P18, P17, P10 > spi; +#elif defined(ESP8266) +typedef SPi< P14, P13, P12, P15 > spi; #else #error "No SPI entry in usbhost.h" #endif