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>
This commit is contained in:
parent
ed86fdbdf6
commit
1a6279ba37
@ -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
|
||||
--------------
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user