From 8b126215312ccef51b5df7ef92c7839d69fc385c Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 7 Jan 2012 17:46:25 +0100 Subject: merge with current at91lib changes (82eaac47c73621cc42ea6f40ffca2118e764a3ae) --- usb-dfu-experiment/Makefile | 2 +- usb-dfu-experiment/main.c | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) (limited to 'usb-dfu-experiment') diff --git a/usb-dfu-experiment/Makefile b/usb-dfu-experiment/Makefile index e7ef099..f273c65 100644 --- a/usb-dfu-experiment/Makefile +++ b/usb-dfu-experiment/Makefile @@ -45,7 +45,7 @@ BOARD = at91sam3u-ek # TRACE_LEVEL_ERROR 2 # TRACE_LEVEL_FATAL 1 # TRACE_LEVEL_NO_TRACE 0 -TRACE_LEVEL = 5 +TRACE_LEVEL = 4 # Optimization level, put in comment for debugging OPTIMIZATION = -Os diff --git a/usb-dfu-experiment/main.c b/usb-dfu-experiment/main.c index 4d1d59c..91c35b4 100644 --- a/usb-dfu-experiment/main.c +++ b/usb-dfu-experiment/main.c @@ -292,27 +292,36 @@ void USBDCallbacks_RequestReceived(const USBGenericRequest *request) void USBDDriverCallbacks_InterfaceSettingChanged(unsigned char interface, unsigned char setting) { - TRACE_DEBUG("DFU: IfSettingChgd()\n"); + TRACE_INFO("DFU: IfSettingChgd(if=%u, alt=%u)\n\r", interface, setting); } +static int upl_first = 1; + /* DFU callback */ -int USBDFU_handle_upload(uint16_t val, uint16_t len, int first) +int USBDFU_handle_upload(uint8_t altif, unsigned int offset, + uint8_t *buf, unsigned int req_len) { - TRACE_DEBUG("DFU: handle_upload()\n"); - return DFU_RET_ZLP; + TRACE_INFO("DFU: handle_upload(%u, %u, %u)\n\r", altif, offset, req_len); + if (upl_first) { + upl_first = 0; + return req_len; + } + + return 4; } /* DFU callback */ -int USBDFU_handle_dnload(uint16_t val, uint16_t len, int first) +int USBDFU_handle_dnload(uint8_t altif, unsigned int offset, + uint8_t *buf, unsigned int len) { - TRACE_DEBUG("DFU: handle_dnload()\n"); + TRACE_INFO("DFU: handle_dnload(%u, %u, %u)\n\r", altif, offset, len); return DFU_RET_ZLP; } /* DFU callback */ void dfu_drv_updstatus(void) { - TRACE_DEBUG("DFU: updstatus()\n"); + TRACE_INFO("DFU: updstatus()\n\r"); } @@ -322,8 +331,6 @@ void dfu_drv_updstatus(void) extern void USBD_IrqHandler(void); -static unsigned char altsettings[4]; - int main(void) { volatile uint8_t usbConn = 0; @@ -343,7 +350,7 @@ int main(void) /* Audio STREAM LED */ LED_Configure(USBD_LEDOTHER); - USBDFU_Initialize(&dfu_descriptors, altsettings); + USBDFU_Initialize(&dfu_descriptors); /* connect if needed */ VBus_Configure(); -- cgit v1.2.3