File tree 3 files changed +33
-0
lines changed
3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 43
43
#include "usb_device_state.h"
44
44
#include "usb_descriptor.h"
45
45
#include "usb_driver.h"
46
+ #include "platforms/bootloader.h"
46
47
47
48
#ifdef NKRO_ENABLE
48
49
# include "keycode_config.h"
@@ -651,6 +652,21 @@ static bool usb_request_hook_cb(USBDriver *usbp) {
651
652
* 4,5: (LSB,MSB) wIndex
652
653
* 6,7: (LSB,MSB) wLength (number of bytes to transfer if there is a data phase) */
653
654
655
+ if (((usbp -> setup [0 ] & USB_RTYPE_TYPE_MASK ) == USB_RTYPE_TYPE_CLASS ) && ((usbp -> setup [0 ] & USB_RTYPE_RECIPIENT_MASK ) == USB_RTYPE_RECIPIENT_INTERFACE )) {
656
+ dprint (" TYPE_CLASS, RECIPIENT_INTERFACE\n" );
657
+ if ((usbp -> setup [0 ] & USB_RTYPE_DIR_MASK ) == USB_RTYPE_DIR_HOST2DEV ) {
658
+ if (usbp -> setup [4 ] == RP2040_RESET_INTERFACE ) {
659
+ switch (usbp -> setup [1 ]) { /* bRequest */
660
+ case 0x01 : // RESET_REQUEST_BOOTSEL
661
+ case 0x02 : // RESET_REQUEST_FLASH
662
+ dprint (" Reset interface\n" );
663
+ bootloader_jump ();
664
+ break ;
665
+ }
666
+ }
667
+ }
668
+ }
669
+
654
670
/* Handle HID class specific requests */
655
671
if (((usbp -> setup [0 ] & USB_RTYPE_TYPE_MASK ) == USB_RTYPE_TYPE_CLASS ) && ((usbp -> setup [0 ] & USB_RTYPE_RECIPIENT_MASK ) == USB_RTYPE_RECIPIENT_INTERFACE )) {
656
672
switch (usbp -> setup [0 ] & USB_RTYPE_DIR_MASK ) {
Original file line number Diff line number Diff line change @@ -738,6 +738,19 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = {
738
738
.PollingIntervalMS = USB_POLLING_INTERVAL_MS
739
739
},
740
740
#endif
741
+ .Rp2040_Reset_Interface = {
742
+ .Header = {
743
+ .Size = sizeof (USB_Descriptor_Interface_t ),
744
+ .Type = DTYPE_Interface
745
+ },
746
+ .InterfaceNumber = RP2040_RESET_INTERFACE ,
747
+ .AlternateSetting = 0x00 ,
748
+ .TotalEndpoints = 2 ,
749
+ .Class = 0xFF ,
750
+ .SubClass = 0x00 , // RESET_INTERFACE_SUBCLASS
751
+ .Protocol = 0x01 , // RESET_INTERFACE_PROTOCOL
752
+ .InterfaceStrIndex = NO_DESCRIPTOR
753
+ },
741
754
742
755
#ifdef CONSOLE_ENABLE
743
756
/*
Original file line number Diff line number Diff line change @@ -92,6 +92,8 @@ typedef struct {
92
92
USB_Descriptor_Endpoint_t Shared_INEndpoint ;
93
93
#endif
94
94
95
+ USB_Descriptor_Interface_t Rp2040_Reset_Interface ;
96
+
95
97
#ifdef CONSOLE_ENABLE
96
98
// Console HID Interface
97
99
USB_Descriptor_Interface_t Console_Interface ;
@@ -173,6 +175,8 @@ enum usb_interfaces {
173
175
SHARED_INTERFACE ,
174
176
#endif
175
177
178
+ RP2040_RESET_INTERFACE ,
179
+
176
180
#ifdef CONSOLE_ENABLE
177
181
CONSOLE_INTERFACE ,
178
182
#endif
You can’t perform that action at this time.
0 commit comments