aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGareth McMullin2011-02-16 09:04:06 +1300
committerGareth McMullin2011-02-16 09:04:06 +1300
commitf08914ec1f2ee8630653278971e087cc358d98dc (patch)
tree64a7006bad00312b9b49ed1e9955615010c4404c
parentf9a7cd9c6e114f8de2b1d4dd1307d8a87bae065e (diff)
Fixed DFU_DETACH request handling when usb-uart is excluded.
-rw-r--r--src/stm32/cdcacm.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/stm32/cdcacm.c b/src/stm32/cdcacm.c
index 2463628..31fc024 100644
--- a/src/stm32/cdcacm.c
+++ b/src/stm32/cdcacm.c
@@ -37,6 +37,12 @@
#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 int configured;
@@ -258,11 +264,7 @@ const struct usb_dfu_descriptor dfu_function = {
const struct usb_interface_descriptor dfu_iface = {
.bLength = USB_DT_INTERFACE_SIZE,
.bDescriptorType = USB_DT_INTERFACE,
-#ifdef INCLUDE_UART_INTERFACE
- .bInterfaceNumber = 4,
-#else
- .bInterfaceNumber = 2,
-#endif
+ .bInterfaceNumber = DFU_IF_NO,
.bAlternateSetting = 0,
.bNumEndpoints = 0,
.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
* advertise it in the ACM functional descriptor. */
return 1;
-#ifdef INLCUDE_UART_INTERFACE
+#ifdef INCLUDE_UART_INTERFACE
case USB_CDC_REQ_SET_LINE_CODING: {
if(*len < sizeof(struct usb_cdc_line_coding))
return 0;
@@ -354,7 +356,7 @@ static int cdcacm_control_request(struct usb_setup_data *req, uint8_t **buf,
if(req->wIndex != 2)
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_databits(USART1, coding->bDataBits);
switch(coding->bCharFormat) {
@@ -384,7 +386,7 @@ static int cdcacm_control_request(struct usb_setup_data *req, uint8_t **buf,
}
#endif
case DFU_DETACH:
- if(req->wIndex == 4) {
+ if(req->wIndex == DFU_IF_NO) {
*complete = dfu_detach_complete;
return 1;
}