Skip to content

Commit b385288

Browse files
committed
pbio/drv/usb_stm32: Simplify event loop and use pbio/os.
BCD and data handling happen separately, so we can have them chronologically in the process thread. Also fix a revisit note for not needing a timer to resend the status. Since we recently introduced status scheduling by the host module, we can just re-schedule the latest on subscribing. Also introduce shutting down via pbdrv_deinit rather than polling statuses from pbsys.
1 parent 76893f6 commit b385288

File tree

3 files changed

+189
-180
lines changed

3 files changed

+189
-180
lines changed

lib/pbio/drv/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ void pbdrv_deinit(void) {
9090
pbdrv_imu_deinit();
9191
pbdrv_bluetooth_deinit();
9292
pbdrv_button_deinit();
93+
pbdrv_usb_deinit();
9394

9495
while (pbio_busy_count_busy()) {
9596
pbio_os_run_processes_and_wait_for_event();

lib/pbio/drv/usb/usb.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,19 @@
1111
#if PBDRV_CONFIG_USB
1212

1313
/**
14-
* Initializes the USB driver.
14+
* Initializes the USB driver on boot.
1515
*/
1616
void pbdrv_usb_init(void);
1717

18+
/**
19+
* De-initializes the USB driver for data transfers on soft-poweroff. Keeps charging if supported.
20+
*/
21+
void pbdrv_usb_deinit(void);
22+
1823
#else // PBDRV_CONFIG_USB
1924

2025
#define pbdrv_usb_init()
26+
#define pbdrv_usb_deinit()
2127

2228
#endif // PBDRV_CONFIG_USB
2329

0 commit comments

Comments
 (0)