class PinAF – pin alternate functions¶
Each STM32 pin can serve as plain GPIO or as one of several
peripheral alternate functions (UART4_TX, I2C2_SCL,
TIM2_CH3, etc.). A PinAF object describes a single
alternate function that is wired to a particular pin, and is what
Pin.af_list() returns.
Usage Model:
p4 = pyb.Pin.board.P4
p4_af = p4.af_list()
p4_af now holds the list of PinAF objects available on
P4. The exact list depends on the STM32 MCU on the OpenMV Cam in
use.
Normally each peripheral driver configures the alternate function it
needs automatically. When the same peripheral function is wired to
more than one pin, or several functions share a pin, you can pick one
explicitly through Pin.ALT either by name:
pin = pyb.Pin(pyb.Pin.board.P4, mode=pyb.Pin.ALT, alt=pyb.Pin.AF1_TIM2)
or by raw index:
pin = pyb.Pin(pyb.Pin.board.P4, mode=pyb.Pin.ALT, alt=1)
Constructors¶
- class pyb.PinAF¶
PinAFobjects are not constructed directly. UsePin.af_list()to enumerate the alternate functions available on a given pin.Methods¶
- index() int¶
Return the alternate-function index. The same integer is accepted by the
altargument ofPin.init().