docs/library/machine.Timer: Add freq argument to machine.Timer.

Based on and tested on the rp2 port.

Signed-off-by: Liao Jingyi <liaojingyi2@gmail>
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
LiaoJingyi_winY7kp 2022-10-23 20:47:14 +03:00 committed by Damien George
parent 720f2cfba9
commit 7f6345a973

View File

@ -38,13 +38,16 @@ Constructors
Methods
-------
.. method:: Timer.init(*, mode=Timer.PERIODIC, period=-1, callback=None)
.. method:: Timer.init(*, mode=Timer.PERIODIC, freq=-1, period=-1, callback=None)
Initialise the timer. Example::
def mycallback(t):
pass
# periodic at 1kHz
tim.init(mode=Timer.PERIODIC, freq=1000, callback=mycallback)
# periodic with 100ms period
tim.init(period=100, callback=mycallback)
@ -60,6 +63,11 @@ Methods
- ``Timer.PERIODIC`` - The timer runs periodically at the configured
frequency of the channel.
- ``freq`` - The timer frequency, in units of Hz. The upper bound of
the frequency is dependent on the port. When both the ``freq`` and
``period`` arguments are given, ``freq`` has a higher priority and
``period`` is ignored.
- ``period`` - The timer period, in milliseconds.
- ``callback`` - The callable to call upon expiration of the timer period.