NANO100_BSP V3.04.002
The Board Support Package for Nano100BN Series
Data Structures | Macros | Typedefs | Functions | Variables
usbd.h File Reference

NANO100 series USB driver header file. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  s_usbd_info
 

Macros

#define USBD_BUF_BASE   (USBD_BASE+0x100)
 
#define USBD_MAX_EP   8
 
#define EP0   0
 
#define EP1   1
 
#define EP2   2
 
#define EP3   3
 
#define EP4   4
 
#define EP5   5
 
#define EP6   6
 
#define EP7   7
 
#define USBD_WAKEUP_EN   USBD_CTL_WAKEUP_EN_Msk
 
#define USBD_DRVSE0   USBD_CTL_DRVSE0_Msk
 
#define USBD_DPPU_EN   USBD_CTL_DPPU_EN_Msk
 
#define USBD_PWRDN   USBD_CTL_PWRDB_Msk
 
#define USBD_PHY_EN   USBD_CTL_PHY_EN_Msk
 
#define USBD_USB_EN   USBD_CTL_USB_EN_Msk
 
#define USBD_INT_BUS   USBD_INTEN_BUSEVT_IE_Msk
 
#define USBD_INT_USB   USBD_INTEN_USBEVT_IE_Msk
 
#define USBD_INT_FLDET   USBD_INTEN_FLDET_IE_Msk
 
#define USBD_INT_WAKEUP   USBD_INTEN_WAKEUP_IE_Msk
 
#define USBD_INTSTS_WAKEUP   USBD_INTSTS_WKEUP_STS_Msk
 
#define USBD_INTSTS_FLDET   USBD_INTSTS_FLD_STS_Msk
 
#define USBD_INTSTS_BUS   USBD_INTSTS_BUS_STS_Msk
 
#define USBD_INTSTS_USB   USBD_INTSTS_USB_STS_Msk
 
#define USBD_INTSTS_SETUP   USBD_INTSTS_SETUP_Msk
 
#define USBD_INTSTS_EP0   USBD_INTSTS_EPEVT0_Msk
 
#define USBD_INTSTS_EP1   USBD_INTSTS_EPEVT1_Msk
 
#define USBD_INTSTS_EP2   USBD_INTSTS_EPEVT2_Msk
 
#define USBD_INTSTS_EP3   USBD_INTSTS_EPEVT3_Msk
 
#define USBD_INTSTS_EP4   USBD_INTSTS_EPEVT4_Msk
 
#define USBD_INTSTS_EP5   USBD_INTSTS_EPEVT5_Msk
 
#define USBD_INTSTS_EP6   USBD_INTSTS_EPEVT6_Msk
 
#define USBD_INTSTS_EP7   USBD_INTSTS_EPEVT7_Msk
 
#define USBD_STATE_USBRST   USBD_BUSSTS_USBRST_Msk
 
#define USBD_STATE_SUSPEND   USBD_BUSSTS_SUSPEND_Msk
 
#define USBD_STATE_RESUME   USBD_BUSSTS_RESUME_Msk
 
#define USBD_STATE_TIMEOUT   USBD_BUSSTS_TIMEOUT_Msk
 
#define USBD_CFG_SSTALL   USBD_CFG_SSTALL_Msk
 
#define USBD_CFG_CSTALL   USBD_CFG_CSTALL_Msk
 
#define USBD_CFG_EPMODE_DISABLE   (0ul << USBD_CFG_EPMODE_Pos)
 
#define USBD_CFG_EPMODE_OUT   (1ul << USBD_CFG_EPMODE_Pos)
 
#define USBD_CFG_EPMODE_IN   (2ul << USBD_CFG_EPMODE_Pos)
 
#define USBD_CFG_TYPE_ISO   (1ul << USBD_CFG_ISOCH_Pos)
 
#define Maximum(a, b)   ((a)>(b) ? (a) : (b))
 Compare two input numbers and return maximum one. More...
 
