Skip to content

Commit 0ecb9bd

Browse files
committed
Nuvoton HUSBD support endpoint write ZLP
1 parent 7049bfc commit 0ecb9bd

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

targets/TARGET_NUVOTON/USBEndpoints_Nuvoton.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,11 +915,13 @@ static volatile int epComplete = 0;
915915
#define HSUSBD_GET_EP_MAX_PAYLOAD(ep) HSUSBD->EP[ep].EPMPS
916916
#define HSUSBD_GET_EP_DATA_COUNT(ep) (HSUSBD->EP[ep].EPDATCNT & 0xFFFFF)
917917
#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)
918919
#define HSUSBD_GET_EP_INT_EN(ep) HSUSBD->EP[ep].EPINTEN
919920
#elif defined (TARGET_NUC472)
920921
#define USBD_GET_EP_MAX_PAYLOAD(ep) *((__IO uint32_t *) ((uint32_t)&USBD->EPAMPS + (uint32_t)(ep*0x28)))
921922
#define USBD_GET_EP_DATA_COUNT(ep) *((__IO uint32_t *) ((uint32_t)&USBD->EPADATCNT + (uint32_t)(ep*0x28)))
922923
#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 HSUSBD_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)
923925
#define USBD_SET_EP_BUF_FLUSH(ep) *((__IO uint32_t *) ((uint32_t)&USBD->EPARSPCTL + (uint32_t)(ep*0x28))) = USBD_EPRSPCTL_FLUSH_Msk
924926
#define USBD_GET_EP_INT_EN(ep) *((__IO uint32_t *) ((uint32_t)&USBD->EPAINTEN + (uint32_t)(ep*0x28)))
925927
#define USBD_GET_EP_INT(ep) *((__IO uint32_t *) ((uint32_t)&USBD->EPAINTSTS + (uint32_t)(ep*0x28)))
@@ -1699,6 +1701,13 @@ bool USBPhyHw::endpoint_write(usb_ep_t endpoint, uint8_t *data, uint32_t size)
16991701
if (size > mps)
17001702
return false;
17011703

1704+
/* Send Zero packet */
1705+
if (size == 0) {
1706+
HSUSBD_SET_EP_ZERO_PACKET(ep_hw_index);
1707+
HSUSBD->EP[ep_hw_index].EPINTEN |= HSUSBD_EPINTEN_TXPKIEN_Msk;
1708+
return true;
1709+
}
1710+
17021711
#if defined (TARGET_NUC472)
17031712
if(USBD_GET_EP_DATA_COUNT(ep_hw_index) & 0xFFFF)
17041713
{

0 commit comments

Comments
 (0)