summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorrobert-hh <robert@hammelrath.com>2024-08-17 17:07:44 +0200
committerDamien George <damien@micropython.org>2024-09-06 17:43:49 +1000
commit1a6279ba37678893db9f2756fceaa5c817cae888 (patch)
tree3371cb97fdb96f9d1c543f0cc1cdf79e4e2c2479
parented86fdbdf6e2d3eb9a118d3476ce4c370ec48b06 (diff)
downloadmicropython-1a6279ba37678893db9f2756fceaa5c817cae888.tar.gz
micropython-1a6279ba37678893db9f2756fceaa5c817cae888.zip
samd/mphalport: Simplify mp_hal_delay_ms().
Do NOT use `mp_hal_delay_us()` for short delays. This was initially done to make short delays precise, but it does not allow for scheduling. Leave using `mp_hal_delay_us()` to user code if needed. Signed-off-by: robert-hh <robert@hammelrath.com>
-rw-r--r--docs/samd/quickref.rst2
-rw-r--r--ports/samd/mphalport.c10
2 files changed, 5 insertions, 7 deletions
diff --git a/docs/samd/quickref.rst b/docs/samd/quickref.rst
index 60c57b3a47..25b5a8fc8a 100644
--- a/docs/samd/quickref.rst
+++ b/docs/samd/quickref.rst
@@ -65,6 +65,8 @@ Use the :mod:`time <time>` module::
start = time.ticks_ms() # get millisecond counter
delta = time.ticks_diff(time.ticks_ms(), start) # compute time difference
+Note that :func:`time.sleep_us()` delays by busy waiting. During that time, other tasks are
+not scheduled.
Clock and time
--------------
diff --git a/ports/samd/mphalport.c b/ports/samd/mphalport.c
index 3a33fdd6b5..84d05b9185 100644
--- a/ports/samd/mphalport.c
+++ b/ports/samd/mphalport.c
@@ -69,13 +69,9 @@ void mp_hal_clr_pin_mux(mp_hal_pin_obj_t pin) {
}
void mp_hal_delay_ms(mp_uint_t ms) {
- if (ms > 10) {
- uint32_t t0 = systick_ms;
- while (systick_ms - t0 < ms) {
- MICROPY_EVENT_POLL_HOOK
- }
- } else {
- mp_hal_delay_us(ms * 1000);
+ uint32_t t0 = systick_ms;
+ while (systick_ms - t0 < ms) {
+ MICROPY_EVENT_POLL_HOOK
}
}