#define Minimum(a, b)   ((a)<(b) ? (a) : (b))
 Compare two input numbers and return minimum one. More...
 
#define USBD_ENABLE_USB()   ((uint32_t)(USBD->CTL |= 0xF))
 Enable USBD engine. More...
 
#define USBD_DISABLE_USB()   ((uint32_t)(USBD->CTL &= ~USBD_USB_EN))
 Disable USBD engine. More...
 
#define USBD_ENABLE_PHY()   ((uint32_t)(USBD->CTL |= USBD_PHY_EN))
 Enable USBD PHY. More...
 
#define USBD_DISABLE_PHY()   ((uint32_t)(USBD->CTL &= ~USBD_PHY_EN))
 Disable USBD PHY. More...
 
#define USBD_SET_SE0()   ((uint32_t)(USBD->CTL |= USBD_DRVSE0))
 Force USB PHY Transceiver to Drive SE0. More...
 
#define USBD_CLR_SE0()   ((uint32_t)(USBD->CTL &= ~USBD_DRVSE0))
 Release SE0. More...
 
#define USBD_SET_ADDR(addr)   (USBD->FADDR = (addr))
 Set USBD address. More...
 
#define USBD_GET_ADDR()   ((uint32_t)(USBD->FADDR))
 Get USBD address. More...
 
#define USBD_ENABLE_INT(intr)   (USBD->INTEN |= (intr))
 Enable USBD interrupt. More...
 
#define USBD_GET_INT_FLAG()   ((uint32_t)(USBD->INTSTS))
 Get USBD interrupt flag. More...
 
#define USBD_CLR_INT_FLAG(flag)   (USBD->INTSTS = flag)
 Clear USBD interrupt. More...
 
#define USBD_GET_EP_FLAG()   ((uint32_t)(USBD->EPSTS))
 Get USBD Endpoint status. More...
 
#define USBD_GET_BUS_STATE()   ((uint32_t)(USBD->BUSSTS & 0xf))
 Get USBD bus state. More...
 
#define USBD_IS_ATTACHED()   ((uint32_t)(USBD->BUSSTS & USBD_BUSSTS_FLDET_Msk))
 check cable connect state More...
 
#define USBD_STOP_TRANSACTION(ep)   (*((__IO uint32_t *) ((uint32_t)&USBD->EP[0].CFG + (uint32_t)((ep) << 4))) |= USBD_CFG_CLRRDY_Msk)
 Stop USB endpoint transaction. More...
 
#define USBD_SET_DATA1(ep)   (*((__IO uint32_t *) ((uint32_t)&USBD->EP[0].CFG + (uint32_t)((ep) << 4))) |= USBD_CFG_DSQ_SYNC_Msk)
 Set USB data1 token. More...
 
#define USBD_SET_DATA0(ep)   (*((__IO uint32_t *) ((uint32_t)&USBD->EP[0].CFG + (uint32_t)((ep) << 4))) &= (~USBD_CFG_DSQ_SYNC_Msk))
 Set USB data0 token. More...
 
#define USBD_SET_PAYLOAD_LEN(ep, size)   (*((__IO uint32_t *) ((uint32_t)&USBD->EP[0].MXPLD + (uint32_t)((ep) << 4))) = (size))
 Set USB payload size (IN data) More...
 
#define USBD_GET_PAYLOAD_LEN(ep)   ((uint32_t)*((__IO uint32_t *) ((uint32_t)&USBD->EP[0].MXPLD + (uint32_t)((ep) << 4))))
 Get USB payload size (OUT data) More...
 
#define USBD_CONFIG_EP(ep, config)   (*((__IO uint32_t *) ((uint32_t)&USBD->EP[0].CFG + (uint32_t)((ep) << 4))) = (config))
 config endpoint More...
 
