Skip to content

How to name pins and peripherals #265

Closed
@dpgeorge

Description

@dpgeorge

There has been a discussion in #227 on how to name pins (and peripherals such as I2C). Most MCUs have pins named by port and pin number on that port, such as Port A, Pin 4, referred to as PA4 for example. On the pyboard, the pins are not sequential and have been renamed to reflect their location on the board (and also location within a skin), for example X1 or Y12. These names can still be considered to have a port and pin, ie Port X, Pin 1 or Port Y, Pin 12.

For peripherals, they can be numbered simply as USART1, USART2, SPI1, etc. On the pyboard these can be named USART_X, SPI_Y, etc, so that you know exactly where they are.

Coming back to pins, the discussion boiled down to whether we separate the port and pin, or keep them together, eg

# together
p = pyb.Gpio(A4)
# or separate
p = pyb.Gpio(A, 4)

Part of the discussion was about efficiency, and that specifying port and pin separately is closer to the hardware and more efficient to map to the underlying hardware implementation. But note that on the STM, each port is actually a pointer and so there is going to be some level of mapping no matter what.

Metadata

Metadata

Assignees

No one assigned

    Labels

    rfcRequest for Comment

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions