summaryrefslogtreecommitdiffstatshomepage
path: root/esp8266/espneopixel.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-08-07 16:03:00 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-08-07 16:03:00 +0300
commitf71f37e4269b43222d6b1b812e7109e946345b53 (patch)
treef73d4d3dbfb639f5c4c97fe04d88d0f739149239 /esp8266/espneopixel.c
parentc2070d771a70df6ebe19d6ca97b363b2b38d69fa (diff)
downloadmicropython-f71f37e4269b43222d6b1b812e7109e946345b53.tar.gz
micropython-f71f37e4269b43222d6b1b812e7109e946345b53.zip
esp8266/esp_mphal.h: Add mp_hal_ticks_cpu() for reuse.
Diffstat (limited to 'esp8266/espneopixel.c')
-rw-r--r--esp8266/espneopixel.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/esp8266/espneopixel.c b/esp8266/espneopixel.c
index 26776f025e..0f12f4c820 100644
--- a/esp8266/espneopixel.c
+++ b/esp8266/espneopixel.c
@@ -9,16 +9,10 @@
#include "eagle_soc.h"
#include "user_interface.h"
#include "espneopixel.h"
+#include "esp_mphal.h"
#define NEO_KHZ400 (1)
-static uint32_t _getCycleCount(void) __attribute__((always_inline));
-static inline uint32_t _getCycleCount(void) {
- uint32_t ccount;
- __asm__ __volatile__("rsr %0,ccount":"=a" (ccount));
- return ccount;
-}
-
void /*ICACHE_RAM_ATTR*/ esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32_t numBytes, bool is800KHz) {
uint8_t *p, *end, pix, mask;
@@ -49,10 +43,10 @@ void /*ICACHE_RAM_ATTR*/ esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32
for(t = time0;; t = time0) {
if(pix & mask) t = time1; // Bit high duration
- while(((c = _getCycleCount()) - startTime) < period); // Wait for bit start
+ while(((c = mp_hal_ticks_cpu()) - startTime) < period); // Wait for bit start
GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, pinMask); // Set high
startTime = c; // Save start time
- while(((c = _getCycleCount()) - startTime) < t); // Wait high duration
+ while(((c = mp_hal_ticks_cpu()) - startTime) < t); // Wait high duration
GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, pinMask); // Set low
if(!(mask >>= 1)) { // Next bit/byte
if(p >= end) break;
@@ -60,5 +54,5 @@ void /*ICACHE_RAM_ATTR*/ esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32
mask = 0x80;
}
}
- while((_getCycleCount() - startTime) < period); // Wait for last bit
+ while((mp_hal_ticks_cpu() - startTime) < period); // Wait for last bit
}