From 7f6345a9734f5772b2b579d2ac915cdeb1fcbed1 Mon Sep 17 00:00:00 2001 From: LiaoJingyi_winY7kp <924765359@qq.com> Date: Sun, 23 Oct 2022 20:47:14 +0300 Subject: [PATCH] docs/library/machine.Timer: Add freq argument to machine.Timer. Based on and tested on the rp2 port. Signed-off-by: Liao Jingyi Signed-off-by: Damien George --- docs/library/machine.Timer.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/library/machine.Timer.rst b/docs/library/machine.Timer.rst index 424a49bcba..48c023a11c 100644 --- a/docs/library/machine.Timer.rst +++ b/docs/library/machine.Timer.rst @@ -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.