|
44 | 44 | #if LIB_PICO_USB_RESET_INTERFACE |
45 | 45 | // These defines are only used by the pico_usb_reset_interface library, not the pico_usb_reset_interface_headers library |
46 | 46 |
|
47 | | -// PICO_CONFIG: PICO_STDIO_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_interface |
48 | | - |
49 | | -// PICO_CONFIG: PICO_STDIO_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, type=bool, default=0, group=pico_usb_reset_interface |
50 | | -#ifndef PICO_STDIO_USB_RESET_BOOTSEL_ACTIVITY_LED_ACTIVE_LOW |
51 | | -#define PICO_STDIO_USB_RESET_BOOTSEL_ACTIVITY_LED_ACTIVE_LOW 0 |
52 | | -#endif |
53 | | - |
54 | | -// PICO_CONFIG: PICO_STDIO_USB_RESET_BOOTSEL_FIXED_ACTIVITY_LED, Whether the pin specified by PICO_STDIO_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_interface |
55 | | -#ifndef PICO_STDIO_USB_RESET_BOOTSEL_FIXED_ACTIVITY_LED |
56 | | -#define PICO_STDIO_USB_RESET_BOOTSEL_FIXED_ACTIVITY_LED 0 |
57 | | -#endif |
58 | | - |
59 | | -// Any modes disabled here can't be re-enabled by picotool via VENDOR_INTERFACE. |
60 | | -// PICO_CONFIG: PICO_STDIO_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_interface |
61 | | -#ifndef PICO_STDIO_USB_RESET_BOOTSEL_INTERFACE_DISABLE_MASK |
62 | | -#define PICO_STDIO_USB_RESET_BOOTSEL_INTERFACE_DISABLE_MASK 0u |
63 | | -#endif |
64 | | - |
65 | | -// PICO_CONFIG: PICO_STDIO_USB_ENABLE_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_interface |
66 | | -#ifndef PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE |
67 | | -#if !LIB_TINYUSB_HOST && !LIB_TINYUSB_DEVICE |
68 | | -#define PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE 1 |
69 | | -#else |
70 | | -#define PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE 0 |
71 | | -#endif |
72 | | -#endif |
73 | | - |
74 | | -// PICO_CONFIG: PICO_STDIO_USB_RESET_INCLUDE_APP_DRIVER_CB, Set to 0 if your application defines usbd_app_driver_get_cb, type=bool, default=1 when using pico_usb_reset_interface, 0 otherwise, group=pico_usb_reset_interface |
75 | | -#ifndef PICO_STDIO_USB_RESET_INCLUDE_APP_DRIVER_CB |
76 | | -#define PICO_STDIO_USB_RESET_INCLUDE_APP_DRIVER_CB LIB_PICO_STDIO_USB |
77 | | -#endif |
78 | | - |
79 | | -// PICO_CONFIG: PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_BOOTSEL, If vendor reset interface is included allow rebooting to BOOTSEL mode, type=bool, default=1, group=pico_usb_reset_interface |
80 | | -#ifndef PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_BOOTSEL |
81 | | -#define PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_BOOTSEL 1 |
82 | | -#endif |
83 | | - |
84 | | -// PICO_CONFIG: PICO_STDIO_USB_RESET_INTERFACE_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_interface |
85 | | -#ifndef PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_FLASH_BOOT |
86 | | -#define PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_FLASH_BOOT 1 |
87 | | -#endif |
88 | | - |
89 | | -// PICO_CONFIG: PICO_STDIO_USB_RESET_RESET_TO_FLASH_DELAY_MS, Delay in ms before rebooting via regular flash boot, default=100, group=pico_usb_reset_interface |
90 | | -#ifndef PICO_STDIO_USB_RESET_RESET_TO_FLASH_DELAY_MS |
91 | | -#define PICO_STDIO_USB_RESET_RESET_TO_FLASH_DELAY_MS 100 |
92 | | -#endif |
93 | | - |
94 | | -// PICO_CONFIG: PICO_STDIO_USB_RESET_INTERFACE_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_interface |
95 | | -#ifndef PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR |
96 | | -#if !LIB_TINYUSB_HOST && !LIB_TINYUSB_DEVICE |
97 | | -#define PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR 1 |
98 | | -#else |
99 | | -#define PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR 0 |
100 | | -#endif |
101 | | -#endif |
102 | | - |
103 | | -// PICO_CONFIG: PICO_STDIO_USB_RESET_INTERFACE_MS_OS_20_DESCRIPTOR_ITF, If vendor reset interface is included 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_interface |
104 | | -#ifndef PICO_STDIO_USB_RESET_INTERFACE_MS_OS_20_DESCRIPTOR_ITF |
105 | | -#if !LIB_TINYUSB_HOST && !LIB_TINYUSB_DEVICE |
106 | | -#define PICO_STDIO_USB_RESET_INTERFACE_MS_OS_20_DESCRIPTOR_ITF 2 |
107 | | -#elif PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR |
108 | | -#error Must set PICO_STDIO_USB_RESET_INTERFACE_MS_OS_20_DESCRIPTOR_ITF to the reset interface number when using PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR with custom USB descriptors |
109 | | -#endif |
110 | | -#endif |
111 | | - |
112 | | -// Interface descriptor |
113 | | -#define TUD_RPI_RESET_DESC_LEN 9 |
114 | | -#define TUD_RPI_RESET_DESCRIPTOR(_itfnum, _stridx) \ |
115 | | - /* Interface */\ |
116 | | - TUD_RPI_RESET_DESC_LEN, TUSB_DESC_INTERFACE, _itfnum, 0, 0, TUSB_CLASS_VENDOR_SPECIFIC, RESET_INTERFACE_SUBCLASS, RESET_INTERFACE_PROTOCOL, _stridx |
117 | | - |
118 | | - |
119 | | -// Microsoft OS 2.0 Descriptor |
120 | | -#define RPI_RESET_MS_OS_20_DESC_LEN (0x08 + 0x14 + 0x80) |
121 | | -#define RPI_RESET_MS_OS_20_DESCRIPTOR(itf_num) \ |
122 | | - /* Function Subset header: length, type, first interface, reserved, subset length */ \ |
123 | | - U16_TO_U8S_LE(0x0008), U16_TO_U8S_LE(MS_OS_20_SUBSET_HEADER_FUNCTION), itf_num, 0, U16_TO_U8S_LE(RPI_RESET_MS_OS_20_DESC_LEN), \ |
124 | | - \ |
125 | | - /* MS OS 2.0 Compatible ID descriptor: length, type, compatible ID, sub compatible ID */ \ |
126 | | - U16_TO_U8S_LE(0x0014), U16_TO_U8S_LE(MS_OS_20_FEATURE_COMPATBLE_ID), 'W', 'I', 'N', 'U', 'S', 'B', 0x00, 0x00, \ |
127 | | - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* sub-compatible */ \ |
128 | | - \ |
129 | | - /* MS OS 2.0 Registry property descriptor: length, type */ \ |
130 | | - U16_TO_U8S_LE(0x0080), U16_TO_U8S_LE(MS_OS_20_FEATURE_REG_PROPERTY), \ |
131 | | - U16_TO_U8S_LE(0x0001), U16_TO_U8S_LE(0x0028), /* wPropertyDataType, wPropertyNameLength and PropertyName "DeviceInterfaceGUID" in UTF-16 */ \ |
132 | | - 'D', 0x00, 'e', 0x00, 'v', 0x00, 'i', 0x00, 'c', 0x00, 'e', 0x00, 'I', 0x00, 'n', 0x00, 't', 0x00, 'e', 0x00, \ |
133 | | - 'r', 0x00, 'f', 0x00, 'a', 0x00, 'c', 0x00, 'e', 0x00, 'G', 0x00, 'U', 0x00, 'I', 0x00, 'D', 0x00, 0x00, 0x00, \ |
134 | | - U16_TO_U8S_LE(0x004E), /* wPropertyDataLength */ \ |
135 | | - /* Vendor-defined Property Data: {bc7398c1-73cd-4cb7-98b8-913a8fca7bf6} */ \ |
136 | | - '{', 0, 'b', 0, 'c', 0, '7', 0, '3', 0, '9', 0, \ |
137 | | - '8', 0, 'c', 0, '1', 0, '-', 0, '7', 0, '3', 0, \ |
138 | | - 'c', 0, 'd', 0, '-', 0, '4', 0, 'c', 0, 'b', 0, \ |
139 | | - '7', 0, '-', 0, '9', 0, '8', 0, 'b', 0, '8', 0, \ |
140 | | - '-', 0, '9', 0, '1', 0, '3', 0, 'a', 0, '8', 0, \ |
141 | | - 'f', 0, 'c', 0, 'a', 0, '7', 0, 'b', 0, 'f', 0, \ |
142 | | - '6', 0, '}', 0, 0, 0 |
143 | | - |
144 | | -#include "stdint.h" |
145 | | -#include "device/usbd_pvt.h" |
146 | | - |
147 | | -void pico_usb_reset_interface_init(void); |
148 | | -void pico_usb_reset_interface_reset(uint8_t __unused rhport); |
149 | | -uint16_t pico_usb_reset_interface_open(uint8_t __unused rhport, tusb_desc_interface_t const *itf_desc, uint16_t max_len); |
150 | | -bool pico_usb_reset_interface_control_xfer_cb(uint8_t __unused rhport, uint8_t stage, tusb_control_request_t const * request); |
151 | | -bool pico_usb_reset_interface_xfer_cb(uint8_t __unused rhport, uint8_t __unused ep_addr, xfer_result_t __unused result, uint32_t __unused xferred_bytes); |
152 | | - |
153 | | -static usbd_class_driver_t const pico_usb_reset_interface_driver = |
154 | | -{ |
155 | | -#if CFG_TUSB_DEBUG >= 2 |
156 | | - .name = "RESET", |
157 | | -#endif |
158 | | - .init = pico_usb_reset_interface_init, |
159 | | - .reset = pico_usb_reset_interface_reset, |
160 | | - .open = pico_usb_reset_interface_open, |
161 | | - .control_xfer_cb = pico_usb_reset_interface_control_xfer_cb, |
162 | | - .xfer_cb = pico_usb_reset_interface_xfer_cb, |
163 | | - .sof = NULL |
164 | | -}; |
| 47 | +#include "pico/usb_reset_interface_config.h" |
| 48 | +#include "pico/usb_reset_interface_tusb.h" |
165 | 49 |
|
166 | 50 | #endif |
167 | 51 |
|
|
0 commit comments