![]() |
M480 BSP
V3.05.001
The Board Support Package for M480 Series
|
Macros | |
| #define | USBD_Maximum(a, b) |
| Compare two input numbers and return maximum one. More... | |
| #define | USBD_Minimum(a, b) |
| Compare two input numbers and return minimum one. More... | |
| #define | USBD_ENABLE_USB() |
| Enable USB. More... | |
| #define | USBD_DISABLE_USB() |
| Disable USB. More... | |
| #define | USBD_ENABLE_PHY() |
| Enable USB PHY. More... | |
| #define | USBD_DISABLE_PHY() |
| Disable USB PHY. More... | |
| #define | USBD_SET_SE0() |
| Enable SE0. Force USB PHY transceiver to drive SE0. More... | |
| #define | USBD_CLR_SE0() |
| Disable SE0. More... | |
| #define | USBD_SET_ADDR(addr) |
| Set USB device address. More... | |
| #define | USBD_GET_ADDR() |
| Get USB device address. More... | |
| #define | USBD_ENABLE_INT(intr) |
| Enable USB interrupt function. More... | |
| #define | USBD_GET_INT_FLAG() |
| Get interrupt status. More... | |
| #define | USBD_CLR_INT_FLAG(flag) |
| Clear USB interrupt flag. More... | |
| #define | USBD_GET_EP_FLAG() |
| Get endpoint status. More... | |
| #define | USBD_GET_BUS_STATE() |
| Get USB bus state. More... | |
| #define | USBD_IS_ATTACHED() |
| Check cable connection state. More... | |
| #define | USBD_STOP_TRANSACTION(ep) |
| Stop USB transaction of the specified endpoint ID. More... | |
| #define | USBD_SET_DATA1(ep) |
| Set USB DATA1 PID for the specified endpoint ID. More... | |
| #define | USBD_SET_DATA0(ep) |
| Set USB DATA0 PID for the specified endpoint ID. More... | |
| #define | USBD_SET_PAYLOAD_LEN(ep, size) |
| Set USB payload size (IN data) More... | |
| #define | USBD_GET_PAYLOAD_LEN(ep) |
| Get USB payload size (OUT data) More... | |
| #define | USBD_CONFIG_EP(ep, config) |
| Configure endpoint. More... | |
| #define | USBD_SET_EP_BUF_ADDR(ep, offset) |
| Set USB endpoint buffer. More... | |
| #define | USBD_GET_EP_BUF_ADDR(ep) |
| Get the offset of the specified USB endpoint buffer. More... | |
| #define | USBD_SET_EP_STALL(ep) |
| Set USB endpoint stall state. More... | |
| #define | USBD_CLR_EP_STALL(ep) |
| Clear USB endpoint stall state. More... | |
| #define | USBD_GET_EP_STALL(ep) |
| Get USB endpoint stall state. More... | |
Typedefs | |
| 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[], uint32_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 (const S_USBD_INFO_T *param, CLASS_REQ pfnClassReq, SET_INTERFACE_REQ pfnSetInterface) |
| This function makes USBD module to be ready to use. More... | |
| void | USBD_Start (void) |
| This function makes USB host to recognize the device. More... | |
| void | USBD_GetSetupPacket (uint8_t *buf) |
| Get the received SETUP packet. More... | |
| void | USBD_ProcessSetupPacket (void) |
| Process SETUP packet. More... | |
| void | USBD_StandardRequest (void) |
| Process standard request. More... | |
| void | USBD_PrepareCtrlIn (uint8_t pu8Buf[], uint32_t u32Size) |
| Prepare the first Control IN pipe. More... | |
| void | USBD_CtrlIn (void) |
| Repeat Control IN pipe. More... | |
| void | USBD_PrepareCtrlOut (uint8_t *pu8Buf, uint32_t u32Size) |
| Prepare the first Control OUT pipe. More... | |
| void | USBD_CtrlOut (void) |
| Repeat Control OUT pipe. More... | |
| void | USBD_SwReset (void) |
| Reset 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) |
| EP stall lock function to avoid stall clear by USB SET FEATURE request. More... | |
| void | USBD_GetDescriptor (void) |
| Process GetDescriptor request. More... | |
Variables | |
| volatile uint8_t | g_usbd_RemoteWakeupEn |
| uint8_t | g_usbd_SetupPacket [8] = {0ul} |
| volatile uint8_t | g_usbd_RemoteWakeupEn = 0ul |
| const S_USBD_INFO_T * | g_usbd_sInfo |
| VENDOR_REQ | g_usbd_pfnVendorRequest = NULL |
| CLASS_REQ | g_usbd_pfnClassRequest = NULL |
| SET_INTERFACE_REQ | g_usbd_pfnSetInterface = NULL |
| SET_CONFIG_CB | g_usbd_pfnSetConfigCallback = NULL |
| uint32_t | g_u32EpStallLock = 0ul |
| #define USBD_CLR_EP_STALL | ( | ep | ) |
| #define USBD_CLR_INT_FLAG | ( | flag | ) |
Clear USB interrupt flag.
| [in] | flag | The combination of the specified interrupt flags. Each bit corresponds to a interrupt source. This parameter decides which interrupt flags will be cleared. (USBD_INTSTS_WAKEUP, USBD_INTSTS_FLDET, USBD_INTSTS_BUS, USBD_INTSTS_USB) |
Clear USB related interrupt flags specified by flag parameter.
| #define USBD_CLR_SE0 | ( | ) |
| #define USBD_CONFIG_EP | ( | ep, | |
| config | |||
| ) |
Configure endpoint.
| [in] | ep | The USB endpoint ID. M480 Series supports 8 hardware endpoint ID. This parameter could be 0 ~ 11. |
| [in] | config | The USB configuration. |
This macro will write config parameter to USB_CFGx register of specified endpoint ID.
| #define USBD_DISABLE_PHY | ( | ) |
| #define USBD_DISABLE_USB | ( | ) |
| #define USBD_ENABLE_INT | ( | intr | ) |
Enable USB interrupt function.
| [in] | intr | The combination of the specified interrupt enable bits. Each bit corresponds to a interrupt enable bit. This parameter decides which interrupts will be enabled. (USBD_INT_WAKEUP, USBD_INT_FLDET, USBD_INT_USB, USBD_INT_BUS) |
Enable USB related interrupt functions specified by intr parameter.
| #define USBD_ENABLE_PHY | ( | ) |
| #define USBD_ENABLE_USB | ( | ) |
| #define USBD_GET_ADDR | ( | ) |
| #define USBD_GET_BUS_STATE | ( | ) |
Get USB bus state.
| None |
Return USB_ATTR[3:0] for USB bus events.
| #define USBD_GET_EP_BUF_ADDR | ( | ep | ) |
Get the offset of the specified USB endpoint buffer.
| [in] | ep | The USB endpoint ID. M480 Series supports 8 hardware endpoint ID. This parameter could be 0 ~ 11. |
This macro will return the SRAM offset of the specified endpoint ID.
| #define USBD_GET_EP_FLAG | ( | ) |
| #define USBD_GET_EP_STALL | ( | ep | ) |
Get USB endpoint stall state.
| [in] | ep | The USB endpoint ID. M480 Series supports 8 hardware endpoint ID. This parameter could be 0 ~ 11. |
| 0 | USB endpoint is not stalled. |
| Others | USB endpoint is stalled. |
Get USB endpoint stall state of the specified endpoint ID.
| #define USBD_GET_INT_FLAG | ( | ) |
| #define USBD_GET_PAYLOAD_LEN | ( | ep | ) |
| #define USBD_IS_ATTACHED | ( | ) |
| #define USBD_Maximum | ( | a, | |
| b | |||
| ) |
| #define USBD_Minimum | ( | a, | |
| b | |||
| ) |
| #define USBD_SET_ADDR | ( | addr | ) |
| #define USBD_SET_DATA0 | ( | ep | ) |
Set USB DATA0 PID for the specified endpoint ID.
| [in] | ep | The USB endpoint ID. M480 Series supports 8 hardware endpoint ID. This parameter could be 0 ~ 11. |
Clear DSQ_SYNC bit of USB_CFGx register to specify the DATA0 PID for the following IN token transaction. Base on this setting, hardware will toggle PID between DATA0 and DATA1 automatically for IN token transactions.
| #define USBD_SET_DATA1 | ( | ep | ) |
Set USB DATA1 PID for the specified endpoint ID.
| [in] | ep | The USB endpoint ID. M480 Series supports 8 hardware endpoint ID. This parameter could be 0 ~ 11. |
Set DSQ_SYNC bit of USB_CFGx register to specify the DATA1 PID for the following IN token transaction. Base on this setting, hardware will toggle PID between DATA0 and DATA1 automatically for IN token transactions.
| #define USBD_SET_EP_BUF_ADDR | ( | ep, | |
| offset | |||
| ) |
| #define USBD_SET_EP_STALL | ( | ep | ) |
Set USB endpoint stall state.
| [in] | ep | The USB endpoint ID. M480 Series supports 8 hardware endpoint ID. This parameter could be 0 ~ 11. |
Set USB endpoint stall state for the specified endpoint ID. Endpoint will respond STALL token automatically.
| #define USBD_SET_PAYLOAD_LEN | ( | ep, | |
| size | |||
| ) |
Set USB payload size (IN data)
| [in] | ep | The USB endpoint ID. M480 Series supports 8 hardware endpoint ID. This parameter could be 0 ~ 11. |
| [in] | size | The transfer length. |
This macro will write the transfer length to USB_MXPLDx register for IN data transaction.
| #define USBD_SET_SE0 | ( | ) |
| #define USBD_STOP_TRANSACTION | ( | ep | ) |
Stop USB transaction of the specified endpoint ID.
| [in] | ep | The USB endpoint ID. M480 Series supports 8 hardware endpoint ID. This parameter could be 0 ~ 11. |
Write 1 to CLRRDY bit of USB_CFGPx register to stop USB transaction of the specified endpoint ID.
| typedef void(* CLASS_REQ) (void) |
| typedef void(* SET_CONFIG_CB) (void) |
| typedef void(* SET_INTERFACE_REQ) (uint32_t u32AltInterface) |
| typedef void(* VENDOR_REQ) (void) |
| __STATIC_INLINE void USBD_ClearStall | ( | uint8_t | epnum | ) |
| void USBD_CtrlIn | ( | void | ) |
| void USBD_CtrlOut | ( | void | ) |
| void USBD_GetDescriptor | ( | void | ) |
| void USBD_GetSetupPacket | ( | uint8_t * | buf | ) |
| __STATIC_INLINE uint32_t USBD_GetStall | ( | uint8_t | epnum | ) |
| void USBD_LockEpStall | ( | uint32_t | u32EpBitmap | ) |
EP stall lock function to avoid stall clear by USB SET FEATURE request.
| [in] | u32EpBitmap | Use bitmap to select which endpoints will be locked |
This function is used to lock relative endpoint to avoid stall clear by SET FEATURE request. If ep stall locked, user needs to reset USB device or re-configure device to clear it.
| __STATIC_INLINE void USBD_MemCopy | ( | uint8_t | dest[], |
| uint8_t | src[], | ||
| uint32_t | size | ||
| ) |
To support byte access between USB SRAM and system SRAM.
| [in] | dest | Destination pointer. |
| [in] | src | Source pointer. |
| [in] | size | Byte count. |
This function will copy the number of data specified by size and src parameters to the address specified by dest parameter.
| void USBD_Open | ( | const S_USBD_INFO_T * | param, |
| CLASS_REQ | pfnClassReq, | ||
| SET_INTERFACE_REQ | pfnSetInterface | ||
| ) |
This function makes USBD module to be ready to use.
| [in] | param | The structure of USBD information. |
| [in] | pfnClassReq | USB Class request callback function. |
| [in] | pfnSetInterface | USB Set Interface request callback function. |
This function will enable USB controller, USB PHY transceiver and pull-up resistor of USB_D+ pin. USB PHY will drive SE0 to bus.
| void USBD_PrepareCtrlIn | ( | uint8_t | pu8Buf[], |
| uint32_t | u32Size | ||
| ) |
| void USBD_PrepareCtrlOut | ( | uint8_t * | pu8Buf, |
| uint32_t | u32Size | ||
| ) |
| void USBD_ProcessSetupPacket | ( | void | ) |
| void USBD_SetConfigCallback | ( | SET_CONFIG_CB | pfnSetConfigCallback | ) |
The callback function which called when get SET CONFIGURATION request.
| [in] | pfnSetConfigCallback | Callback function pointer for SET CONFIGURATION request |
This function is used to set the callback function which will be called at SET CONFIGURATION request.
| __STATIC_INLINE void USBD_SetStall | ( | uint8_t | epnum | ) |
| void USBD_SetVendorRequest | ( | VENDOR_REQ | pfnVendorReq | ) |
| void USBD_StandardRequest | ( | void | ) |
| void USBD_Start | ( | void | ) |
| void USBD_SwReset | ( | void | ) |
| uint32_t g_u32EpStallLock = 0ul |
| SET_CONFIG_CB g_usbd_pfnSetConfigCallback = NULL |
| SET_INTERFACE_REQ g_usbd_pfnSetInterface = NULL |
| VENDOR_REQ g_usbd_pfnVendorRequest = NULL |
| volatile uint8_t g_usbd_RemoteWakeupEn = 0ul |
| volatile uint8_t g_usbd_RemoteWakeupEn |
| const S_USBD_INFO_T* g_usbd_sInfo |
1.8.15