Skip to content

Commit 8f85eda

Browse files
committed
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>
1 parent 7816b1f commit 8f85eda

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

tests/ports/rp2/rp2_machine_timer.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from machine import Timer
2+
from time import sleep_ms
3+
4+
# Test the rp2-specific adjustable tick_hz and hard/soft IRQ handlers
5+
# for both one-shot and periodic timers.
6+
7+
modes = {Timer.ONE_SHOT: "one-shot", Timer.PERIODIC: "periodic"}
8+
kinds = {False: "soft", True: "hard"}
9+
10+
for mode in modes:
11+
for hard in kinds:
12+
for period in 2, 4:
13+
timer = Timer(
14+
mode=mode,
15+
period=period,
16+
hard=hard,
17+
callback=lambda t: print("callback", modes[mode], kinds[hard], period),
18+
)
19+
sleep_ms(9)
20+
timer.deinit()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
callback one-shot soft 2
2+
callback one-shot soft 4
3+
callback one-shot hard 2
4+
callback one-shot hard 4
5+
callback periodic soft 2
6+
callback periodic soft 2
7+
callback periodic soft 2
8+
callback periodic soft 2
9+
callback periodic soft 4
10+
callback periodic soft 4
11+
callback periodic hard 2
12+
callback periodic hard 2
13+
callback periodic hard 2
14+
callback periodic hard 2
15+
callback periodic hard 4
16+
callback periodic hard 4

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy