Loading...
Searching...
No Matches
usb_reset_config.h
1/*
2 * Copyright (c) 2025 Raspberry Pi (Trading) Ltd.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef _PICO_USB_RESET_CONFIG_H
8#define _PICO_USB_RESET_CONFIG_H
9
10// PICO_CONFIG: PICO_ENABLE_USB_RESET_VIA_BAUD_RATE, Enable/disable resetting into BOOTSEL mode if the host sets the baud rate to a magic value (PICO_USB_RESET_MAGIC_BAUD_RATE), type=bool, default=1 if application is not using TinyUSB directly, group=pico_usb_reset
11#ifndef PICO_ENABLE_USB_RESET_VIA_BAUD_RATE
12#ifdef PICO_STDIO_USB_ENABLE_RESET_VIA_BAUD_RATE // backwards compatibility with SDK <= 2.2.0
13#define PICO_ENABLE_USB_RESET_VIA_BAUD_RATE PICO_STDIO_USB_ENABLE_RESET_VIA_BAUD_RATE
14#elif !LIB_TINYUSB_HOST && !LIB_TINYUSB_DEVICE
15#define PICO_ENABLE_USB_RESET_VIA_BAUD_RATE 1
16#else
17#define PICO_ENABLE_USB_RESET_VIA_BAUD_RATE 0
18#endif
19#endif
20
21// PICO_CONFIG: PICO_USB_RESET_MAGIC_BAUD_RATE, Baud rate that if selected causes a reset into BOOTSEL mode (if PICO_ENABLE_USB_RESET_VIA_BAUD_RATE is set), default=1200, group=pico_usb_reset
22#ifndef PICO_USB_RESET_MAGIC_BAUD_RATE
23#ifdef PICO_STDIO_USB_RESET_MAGIC_BAUD_RATE // backwards compatibility with SDK <= 2.2.0
24#define PICO_USB_RESET_MAGIC_BAUD_RATE PICO_STDIO_USB_RESET_MAGIC_BAUD_RATE
25#else
26#define PICO_USB_RESET_MAGIC_BAUD_RATE 1200
27#endif
28#endif
29
30// PICO_CONFIG: PICO_ENABLE_USB_RESET_VIA_VENDOR_INTERFACE, Enable/disable resetting into BOOTSEL mode via an additional VENDOR USB interface - enables picotool based reset, type=bool, default=1 if application is not using TinyUSB directly, group=pico_usb_reset
31#ifndef PICO_ENABLE_USB_RESET_VIA_VENDOR_INTERFACE
32#ifdef PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE // backwards compatibility with SDK <= 2.2.0
33#define PICO_ENABLE_USB_RESET_VIA_VENDOR_INTERFACE PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE
34#elif !LIB_TINYUSB_HOST && !LIB_TINYUSB_DEVICE
35#define PICO_ENABLE_USB_RESET_VIA_VENDOR_INTERFACE 1
36#else
37#define PICO_ENABLE_USB_RESET_VIA_VENDOR_INTERFACE 0
38#endif
39#endif
40
41// PICO_CONFIG: PICO_USB_RESET_SUPPORT_MS_OS_20_DESCRIPTOR, If vendor reset interface is included add support for Microsoft OS 2.0 Descriptor, type=bool, default=1 if application is not using TinyUSB directly, 0 otherwise, group=pico_usb_reset
42#ifndef PICO_USB_RESET_SUPPORT_MS_OS_20_DESCRIPTOR
43#ifdef PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR // backwards compatibility with SDK <= 2.2.0
44#define PICO_USB_RESET_SUPPORT_MS_OS_20_DESCRIPTOR PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR
45#elif !LIB_TINYUSB_HOST && !LIB_TINYUSB_DEVICE
46#define PICO_USB_RESET_SUPPORT_MS_OS_20_DESCRIPTOR 1
47#else
48#define PICO_USB_RESET_SUPPORT_MS_OS_20_DESCRIPTOR 0
49#endif
50#endif
51
52// PICO_CONFIG: PICO_USB_RESET_MS_OS_20_DESCRIPTOR_ITF, If vendor reset interface is included this specifies the USB interface number for the reset interface, type=int, default=2 if application is not using TinyUSB directly, undefined otherwise, group=pico_usb_reset
53#ifndef PICO_USB_RESET_MS_OS_20_DESCRIPTOR_ITF
54#if !LIB_TINYUSB_HOST && !LIB_TINYUSB_DEVICE
55#define PICO_USB_RESET_MS_OS_20_DESCRIPTOR_ITF 2
56#elif PICO_USB_RESET_SUPPORT_MS_OS_20_DESCRIPTOR
57#error Must set PICO_USB_RESET_MS_OS_20_DESCRIPTOR_ITF to the reset interface number when using PICO_USB_RESET_SUPPORT_MS_OS_20_DESCRIPTOR with custom USB descriptors
58#endif
59#endif
60
61// PICO_CONFIG: PICO_USB_RESET_INCLUDE_DEFAULT_APP_DRIVER_CB, Set to 0 if your application defines its own usbd_app_driver_get_cb function, type=bool, default=1 when using pico_stdio_usb, 0 otherwise, group=pico_usb_reset
62#ifndef PICO_USB_RESET_INCLUDE_DEFAULT_APP_DRIVER_CB
63#define PICO_USB_RESET_INCLUDE_DEFAULT_APP_DRIVER_CB LIB_PICO_STDIO_USB
64#endif
65
66// PICO_CONFIG: PICO_USB_RESET_SUPPORT_RESET_TO_BOOTSEL, If vendor reset interface is included allow rebooting to BOOTSEL mode, type=bool, default=1, group=pico_usb_reset
67#ifndef PICO_USB_RESET_SUPPORT_RESET_TO_BOOTSEL
68#ifdef PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_BOOTSEL // backwards compatibility with SDK <= 2.2.0
69#define PICO_USB_RESET_SUPPORT_RESET_TO_BOOTSEL PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_BOOTSEL
70#else
71#define PICO_USB_RESET_SUPPORT_RESET_TO_BOOTSEL 1
72#endif
73#endif
74
75// PICO_CONFIG: PICO_USB_RESET_BOOTSEL_ACTIVITY_LED, Optionally define a pin to use as bootloader activity LED when BOOTSEL mode is entered via USB (either VIA_BAUD_RATE or VIA_VENDOR_INTERFACE), type=int, min=0, max=47 on RP2350B, 29 otherwise, group=pico_usb_reset
76#ifdef PICO_STDIO_USB_RESET_BOOTSEL_ACTIVITY_LED // backwards compatibility with SDK <= 2.2.0
77#define PICO_USB_RESET_BOOTSEL_ACTIVITY_LED PICO_STDIO_USB_RESET_BOOTSEL_ACTIVITY_LED
78#endif // default is undefined
79
80// PICO_CONFIG: PICO_USB_RESET_BOOTSEL_ACTIVITY_LED_ACTIVE_LOW, Whether pin to use as bootloader activity LED when BOOTSEL mode is entered via USB (either VIA_BAUD_RATE or VIA_VENDOR_INTERFACE) is active low (ignored on RP2040), type=bool, default=0, group=pico_usb_reset
81#ifndef PICO_USB_RESET_BOOTSEL_ACTIVITY_LED_ACTIVE_LOW
82#ifdef PICO_STDIO_USB_RESET_BOOTSEL_ACTIVITY_LED_ACTIVE_LOW // backwards compatibility with SDK <= 2.2.0
83#define PICO_USB_RESET_BOOTSEL_ACTIVITY_LED_ACTIVE_LOW PICO_STDIO_USB_RESET_BOOTSEL_ACTIVITY_LED_ACTIVE_LOW
84#else
85#define PICO_USB_RESET_BOOTSEL_ACTIVITY_LED_ACTIVE_LOW 0
86#endif
87#endif
88
89// PICO_CONFIG: PICO_USB_RESET_BOOTSEL_FIXED_ACTIVITY_LED, Whether the pin specified by PICO_USB_RESET_BOOTSEL_ACTIVITY_LED is fixed or can be modified by picotool over the VENDOR USB interface, type=bool, default=0, group=pico_usb_reset
90#ifndef PICO_USB_RESET_BOOTSEL_FIXED_ACTIVITY_LED
91#ifdef PICO_STDIO_USB_RESET_BOOTSEL_FIXED_ACTIVITY_LED // backwards compatibility with SDK <= 2.2.0
92#define PICO_USB_RESET_BOOTSEL_FIXED_ACTIVITY_LED PICO_STDIO_USB_RESET_BOOTSEL_FIXED_ACTIVITY_LED
93#else
94#define PICO_USB_RESET_BOOTSEL_FIXED_ACTIVITY_LED 0
95#endif
96#endif
97
98// Any modes disabled here can't be re-enabled by picotool via VENDOR_INTERFACE.
99// PICO_CONFIG: PICO_USB_RESET_BOOTSEL_INTERFACE_DISABLE_MASK, Optionally disable either the mass storage interface (bit 0) or the PICOBOOT interface (bit 1) when entering BOOTSEL mode via USB (either VIA_BAUD_RATE or VIA_VENDOR_INTERFACE), type=int, min=0, max=3, default=0, group=pico_usb_reset
100#ifndef PICO_USB_RESET_BOOTSEL_INTERFACE_DISABLE_MASK
101#ifdef PICO_STDIO_USB_RESET_BOOTSEL_INTERFACE_DISABLE_MASK // backwards compatibility with SDK <= 2.2.0
102#define PICO_USB_RESET_BOOTSEL_INTERFACE_DISABLE_MASK PICO_STDIO_USB_RESET_BOOTSEL_INTERFACE_DISABLE_MASK
103#else
104#define PICO_USB_RESET_BOOTSEL_INTERFACE_DISABLE_MASK 0u
105#endif
106#endif
107
108// PICO_CONFIG: PICO_USB_RESET_SUPPORT_RESET_TO_FLASH_BOOT, If vendor reset interface is included allow rebooting with regular flash boot, type=bool, default=1, group=pico_usb_reset
109#ifndef PICO_USB_RESET_SUPPORT_RESET_TO_FLASH_BOOT
110#ifdef PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_FLASH_BOOT // backwards compatibility with SDK <= 2.2.0
111#define PICO_USB_RESET_SUPPORT_RESET_TO_FLASH_BOOT PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_FLASH_BOOT
112#else
113#define PICO_USB_RESET_SUPPORT_RESET_TO_FLASH_BOOT 1
114#endif
115#endif
116
117// PICO_CONFIG: PICO_USB_RESET_RESET_TO_FLASH_DELAY_MS, Delay in ms before rebooting via regular flash boot, default=100, group=pico_usb_reset
118#ifndef PICO_USB_RESET_RESET_TO_FLASH_DELAY_MS
119#ifdef PICO_STDIO_USB_RESET_RESET_TO_FLASH_DELAY_MS // backwards compatibility with SDK <= 2.2.0
120#define PICO_USB_RESET_RESET_TO_FLASH_DELAY_MS PICO_STDIO_USB_RESET_RESET_TO_FLASH_DELAY_MS
121#else
122#define PICO_USB_RESET_RESET_TO_FLASH_DELAY_MS 100
123#endif
124#endif
125
126#endif