Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arduino Giga support Issue #349 #407

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 69 additions & 1 deletion Adafruit_NeoPixel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
}

/*!
Expand Down
8 changes: 8 additions & 0 deletions Adafruit_NeoPixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
#include <Arduino.h>
#endif

#if defined(TARGET_GIGA) || defined(TARGET_M4)
#include "mbed.h"
#include "pinDefinitions.h"
#endif

#if defined(ARDUINO_ARCH_RP2040)
#include <stdlib.h>
#include "hardware/pio.h"
Expand Down Expand Up @@ -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;
Expand Down
Loading