Skip to content

Commit 73fac84

Browse files
committed
pbio/sys/main: Wait with WFI.
Idling with WFI was previously implemented in the MicroPython HAL. Now that we moved it to pbio/os in a platform agnostic way, we can fix this longstanding open REVISIT note.
1 parent 8d974be commit 73fac84

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/pbio/sys/main.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <pbdrv/reset.h>
1111
#include <pbdrv/usb.h>
1212
#include <pbio/main.h>
13+
#include <pbio/os.h>
1314
#include <pbio/port_interface.h>
1415
#include <pbio/protocol.h>
1516
#include <pbsys/core.h>
@@ -93,10 +94,8 @@ int main(int argc, char **argv) {
9394
pbsys_main_program_request_start(PBIO_PYBRICKS_USER_PROGRAM_ID_REPL, PBSYS_MAIN_PROGRAM_START_REQUEST_TYPE_BOOT);
9495
#endif
9596

96-
// REVISIT: this can be long waiting, so we could do a more efficient
97-
// wait (i.e. __WFI() on embedded system)
98-
while (pbio_do_one_event()) {
99-
}
97+
// Drives all processes while we wait for user input.
98+
pbio_os_run_while_idle();
10099

101100
if (!pbsys_main_program_start_requested()) {
102101
continue;
@@ -109,7 +108,7 @@ int main(int argc, char **argv) {
109108

110109
// Handle pending events triggered by the status change, such as
111110
// starting status light animation.
112-
while (pbio_do_one_event()) {
111+
while (pbio_os_run_processes_once()) {
113112
}
114113

115114
// Run the main application.

0 commit comments

Comments
 (0)