@@ -18,8 +18,9 @@ Timer callbacks.
1818
1919 Memory can't be allocated inside irq handlers (an interrupt) and so
2020 exceptions raised within a handler don't give much information. See
21- :func: `micropython.alloc_emergency_exception_buf ` for how to get around this
22- limitation.
21+ :func: `micropython.alloc_emergency_exception_buf ` for how to get around
22+ this limitation, which applies to all callbacks of Timers created with
23+ ``hard=True ``.
2324
2425If you are using a WiPy board please refer to :ref: `machine.TimerWiPy <machine.TimerWiPy >`
2526instead of this class.
@@ -38,7 +39,7 @@ Constructors
3839Methods
3940-------
4041
41- .. method :: Timer.init(*, mode=Timer.PERIODIC, freq=-1, period=-1, callback=None)
42+ .. method :: Timer.init(*, mode=Timer.PERIODIC, freq=-1, period=-1, callback=None, hard=True )
4243
4344 Initialise the timer. Example::
4445
@@ -76,6 +77,19 @@ Methods
7677 will occur upon timer expiration:
7778 ``TypeError: 'NoneType' object isn't callable ``
7879
80+ - ``hard `` can be one of:
81+
82+ - ``True `` - The callback will be executed in hard interrupt
83+ context, which minimises delay and jitter but is subject to the
84+ limitations described in :ref: `isr_rules ` including being unable
85+ to allocate on the heap.
86+ - ``False `` - The callback will be scheduled as a soft interrupt,
87+ allowing it to allocate but possibly also introducing
88+ garbage-collection delays and jitter.
89+
90+ The default value of this option is port-specific for historical
91+ reasons.
92+
7993.. method :: Timer.deinit()
8094
8195 Deinitialises the timer. Stops the timer, and disables the timer peripheral.
0 commit comments