From d77694f33a1221b861c461aa2093d6ffb9626734 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 5 Jan 2012 22:16:24 +0100 Subject: dfu fixes --- usb/device/dfu/dfu.h | 20 ++++++++++++++------ usb/device/dfu/dfu_driver.c | 10 ++++++++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/usb/device/dfu/dfu.h b/usb/device/dfu/dfu.h index 00a0622..4d5aa5b 100644 --- a/usb/device/dfu/dfu.h +++ b/usb/device/dfu/dfu.h @@ -1,5 +1,5 @@ -#ifndef _USB_DFU_DESC_H -#define _USB_DFU_DESC_H +#ifndef _USB_DEV_DFU_H +#define _USB_DEV_DFU_H #include #include @@ -25,7 +25,15 @@ struct USBStringDescriptor { #ifdef BOARD_USB_DFU -#define DFU_NUM_IF 3 +/* USB DFU functional descriptor */ +#define DFU_FUNC_DESC { \ + .bLength = USB_DT_DFU_SIZE, \ + .bDescriptorType = USB_DT_DFU, \ + .bmAttributes = USB_DFU_CAN_UPLOAD | USB_DFU_CAN_DOWNLOAD, \ + .wDetachTimeOut = 0xff00, \ + .wTransferSize = BOARD_DFU_PAGE_SIZE, \ + .bcdDFUVersion = 0x0100, \ +} #define DFU_IF_DESCRIPTORS_STRUCT \ USBInterfaceDescriptor dfu_interface[DFU_NUM_IF]; @@ -100,10 +108,10 @@ extern struct dfu dfu; /* call-backs by the board/SOC */ extern int USBDFU_handle_dnload(uint16_t val, uint16_t len, int first); -static int USBDFU_handle_upload(uint16_t val, uint16_t len, int first); +extern int USBDFU_handle_upload(uint16_t val, uint16_t len, int first); -void USBDFU_Runtime_RequestHandler(USBDDriver *pDriver, const USBGenericRequest *request); -void USBDFU_DFU_RequestHandler(USBDDriver *pDriver, const USBGenericRequest *request); +void USBDFU_Runtime_RequestHandler(const USBGenericRequest *request); +void USBDFU_DFU_RequestHandler(const USBGenericRequest *request); void USBDFU_Initialize(const USBDDriverDescriptors *pDescriptors, unsigned char *pInterfaces); diff --git a/usb/device/dfu/dfu_driver.c b/usb/device/dfu/dfu_driver.c index df6fb4f..1e9286e 100644 --- a/usb/device/dfu/dfu_driver.c +++ b/usb/device/dfu/dfu_driver.c @@ -22,8 +22,11 @@ #include +#include + #include #include +#include #include #include @@ -66,7 +69,7 @@ static void __dfufunc handle_getstate(void) } /* this function gets daisy-chained into processing EP0 requests */ -void USBDFU_DFU_RequestHandler(USBDDriver *pDriver, const USBGenericRequest *request) +void USBDFU_DFU_RequestHandler(const USBGenericRequest *request) { uint8_t req = USBGenericRequest_GetRequest(request); uint16_t len = USBGenericRequest_GetLength(request); @@ -76,7 +79,8 @@ void USBDFU_DFU_RequestHandler(USBDDriver *pDriver, const USBGenericRequest *req /* only process actual DFU specific messages */ if (USBGenericRequest_GetType(request) != USBGenericRequest_CLASS || USBGenericRequest_GetRecipient(request) != USBGenericRequest_INTERFACE) { - USBDDriver_RequestHandler(pDriver, request); + TRACE_DEBUG("std_ho_usbd "); + USBDDriver_RequestHandler(&usbdDriver, request); } switch (dfu.state) { @@ -299,4 +303,6 @@ out: void USBDFU_Initialize(const USBDDriverDescriptors *pDescriptors, unsigned char *pInterfaces) { USBDDriver_Initialize(&usbdDriver, pDescriptors, pInterfaces); + + USBD_Init(); } -- cgit v1.2.3