Skip to content

Commit f901baf

Browse files
committed
Move pico_usb_reset_interface library into separate folder
1 parent 0223656 commit f901baf

File tree

8 files changed

+114
-119
lines changed

8 files changed

+114
-119
lines changed

src/cmake/rp2_common.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ if (NOT PICO_BARE_METAL)
121121
endif()
122122
pico_add_subdirectory(rp2_common/tinyusb)
123123
pico_add_subdirectory(rp2_common/pico_stdio_usb)
124+
pico_add_subdirectory(rp2_common/pico_usb_reset_interface)
124125
pico_add_subdirectory(rp2_common/pico_i2c_slave)
125126

126127
# networking libraries - note dependency order is important
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# don't use pico_add_library here as picotool includes it directly
22
add_library(pico_usb_reset_interface_headers INTERFACE)
3-
add_library(pico_usb_reset_interface INTERFACE)
4-
target_link_libraries(pico_usb_reset_interface INTERFACE pico_usb_reset_interface_headers)
53

64
target_include_directories(pico_usb_reset_interface_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)

src/common/pico_usb_reset_interface_headers/include/pico/usb_reset_interface.h

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/** \file usb_reset_interface.h
1111
* \defgroup pico_usb_reset_interface_headers pico_usb_reset_interface_headers
1212
*
13-
* \brief Definition for the reset interface that may be exposed by the pico_stdio_usb library
13+
* \brief Definition for the reset interface that may be exposed by the pico_usb_reset_interface library
1414
*/
1515

1616
// These defines are used by picotool
@@ -26,4 +26,101 @@
2626
// regular flash boot
2727
#define RESET_REQUEST_FLASH 0x02
2828

29+
#if PICO_ON_DEVICE
30+
// 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
31+
32+
// 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
33+
#ifndef PICO_STDIO_USB_RESET_BOOTSEL_ACTIVITY_LED_ACTIVE_LOW
34+
#define PICO_STDIO_USB_RESET_BOOTSEL_ACTIVITY_LED_ACTIVE_LOW 0
35+
#endif
36+
37+
// 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
38+
#ifndef PICO_STDIO_USB_RESET_BOOTSEL_FIXED_ACTIVITY_LED
39+
#define PICO_STDIO_USB_RESET_BOOTSEL_FIXED_ACTIVITY_LED 0
40+
#endif
41+
42+
// Any modes disabled here can't be re-enabled by picotool via VENDOR_INTERFACE.
43+
// 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
44+
#ifndef PICO_STDIO_USB_RESET_BOOTSEL_INTERFACE_DISABLE_MASK
45+
#define PICO_STDIO_USB_RESET_BOOTSEL_INTERFACE_DISABLE_MASK 0u
46+
#endif
47+
48+
// 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
49+
#ifndef PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE
50+
#if !LIB_TINYUSB_HOST && !LIB_TINYUSB_DEVICE
51+
#define PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE 1
52+
#else
53+
#define PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE 0
54+
#endif
55+
#endif
56+
57+
// 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
58+
#ifndef PICO_STDIO_USB_RESET_INCLUDE_APP_DRIVER_CB
59+
#define PICO_STDIO_USB_RESET_INCLUDE_APP_DRIVER_CB LIB_PICO_STDIO_USB
60+
#endif
61+
62+
// 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
63+
#ifndef PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_BOOTSEL
64+
#define PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_BOOTSEL 1
65+
#endif
66+
67+
// 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
68+
#ifndef PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_FLASH_BOOT
69+
#define PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_FLASH_BOOT 1
70+
#endif
71+
72+
// 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
73+
#ifndef PICO_STDIO_USB_RESET_RESET_TO_FLASH_DELAY_MS
74+
#define PICO_STDIO_USB_RESET_RESET_TO_FLASH_DELAY_MS 100
75+
#endif
76+
77+
// 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
78+
#ifndef PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR
79+
#if !LIB_TINYUSB_HOST && !LIB_TINYUSB_DEVICE
80+
#define PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR 1
81+
#else
82+
#define PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR 0
83+
#endif
84+
#endif
85+
86+
// 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
87+
#ifndef PICO_STDIO_USB_RESET_INTERFACE_MS_OS_20_DESCRIPTOR_ITF
88+
#if !LIB_TINYUSB_HOST && !LIB_TINYUSB_DEVICE
89+
#define PICO_STDIO_USB_RESET_INTERFACE_MS_OS_20_DESCRIPTOR_ITF 2
90+
#elif PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR
91+
#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
92+
#endif
93+
#endif
94+
95+
// Interface descriptor
96+
#define TUD_RPI_RESET_DESC_LEN 9
97+
#define TUD_RPI_RESET_DESCRIPTOR(_itfnum, _stridx) \
98+
/* Interface */\
99+
TUD_RPI_RESET_DESC_LEN, TUSB_DESC_INTERFACE, _itfnum, 0, 0, TUSB_CLASS_VENDOR_SPECIFIC, RESET_INTERFACE_SUBCLASS, RESET_INTERFACE_PROTOCOL, _stridx
100+
101+
102+
#include "stdint.h"
103+
#include "device/usbd_pvt.h"
104+
105+
void resetd_init(void);
106+
void resetd_reset(uint8_t __unused rhport);
107+
uint16_t resetd_open(uint8_t __unused rhport, tusb_desc_interface_t const *itf_desc, uint16_t max_len);
108+
bool resetd_control_xfer_cb(uint8_t __unused rhport, uint8_t stage, tusb_control_request_t const * request);
109+
bool resetd_xfer_cb(uint8_t __unused rhport, uint8_t __unused ep_addr, xfer_result_t __unused result, uint32_t __unused xferred_bytes);
110+
111+
static usbd_class_driver_t const _resetd_driver =
112+
{
113+
#if CFG_TUSB_DEBUG >= 2
114+
.name = "RESET",
115+
#endif
116+
.init = resetd_init,
117+
.reset = resetd_reset,
118+
.open = resetd_open,
119+
.control_xfer_cb = resetd_control_xfer_cb,
120+
.xfer_cb = resetd_xfer_cb,
121+
.sof = NULL
122+
};
123+
124+
#endif
125+
29126
#endif

