File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -133,10 +133,14 @@ void mp_hal_delay_us(mp_uint_t us) {
133133
134134void mp_hal_delay_ms (mp_uint_t ms ) {
135135 uint32_t t0 = mp_hal_ticks_ms ();
136- do {
137- // TODO: power saving wait
138- mp_event_handle_nowait ();
139- } while (mp_hal_ticks_ms () - t0 < ms );
136+ mp_event_handle_nowait ();
137+ for (;;) {
138+ uint32_t t1 = mp_hal_ticks_ms ();
139+ if (t1 - t0 >= ms ) {
140+ break ;
141+ }
142+ mp_event_wait_ms (ms - (t1 - t0 ));
143+ }
140144}
141145
142146uint64_t mp_hal_time_ns (void ) {
Original file line number Diff line number Diff line change 2727#include "py/ringbuf.h"
2828#include "shared/runtime/interrupt_char.h"
2929#include "irq.h"
30+ #include "system_tick.h"
3031#include ALIF_CMSIS_H
3132
3233#define MICROPY_BEGIN_ATOMIC_SECTION () disable_irq()
4748 if ((TIMEOUT_MS) < 0) { \
4849 __WFE(); \
4950 } else { \
50- /* TODO */ \
51- __WFE (); \
51+ system_tick_wfe_with_timeout_us(TIMEOUT_MS * 1000); \
5252 } \
5353 } while (0)
5454
5757 (SCB_CleanDCache_by_Addr((uint32_t *)((uint32_t)addr & ~0x1f), \
5858 ((uint32_t)((uint8_t *)addr + size + 0x1f) & ~0x1f) - ((uint32_t)addr & ~0x1f)))
5959
60- extern ringbuf_t stdin_ringbuf ;
61-
62- // TODO
63- #define mp_hal_quiet_timing_enter () 0
64- #define mp_hal_quiet_timing_exit (x ) (void)x
60+ #define mp_hal_quiet_timing_enter () raise_irq_pri(IRQ_PRI_QUIET_TIMING)
61+ #define mp_hal_quiet_timing_exit (irq_state ) restore_irq_pri(irq_state)
6562#define mp_hal_delay_us_fast mp_hal_delay_us
6663
64+ extern ringbuf_t stdin_ringbuf ;
65+
6766/******************************************************************************/
6867// C-level pin HAL
6968
You can’t perform that action at this time.
0 commit comments