When to use PA0 or PA_0? #1954
-
There exit two different definitions for hardware Pins. The PA_0 notation can be used with hardware serial, but it seems to cause some trouble with I²C or SPI instances. Here the PA0 notation has to be used. Is there some information on what can be used with which APIs? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @MasteringTheMess
when you used this pin number ( |
Beta Was this translation helpful? Give feedback.
Hi @MasteringTheMess
Arduino API uses pin numbers example on uno connector::
D0
toD15
or 0 to 15A0
toA5
For convenience with STM32, we define
PYn
whereY
is the GPIO port name andn
the GPIO pin number, examplePA0
.This pin number is used with all standard Arduino API.
when you used this pin number (
PYn
) the core convert it to the typePinName
: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
.