add watchdog
This commit is contained in:
+1
-1
@@ -96,7 +96,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC
|
|||||||
target_link_libraries(ds5-bridge
|
target_link_libraries(ds5-bridge
|
||||||
pico_stdlib
|
pico_stdlib
|
||||||
pico_multicore
|
pico_multicore
|
||||||
hardware_interp
|
hardware_watchdog
|
||||||
hardware_timer
|
hardware_timer
|
||||||
pico_btstack_classic
|
pico_btstack_classic
|
||||||
# pico_cyw43_arch_threadsafe_background
|
# pico_cyw43_arch_threadsafe_background
|
||||||
|
|||||||
@@ -81,11 +81,6 @@ void bt_l2cap_init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int bt_init() {
|
int bt_init() {
|
||||||
if (cyw43_arch_init()) {
|
|
||||||
printf("Failed to initialize CYW43\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
critical_section_init(&queue_lock);
|
critical_section_init(&queue_lock);
|
||||||
|
|
||||||
bt_l2cap_init();
|
bt_l2cap_init();
|
||||||
|
|||||||
+27
-4
@@ -10,6 +10,7 @@
|
|||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "hardware/clocks.h"
|
#include "hardware/clocks.h"
|
||||||
#include "hardware/vreg.h"
|
#include "hardware/vreg.h"
|
||||||
|
#include "hardware/watchdog.h"
|
||||||
#include "pico/cyw43_arch.h"
|
#include "pico/cyw43_arch.h"
|
||||||
|
|
||||||
int reportSeqCounter = 0;
|
int reportSeqCounter = 0;
|
||||||
@@ -99,24 +100,46 @@ int main() {
|
|||||||
vreg_set_voltage(VREG_VOLTAGE_1_20);
|
vreg_set_voltage(VREG_VOLTAGE_1_20);
|
||||||
sleep_ms(1000);
|
sleep_ms(1000);
|
||||||
set_sys_clock_khz(320000, true);
|
set_sys_clock_khz(320000, true);
|
||||||
board_init();
|
|
||||||
|
|
||||||
|
board_init();
|
||||||
tusb_rhport_init_t dev_init = {
|
tusb_rhport_init_t dev_init = {
|
||||||
.role = TUSB_ROLE_DEVICE,
|
.role = TUSB_ROLE_DEVICE,
|
||||||
.speed = TUSB_SPEED_AUTO
|
.speed = TUSB_SPEED_FULL
|
||||||
};
|
};
|
||||||
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
tusb_init(BOARD_TUD_RHPORT, &dev_init);
|
||||||
|
|
||||||
tud_disconnect();
|
tud_disconnect();
|
||||||
|
|
||||||
board_init_after_tusb();
|
board_init_after_tusb();
|
||||||
|
|
||||||
|
if (cyw43_arch_init()) {
|
||||||
|
printf("Failed to initialize CYW43\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, false);
|
||||||
|
|
||||||
|
if (watchdog_caused_reboot()) {
|
||||||
|
printf("Rebooted by Watchdog!\n");
|
||||||
|
// 当崩溃重启以后,闪三下灯
|
||||||
|
for (int i = 0;i < 6;i++) {
|
||||||
|
if (i % 2 == 0) {
|
||||||
|
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, true);
|
||||||
|
}else {
|
||||||
|
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, false);
|
||||||
|
}
|
||||||
|
sleep_ms(500);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("Clean boot\n");
|
||||||
|
}
|
||||||
|
|
||||||
bt_init();
|
bt_init();
|
||||||
bt_register_data_callback(on_bt_data);
|
bt_register_data_callback(on_bt_data);
|
||||||
|
|
||||||
audio_init();
|
audio_init();
|
||||||
|
|
||||||
|
watchdog_enable(1000, true);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
watchdog_update();
|
||||||
cyw43_arch_poll();
|
cyw43_arch_poll();
|
||||||
tud_task();
|
tud_task();
|
||||||
audio_loop();
|
audio_loop();
|
||||||
|
|||||||
Reference in New Issue
Block a user