30#define HSUSBD_MAX_EP 12ul
32#define Maximum(a,b) (a)>(b) ? (a) : (b)
33#define Minimum(a,b) (((a)<(b)) ? (a) : (b))
52#define HSUSBD_CEPCTL_NAKCLR ((uint32_t)0x00000000ul)
53#define HSUSBD_CEPCTL_STALL ((uint32_t)0x00000002ul)
54#define HSUSBD_CEPCTL_ZEROLEN ((uint32_t)0x00000004ul)
55#define HSUSBD_CEPCTL_FLUSH ((uint32_t)0x00000008ul)
58#define HSUSBD_EP_RSPCTL_FLUSH ((uint32_t)0x00000001ul)
59#define HSUSBD_EP_RSPCTL_MODE_AUTO ((uint32_t)0x00000000ul)
60#define HSUSBD_EP_RSPCTL_MODE_MANUAL ((uint32_t)0x00000002ul)
61#define HSUSBD_EP_RSPCTL_MODE_FLY ((uint32_t)0x00000004ul)
62#define HSUSBD_EP_RSPCTL_MODE_MASK ((uint32_t)0x00000006ul)
63#define HSUSBD_EP_RSPCTL_TOGGLE ((uint32_t)0x00000008ul)
64#define HSUSBD_EP_RSPCTL_HALT ((uint32_t)0x00000010ul)
65#define HSUSBD_EP_RSPCTL_ZEROLEN ((uint32_t)0x00000020ul)
66#define HSUSBD_EP_RSPCTL_SHORTTXEN ((uint32_t)0x00000040ul)
67#define HSUSBD_EP_RSPCTL_DISBUF ((uint32_t)0x00000080ul)
70#define HSUSBD_EP_CFG_VALID ((uint32_t)0x00000001ul)
71#define HSUSBD_EP_CFG_TYPE_BULK ((uint32_t)0x00000002ul)
72#define HSUSBD_EP_CFG_TYPE_INT ((uint32_t)0x00000004ul)
73#define HSUSBD_EP_CFG_TYPE_ISO ((uint32_t)0x00000006ul)
74#define HSUSBD_EP_CFG_TYPE_MASK ((uint32_t)0x00000006ul)
75#define HSUSBD_EP_CFG_DIR_OUT ((uint32_t)0x00000000ul)
76#define HSUSBD_EP_CFG_DIR_IN ((uint32_t)0x00000008ul)
118extern uint32_t g_u32HsEpStallLock;
119extern uint8_t
volatile g_hsusbd_Configured;
120extern uint8_t g_hsusbd_ShortPacket;
121extern uint8_t g_hsusbd_CtrlZero;
122extern uint8_t g_hsusbd_UsbAddr;
123extern uint32_t
volatile g_hsusbd_DmaDone;
124extern uint32_t g_hsusbd_CtrlInSize;
133#define HSUSBD_ENABLE_USB() ((uint32_t)(HSUSBD->PHYCTL |= (HSUSBD_PHYCTL_PHYEN_Msk|HSUSBD_PHYCTL_DPPUEN_Msk)))
134#define HSUSBD_DISABLE_USB() ((uint32_t)(HSUSBD->PHYCTL &= ~HSUSBD_PHYCTL_DPPUEN_Msk))
135#define HSUSBD_ENABLE_PHY() ((uint32_t)(HSUSBD->PHYCTL |= HSUSBD_PHYCTL_PHYEN_Msk))
136#define HSUSBD_DISABLE_PHY() ((uint32_t)(HSUSBD->PHYCTL &= ~HSUSBD_PHYCTL_PHYEN_Msk))
137#define HSUSBD_SET_SE0() ((uint32_t)(HSUSBD->PHYCTL &= ~HSUSBD_PHYCTL_DPPUEN_Msk))
138#define HSUSBD_CLR_SE0() ((uint32_t)(HSUSBD->PHYCTL |= HSUSBD_PHYCTL_DPPUEN_Msk))
139#define HSUSBD_SET_ADDR(addr) (HSUSBD->FADDR = (addr))
140#define HSUSBD_GET_ADDR() ((uint32_t)(HSUSBD->FADDR))
141#define HSUSBD_ENABLE_USB_INT(intr) (HSUSBD->GINTEN = (intr))
142#define HSUSBD_ENABLE_BUS_INT(intr) (HSUSBD->BUSINTEN = (intr))
143#define HSUSBD_GET_BUS_INT_FLAG() (HSUSBD->BUSINTSTS)
144#define HSUSBD_CLR_BUS_INT_FLAG(flag) (HSUSBD->BUSINTSTS = (flag))
145#define HSUSBD_ENABLE_CEP_INT(intr) (HSUSBD->CEPINTEN = (intr))
146#define HSUSBD_CLR_CEP_INT_FLAG(flag) (HSUSBD->CEPINTSTS = (flag))
147#define HSUSBD_SET_CEP_STATE(flag) (HSUSBD->CEPCTL = (flag))
148#define HSUSBD_START_CEP_IN(size) (HSUSBD->CEPTXCNT = (size))
149#define HSUSBD_SET_MAX_PAYLOAD(ep, size) (HSUSBD->EP[(ep)].EPMPS = (size))
150#define HSUSBD_ENABLE_EP_INT(ep, intr) (HSUSBD->EP[(ep)].EPINTEN = (intr))
151#define HSUSBD_GET_EP_INT_FLAG(ep) (HSUSBD->EP[(ep)].EPINTSTS)
152#define HSUSBD_CLR_EP_INT_FLAG(ep, flag) (HSUSBD->EP[(ep)].EPINTSTS = (flag))
153#define HSUSBD_SET_DMA_LEN(len) (HSUSBD->DMACNT = (len))
154#define HSUSBD_SET_DMA_ADDR(addr) (HSUSBD->DMAADDR = (addr))
155#define HSUSBD_SET_DMA_READ(epnum) (HSUSBD->DMACTL = (HSUSBD->DMACTL & ~HSUSBD_DMACTL_EPNUM_Msk) | HSUSBD_DMACTL_DMARD_Msk | (epnum) | 0x100)
156#define HSUSBD_SET_DMA_WRITE(epnum) (HSUSBD->DMACTL = (HSUSBD->DMACTL & ~(HSUSBD_DMACTL_EPNUM_Msk | HSUSBD_DMACTL_DMARD_Msk | 0x100)) | (epnum))
157#define HSUSBD_ENABLE_DMA() (HSUSBD->DMACTL |= HSUSBD_DMACTL_DMAEN_Msk)
158#define HSUSBD_IS_ATTACHED() ((uint32_t)(HSUSBD->PHYCTL & HSUSBD_PHYCTL_VBUSDET_Msk))
167__STATIC_INLINE
void HSUSBD_MemCopy(uint8_t u8Dst[], uint8_t u8Src[], uint32_t u32Size)
200 HSUSBD->CEPBUFST = u32Base;
201 HSUSBD->CEPBUFEND = u32Base + u32Len - 1ul;
205 HSUSBD->EP[u32Ep].EPBUFST = u32Base;
206 HSUSBD->EP[u32Ep].EPBUFEND = u32Base + u32Len - 1ul;
218__STATIC_INLINE
void HSUSBD_ConfigEp(uint32_t u32Ep, uint32_t u32EpNum, uint32_t u32EpType, uint32_t u32EpDir)
272 for (i=0ul; i<HSUSBD_MAX_EP; i++)
274 if (((
HSUSBD->EP[i].EPCFG & 0xf0ul) >> 4) == u32EpNum)
305 for (i=0ul; i<HSUSBD_MAX_EP; i++)
307 if (((
HSUSBD->EP[i].EPCFG & 0xf0ul) >> 4) == u32EpNum)
340 for (i=0ul; i<HSUSBD_MAX_EP; i++)
342 if (((
HSUSBD->EP[i].EPCFG & 0xf0ul) >> 4) == u32EpNum)
#define HSUSBD_EP_CFG_TYPE_INT
#define HSUSBD_EP_RSPCTL_TOGGLE
#define HSUSBD_EP_RSPCTL_FLUSH
#define HSUSBD_EP_CFG_TYPE_ISO
#define HSUSBD_EP_RSPCTL_MODE_FLY
#define HSUSBD_EP_RSPCTL_MODE_AUTO
#define HSUSBD_EP_CFG_VALID
#define HSUSBD_EP_RSPCTL_HALT
#define HSUSBD_EP_CFG_TYPE_BULK
#define HSUSBD_CEPCTL_STALL
#define HSUSBD_EP_RSPCTL_MODE_MANUAL
__STATIC_INLINE void HSUSBD_ClearEpStall(uint32_t u32Ep)
Clear USB endpoint stall state.
uint8_t * gu8FSOtherConfigDesc
void(* HSUSBD_CLASS_REQ)(void)
__STATIC_INLINE void HSUSBD_SetEpBufAddr(uint32_t u32Ep, uint32_t u32Base, uint32_t u32Len)
HSUSBD_SetEpBufAddr, Set Endpoint buffer address.
void HSUSBD_PrepareCtrlIn(uint8_t pu8Buf[], uint32_t u32Size)
Prepare Control IN transaction.
__STATIC_INLINE void HSUSBD_ConfigEp(uint32_t u32Ep, uint32_t u32EpNum, uint32_t u32EpType, uint32_t u32EpDir)
HSUSBD_ConfigEp, Config Endpoint.
void HSUSBD_ProcessSetupPacket(void)
Process Setup Packet.
__STATIC_INLINE void HSUSBD_MemCopy(uint8_t u8Dst[], uint8_t u8Src[], uint32_t u32Size)
HSUSBD_memcpy, Copy bytes hardware limitation.
void HSUSBD_Start(void)
HSUSBD Start.
__STATIC_INLINE void HSUSBD_ClearStall(uint32_t u32EpNum)
Clear USB endpoint stall state.
__STATIC_INLINE uint32_t HSUSBD_GetStall(uint32_t u32EpNum)
Get USB endpoint stall state.
uint32_t * gu32ConfigHidDescIdx
void HSUSBD_Open(S_HSUSBD_INFO_T *param, HSUSBD_CLASS_REQ pfnClassReq, HSUSBD_SET_INTERFACE_REQ pfnSetInterface)
HSUSBD Initial.
void HSUSBD_StandardRequest(void)
Process USB standard request.
uint8_t * gu8FullConfigDesc
__STATIC_INLINE void HSUSBD_SetStall(uint32_t u32EpNum)
Set USB endpoint stall state.
__STATIC_INLINE void HSUSBD_SetEpStall(uint32_t u32Ep)
Set USB endpoint stall state.
void(* HSUSBD_SET_INTERFACE_REQ)(uint32_t u32AltInterface)
__STATIC_INLINE void HSUSBD_ResetDMA(void)
HSUSBD_ResetDMA.
void HSUSBD_CtrlOut(uint8_t pu8Buf[], uint32_t u32Size)
Start Control OUT transaction.
uint8_t ** gu8HidReportDesc
void HSUSBD_SwReset(void)
Clear all software flags.
uint8_t * gu8HSOtherConfigDesc
#define HSUSBD_SET_CEP_STATE(flag)
void HSUSBD_SetVendorRequest(HSUSBD_VENDOR_REQ pfnVendorReq)
HSUSBD Set Vendor Request.
uint32_t * gu32HidReportSize
void(* HSUSBD_VENDOR_REQ)(void)
__STATIC_INLINE uint32_t HSUSBD_GetEpStall(uint32_t u32Ep)
Get USB endpoint stall state.
void HSUSBD_CtrlIn(void)
Start Control IN transfer.
void HSUSBD_UpdateDeviceState(void)
Update Device State.
struct s_hsusbd_info S_HSUSBD_INFO_T
struct HSUSBD_CMD_STRUCT S_HSUSBD_CMD_T