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

rp2/boards/SEEED_XIAO_RP2040: New board definition. #14402

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mattytrentini
Copy link
Sponsor Contributor

@mattytrentini mattytrentini commented May 1, 2024

A board definition for the Seeed XIAO RP2040.

Pin list:

>>> from machine import Pin
>>> help(Pin.board)
object <class 'board'> is of type type
  D6 -- Pin(GPIO0, mode=ALT, pull=PULL_DOWN, alt=31)
  D7 -- Pin(GPIO1, mode=ALT, pull=PULL_DOWN, alt=31)
  CSn -- Pin(GPIO1, mode=ALT, pull=PULL_DOWN, alt=31)
  D8 -- Pin(GPIO2, mode=ALT, pull=PULL_DOWN, alt=31)
  D10 -- Pin(GPIO3, mode=ALT, pull=PULL_DOWN, alt=31)
  D9 -- Pin(GPIO4, mode=ALT, pull=PULL_DOWN, alt=31)
  D4 -- Pin(GPIO6, mode=ALT, pull=PULL_DOWN, alt=31)
  D5 -- Pin(GPIO7, mode=ALT, pull=PULL_DOWN, alt=31)
  NEOPIXEL_POWER -- Pin(GPIO11, mode=ALT, pull=PULL_DOWN, alt=31)
  NEOPIXEL -- Pin(GPIO12, mode=ALT, pull=PULL_DOWN, alt=31)
  LED_G -- Pin(GPIO16, mode=ALT, pull=PULL_DOWN, alt=31)
  LED_R -- Pin(GPIO17, mode=ALT, pull=PULL_DOWN, alt=31)
  LED_B -- Pin(GPIO25, mode=ALT, pull=PULL_DOWN, alt=31)
  A0_D0 -- Pin(GPIO26, mode=ALT, pull=PULL_DOWN, alt=31)
  A1_D1 -- Pin(GPIO27, mode=ALT, pull=PULL_DOWN, alt=31)
  A2_D2 -- Pin(GPIO28, mode=ALT, pull=PULL_DOWN, alt=31)
  A3_D3 -- Pin(GPIO29, mode=ALT, pull=PULL_DOWN, alt=31)

Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
@mattytrentini
Copy link
Sponsor Contributor Author

Minor nit: There are 3x LEDs (arranged as RGB closely together) on this board but they're active low. To initialise them to off:

>>> leds = (Pin.board.LED_R, Pin.board.LED_G, Pin.board.LED_B)
>>> for l in leds:
...     l.init(Pin.OUT)
...     l.on()  # Turn LED *off*

And to turn them on (purple here):

>>> leds[0].off()
>>> leds[2].off()

Is there a better way to present these LEDs? ie to default them to off but to turn them on with appropriate syntax? Should I just create a module for this board?

@ricksorensen
Copy link
Contributor

Curiosity- why is CSn defined in pins.csv? It is defined as GPIO1 (from SEEED pinout) which is also UART RX. I believe this CSn was thought of for general SPI0 use- but I'm guessing as device SPI will have its CS connected to an arbitrary pin.
I like clearly defining the I2C0 and SPI0 pins.

Signed-off-by: Matt Trentini <matt.trentini@gmail.com>
Copy link

github-actions bot commented May 2, 2024

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS

@mattytrentini
Copy link
Sponsor Contributor Author

Curiosity- why is CSn defined in pins.csv?

Just because that's the pin nominated as CS on Seeed's pinout diagram. You're right that it's largely arbitrary, but it also doesn't have to be used for that purpose. It seems best to define it so users will find it by default if they're looking for a CS pin.

It is defined as GPIO1 (from SEEED pinout) which is also UART RX.

Note that it can be used for either purposes - UART(0) is bound to that pin too.

(I did inadvertently add RX_LED and TX_LED which were copy 'n' paste issues. Removed now!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants