0

I'm using MicroPython v1.19.1 for the RP2040 Connect board as described Here and so far the WiFi is working as well as the IMU. So far so good.

What I haven't figured out is how do I access the three GPIO pins on the NINA module that are hooked to the RGB LED. This micropython includes a driver and the board has a config that makes WiFi work even though it's over SPI. The release notes say that the Wifi NINA102 module is there, but what I can't figure out is did they do something to map the pins so that they appear just as machine.Pin() with a different pin number, and that maps to SPI to the NINA module? Or do I have to add the NINA102 module myself (that seems wrong as I think it would conflict with the network/sockets stuff which is already working).

This Code is part of the NINA driver, and lines 48-56:

static uint8_t pin_map[MICROPY_HW_PIN_EXT_COUNT] = {
    27, // LEDR
    25, // LEDG
    26, // LEDB
    34, // A4
    39, // A5
    36, // A6
    35, // A7
};

have given me the idea that machine.Pin(27, Pin.OUT) should control that pin, even though it's not actually physically on the main controller. In other words, I think their intent was to make it transparent to micropython that the pin is actually remote. It does not work, though, so I feel like I'm missing a step.

wz2b
  • 1,017
  • 7
  • 24
  • 1
    [The source code of `Pin()`](https://github.com/micropython/micropython/blob/67fac4e/ports/rp2/machine_pin.c#L287) suggests that you'd need to pass a string as the first argument if you are accessing pins not on the CPU. Definitely `Pin(27)` should correspond to the RP2040 pin by the same name, not some other pin. – David Grayson Apr 26 '23 at 18:26
  • I didn't even realize pins had string-based names. I'm looking to figure out where those are defined. If it is [this](https://github.com/micropython/micropython/blob/67fac4ebc53db6337008ba06df7932faec80f57c/ports/rp2/boards/rp2_af.csv) then that makes me think only the directly connected (rp2040) pins are supported. Update: trying [this](https://github.com/micropython/micropython/blob/67fac4ebc53db6337008ba06df7932faec80f57c/ports/rp2/boards/ARDUINO_NANO_RP2040_CONNECT/pins.csv) – wz2b Apr 28 '23 at 16:12
  • I ugpraded to v1.20 and now I can refer to pins by names. It seem to be opposite-logic (set it OFF to turn the LED ON) but that's probably an artifact of how the board is wired. Thanks for your help! – wz2b Apr 28 '23 at 17:02

0 Answers0