diff options
Diffstat (limited to 'tests/ports/stm32/timer_callback.py')
-rw-r--r-- | tests/ports/stm32/timer_callback.py | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/tests/ports/stm32/timer_callback.py b/tests/ports/stm32/timer_callback.py index 5f170ccde1..4add88ec6a 100644 --- a/tests/ports/stm32/timer_callback.py +++ b/tests/ports/stm32/timer_callback.py @@ -1,8 +1,14 @@ # check callback feature of the timer class -import pyb +import sys +import time from pyb import Timer +if "STM32WB" in sys.implementation._machine: + tim_extra_id = 16 +else: + tim_extra_id = 4 + # callback function that disables the callback when called def cb1(t): @@ -29,27 +35,27 @@ def cb3(x): # create a timer with a callback, using callback(None) to stop tim = Timer(1, freq=100, callback=cb1) -pyb.delay(5) +time.sleep_ms(5) print("before cb1") -pyb.delay(15) +time.sleep_ms(15) # create a timer with a callback, using deinit to stop tim = Timer(2, freq=100, callback=cb2) -pyb.delay(5) +time.sleep_ms(5) print("before cb2") -pyb.delay(15) +time.sleep_ms(15) # create a timer, then set the freq, then set the callback -tim = Timer(4) +tim = Timer(tim_extra_id) tim.init(freq=100) tim.callback(cb1) -pyb.delay(5) +time.sleep_ms(5) print("before cb1") -pyb.delay(15) +time.sleep_ms(15) # test callback with a closure tim.init(freq=100) tim.callback(cb3(3)) -pyb.delay(5) +time.sleep_ms(5) print("before cb4") -pyb.delay(15) +time.sleep_ms(15) |