esp32/espneopixel: Add support for GPIO32 and GPIO33.

Adds support for NeoPixels on GPIO32 and GPIO33 on ESP32.  Otherwise,
NeoPixels wired to GPIO32/33 wll silently fail without any hints to the
user.

With thanks to @robert-hh.

Fixes issue #7221.
This commit is contained in:
Joseph Chiu 2021-05-05 03:43:42 -07:00 committed by Damien George
parent a18f695e29
commit c5d2095e59

View File

@ -11,9 +11,17 @@
void IRAM_ATTR esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32_t numBytes, uint8_t timing) {
uint8_t *p, *end, pix, mask;
uint32_t t, time0, time1, period, c, startTime, pinMask;
uint32_t t, time0, time1, period, c, startTime, pinMask, gpio_reg_set, gpio_reg_clear;
if (pin < 32) {
pinMask = 1 << pin;
gpio_reg_set = GPIO_OUT_W1TS_REG;
gpio_reg_clear = GPIO_OUT_W1TC_REG;
} else {
pinMask = 1 << (pin - 32);
gpio_reg_set = GPIO_OUT1_W1TS_REG;
gpio_reg_clear = GPIO_OUT1_W1TC_REG;
}
p = pixels;
end = p + numBytes;
pix = *p++;
@ -42,12 +50,12 @@ void IRAM_ATTR esp_neopixel_write(uint8_t pin, uint8_t *pixels, uint32_t numByte
while (((c = mp_hal_ticks_cpu()) - startTime) < period) {
; // Wait for bit start
}
GPIO_REG_WRITE(GPIO_OUT_W1TS_REG, pinMask); // Set high
GPIO_REG_WRITE(gpio_reg_set, pinMask); // Set high
startTime = c; // Save start time
while (((c = mp_hal_ticks_cpu()) - startTime) < t) {
; // Wait high duration
}
GPIO_REG_WRITE(GPIO_OUT_W1TC_REG, pinMask); // Set low
GPIO_REG_WRITE(gpio_reg_clear, pinMask); // Set low
if (!(mask >>= 1)) { // Next bit/byte
if (p >= end) {
break;