Skip to content

Commit 33ea400

Browse files
chrismas9dpgeorge
authored andcommitted
docs/library/pyb.Pin: Add Pin.ALT constant.
Some Pin alternate functions are inputs, for example, timer capture and break inputs. In Pyb.Pin the only way to set alt mode is with Pin.AF_PP or Pin.AF_OD. It is not intuitive to use an output mode to configure an input. Pin.ALT is used in the machine.Pin class and works in pyb.Pin. The examples are changed to use Pin.ALT because TIM2_CH3 can be a capture input or pulse output. Signed-off-by: Chris Mason <c.mason@inchipdesign.com.au>
1 parent e168d47 commit 33ea400

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

docs/library/pyb.Pin.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ Methods
9797
- ``Pin.IN`` - configure the pin for input;
9898
- ``Pin.OUT_PP`` - configure the pin for output, with push-pull control;
9999
- ``Pin.OUT_OD`` - configure the pin for output, with open-drain control;
100+
- ``Pin.ALT`` - configure the pin for alternate function, input or output;
100101
- ``Pin.AF_PP`` - configure the pin for alternate function, push-pull;
101102
- ``Pin.AF_OD`` - configure the pin for alternate function, open-drain;
102103
- ``Pin.ANALOG`` - configure the pin for analog.
@@ -113,8 +114,8 @@ Methods
113114

114115
- *value* if not None will set the port output value before enabling the pin.
115116

116-
- *alt* can be used when mode is ``Pin.AF_PP`` or ``Pin.AF_OD`` to set the
117-
index or name of one of the alternate functions associated with a pin.
117+
- *alt* can be used when mode is ``Pin.ALT`` , ``Pin.AF_PP`` or ``Pin.AF_OD`` to
118+
set the index or name of one of the alternate functions associated with a pin.
118119
This arg was previously called *af* which can still be used if needed.
119120

120121
Returns: ``None``.
@@ -177,6 +178,10 @@ Methods
177178
Constants
178179
---------
179180

181+
.. data:: Pin.ALT
182+
183+
initialise the pin to alternate-function mode for input or output
184+
180185
.. data:: Pin.AF_OD
181186

182187
initialise the pin to alternate-function mode with an open-drain drive
@@ -237,11 +242,11 @@ control is desired.
237242

238243
To configure X3 to expose TIM2_CH3, you could use::
239244

240-
pin = pyb.Pin(pyb.Pin.board.X3, mode=pyb.Pin.AF_PP, alt=pyb.Pin.AF1_TIM2)
245+
pin = pyb.Pin(pyb.Pin.board.X3, mode=pyb.Pin.ALT, alt=pyb.Pin.AF1_TIM2)
241246

242247
or::
243248

244-
pin = pyb.Pin(pyb.Pin.board.X3, mode=pyb.Pin.AF_PP, alt=1)
249+
pin = pyb.Pin(pyb.Pin.board.X3, mode=pyb.Pin.ALT, alt=1)
245250

246251
Methods
247252
-------

0 commit comments

Comments
 (0)