Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FastLED/FastLED.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Garcia <danielgarcia@gmail.com>2016-01-24 04:12:35 +0300
committerDaniel Garcia <danielgarcia@gmail.com>2016-01-24 04:12:35 +0300
commit55690d683283fac76602fa8e193d886f7c174ebe (patch)
tree97fc2d0cc74b0974870647d9b78d7abca3ed44ba
parentdbf4292184110d1a5e36818c437a44004786c92f (diff)
ESP8266 first light - FastPin, bitbang'd spi output
-rw-r--r--led_sysdefs.h4
-rw-r--r--lib8tion.h4
-rw-r--r--platforms.h4
-rw-r--r--platforms/esp/8266/fastled_esp8266.h4
-rw-r--r--platforms/esp/8266/fastpin_esp8266.h42
-rw-r--r--platforms/esp/8266/led_sysdefs_esp8266.h26
6 files changed, 78 insertions, 6 deletions
diff --git a/led_sysdefs.h b/led_sysdefs.h
index c6cecd52..0876bb61 100644
--- a/led_sysdefs.h
+++ b/led_sysdefs.h
@@ -20,8 +20,8 @@
#include "platforms/arm/stm32/led_sysdefs_arm_stm32.h"
#elif defined(__SAMD21G18A__)
#include "platforms/arm/d21/led_sysdefs_arm_d21.h"
-#elif defined(__XTENSA__)
-#error "XTENSA-architecture microcontrollers are not supported."
+#elif defined(ESP8266)
+#include "platforms/esp/8266/led_sysdefs_esp8266.h"
#else
// AVR platforms
#include "platforms/avr/led_sysdefs_avr.h"
diff --git a/lib8tion.h b/lib8tion.h
index 9d66624a..0dbbbff4 100644
--- a/lib8tion.h
+++ b/lib8tion.h
@@ -837,9 +837,9 @@ typedef q<uint16_t, 12,4> q124;
// that provides similar functionality.
// You can also force use of the get_millisecond_timer function
// by #defining USE_GET_MILLISECOND_TIMER.
-#if (defined(ARDUINO) || defined(SPARK)) && !defined(USE_GET_MILLISECOND_TIMER)
+#if (defined(ARDUINO) || defined(SPARK) || defined(FASTLED_HAS_MILLIS)) && !defined(USE_GET_MILLISECOND_TIMER)
// Forward declaration of Arduino function 'millis'.
-uint32_t millis();
+//uint32_t millis();
#define GET_MILLIS millis
#else
uint32_t get_millisecond_timer();
diff --git a/platforms.h b/platforms.h
index c36b016c..b92dafac 100644
--- a/platforms.h
+++ b/platforms.h
@@ -20,8 +20,8 @@
#include "platforms/arm/stm32/fastled_arm_stm32.h"
#elif defined(__SAMD21G18A__)
#include "platforms/arm/d21/fastled_arm_d21.h"
-#elif defined(__XTENSA__)
-#error "XTENSA-architecture microcontrollers are not supported"
+#elif defined(ESP8266)
+#include "platforms/esp/8266/fastled_esp8266.h"
#else
// AVR platforms
#include "platforms/avr/fastled_avr.h"
diff --git a/platforms/esp/8266/fastled_esp8266.h b/platforms/esp/8266/fastled_esp8266.h
new file mode 100644
index 00000000..eda245f5
--- /dev/null
+++ b/platforms/esp/8266/fastled_esp8266.h
@@ -0,0 +1,4 @@
+#pragma once
+
+#include "fastled_delay.h"
+#include "fastpin_esp8266.h"
diff --git a/platforms/esp/8266/fastpin_esp8266.h b/platforms/esp/8266/fastpin_esp8266.h
new file mode 100644
index 00000000..6b9b5e7a
--- /dev/null
+++ b/platforms/esp/8266/fastpin_esp8266.h
@@ -0,0 +1,42 @@
+#pragma once
+
+
+template<uint8_t PIN, uint32_t MASK> class _ESPPIN {
+
+public:
+ typedef volatile uint32_t * port_ptr_t;
+ typedef uint32_t port_t;
+
+ inline static void setOutput() { pinMode(PIN, OUTPUT); }
+ inline static void setInput() { pinMode(PIN, INPUT); }
+
+ inline static void hi() __attribute__ ((always_inline)) { if(PIN < 16) { GPOS = MASK; } else { GP16O |= MASK; } }
+ inline static void lo() __attribute__ ((always_inline)) { if(PIN < 16) { GPOC = MASK; } else { GP16O &= ~MASK; } }
+ inline static void set(register port_t val) __attribute__ ((always_inline)) { if(PIN < 16) { GPO = val; } else { GP16O = val; }}
+
+ inline static void strobe() __attribute__ ((always_inline)) { toggle(); toggle(); }
+
+ inline static void toggle() __attribute__ ((always_inline)) { if(PIN < 16) { GPO ^= MASK; } else { GP16O ^= MASK; } }
+
+ inline static void hi(register port_ptr_t port) __attribute__ ((always_inline)) { hi(); }
+ inline static void lo(register port_ptr_t port) __attribute__ ((always_inline)) { lo(); }
+ inline static void fastset(register port_ptr_t port, register port_t val) __attribute__ ((always_inline)) { *port = val; }
+
+ inline static port_t hival() __attribute__ ((always_inline)) { if (PIN<16) { return GPO | MASK; } else { return GP16O | MASK; } }
+ inline static port_t loval() __attribute__ ((always_inline)) { if (PIN<16) { return GPO & ~MASK; } else { return GP16O & ~MASK; } }
+ inline static port_ptr_t port() __attribute__ ((always_inline)) { if(PIN<16) { return &GPO; } else { return &GP16O; } }
+ inline static port_t mask() __attribute__ ((always_inline)) { return MASK; }
+
+ inline static bool isset() __attribute__ ((always_inline)) { return (PIN < 16) ? (GPO & MASK) : (GP16O & MASK); }
+};
+
+#define _DEFPIN_ESP8266(PIN) template<> class FastPin<PIN> : public _ESPPIN<PIN, (1<<(PIN & 0xFF))> {};
+
+#define MAX_PIN 116
+_DEFPIN_ESP8266(0); _DEFPIN_ESP8266(1); _DEFPIN_ESP8266(2); _DEFPIN_ESP8266(3);
+_DEFPIN_ESP8266(4); _DEFPIN_ESP8266(5); _DEFPIN_ESP8266(6); _DEFPIN_ESP8266(7);
+_DEFPIN_ESP8266(8); _DEFPIN_ESP8266(9); _DEFPIN_ESP8266(10); _DEFPIN_ESP8266(11);
+_DEFPIN_ESP8266(12); _DEFPIN_ESP8266(13); _DEFPIN_ESP8266(14); _DEFPIN_ESP8266(15);
+_DEFPIN_ESP8266(16);
+
+#define HAS_HARDWARE_PIN_SUPPORT
diff --git a/platforms/esp/8266/led_sysdefs_esp8266.h b/platforms/esp/8266/led_sysdefs_esp8266.h
new file mode 100644
index 00000000..b9b3376c
--- /dev/null
+++ b/platforms/esp/8266/led_sysdefs_esp8266.h
@@ -0,0 +1,26 @@
+#pragma once
+
+#ifndef ESP8266
+#define ESP8266
+#endif
+
+#define FASTLED_ESP8266
+
+// Use system millis timer
+#define FASTLED_HAS_MILLIS
+
+typedef volatile uint32_t RoReg;
+typedef volatile uint32_t RwReg;
+typedef uint32_t prog_uint32_t;
+typedef uint8_t boolean;
+
+// Default to NOT using PROGMEM here
+#ifndef FASTLED_USE_PROGMEM
+#define FASTLED_USE_PROGMEM 0
+#endif
+
+#ifndef FASTLED_ALLOW_INTERRUPTS
+#define FASTLED_ALLOW_INTERRUPTS 0
+#endif
+
+#define NEED_CXX_BITS