Skip to content

When to use PA0 or PA_0? #1954

Closed Answered by fpistm
PerennialNovice asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @MasteringTheMess
Arduino API uses pin numbers example on uno connector::

  • digital pin number: D0 to D15 or 0 to 15
  • analog pin number: A0 to A5
    For convenience with STM32, we define PYn where Y is the GPIO port name and n the GPIO pin number, example PA0.
    This pin number is used with all standard Arduino API.

when you used this pin number (PYn) the core convert it to the type PinName: PY_n
This type is a concatenation, ex: PA_0 = (PortA << 4) + 0x00, which allows to retrieve the HAL GPIO port and pin.
Some extended API allows to use it for convenience or to go faster, ex: digitalWriteFast.
In a general way the pin number is always converted to PinName using macros: digitalPinToPinName.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@PerennialNovice
Comment options

Answer selected by fpistm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants