@@ -915,11 +915,13 @@ static volatile int epComplete = 0;
915
915
#define HSUSBD_GET_EP_MAX_PAYLOAD (ep ) HSUSBD->EP[ep].EPMPS
916
916
#define HSUSBD_GET_EP_DATA_COUNT (ep ) (HSUSBD->EP[ep].EPDATCNT & 0xFFFFF )
917
917
#define HSUSBD_SET_EP_SHORT_PACKET (ep ) HSUSBD->EP[ep].EPRSPCTL = ((HSUSBD->EP[ep].EPRSPCTL & 0x10 ) | 0x40 )
918
+ #define HSUSBD_SET_EP_ZERO_PACKET (ep ) HSUSBD->EP[ep].EPRSPCTL = ((HSUSBD->EP[ep].EPRSPCTL & 0x10 ) | 0x20 )
918
919
#define HSUSBD_GET_EP_INT_EN (ep ) HSUSBD->EP[ep].EPINTEN
919
920
#elif defined (TARGET_NUC472)
920
921
#define USBD_GET_EP_MAX_PAYLOAD (ep ) *((__IO uint32_t *) ((uint32_t )&USBD->EPAMPS + (uint32_t )(ep*0x28 )))
921
922
#define USBD_GET_EP_DATA_COUNT (ep ) *((__IO uint32_t *) ((uint32_t )&USBD->EPADATCNT + (uint32_t )(ep*0x28 )))
922
923
#define USBD_SET_EP_SHORT_PACKET (ep ) *((__IO uint32_t *) ((uint32_t )&USBD->EPARSPCTL + (uint32_t )(ep*0x28 ))) = ((*((__IO uint32_t *)((uint32_t )&USBD->EPARSPCTL+(uint32_t )(ep*0x28 ))) & 0x10 ) | 0x40 )
924
+ #define USBD_SET_EP_ZERO_PACKET (ep ) *((__IO uint32_t *) ((uint32_t )&USBD->EPARSPCTL + (uint32_t )(ep*0x28 ))) = (*((__IO uint32_t *)((uint32_t )&USBD->EPARSPCTL+(uint32_t )(ep*0x28 ))) & 0x10 )
923
925
#define USBD_SET_EP_BUF_FLUSH (ep ) *((__IO uint32_t *) ((uint32_t )&USBD->EPARSPCTL + (uint32_t )(ep*0x28 ))) = USBD_EPRSPCTL_FLUSH_Msk
924
926
#define USBD_GET_EP_INT_EN (ep ) *((__IO uint32_t *) ((uint32_t )&USBD->EPAINTEN + (uint32_t )(ep*0x28 )))
925
927
#define USBD_GET_EP_INT (ep ) *((__IO uint32_t *) ((uint32_t )&USBD->EPAINTSTS + (uint32_t )(ep*0x28 )))
@@ -1699,6 +1701,18 @@ bool USBPhyHw::endpoint_write(usb_ep_t endpoint, uint8_t *data, uint32_t size)
1699
1701
if (size > mps)
1700
1702
return false ;
1701
1703
1704
+ /* Send Zero packet */
1705
+ if (size == 0 ) {
1706
+ #if defined (TARGET_NUC472)
1707
+ USBD_SET_EP_ZERO_PACKET (ep_hw_index);
1708
+ USBD_ENABLE_EP_INT (ep_hw_index, USBD_GET_EP_INT_EN (ep_hw_index) | USBD_EPINTEN_TXPKIEN_Msk);
1709
+ #elif defined (TARGET_M480) || defined (TARGET_M460)
1710
+ HSUSBD_SET_EP_ZERO_PACKET (ep_hw_index);
1711
+ HSUSBD->EP [ep_hw_index].EPINTEN |= HSUSBD_EPINTEN_TXPKIEN_Msk;
1712
+ #endif
1713
+ return true ;
1714
+ }
1715
+
1702
1716
#if defined (TARGET_NUC472)
1703
1717
if (USBD_GET_EP_DATA_COUNT (ep_hw_index) & 0xFFFF )
1704
1718
{
0 commit comments