From 2e9159cb57e929d11a170e1d0a13eb6baabb6ec7 Mon Sep 17 00:00:00 2001 From: kenji Date: Tue, 9 Sep 2025 15:05:45 -0400 Subject: [PATCH] Fix preserve pairing on power cycle --- bt_device.c | 2 -- main.c | 5 ++++- usb_host.c | 2 +- usb_host.h | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bt_device.c b/bt_device.c index 68c28d3..24a283c 100644 --- a/bt_device.c +++ b/bt_device.c @@ -51,8 +51,6 @@ void btstack_main(void){ bt_hid_setup(); init_report_buf(); - - hci_power_control(HCI_POWER_ON); } static void bt_hid_setup(void) { diff --git a/main.c b/main.c index 69ab91d..83ff115 100644 --- a/main.c +++ b/main.c @@ -16,9 +16,12 @@ static void usb_main(void); // main loop int main(void) { - + // for PIO USB, we want clock speed to be multiple of 12MHz set_sys_clock_khz(144000, true); + // need so BTstack can save pairing information to flash + flash_safe_execute_core_init(); + sleep_ms(10); // run BLE on core 1 diff --git a/usb_host.c b/usb_host.c index 53ed36e..7701eb5 100644 --- a/usb_host.c +++ b/usb_host.c @@ -18,7 +18,7 @@ host_state_t host_state; static absolute_time_t request_time; static absolute_time_t last_report; -static uint16_t host_poll_interval=8000; +static uint16_t host_poll_interval=HOST_POLL_INTERVAL; // initialize usb host void usb_host_init(void) { diff --git a/usb_host.h b/usb_host.h index 7238766..2a6f5c5 100644 --- a/usb_host.h +++ b/usb_host.h @@ -1,7 +1,7 @@ #ifndef USB_HOST_H_ #define USB_HOST_H_ -#define HOST_POLL_INTERVAL 25000 +#define HOST_POLL_INTERVAL 8000 typedef enum { HOST_INACTIVE=0,