diff options
author | Chris Webb <chris@arachsys.com> | 2025-06-16 12:35:51 +0100 |
---|---|---|
committer | Chris Webb <chris@arachsys.com> | 2025-06-16 12:35:51 +0100 |
commit | 8f85edad8601c87a107b51a1b417600fbb8d8087 (patch) | |
tree | 169125541b88aaf5330d723e3a9b99dc9a722fcd /tests | |
parent | 7816b1f5134b24d5c352af679d398a491a427edd (diff) |
tests/ports/rp2: Add tests for rp2-specific timer options.
Add tests for both one-shot and periodic timers using the rp2-specific
tick_hz= and hard= parameters.
Signed-off-by: Chris Webb <chris@arachsys.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ports/rp2/rp2_machine_timer.py | 20 | ||||
-rw-r--r-- | tests/ports/rp2/rp2_machine_timer.py.exp | 16 |
2 files changed, 36 insertions, 0 deletions
diff --git a/tests/ports/rp2/rp2_machine_timer.py b/tests/ports/rp2/rp2_machine_timer.py new file mode 100644 index 000000000..ac4efcf7f --- /dev/null +++ b/tests/ports/rp2/rp2_machine_timer.py @@ -0,0 +1,20 @@ +from machine import Timer +from time import sleep_ms + +# Test the rp2-specific adjustable tick_hz and hard/soft IRQ handlers +# for both one-shot and periodic timers. + +modes = {Timer.ONE_SHOT: "one-shot", Timer.PERIODIC: "periodic"} +kinds = {False: "soft", True: "hard"} + +for mode in modes: + for hard in kinds: + for period in 2, 4: + timer = Timer( + mode=mode, + period=period, + hard=hard, + callback=lambda t: print("callback", modes[mode], kinds[hard], period), + ) + sleep_ms(9) + timer.deinit() diff --git a/tests/ports/rp2/rp2_machine_timer.py.exp b/tests/ports/rp2/rp2_machine_timer.py.exp new file mode 100644 index 000000000..b3dd93dfa --- /dev/null +++ b/tests/ports/rp2/rp2_machine_timer.py.exp @@ -0,0 +1,16 @@ +callback one-shot soft 2 +callback one-shot soft 4 +callback one-shot hard 2 +callback one-shot hard 4 +callback periodic soft 2 +callback periodic soft 2 +callback periodic soft 2 +callback periodic soft 2 +callback periodic soft 4 +callback periodic soft 4 +callback periodic hard 2 +callback periodic hard 2 +callback periodic hard 2 +callback periodic hard 2 +callback periodic hard 4 +callback periodic hard 4 |