Lepsi zakazovani preruseni pro ESP32.

This commit is contained in:
Pavel Brychta 2020-08-18 13:01:44 +02:00
parent 69a5b37616
commit 44de7d5d15
5 changed files with 24 additions and 13 deletions

View File

@ -1,4 +1,4 @@
MIT License Copyright (c) <year> <copyright holders> MIT License Copyright (c) 2019,2020 xPablo.cz
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,3 +1,5 @@
# WSLed # WSLed
WS2812 signalizační LED pro platformu ESP8266/ESP32 WS2812 signalizační LED pro platformu ESP8266/ESP32.
Dvojí možnost časování - starší provedení vývodové LED 5mm - `NEOPIXEL_OLD_TIMING`, nebo novější časování, např. pro diody v pouzdru 2020.

View File

@ -43,12 +43,15 @@ inline uint32_t _getCycleCount()
return ccount; return ccount;
} }
//#define CYCLES_800_T0H (F_CPU / 2500000) // 0.4us #if defined(NEOPIXEL_OLD_TIMING)
//#define CYCLES_800_T1H (F_CPU / 1250000) // 0.8us # define CYCLES_800_T0H (F_CPU / 2500000) // 0.4us
//#define CYCLES_800 (F_CPU / 800000) // 1.25us per bit # define CYCLES_800_T1H (F_CPU / 1250000) // 0.8us
#define CYCLES_800_T0H (F_CPU / 2600000) // 0.4us # define CYCLES_800 (F_CPU / 800000) // 1.25us per bit
#define CYCLES_800_T1H (F_CPU / 1350000) // 0.8us #else
#define CYCLES_800 (F_CPU / 900000) // 1.25us per bit # define CYCLES_800_T0H (F_CPU / 2600000) // 0.4us
# define CYCLES_800_T1H (F_CPU / 1350000) // 0.8us
# define CYCLES_800 (F_CPU / 900000) // 1.25us per bit
#endif
void ICACHE_RAM_ATTR send_pixels_800(uint8_t* pixels, size_t count, uint8_t pin) void ICACHE_RAM_ATTR send_pixels_800(uint8_t* pixels, size_t count, uint8_t pin)
{ {

View File

@ -1,5 +1,8 @@
// Ovladani signalizacni chytre LED diody // Ovladani signalizacni chytre LED diody
#include "wsLED.h" #include "wsLED.h"
//#if defined(ARDUINO_ARCH_ESP32)
//# include "esp_task.h"
//#endif
// due to linker overriding the ICACHE_RAM_ATTR for cpp files, these methods are // due to linker overriding the ICACHE_RAM_ATTR for cpp files, these methods are
// moved into a C file so the attribute will be applied correctly // moved into a C file so the attribute will be applied correctly
extern "C" void ICACHE_RAM_ATTR send_pixels_800(uint8_t* pixel, size_t count, uint8_t pin); extern "C" void ICACHE_RAM_ATTR send_pixels_800(uint8_t* pixel, size_t count, uint8_t pin);
@ -17,7 +20,7 @@ static const uint16_t LB[] PROGMEM = {
inline bool wsLED::canShow(void) inline bool wsLED::canShow(void)
{ {
return (micros() - _endtime) >= 50L; return (micros() - _endtime) >= 70L;
} }
void wsLED::show(void) void wsLED::show(void)
@ -32,17 +35,17 @@ void wsLED::show(void)
while (!canShow()) while (!canShow())
__asm__ volatile ("nop"); __asm__ volatile ("nop");
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
uint32_t volatile register ilevel = XTOS_DISABLE_ALL_INTERRUPTS; // uint32_t volatile register ilevel = XTOS_DISABLE_ALL_INTERRUPTS;
portENTER_CRITICAL(&_mux);
#else #else
noInterrupts(); noInterrupts();
//cli();
#endif #endif
send_pixels_800(color, 1, _pin); send_pixels_800(color, 1, _pin);
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
XTOS_RESTORE_INTLEVEL(ilevel); // XTOS_RESTORE_INTLEVEL(ilevel);
portEXIT_CRITICAL(&_mux);
#else #else
interrupts(); interrupts();
//sei();
#endif #endif
_endtime = micros(); _endtime = micros();
} }

View File

@ -135,6 +135,9 @@ protected:
bool canShow(void); bool canShow(void);
void show(void); void show(void);
void setColor(LEDRGB &color); void setColor(LEDRGB &color);
#if defined(ARDUINO_ARCH_ESP32)
portMUX_TYPE _mux = portMUX_INITIALIZER_UNLOCKED;
#endif
public: public:
wsLED(int pin, int order = RGB); wsLED(int pin, int order = RGB);