From 479e719a64d75374f00438498cf91ba2601a63f1 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 2 Nov 2014 15:16:42 +0000 Subject: fish --- src/dfu.c | 78 ++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 40 insertions(+), 38 deletions(-) (limited to 'src/dfu.c') diff --git a/src/dfu.c b/src/dfu.c index 56420ad..e9de46f 100644 --- a/src/dfu.c +++ b/src/dfu.c @@ -3,56 +3,58 @@ #ifdef INCLUDE_DFU_INTERFACE const struct usb_dfu_descriptor dfu_function = { - .bLength = sizeof(struct usb_dfu_descriptor), - .bDescriptorType = DFU_FUNCTIONAL, - .bmAttributes = USB_DFU_CAN_DOWNLOAD | USB_DFU_WILL_DETACH, - .wDetachTimeout = 255, - .wTransferSize = 1024, - .bcdDFUVersion = 0x011A, + .bLength = sizeof (struct usb_dfu_descriptor), + .bDescriptorType = DFU_FUNCTIONAL, + .bmAttributes = USB_DFU_CAN_DOWNLOAD | USB_DFU_WILL_DETACH, + .wDetachTimeout = 255, + .wTransferSize = 1024, + .bcdDFUVersion = 0x011A, }; const struct usb_interface_descriptor dfu_iface = { - .bLength = USB_DT_INTERFACE_SIZE, - .bDescriptorType = USB_DT_INTERFACE, - .bInterfaceNumber = 3, - .bAlternateSetting = 0, - .bNumEndpoints = 0, - .bInterfaceClass = 0xFE, - .bInterfaceSubClass = 1, - .bInterfaceProtocol = 1, - .iInterface = 0, - - .extra = &dfu_function, - .extralen = sizeof(dfu_function), + .bLength = USB_DT_INTERFACE_SIZE, + .bDescriptorType = USB_DT_INTERFACE, + .bInterfaceNumber = 3, + .bAlternateSetting = 0, + .bNumEndpoints = 0, + .bInterfaceClass = 0xFE, + .bInterfaceSubClass = 1, + .bInterfaceProtocol = 1, + .iInterface = 0, + + .extra = &dfu_function, + .extralen = sizeof (dfu_function), }; -static void dfu_detach_complete(usbd_device *usbd_dev, struct usb_setup_data *req) +static void +dfu_detach_complete (usbd_device * usbd_dev, struct usb_setup_data *req) { - (void)req; - (void)usbd_dev; - - gpio_set_mode(GPIOA, GPIO_MODE_INPUT, 0, GPIO15); - gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ, - GPIO_CNF_OUTPUT_PUSHPULL, GPIO10); - gpio_set(GPIOA, GPIO10); - scb_reset_core(); + (void) req; + (void) usbd_dev; + + gpio_set_mode (GPIOA, GPIO_MODE_INPUT, 0, GPIO15); + gpio_set_mode (GPIOA, GPIO_MODE_OUTPUT_2_MHZ, + GPIO_CNF_OUTPUT_PUSHPULL, GPIO10); + gpio_set (GPIOA, GPIO10); + scb_reset_core (); } -int dfu_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, - void (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req)) +int +dfu_control_request (usbd_device * usbd_dev, struct usb_setup_data *req, + uint8_t ** buf, uint16_t * len, + void (**complete) (usbd_device * usbd_dev, + struct usb_setup_data * req)) { - (void)buf; - (void)len; - (void)usbd_dev; + (void) buf; + (void) len; + (void) usbd_dev; - if ((req->bmRequestType != 0x21) || (req->bRequest != DFU_DETACH)) - return 0; /* Only accept class request. */ + if ((req->bmRequestType != 0x21) || (req->bRequest != DFU_DETACH)) + return 0; /* Only accept class request. */ - *complete = dfu_detach_complete; + *complete = dfu_detach_complete; - return 1; + return 1; } #endif - - -- cgit v1.2.3