Skip to content

Commit 1cdfa97

Browse files
committed
pbio/drv: Use wait for event in init loops.
We shouldn't be enforcing tight loops here. If drivers rely on it, they should request polling. This makes event handling the same everywhere. Only MicroPython is allowed to drive pbio without waiting for events.
1 parent 6940986 commit 1cdfa97

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/pbio/drv/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void pbdrv_init(void) {
7676
// Wait for all async pbdrv drivers to initialize before starting
7777
// higher level system processes.
7878
while (pbio_busy_count_busy()) {
79-
pbio_os_run_processes_once();
79+
pbio_os_run_processes_and_wait_for_event();
8080
}
8181

8282
pbdrv_ioport_enable_vcc(true);
@@ -91,7 +91,7 @@ void pbdrv_deinit(void) {
9191
pbdrv_bluetooth_deinit();
9292

9393
while (pbio_busy_count_busy()) {
94-
pbio_os_run_processes_once();
94+
pbio_os_run_processes_and_wait_for_event();
9595
}
9696

9797
}

lib/pbio/sys/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void pbsys_init(void) {
7878
pbio_os_process_start(&pbsys_system_poll_process, pbsys_system_poll_process_thread, NULL);
7979

8080
while (pbio_busy_count_busy()) {
81-
pbio_os_run_processes_once();
81+
pbio_os_run_processes_and_wait_for_event();
8282
}
8383
}
8484

@@ -94,6 +94,6 @@ void pbsys_deinit(void) {
9494
// Wait for all relevant pbsys processes to end, but at least 500 ms so we
9595
// see a shutdown animation even if the button is released sooner.
9696
while (pbio_busy_count_busy() || pbdrv_clock_get_ms() - start < 500) {
97-
pbio_os_run_processes_once();
97+
pbio_os_run_processes_and_wait_for_event();
9898
}
9999
}

0 commit comments

Comments
 (0)