#define USBD_SET_EP_BUF_ADDR(ep, offset)   (*((__IO uint32_t *) ((uint32_t)&USBD->EP[0].BUFSEG + (uint32_t)((ep) << 4))) = (offset))
 Set buffer for USB endpoint. More...
 
#define USBD_GET_EP_BUF_ADDR(ep)   ((uint32_t)*((__IO uint32_t *) ((uint32_t)&USBD->EP[0].BUFSEG + (uint32_t)((ep) << 4))))
 Get buffer for USB endpoint. More...
 
#define USBD_SET_EP_STALL(ep)   (*((__IO uint32_t *) ((uint32_t)&USBD->EP[0].CFG + (uint32_t)((ep) << 4))) |= USBD_CFG_SSTALL_Msk)
 Set USB endpoint stall state. More...
 
#define USBD_CLR_EP_STALL(ep)   (*((__IO uint32_t *) ((uint32_t)&USBD->EP[0].CFG + (uint32_t)((ep) << 4))) &= ~USBD_CFG_SSTALL_Msk)
 Clear USB endpoint stall state. More...
 
#define USBD_GET_EP_STALL(ep)   (*((__IO uint32_t *) ((uint32_t)&USBD->EP[0].CFG + (uint32_t)((ep) << 4))) & USBD_CFG_SSTALL_Msk)
 Get USB endpoint stall state. More...
 

Typedefs

typedef struct s_usbd_info S_USBD_INFO_T
 
typedef void(* VENDOR_REQ) (void)
 
typedef void(* CLASS_REQ) (void)
 
typedef void(* SET_INTERFACE_REQ) (uint32_t u32AltInterface)
 
typedef void(* SET_CONFIG_CB) (void)
 

Functions

static __INLINE void USBD_MemCopy (uint8_t *dest, uint8_t *src, int32_t size)
 To support byte access between USB SRAM and system SRAM. More...
 
static __INLINE void USBD_SetStall (uint8_t epnum)
 Set USB endpoint stall state. More...
 
static __INLINE void USBD_ClearStall (uint8_t epnum)
 Clear USB endpoint stall state. More...
 
static __INLINE uint32_t USBD_GetStall (uint8_t epnum)
 Get USB endpoint stall state. More...
 
void USBD_Open (S_USBD_INFO_T *param, CLASS_REQ pfnClassReq, SET_INTERFACE_REQ pfnSetInterface)
 USBD Initial, Enable clock and reset USB. More...
 
void USBD_Start (void)
 USBD Start. More...
 
void USBD_GetSetupPacket (uint8_t *buf)
 Get Setup Packet. More...
 
void USBD_ProcessSetupPacket (void)
 Process Setup Packet. More...
 
void USBD_StandardRequest (void)
 Process USB standard request. More...
 
void USBD_PrepareCtrlIn (uint8_t *pu8Buf, uint32_t u32Size)
 Prepare Control IN transaction. More...
 
void USBD_CtrlIn (void)
 Start Control IN transfer. More...
 
void USBD_PrepareCtrlOut (uint8_t *pu8Buf, uint32_t u32Size)
 Prepare Control OUT transaction. More...
 
void USBD_CtrlOut (void)
 Start Control OUT transfer. More...
 
void USBD_SwReset (void)
 Clear all software flags. More...
 
void USBD_SetVendorRequest (VENDOR_REQ pfnVendorReq)
 USBD Set Vendor Request. More...
 
void USBD_SetConfigCallback (SET_CONFIG_CB pfnSetConfigCallback)
 The callback function which called when get SET CONFIGURATION request. More...
 
void USBD_LockEpStall (uint32_t u32EpBitmap)
 

Variables

volatile uint8_t g_usbd_RemoteWakeupEn
 

Detailed Description

NANO100 series USB driver header file.

Version
2.0.0
Date
20, September, 2014
Note
SPDX-License-Identifier: Apache-2.0 Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved.

Definition in file usbd.h.