From d96abdb0ad3297239951b35cb24ad035dec19a59 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 15 May 2018 22:06:49 +0700 Subject: [PATCH] add xferred bytes for device control --- tinyusb/device/dcd.h | 4 ++-- tinyusb/device/usbd.c | 6 +++--- tinyusb/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tinyusb/device/dcd.h b/tinyusb/device/dcd.h index fb9d992fb..bee787d03 100644 --- a/tinyusb/device/dcd.h +++ b/tinyusb/device/dcd.h @@ -76,10 +76,10 @@ void dcd_bus_event (uint8_t rhport, usbd_bus_event_type_t bus_event); void dcd_setup_received (uint8_t rhport, uint8_t const* p_request); void dcd_xfer_complete (uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, bool succeeded); -static inline void dcd_control_complete(uint8_t rhport) +static inline void dcd_control_complete(uint8_t rhport, uint32_t xferred_bytes) { // all control complete is successful !! - dcd_xfer_complete(rhport, 0, 0, true); + dcd_xfer_complete(rhport, 0, xferred_bytes, true); } /*------------------------------------------------------------------*/ diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c index d449c6389..2df7d49c6 100644 --- a/tinyusb/device/usbd.c +++ b/tinyusb/device/usbd.c @@ -556,12 +556,12 @@ void dcd_xfer_complete(uint8_t rhport, uint8_t ep_addr, uint32_t xferred_bytes, { if (ep_addr == 0 ) { + // Control Transfer (void) rhport; - (void) xferred_bytes; (void) succeeded; - // Control Transfer - osal_semaphore_post( _usbd_ctrl_sem ); + // only signal data stage, skip status (zero byte) + if (xferred_bytes) osal_semaphore_post( _usbd_ctrl_sem ); }else { usbd_task_event_t task_event = diff --git a/tinyusb/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c b/tinyusb/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c index 7e15eb920..ef586c9e3 100644 --- a/tinyusb/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c +++ b/tinyusb/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c @@ -475,7 +475,7 @@ void hal_dcd_isr(uint8_t rhport) bool succeeded = ( p_qtd->xact_err || p_qtd->halted || p_qtd->buffer_err ) ? false : true; (void) succeeded; - dcd_control_complete(rhport); + dcd_control_complete(rhport, p_qtd->expected_bytes - p_qtd->total_bytes); } }