make "set mode 0" mean reset to bootloader

This commit is contained in:
xenia 2021-07-25 18:21:02 -04:00 committed by sys64738
parent 28b3e29ef2
commit 1e0b016c0a
2 changed files with 10 additions and 2 deletions

View File

@ -28,6 +28,8 @@
#ifndef BOARD_H_MOD
#define BOARD_H_MOD
#include <pico/bootrom.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -48,6 +50,9 @@ extern "C" {
#define UART_RX_PIN PICO_DEFAULT_UART_RX_PIN
#endif
// Reset to bootloader
#define bsp_reset_bootloader() reset_usb_boot(0, 0)
#ifdef __cplusplus
}
#endif

View File

@ -5,10 +5,10 @@
#include <string.h>
#include <tusb.h>
#include "board.h"
#include "info.h"
#include "mode.h"
#include "vnd_cfg.h"
#include "thread.h"
#if CFG_TUD_VENDOR > 0
@ -175,7 +175,10 @@ void vnd_cfg_task(void) {
break;
case cfg_cmd_set_cur_mode:
verbuf[0] = vnd_cfg_read_byte();
if (verbuf[0] == 0 || verbuf[0] >= 0x10 || mode_list[verbuf[0]] == NULL) {
if (verbuf[0] == 0) {
// reset
bsp_reset_bootloader();
} else if (verbuf[0] >= 0x10 || mode_list[verbuf[0]] == NULL) {
vnd_cfg_write_resp(cfg_resp_nosuchmode, 0, NULL);
} else {
// will be handled later so the USB stack won't break, whcih might happen if reconfig would happen now