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

fix setPin() for RP2040 #389

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 13 additions & 3 deletions Adafruit_NeoPixel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3127,13 +3127,23 @@ if(is800KHz) {
@param p Arduino pin number (-1 = no pin).
*/
void Adafruit_NeoPixel::setPin(int16_t p) {
if (begun && (pin >= 0))
pinMode(pin, INPUT); // Disable existing out pin
pin = p;
if (begun) {
pinMode(p, OUTPUT);
digitalWrite(p, LOW);
}
#if defined(ARDUINO_ARCH_RP2040)
if (!init)
{
delayMicroseconds(100);
pio_gpio_init(pio, p);
pio_sm_set_consecutive_pindirs(pio, sm, p, 1, true);
pio_sm_set_sideset_pins(pio, sm, p);
}
#endif
if (begun && (pin >= 0))
pinMode(pin, INPUT); // Disable existing out pin
pin = p;

#if defined(__AVR__)
port = portOutputRegister(digitalPinToPort(p));
pinMask = digitalPinToBitMask(p);
Expand Down
Loading