pyb.Pin
Classes
Create a new Pin object associated with the id. If additional arguments are given, |
|
Module Contents
- class pyb.Pin.Pin(id, *args, **kwargs)
Create a new Pin object associated with the id. If additional arguments are given, they are used to initialise the pin. See
pin.init()
.- af() Incomplete
Returns the currently configured alternate-function of the pin. The integer returned will match one of the allowed constants for the af argument to the init function.
- af_list() List
Returns an array of alternate functions available for this pin.
- classmethod debug(state: Any | None = None) bool
Get or set the debugging state (
True
orFalse
for on or off).
- classmethod dict(dict: Any | None = None) Incomplete
Get or set the pin mapper dictionary.
- init(mode, pull=PULL_NONE, *, value=None, alt=-1) None
Initialise the pin:
mode can be one of:
Pin.IN
- configure the pin for input;Pin.OUT_PP
- configure the pin for output, with push-pull control;Pin.OUT_OD
- configure the pin for output, with open-drain control;Pin.ALT
- configure the pin for alternate function, input or output;Pin.AF_PP
- configure the pin for alternate function, push-pull;Pin.AF_OD
- configure the pin for alternate function, open-drain;Pin.ANALOG
- configure the pin for analog.
pull can be one of:
Pin.PULL_NONE
- no pull up or down resistors;Pin.PULL_UP
- enable the pull-up resistor;Pin.PULL_DOWN
- enable the pull-down resistor.
When a pin has the
Pin.PULL_UP
orPin.PULL_DOWN
pull-mode enabled, that pin has an effective 40k Ohm resistor pulling it to 3V3 or GND respectively (except pin Y5 which has 11k Ohm resistors).value if not None will set the port output value before enabling the pin.
alt can be used when mode is
Pin.ALT
,Pin.AF_PP
orPin.AF_OD
to set the index or name of one of the alternate functions associated with a pin. This arg was previously called af which can still be used if needed.
Returns:
None
.
- classmethod mapper(fun: Any | None = None) Incomplete
Get or set the pin mapper function.
- mode() Incomplete
Returns the currently configured mode of the pin. The integer returned will match one of the allowed constants for the mode argument to the init function.
- port() Incomplete
Get the pin port.
- pull() Incomplete
Returns the currently configured pull of the pin. The integer returned will match one of the allowed constants for the pull argument to the init function.
- value(value: Any | None = None) int
Get or set the digital logic level of the pin:
With no argument, return 0 or 1 depending on the logic level of the pin.
With
value
given, set the logic level of the pin.value
can be anything that converts to a boolean. If it converts toTrue
, the pin is set high, otherwise it is set low.
- AF_OD: Incomplete
initialise the pin to alternate-function mode with an open-drain drive
- AF_PP: Incomplete
initialise the pin to alternate-function mode with a push-pull drive
- ALT: Incomplete
initialise the pin to alternate-function mode for input or output
- ANALOG: Incomplete
initialise the pin to analog mode
- IN: Incomplete
initialise the pin to input mode
- OUT_OD: Incomplete
initialise the pin to output mode with an open-drain drive
- OUT_PP: Incomplete
initialise the pin to output mode with a push-pull drive
- PULL_DOWN: Incomplete
enable the pull-down resistor on the pin
- PULL_NONE: Incomplete
don’t enable any pull up or down resistors on the pin
- PULL_UP: Incomplete
enable the pull-up resistor on the pin
- class pyb.Pin.pinaf
-
- reg() Incomplete
Return the base register associated with the peripheral assigned to this alternate function. For example, if the alternate function were TIM2_CH3 this would return stm.TIM2