src/rp2_common/pico_stdio_usb/CMakeLists.txt

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
11
if (TARGET tinyusb_device_unmarked)
2-
pico_add_library(pico_stdio_usb_reset_interface)
3-
4-
target_include_directories(pico_stdio_usb_reset_interface_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
5-
6-
target_sources(pico_stdio_usb_reset_interface INTERFACE
7-
${CMAKE_CURRENT_LIST_DIR}/reset_interface.c
8-
)
9-
10-
pico_mirrored_target_link_libraries(pico_stdio_usb_reset_interface INTERFACE
11-
pico_usb_reset_interface
12-
)
13-
target_link_libraries(pico_stdio_usb_reset_interface INTERFACE
14-
tinyusb_device_unmarked
15-
)
16-
172
pico_add_library(pico_stdio_usb)
183

194
target_include_directories(pico_stdio_usb_headers SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
@@ -27,7 +12,7 @@ if (TARGET tinyusb_device_unmarked)
2712
pico_stdio
2813
pico_time
2914
pico_unique_id
30-
pico_stdio_usb_reset_interface
15+
pico_usb_reset_interface
3116
)
3217
target_link_libraries(pico_stdio_usb INTERFACE
3318
tinyusb_device_unmarked

src/rp2_common/pico_stdio_usb/include/pico/stdio_usb/reset_interface.h

Lines changed: 1 addition & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -8,103 +8,6 @@
88
#define _PICO_STDIO_USB_RESET_INTERFACE_H
99

1010
// definitions have been moved here
11-
#include "pico/usb_reset_interface.h"
12-
13-
#if PICO_ON_DEVICE
14-
// 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_stdio_usb
15-
16-
// 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_stdio_usb
17-
#ifndef PICO_STDIO_USB_RESET_BOOTSEL_ACTIVITY_LED_ACTIVE_LOW
18-
#define PICO_STDIO_USB_RESET_BOOTSEL_ACTIVITY_LED_ACTIVE_LOW 0
19-
#endif
20-
21-
// 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_stdio_usb
22-
#ifndef PICO_STDIO_USB_RESET_BOOTSEL_FIXED_ACTIVITY_LED
23-
#define PICO_STDIO_USB_RESET_BOOTSEL_FIXED_ACTIVITY_LED 0
24-
#endif
25-
26-
// Any modes disabled here can't be re-enabled by picotool via VENDOR_INTERFACE.
27-
// 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_stdio_usb
28-
#ifndef PICO_STDIO_USB_RESET_BOOTSEL_INTERFACE_DISABLE_MASK
29-
#define PICO_STDIO_USB_RESET_BOOTSEL_INTERFACE_DISABLE_MASK 0u
30-
#endif
31-
32-
// 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_stdio_usb
33-
#ifndef PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE
34-
#if !LIB_TINYUSB_HOST && !LIB_TINYUSB_DEVICE
35-
#define PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE 1
36-
#else
37-
#define PICO_STDIO_USB_ENABLE_RESET_VIA_VENDOR_INTERFACE 0
38-
#endif
39-
#endif
40-
41-
// 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, group=pico_stdio_usb
42-
#ifndef PICO_STDIO_USB_RESET_INCLUDE_APP_DRIVER_CB
43-
#define PICO_STDIO_USB_RESET_INCLUDE_APP_DRIVER_CB 1
44-
#endif
45-
46-
// 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_stdio_usb
47-
#ifndef PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_BOOTSEL
48-
#define PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_BOOTSEL 1
49-
#endif
50-
51-
// 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_stdio_usb
52-
#ifndef PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_FLASH_BOOT
53-
#define PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_RESET_TO_FLASH_BOOT 1
54-
#endif
55-
56-
// PICO_CONFIG: PICO_STDIO_USB_RESET_RESET_TO_FLASH_DELAY_MS, Delay in ms before rebooting via regular flash boot, default=100, group=pico_stdio_usb
57-
#ifndef PICO_STDIO_USB_RESET_RESET_TO_FLASH_DELAY_MS
58-
#define PICO_STDIO_USB_RESET_RESET_TO_FLASH_DELAY_MS 100
59-
#endif
60-
61-
// 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 when using default USB descriptors, 0 otherwise, group=pico_stdio_usb
62-
#ifndef PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR
63-
#ifdef PICO_STDIO_USB_USE_DEFAULT_DESCRIPTORS
64-
#define PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR 1
65-
#else
66-
#define PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR 0
67-
#endif
68-
#endif
69-
70-
// 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 when using default USB descriptors, undefined otherwise, group=pico_stdio_usb
71-
#ifndef PICO_STDIO_USB_RESET_INTERFACE_MS_OS_20_DESCRIPTOR_ITF
72-
#if PICO_STDIO_USB_USE_DEFAULT_DESCRIPTORS
73-
#define PICO_STDIO_USB_RESET_INTERFACE_MS_OS_20_DESCRIPTOR_ITF 2
74-
#elif PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR
75-
#error Must set PICO_STDIO_USB_RESET_INTERFACE_MS_OS_20_DESCRIPTOR_ITF when using PICO_STDIO_USB_RESET_INTERFACE_SUPPORT_MS_OS_20_DESCRIPTOR with custom USB descriptors
76-
#endif
77-
#endif
78-
79-
// Interface descriptor
80-
#define TUD_RPI_RESET_DESC_LEN 9
81-
#define TUD_RPI_RESET_DESCRIPTOR(_itfnum, _stridx) \
82-
/* Interface */\
83-
TUD_RPI_RESET_DESC_LEN, TUSB_DESC_INTERFACE, _itfnum, 0, 0, TUSB_CLASS_VENDOR_SPECIFIC, RESET_INTERFACE_SUBCLASS, RESET_INTERFACE_PROTOCOL, _stridx
84-
85-
86-
#include "stdint.h"
87-
#include "device/usbd_pvt.h"
88-
89-
void resetd_init(void);
90-
void resetd_reset(uint8_t __unused rhport);
91-
uint16_t resetd_open(uint8_t __unused rhport, tusb_desc_interface_t const *itf_desc, uint16_t max_len);
92-
bool resetd_control_xfer_cb(uint8_t __unused rhport, uint8_t stage, tusb_control_request_t const * request);
93-
bool resetd_xfer_cb(uint8_t __unused rhport, uint8_t __unused ep_addr, xfer_result_t __unused result, uint32_t __unused xferred_bytes);
94-
95-
static usbd_class_driver_t const _resetd_driver =
96-
{
97-
#if CFG_TUSB_DEBUG >= 2
98-
.name = "RESET",
99-
#endif
100-
.init = resetd_init,
101-
.reset = resetd_reset,
102-
.open = resetd_open,
103-
.control_xfer_cb = resetd_control_xfer_cb,
104-
.xfer_cb = resetd_xfer_cb,
105-
.sof = NULL
106-
};
107-
108-
#endif
11+
#include "pico/usb_reset_interface_constants.h"
10912

11013
#endif

src/rp2_common/pico_stdio_usb/stdio_usb_descriptors.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828

2929
#include "pico/stdio_usb.h"
30-
#include "pico/stdio_usb/reset_interface.h"
30+
#include "pico/usb_reset_interface.h"
3131
#include "pico/unique_id.h"
3232
#include "tusb.h"
3333

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
if (TARGET tinyusb_device_unmarked)
2+
pico_add_impl_library(pico_usb_reset_interface)
3+
4+
target_sources(pico_usb_reset_interface INTERFACE
5+
${CMAKE_CURRENT_LIST_DIR}/usb_reset_interface.c
6+
)
7+
8+
target_link_libraries(pico_usb_reset_interface INTERFACE
9+
tinyusb_device_unmarked
10+
)
11+
endif()

src/rp2_common/pico_stdio_usb/reset_interface.c renamed to src/rp2_common/pico_usb_reset_interface/usb_reset_interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "tusb.h"
77

88
#include "pico/bootrom.h"
9-
#include "pico/stdio_usb/reset_interface.h"
9+
#include "pico/usb_reset_interface.h"
1010

1111
#if !defined(LIB_TINYUSB_HOST)
1212

0 commit comments

Comments
 (0)