From 91b0d18e89e61efcef24d2896ed71bd1e0d79f84 Mon Sep 17 00:00:00 2001 From: tineira <55414933+tineira@users.noreply.github.com> Date: Sun, 13 Oct 2024 18:57:08 -0300 Subject: [PATCH 1/2] Added Arduino Giga Support --- Adafruit_NeoPixel.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Adafruit_NeoPixel.h b/Adafruit_NeoPixel.h index 18fabbf..1d58b99 100644 --- a/Adafruit_NeoPixel.h +++ b/Adafruit_NeoPixel.h @@ -54,6 +54,11 @@ #include #endif +#if defined(TARGET_GIGA) || defined(TARGET_M4) +#include "mbed.h" +#include "pinDefinitions.h" +#endif + #if defined(ARDUINO_ARCH_RP2040) #include #include "hardware/pio.h" @@ -402,6 +407,9 @@ class Adafruit_NeoPixel { GPIO_TypeDef *gpioPort; ///< Output GPIO PORT uint32_t gpioPin; ///< Output GPIO PIN #endif +#if defined(TARGET_GIGA) || defined(TARGET_M4) + mbed::DigitalInOut *gpio; +#endif #if defined(ARDUINO_ARCH_RP2040) PIO pio = pio0; int sm = 0; From 77e9d543eff3854c07f0639466000c435e82d7c9 Mon Sep 17 00:00:00 2001 From: tineira <55414933+tineira@users.noreply.github.com> Date: Sun, 13 Oct 2024 18:58:32 -0300 Subject: [PATCH 2/2] Update Adafruit_NeoPixel.cpp Added Arduino Giga Support --- Adafruit_NeoPixel.cpp | 70 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/Adafruit_NeoPixel.cpp b/Adafruit_NeoPixel.cpp index 39f0b11..1e97590 100644 --- a/Adafruit_NeoPixel.cpp +++ b/Adafruit_NeoPixel.cpp @@ -1827,9 +1827,69 @@ void Adafruit_NeoPixel::show(void) { #elif defined(__arm__) +#if defined(TARGET_GIGA) || defined(TARGET_M4) + // Arduino GIGA ----------------------------------------------------------- + uint8_t *p = pixels, *end = p + numBytes, pix; + while (p < end) + { + pix = *p++; + for (int i = 7; i >= 0; i--) + { + // gpio_write(&gpio->gpio, 1); + gpio->write(1); + + // duty cycle determines bit value + // if (pix & 0x80) + if (bitRead(pix, i) == 0) + { + // one + // wait_ns(400); -> 192 cycles +#if defined(TARGET_GIGA) + for (int j = 0; j < 96; j++) +#else + for (int j = 0; j < 48; j++) +#endif + __NOP(); + + // gpio_write(&gpio->gpio, 0); + gpio->write(0); + + // wait_ns(850) -> 408 cycles +#if defined(TARGET_GIGA) + for (int j = 0; j < 204; j++) +#else + for (int j = 0; j < 102; j++) +#endif + __NOP(); + } + else + { + // zero + // wait_ns(800) -> 384 cycles +#if defined(TARGET_GIGA) + for (int j = 0; j < 192; j++) +#else + for (int j = 0; j < 96; j++) +#endif + __NOP(); + + gpio->write(0); + // gpio_write(&gpio->gpio, 0); + // wait_ns(450) -> 216 cycles +#if defined(TARGET_GIGA) + for (int j = 0; j < 108; j++) +#else + for (int j = 0; j < 54; j++) +#endif + __NOP(); + } + + // pix = pix << 1; // shift to next bit + } + } // ARM MCUs -- Teensy 3.0, 3.1, LC, Arduino Due, RP2040 ------------------- -#if defined(ARDUINO_ARCH_RP2040) +#elif defined(ARDUINO_ARCH_RP2040) // Use PIO rp2040Show(pin, pixels, numBytes, is800KHz); @@ -3308,6 +3368,14 @@ void Adafruit_NeoPixel::setPin(int16_t p) { } #endif #endif +#if defined(TARGET_GIGA) || defined(TARGET_M4) + gpio = digitalPinToGpio(pin); + if (gpio == NULL) + { + gpio = new mbed::DigitalInOut(digitalPinToPinName(pin), PIN_OUTPUT, PullNone, 0); + digitalPinToGpio(pin) = gpio; + } +#endif } /*!