Fixed DFU_DETACH request handling when usb-uart is excluded.
This commit is contained in:
parent
f9a7cd9c6e
commit
f08914ec1f
|
@ -37,6 +37,12 @@
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
|
#ifdef INCLUDE_UART_INTERFACE
|
||||||
|
# define DFU_IF_NO 4
|
||||||
|
#else
|
||||||
|
# define DFU_IF_NO 2
|
||||||
|
#endif
|
||||||
|
|
||||||
static char *get_dev_unique_id(char *serial_no);
|
static char *get_dev_unique_id(char *serial_no);
|
||||||
|
|
||||||
static int configured;
|
static int configured;
|
||||||
|
@ -258,11 +264,7 @@ const struct usb_dfu_descriptor dfu_function = {
|
||||||
const struct usb_interface_descriptor dfu_iface = {
|
const struct usb_interface_descriptor dfu_iface = {
|
||||||
.bLength = USB_DT_INTERFACE_SIZE,
|
.bLength = USB_DT_INTERFACE_SIZE,
|
||||||
.bDescriptorType = USB_DT_INTERFACE,
|
.bDescriptorType = USB_DT_INTERFACE,
|
||||||
#ifdef INCLUDE_UART_INTERFACE
|
.bInterfaceNumber = DFU_IF_NO,
|
||||||
.bInterfaceNumber = 4,
|
|
||||||
#else
|
|
||||||
.bInterfaceNumber = 2,
|
|
||||||
#endif
|
|
||||||
.bAlternateSetting = 0,
|
.bAlternateSetting = 0,
|
||||||
.bNumEndpoints = 0,
|
.bNumEndpoints = 0,
|
||||||
.bInterfaceClass = 0xFE,
|
.bInterfaceClass = 0xFE,
|
||||||
|
@ -346,7 +348,7 @@ static int cdcacm_control_request(struct usb_setup_data *req, uint8_t **buf,
|
||||||
* even though it's optional in the CDC spec, and we don't
|
* even though it's optional in the CDC spec, and we don't
|
||||||
* advertise it in the ACM functional descriptor. */
|
* advertise it in the ACM functional descriptor. */
|
||||||
return 1;
|
return 1;
|
||||||
#ifdef INLCUDE_UART_INTERFACE
|
#ifdef INCLUDE_UART_INTERFACE
|
||||||
case USB_CDC_REQ_SET_LINE_CODING: {
|
case USB_CDC_REQ_SET_LINE_CODING: {
|
||||||
if(*len < sizeof(struct usb_cdc_line_coding))
|
if(*len < sizeof(struct usb_cdc_line_coding))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -354,7 +356,7 @@ static int cdcacm_control_request(struct usb_setup_data *req, uint8_t **buf,
|
||||||
if(req->wIndex != 2)
|
if(req->wIndex != 2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
struct usb_cdc_line_coding *coding = *buf;
|
struct usb_cdc_line_coding *coding = (void*)*buf;
|
||||||
usart_set_baudrate(USART1, coding->dwDTERate);
|
usart_set_baudrate(USART1, coding->dwDTERate);
|
||||||
usart_set_databits(USART1, coding->bDataBits);
|
usart_set_databits(USART1, coding->bDataBits);
|
||||||
switch(coding->bCharFormat) {
|
switch(coding->bCharFormat) {
|
||||||
|
@ -384,7 +386,7 @@ static int cdcacm_control_request(struct usb_setup_data *req, uint8_t **buf,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
case DFU_DETACH:
|
case DFU_DETACH:
|
||||||
if(req->wIndex == 4) {
|
if(req->wIndex == DFU_IF_NO) {
|
||||||
*complete = dfu_detach_complete;
|
*complete = dfu_detach_complete;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue