SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
Macros | Functions
usb_device.h File Reference
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <types.h>
#include "reg/reg-usb.h"
Include dependency graph for usb_device.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define USB_CLASS_PER_INTERFACE   0 /* for DeviceClass */
 
#define USB_CLASS_AUDIO   1
 
#define USB_CLASS_COMM   2
 
#define USB_CLASS_HID   3
 
#define USB_CLASS_PHYSICAL   5
 
#define USB_CLASS_PRINTER   7
 
#define USB_CLASS_MASS_STORAGE   8
 
#define USB_CLASS_HUB   9
 
#define USB_CLASS_DATA   10
 
#define USB_CLASS_APP_SPEC   0xfe
 
#define USB_CLASS_VENDOR_SPEC   0xff
 
#define USB_TYPE_STANDARD   (0x00 << 5)
 
#define USB_TYPE_CLASS   (0x01 << 5)
 
#define USB_TYPE_VENDOR   (0x02 << 5)
 
#define USB_TYPE_RESERVED   (0x03 << 5)
 
#define USB_RECIP_DEVICE   0x00
 
#define USB_RECIP_INTERFACE   0x01
 
#define USB_RECIP_ENDPOINT   0x02
 
#define USB_RECIP_OTHER   0x03
 
#define USB_DIR_OUT   0
 
#define USB_DIR_IN   0x80
 
#define USB_DT_DEVICE   0x01
 
#define USB_DT_CONFIG   0x02
 
#define USB_DT_STRING   0x03
 
#define USB_DT_INTERFACE   0x04
 
#define USB_DT_ENDPOINT   0x05
 
#define USB_DT_DEVICE_QUALIFIER   0x06
 
#define USB_DT_HID   (USB_TYPE_CLASS | 0x01)
 
#define USB_DT_REPORT   (USB_TYPE_CLASS | 0x02)
 
#define USB_DT_PHYSICAL   (USB_TYPE_CLASS | 0x03)
 
#define USB_DT_HUB   (USB_TYPE_CLASS | 0x09)
 
#define USB_DT_DEVICE_SIZE   18
 
#define USB_DT_CONFIG_SIZE   9
 
#define USB_DT_INTERFACE_SIZE   9
 
#define USB_DT_ENDPOINT_SIZE   7
 
#define USB_DT_ENDPOINT_AUDIO_SIZE   9 /* Audio extension */
 
#define USB_DT_HUB_NONVAR_SIZE   7
 
#define USB_DT_HID_SIZE   9
 
#define USB_ENDPOINT_NUMBER_MASK   0x0f /* in bEndpointAddress */
 
#define USB_ENDPOINT_DIR_MASK   0x80
 
#define USB_ENDPOINT_XFERTYPE_MASK   0x03 /* in bmAttributes */
 
#define USB_ENDPOINT_XFER_CONTROL   0
 
#define USB_ENDPOINT_XFER_ISOC   1
 
#define USB_ENDPOINT_XFER_BULK   2
 
#define USB_ENDPOINT_XFER_INT   3
 
#define USB_PID_UNDEF_0   0xf0
 
#define USB_PID_OUT   0xe1
 
#define USB_PID_ACK   0xd2
 
#define USB_PID_DATA0   0xc3
 
#define USB_PID_PING   0xb4 /* USB 2.0 */
 
#define USB_PID_SOF   0xa5
 
#define USB_PID_NYET   0x96 /* USB 2.0 */
 
#define USB_PID_DATA2   0x87 /* USB 2.0 */
 
#define USB_PID_SPLIT   0x78 /* USB 2.0 */
 
#define USB_PID_IN   0x69
 
#define USB_PID_NAK   0x5a
 
#define USB_PID_DATA1   0x4b
 
#define USB_PID_PREAMBLE   0x3c /* Token mode */
 
#define USB_PID_ERR   0x3c /* USB 2.0: handshake mode */
 
#define USB_PID_SETUP   0x2d
 
#define USB_PID_STALL   0x1e
 
#define USB_PID_MDATA   0x0f /* USB 2.0 */
 
#define USB_REQ_GET_STATUS   0x00
 
#define USB_REQ_CLEAR_FEATURE   0x01
 
#define USB_REQ_SET_FEATURE   0x03
 
#define USB_REQ_SET_ADDRESS   0x05
 
#define USB_REQ_GET_DESCRIPTOR   0x06
 
#define USB_REQ_SET_DESCRIPTOR   0x07
 
#define USB_REQ_GET_CONFIGURATION   0x08
 
#define USB_REQ_SET_CONFIGURATION   0x09
 
#define USB_REQ_GET_INTERFACE   0x0A
 
#define USB_REQ_SET_INTERFACE   0x0B
 
#define USB_REQ_SYNCH_FRAME   0x0C
 
#define USBD_DEVICE_REQUESTS(x)   (((unsigned int) x <= USB_REQ_SYNCH_FRAME) ? usbd_device_requests[x] : "UNKNOWN")
 
#define USB_REQ_GET_REPORT   0x01
 
#define USB_REQ_GET_IDLE   0x02
 
#define USB_REQ_GET_PROTOCOL   0x03
 
#define USB_REQ_SET_REPORT   0x09
 
#define USB_REQ_SET_IDLE   0x0A
 
#define USB_REQ_SET_PROTOCOL   0x0B
 
#define USB_BCD_VERSION   0x0110
 
#define USB_REQ_DIRECTION_MASK   0x80
 
#define USB_REQ_TYPE_MASK   0x60
 
#define USB_REQ_RECIPIENT_MASK   0x1f
 
#define USB_REQ_DEVICE2HOST   0x80
 
#define USB_REQ_HOST2DEVICE   0x00
 
#define USB_REQ_TYPE_STANDARD   0x00
 
#define USB_REQ_TYPE_CLASS   0x20
 
#define USB_REQ_TYPE_VENDOR   0x40
 
#define USB_REQ_RECIPIENT_DEVICE   0x00
 
#define USB_REQ_RECIPIENT_INTERFACE   0x01
 
#define USB_REQ_RECIPIENT_ENDPOINT   0x02
 
#define USB_REQ_RECIPIENT_OTHER   0x03
 
#define USB_STATUS_SELFPOWERED   0x01
 
#define USB_STATUS_REMOTEWAKEUP   0x02
 
#define USB_STATUS_HALT   0x01
 
#define USB_DESCRIPTOR_TYPE_DEVICE   0x01
 
#define USB_DESCRIPTOR_TYPE_CONFIGURATION   0x02
 
#define USB_DESCRIPTOR_TYPE_STRING   0x03
 
#define USB_DESCRIPTOR_TYPE_INTERFACE   0x04
 
#define USB_DESCRIPTOR_TYPE_ENDPOINT   0x05
 
#define USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER   0x06
 
#define USB_DESCRIPTOR_TYPE_OTHER_SPEED_CONFIGURATION   0x07
 
#define USB_DESCRIPTOR_TYPE_INTERFACE_POWER   0x08
 
#define USB_DESCRIPTOR_TYPE_HID   0x21
 
#define USB_DESCRIPTOR_TYPE_REPORT   0x22
 
#define USBD_DEVICE_DESCRIPTORS(x)   (((unsigned int) x <= USB_DESCRIPTOR_TYPE_INTERFACE_POWER) ? usbd_device_descriptors[x] : "UNKNOWN")
 
#define USB_ENDPOINT_HALT   0x00
 
#define USB_DEVICE_REMOTE_WAKEUP   0x01
 
#define USB_TEST_MODE   0x02
 

Functions

static void usb_device_transfer_type_default (uint32_t addr)
 Disable all transfer types for the USB device.
 
static void usb_device_transfer_type_ctrl (uint32_t addr)
 Set the control transfer type for the USB device.
 
static void usb_device_transfer_type_iso (uint32_t addr)
 Set the ISO transfer type for the USB device.
 
static void usb_device_transfer_type_int (uint32_t addr)
 Set the interrupt transfer type for the USB device.
 
static void usb_device_transfer_type_bulk (uint32_t addr)
 Set the bulk transfer type for the USB device.
 
static void usb_device_transfer_mode_default (uint32_t addr)
 Disable all transfer modes for the USB device.
 
static void usb_device_transfer_mode_hs (uint32_t addr)
 Set the mode to High Speed (HS) for the USB device.
 
static void usb_device_transfer_mode_fs (uint32_t addr)
 Set the mode to Full Speed (FS) for the USB device.
 
static void usb_device_transfer_mode_ls (uint32_t addr)
 Set the mode to Low Speed (LS) for the USB device.
 
static void usb_device_ep0_config_ep0_default (uint32_t addr)
 Configure Endpoint 0 (EP0) in default mode for the USB device.
 
static void usb_device_ep0_config_ep0 (uint32_t addr)
 Configure Endpoint 0 (EP0) for the USB device.
 
static uint32_t usb_device_ep0_get_read_data_ready (uint32_t addr)
 Check if Endpoint 0 (EP0) has received data ready flag for the USB device.
 
static uint32_t usb_device_ep0_get_write_data_ready (uint32_t addr)
 Check if Endpoint 0 (EP0) has write data ready flag for the USB device.
 
static void usb_device_ep0_read_data_half (uint32_t addr)
 Clear the read data half flag for Endpoint 0 (EP0) of the USB device.
 
static void usb_device_ep0_read_data_complete (uint32_t addr)
 Clear the read data complete flag for Endpoint 0 (EP0) of the USB device.
 
static void usb_device_ep0_write_data_half (uint32_t addr)
 Clear the write data half flag for Endpoint 0 (EP0) of the USB device.
 
static void usb_device_ep0_write_data_complete (uint32_t addr)
 Set the write data complete flag for Endpoint 0 (EP0) of the USB device.
 
static uint32_t usb_device_ep0_get_stall (uint32_t addr)
 Check if Endpoint 0 (EP0) has the stall flag set for the USB device.
 
static void usb_device_ep0_send_stall (uint32_t addr)
 Set the send stall flag for Endpoint 0 (EP0) of the USB device.
 
static void usb_device_ep0_clear_stall (uint32_t addr)
 Clear the stall flag for Endpoint 0 (EP0) of the USB device.
 
static uint32_t usb_device_ep0_get_setup_end (uint32_t addr)
 Check if Endpoint 0 (EP0) has the setup end flag set for the USB device.
 
static void usb_device_ep0_clear_setup_end (uint32_t addr)
 Clear the setup end flag for Endpoint 0 (EP0) of the USB device.
 
static void usb_device_tx_iso_ep_enable (uint32_t addr)
 Enable ISO transfer for the USB device.
 
static void usb_device_tx_int_ep_enable (uint32_t addr)
 Enable interrupt transfer for the USB device.
 
static void usb_device_tx_bulk_ep_enable (uint32_t addr)
 Enable bulk transfer for the USB device.
 
static void usb_device_tx_config_ep_default (uint32_t addr)
 Configure the default settings for the transmit endpoint (EP) of the USB device.
 
static void usb_device_clear_dma_trans (uint32_t addr)
 Clear the DMA transfer flag for the USB device.
 
static void usb_device_config_dma_trans (uint32_t addr)
 Configure the DMA transfer settings for the USB device.
 
static void usb_device_tx_config_ep (uint32_t addr, uint32_t ts_type, uint32_t is_double_fifo, uint32_t ep_maxpkt)
 Configure the transmit endpoint (EP) of the USB device.
 
static void usb_device_tx_config_ep_dma (uint32_t addr)
 Configure the DMA transfer settings for the transmit endpoint (EP) of the USB device.
 
static void usb_device_tx_clear_ep_dma (uint32_t addr)
 Clear the DMA transfer flag for the transmit endpoint (EP) of the USB device.
 
static uint32_t usb_device_tx_get_write_data_ready (uint32_t addr)
 Check if the transmit endpoint (EP) is ready to write data for the USB device.
 
static uint32_t usb_device_tx_get_write_data_ready_fifo_empty (uint32_t addr)
 Check if the FIFO of the transmit endpoint (EP) is empty for the USB device.
 
static void usb_device_tx_write_data_half (uint32_t addr)
 Write half of the data to the transmit endpoint (EP) of the USB device.
 
static void usb_device_tx_write_data_complete (uint32_t addr)
 Write all of the data to the transmit endpoint (EP) of the USB device.
 
static void usb_device_tx_send_stall (uint32_t addr)
 Send a stall signal and flush the FIFO of the transmit endpoint (EP) of the USB device.
 
static uint32_t usb_device_tx_get_ep_stall (uint32_t addr)
 Check if the transmit endpoint (EP) of the USB device is stalled.
 
static void usb_device_tx_clear_stall (uint32_t addr)
 Clear the stall signal and reset the FIFO of the transmit endpoint (EP) of the USB device.
 
static void usb_device_rx_enable_iso_ep (uint32_t addr)
 Enable the isochronous transfer type for the receive endpoint (EP) of the USB device.
 
static void usb_device_rx_enable_int_ep (uint32_t addr)
 Enable the interrupt transfer type for the receive endpoint (EP) of the USB device.
 
static void usb_device_rx_enable_bulk_ep (uint32_t addr)
 Enable the bulk transfer type for the receive endpoint (EP) of the USB device.
 
static void usb_device_rx_config_ep_default (uint32_t addr)
 Configure the default settings for the receive endpoint (EP) of the USB device.
 
static void usb_device_rx_config_ep (uint32_t addr, uint32_t ts_type, uint32_t is_double_fifo, uint32_t ep_maxpkt)
 Configures the receive endpoint of the USB device.
 
static void usb_device_rx_config_ep_dma (uint32_t addr)
 Configures the DMA for the receive endpoint of the USB device.
 
static void usb_device_rx_clear_ep_dma (uint32_t addr)
 Clears the DMA configuration for the receive endpoint of the USB device.
 
static uint32_t usb_device_rx_get_read_data_ready (uint32_t addr)
 Checks if there is data ready to be read from the receive endpoint of the USB device.
 
static void usb_device_rx_read_data_half (uint32_t addr)
 Reads half of the data from the receive endpoint of the USB device.
 
static void usb_device_rx_read_data_complete (uint32_t addr)
 Reads the rest of the data from the receive endpoint of the USB device.
 
static int usb_device_write_data_half (uint32_t addr, uint32_t ep_type)
 Writes half of the data to the specified endpoint of the USB device.
 
static int usb_device_write_data_complete (uint32_t addr, uint32_t ep_type)
 Writes the rest of the data to the specified endpoint of the USB device.
 
static int usb_device_read_data_half (uint32_t addr, uint32_t ep_type)
 Reads half of the data from the specified endpoint of the USB device.
 
static int usb_device_read_data_complete (uint32_t addr, uint32_t ep_type)
 Reads the rest of the data from the specified endpoint of the USB device.
 
static void usb_device_rx_send_stall (uint32_t addr)
 Sends a stall on the receive endpoint of the USB device.
 
static uint32_t usb_device_rx_get_ep_stall (uint32_t addr)
 Gets the stall status of the specified endpoint of the USB device.
 
static void usb_device_rx_clear_stall (uint32_t addr)
 Clears the stall on the specified endpoint of the USB device.
 
static void usb_device_ep0_flush_fifo (uint32_t addr)
 Flushes the FIFO for endpoint 0 of the USB device.
 
static void usb_device_tx_flush_fifo (uint32_t addr)
 Flushes the transmit FIFO for the specified endpoint of the USB device.
 
static void usb_device_rx_flush_fifo (uint32_t addr)
 Flushes the receive FIFO for the specified endpoint of the USB device.
 
void usb_device_set_address_default (uint64_t husb)
 Set the default address for the USB device.
 
void usb_device_set_address (uint64_t husb, uint8_t address)
 Set the address for the USB device.
 
uint32_t usb_device_query_transfer_mode (uint64_t husb)
 Query the transfer mode of the USB device.
 
void usb_device_config_transfer_mode (uint64_t husb, uint8_t ts_type, uint8_t speed_mode)
 Configure the transfer mode of the USB device.
 
void usb_device_connect_switch (uint64_t husb, uint32_t is_on)
 Switch the USB device connection on or off.
 
uint32_t usb_device_query_power_status (uint64_t husb)
 Query the power status of the USB device.
 
int usb_device_config_ep (uint64_t husb, uint32_t ts_type, uint32_t ep_type, uint32_t is_double_fifo, uint32_t ep_maxpkt)
 Configure an endpoint of the USB device.
 
int usb_device_config_ep_default (uint64_t husb, uint32_t ep_type)
 Configure a default endpoint of the USB device.
 
int usb_device_config_ep_dma (uint64_t husb, uint32_t ep_type)
 Configure an endpoint of the USB device to use DMA.
 
int usb_device_clear_ep_dma (uint64_t husb, uint32_t ep_type)
 Clear the DMA configuration for an endpoint of the USB device.
 
int usb_device_get_ep_stall (uint64_t husb, uint32_t ep_type)
 Get the stall status of an endpoint of the USB device.
 
int usb_device_ep_send_stall (uint64_t husb, uint32_t ep_type)
 Send a stall condition on an endpoint of the USB device.
 
int usb_device_ep_clear_stall (uint64_t husb, uint32_t ep_type)
 Clear the stall condition on an endpoint of the USB device.
 
uint32_t usb_device_ctrl_get_setup_end (uint64_t husb)
 Get the setup end status of the control endpoint of the USB device.
 
void usb_device_ctrl_clear_setup_end (uint64_t husb)
 Clear the setup end status of the control endpoint of the USB device.
 
int usb_device_write_data_status (uint64_t husb, uint32_t ep_type, uint32_t complete)
 Check the write data status of an endpoint of the USB device.
 
int usb_device_read_data_status (uint64_t husb, uint32_t ep_type, uint32_t complete)
 Check the read data status of an endpoint of the USB device.
 
uint32_t usb_device_get_read_data_ready (uint64_t husb, uint32_t ep_type)
 Check if there is ready data to be read from an endpoint of the USB device.
 
uint32_t usb_device_get_write_data_ready (uint64_t husb, uint32_t ep_type)
 Check if an endpoint of the USB device is ready to write data.
 
uint32_t usb_device_get_write_data_ready_fifo_empty (uint64_t husb, uint32_t ep_type)
 Check if the FIFO of an endpoint of the USB device is empty and ready to write data.
 
int usb_device_iso_update_enable (uint64_t husb)
 Enable ISO update for the USB device.
 
void usb_device_flush_fifo (uint64_t husb, uint32_t ep_type)
 Flush the FIFO of an endpoint of the USB device.
 

Macro Definition Documentation

◆ USB_BCD_VERSION

#define USB_BCD_VERSION   0x0110

◆ USB_CLASS_APP_SPEC

#define USB_CLASS_APP_SPEC   0xfe

◆ USB_CLASS_AUDIO

#define USB_CLASS_AUDIO   1

◆ USB_CLASS_COMM

#define USB_CLASS_COMM   2

◆ USB_CLASS_DATA

#define USB_CLASS_DATA   10

◆ USB_CLASS_HID

#define USB_CLASS_HID   3

◆ USB_CLASS_HUB

#define USB_CLASS_HUB   9

◆ USB_CLASS_MASS_STORAGE

#define USB_CLASS_MASS_STORAGE   8

◆ USB_CLASS_PER_INTERFACE

#define USB_CLASS_PER_INTERFACE   0 /* for DeviceClass */

◆ USB_CLASS_PHYSICAL

#define USB_CLASS_PHYSICAL   5

◆ USB_CLASS_PRINTER

#define USB_CLASS_PRINTER   7

◆ USB_CLASS_VENDOR_SPEC

#define USB_CLASS_VENDOR_SPEC   0xff

◆ USB_DESCRIPTOR_TYPE_CONFIGURATION

#define USB_DESCRIPTOR_TYPE_CONFIGURATION   0x02

◆ USB_DESCRIPTOR_TYPE_DEVICE

#define USB_DESCRIPTOR_TYPE_DEVICE   0x01

◆ USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER

#define USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER   0x06

◆ USB_DESCRIPTOR_TYPE_ENDPOINT

#define USB_DESCRIPTOR_TYPE_ENDPOINT   0x05

◆ USB_DESCRIPTOR_TYPE_HID

#define USB_DESCRIPTOR_TYPE_HID   0x21

◆ USB_DESCRIPTOR_TYPE_INTERFACE

#define USB_DESCRIPTOR_TYPE_INTERFACE   0x04

◆ USB_DESCRIPTOR_TYPE_INTERFACE_POWER

#define USB_DESCRIPTOR_TYPE_INTERFACE_POWER   0x08

◆ USB_DESCRIPTOR_TYPE_OTHER_SPEED_CONFIGURATION

#define USB_DESCRIPTOR_TYPE_OTHER_SPEED_CONFIGURATION   0x07

◆ USB_DESCRIPTOR_TYPE_REPORT

#define USB_DESCRIPTOR_TYPE_REPORT   0x22

◆ USB_DESCRIPTOR_TYPE_STRING

#define USB_DESCRIPTOR_TYPE_STRING   0x03

◆ USB_DEVICE_REMOTE_WAKEUP

#define USB_DEVICE_REMOTE_WAKEUP   0x01

◆ USB_DIR_IN

#define USB_DIR_IN   0x80

◆ USB_DIR_OUT

#define USB_DIR_OUT   0

◆ USB_DT_CONFIG

#define USB_DT_CONFIG   0x02

◆ USB_DT_CONFIG_SIZE

#define USB_DT_CONFIG_SIZE   9

◆ USB_DT_DEVICE

#define USB_DT_DEVICE   0x01

◆ USB_DT_DEVICE_QUALIFIER

#define USB_DT_DEVICE_QUALIFIER   0x06

◆ USB_DT_DEVICE_SIZE

#define USB_DT_DEVICE_SIZE   18

◆ USB_DT_ENDPOINT

#define USB_DT_ENDPOINT   0x05

◆ USB_DT_ENDPOINT_AUDIO_SIZE

#define USB_DT_ENDPOINT_AUDIO_SIZE   9 /* Audio extension */

◆ USB_DT_ENDPOINT_SIZE

#define USB_DT_ENDPOINT_SIZE   7

◆ USB_DT_HID

#define USB_DT_HID   (USB_TYPE_CLASS | 0x01)

◆ USB_DT_HID_SIZE

#define USB_DT_HID_SIZE   9

◆ USB_DT_HUB

#define USB_DT_HUB   (USB_TYPE_CLASS | 0x09)

◆ USB_DT_HUB_NONVAR_SIZE

#define USB_DT_HUB_NONVAR_SIZE   7

◆ USB_DT_INTERFACE

#define USB_DT_INTERFACE   0x04

◆ USB_DT_INTERFACE_SIZE

#define USB_DT_INTERFACE_SIZE   9

◆ USB_DT_PHYSICAL

#define USB_DT_PHYSICAL   (USB_TYPE_CLASS | 0x03)

◆ USB_DT_REPORT

#define USB_DT_REPORT   (USB_TYPE_CLASS | 0x02)

◆ USB_DT_STRING

#define USB_DT_STRING   0x03

◆ USB_ENDPOINT_DIR_MASK

#define USB_ENDPOINT_DIR_MASK   0x80

◆ USB_ENDPOINT_HALT

#define USB_ENDPOINT_HALT   0x00

◆ USB_ENDPOINT_NUMBER_MASK

#define USB_ENDPOINT_NUMBER_MASK   0x0f /* in bEndpointAddress */

◆ USB_ENDPOINT_XFER_BULK

#define USB_ENDPOINT_XFER_BULK   2

◆ USB_ENDPOINT_XFER_CONTROL

#define USB_ENDPOINT_XFER_CONTROL   0

◆ USB_ENDPOINT_XFER_INT

#define USB_ENDPOINT_XFER_INT   3

◆ USB_ENDPOINT_XFER_ISOC

#define USB_ENDPOINT_XFER_ISOC   1

◆ USB_ENDPOINT_XFERTYPE_MASK

#define USB_ENDPOINT_XFERTYPE_MASK   0x03 /* in bmAttributes */

◆ USB_PID_ACK

#define USB_PID_ACK   0xd2

◆ USB_PID_DATA0

#define USB_PID_DATA0   0xc3

◆ USB_PID_DATA1

#define USB_PID_DATA1   0x4b

◆ USB_PID_DATA2

#define USB_PID_DATA2   0x87 /* USB 2.0 */

◆ USB_PID_ERR

#define USB_PID_ERR   0x3c /* USB 2.0: handshake mode */

◆ USB_PID_IN

#define USB_PID_IN   0x69

◆ USB_PID_MDATA

#define USB_PID_MDATA   0x0f /* USB 2.0 */

◆ USB_PID_NAK

#define USB_PID_NAK   0x5a

◆ USB_PID_NYET

#define USB_PID_NYET   0x96 /* USB 2.0 */

◆ USB_PID_OUT

#define USB_PID_OUT   0xe1

◆ USB_PID_PING

#define USB_PID_PING   0xb4 /* USB 2.0 */

◆ USB_PID_PREAMBLE

#define USB_PID_PREAMBLE   0x3c /* Token mode */

◆ USB_PID_SETUP

#define USB_PID_SETUP   0x2d

◆ USB_PID_SOF

#define USB_PID_SOF   0xa5

◆ USB_PID_SPLIT

#define USB_PID_SPLIT   0x78 /* USB 2.0 */

◆ USB_PID_STALL

#define USB_PID_STALL   0x1e

◆ USB_PID_UNDEF_0

#define USB_PID_UNDEF_0   0xf0

◆ USB_RECIP_DEVICE

#define USB_RECIP_DEVICE   0x00

◆ USB_RECIP_ENDPOINT

#define USB_RECIP_ENDPOINT   0x02

◆ USB_RECIP_INTERFACE

#define USB_RECIP_INTERFACE   0x01

◆ USB_RECIP_OTHER

#define USB_RECIP_OTHER   0x03

◆ USB_REQ_CLEAR_FEATURE

#define USB_REQ_CLEAR_FEATURE   0x01

◆ USB_REQ_DEVICE2HOST

#define USB_REQ_DEVICE2HOST   0x80

◆ USB_REQ_DIRECTION_MASK

#define USB_REQ_DIRECTION_MASK   0x80

◆ USB_REQ_GET_CONFIGURATION

#define USB_REQ_GET_CONFIGURATION   0x08

◆ USB_REQ_GET_DESCRIPTOR

#define USB_REQ_GET_DESCRIPTOR   0x06

◆ USB_REQ_GET_IDLE

#define USB_REQ_GET_IDLE   0x02

◆ USB_REQ_GET_INTERFACE

#define USB_REQ_GET_INTERFACE   0x0A

◆ USB_REQ_GET_PROTOCOL

#define USB_REQ_GET_PROTOCOL   0x03

◆ USB_REQ_GET_REPORT

#define USB_REQ_GET_REPORT   0x01

◆ USB_REQ_GET_STATUS

#define USB_REQ_GET_STATUS   0x00

◆ USB_REQ_HOST2DEVICE

#define USB_REQ_HOST2DEVICE   0x00

◆ USB_REQ_RECIPIENT_DEVICE

#define USB_REQ_RECIPIENT_DEVICE   0x00

◆ USB_REQ_RECIPIENT_ENDPOINT

#define USB_REQ_RECIPIENT_ENDPOINT   0x02

◆ USB_REQ_RECIPIENT_INTERFACE

#define USB_REQ_RECIPIENT_INTERFACE   0x01

◆ USB_REQ_RECIPIENT_MASK

#define USB_REQ_RECIPIENT_MASK   0x1f

◆ USB_REQ_RECIPIENT_OTHER

#define USB_REQ_RECIPIENT_OTHER   0x03

◆ USB_REQ_SET_ADDRESS

#define USB_REQ_SET_ADDRESS   0x05

◆ USB_REQ_SET_CONFIGURATION

#define USB_REQ_SET_CONFIGURATION   0x09

◆ USB_REQ_SET_DESCRIPTOR

#define USB_REQ_SET_DESCRIPTOR   0x07

◆ USB_REQ_SET_FEATURE

#define USB_REQ_SET_FEATURE   0x03

◆ USB_REQ_SET_IDLE

#define USB_REQ_SET_IDLE   0x0A

◆ USB_REQ_SET_INTERFACE

#define USB_REQ_SET_INTERFACE   0x0B

◆ USB_REQ_SET_PROTOCOL

#define USB_REQ_SET_PROTOCOL   0x0B

◆ USB_REQ_SET_REPORT

#define USB_REQ_SET_REPORT   0x09

◆ USB_REQ_SYNCH_FRAME

#define USB_REQ_SYNCH_FRAME   0x0C

◆ USB_REQ_TYPE_CLASS

#define USB_REQ_TYPE_CLASS   0x20

◆ USB_REQ_TYPE_MASK

#define USB_REQ_TYPE_MASK   0x60

◆ USB_REQ_TYPE_STANDARD

#define USB_REQ_TYPE_STANDARD   0x00

◆ USB_REQ_TYPE_VENDOR

#define USB_REQ_TYPE_VENDOR   0x40

◆ USB_STATUS_HALT

#define USB_STATUS_HALT   0x01

◆ USB_STATUS_REMOTEWAKEUP

#define USB_STATUS_REMOTEWAKEUP   0x02

◆ USB_STATUS_SELFPOWERED

#define USB_STATUS_SELFPOWERED   0x01

◆ USB_TEST_MODE

#define USB_TEST_MODE   0x02

◆ USB_TYPE_CLASS

#define USB_TYPE_CLASS   (0x01 << 5)

◆ USB_TYPE_RESERVED

#define USB_TYPE_RESERVED   (0x03 << 5)

◆ USB_TYPE_STANDARD

#define USB_TYPE_STANDARD   (0x00 << 5)

◆ USB_TYPE_VENDOR

#define USB_TYPE_VENDOR   (0x02 << 5)

◆ USBD_DEVICE_DESCRIPTORS

#define USBD_DEVICE_DESCRIPTORS (   x)    (((unsigned int) x <= USB_DESCRIPTOR_TYPE_INTERFACE_POWER) ? usbd_device_descriptors[x] : "UNKNOWN")

◆ USBD_DEVICE_REQUESTS

#define USBD_DEVICE_REQUESTS (   x)    (((unsigned int) x <= USB_REQ_SYNCH_FRAME) ? usbd_device_requests[x] : "UNKNOWN")

Function Documentation

◆ usb_device_clear_dma_trans()

static void usb_device_clear_dma_trans ( uint32_t  addr)
inlinestatic

Clear the DMA transfer flag for the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_clear_ep_dma()

int usb_device_clear_ep_dma ( uint64_t  husb,
uint32_t  ep_type 
)

Clear the DMA configuration for an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
0 on success, -1 on failure.

◆ usb_device_config_dma_trans()

static void usb_device_config_dma_trans ( uint32_t  addr)
inlinestatic

Configure the DMA transfer settings for the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_config_ep()

int usb_device_config_ep ( uint64_t  husb,
uint32_t  ts_type,
uint32_t  ep_type,
uint32_t  is_double_fifo,
uint32_t  ep_maxpkt 
)

Configure an endpoint of the USB device.

Parameters
husbThe USB device handle.
ts_typeThe transfer mode type.
ep_typeThe endpoint type.
is_double_fifoWhether to use double FIFO or not.
ep_maxpktThe maximum packet size of the endpoint.
Returns
0 on success, -1 on failure.

◆ usb_device_config_ep_default()

int usb_device_config_ep_default ( uint64_t  husb,
uint32_t  ep_type 
)

Configure a default endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
0 on success, -1 on failure.

◆ usb_device_config_ep_dma()

int usb_device_config_ep_dma ( uint64_t  husb,
uint32_t  ep_type 
)

Configure an endpoint of the USB device to use DMA.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
0 on success, -1 on failure.

◆ usb_device_config_transfer_mode()

void usb_device_config_transfer_mode ( uint64_t  husb,
uint8_t  ts_type,
uint8_t  speed_mode 
)

Configure the transfer mode of the USB device.

Parameters
husbThe USB device handle.
ts_typeThe transfer mode type.
speed_modeThe speed mode.

◆ usb_device_connect_switch()

void usb_device_connect_switch ( uint64_t  husb,
uint32_t  is_on 
)

Switch the USB device connection on or off.

Parameters
husbThe USB device handle.
is_onWhether to turn the connection on (1) or off (0).

◆ usb_device_ctrl_clear_setup_end()

void usb_device_ctrl_clear_setup_end ( uint64_t  husb)

Clear the setup end status of the control endpoint of the USB device.

Parameters
husbThe USB device handle.

◆ usb_device_ctrl_get_setup_end()

uint32_t usb_device_ctrl_get_setup_end ( uint64_t  husb)

Get the setup end status of the control endpoint of the USB device.

Parameters
husbThe USB device handle.
Returns
The setup end status.

◆ usb_device_ep0_clear_setup_end()

static void usb_device_ep0_clear_setup_end ( uint32_t  addr)
inlinestatic

Clear the setup end flag for Endpoint 0 (EP0) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_ep0_clear_stall()

static void usb_device_ep0_clear_stall ( uint32_t  addr)
inlinestatic

Clear the stall flag for Endpoint 0 (EP0) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_ep0_config_ep0()

static void usb_device_ep0_config_ep0 ( uint32_t  addr)
inlinestatic

Configure Endpoint 0 (EP0) for the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_ep0_config_ep0_default()

static void usb_device_ep0_config_ep0_default ( uint32_t  addr)
inlinestatic

Configure Endpoint 0 (EP0) in default mode for the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_ep0_flush_fifo()

static void usb_device_ep0_flush_fifo ( uint32_t  addr)
inlinestatic

Flushes the FIFO for endpoint 0 of the USB device.

Parameters
addrThe address of the device.

◆ usb_device_ep0_get_read_data_ready()

static uint32_t usb_device_ep0_get_read_data_ready ( uint32_t  addr)
inlinestatic

Check if Endpoint 0 (EP0) has received data ready flag for the USB device.

Parameters
addrThe address of the USB device.
Returns
Returns the status of the flag.

◆ usb_device_ep0_get_setup_end()

static uint32_t usb_device_ep0_get_setup_end ( uint32_t  addr)
static

Check if Endpoint 0 (EP0) has the setup end flag set for the USB device.

Parameters
addrThe address of the USB device.
Returns
Returns the status of the flag.

◆ usb_device_ep0_get_stall()

static uint32_t usb_device_ep0_get_stall ( uint32_t  addr)
static

Check if Endpoint 0 (EP0) has the stall flag set for the USB device.

Parameters
addrThe address of the USB device.
Returns
Returns the status of the flag.

◆ usb_device_ep0_get_write_data_ready()

static uint32_t usb_device_ep0_get_write_data_ready ( uint32_t  addr)
inlinestatic

Check if Endpoint 0 (EP0) has write data ready flag for the USB device.

Parameters
addrThe address of the USB device.
Returns
Returns the status of the flag.

◆ usb_device_ep0_read_data_complete()

static void usb_device_ep0_read_data_complete ( uint32_t  addr)
inlinestatic

Clear the read data complete flag for Endpoint 0 (EP0) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_ep0_read_data_half()

static void usb_device_ep0_read_data_half ( uint32_t  addr)
inlinestatic

Clear the read data half flag for Endpoint 0 (EP0) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_ep0_send_stall()

static void usb_device_ep0_send_stall ( uint32_t  addr)
inlinestatic

Set the send stall flag for Endpoint 0 (EP0) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_ep0_write_data_complete()

static void usb_device_ep0_write_data_complete ( uint32_t  addr)
inlinestatic

Set the write data complete flag for Endpoint 0 (EP0) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_ep0_write_data_half()

static void usb_device_ep0_write_data_half ( uint32_t  addr)
inlinestatic

Clear the write data half flag for Endpoint 0 (EP0) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_ep_clear_stall()

int usb_device_ep_clear_stall ( uint64_t  husb,
uint32_t  ep_type 
)

Clear the stall condition on an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
0 on success, -1 on failure.

◆ usb_device_ep_send_stall()

int usb_device_ep_send_stall ( uint64_t  husb,
uint32_t  ep_type 
)

Send a stall condition on an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
0 on success, -1 on failure.

◆ usb_device_flush_fifo()

void usb_device_flush_fifo ( uint64_t  husb,
uint32_t  ep_type 
)

Flush the FIFO of an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.

◆ usb_device_get_ep_stall()

int usb_device_get_ep_stall ( uint64_t  husb,
uint32_t  ep_type 
)

Get the stall status of an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
1 if stalled, 0 if not stalled.

◆ usb_device_get_read_data_ready()

uint32_t usb_device_get_read_data_ready ( uint64_t  husb,
uint32_t  ep_type 
)

Check if there is ready data to be read from an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
1 if ready, 0 if not ready.

◆ usb_device_get_write_data_ready()

uint32_t usb_device_get_write_data_ready ( uint64_t  husb,
uint32_t  ep_type 
)

Check if an endpoint of the USB device is ready to write data.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
1 if ready, 0 if not ready.

◆ usb_device_get_write_data_ready_fifo_empty()

uint32_t usb_device_get_write_data_ready_fifo_empty ( uint64_t  husb,
uint32_t  ep_type 
)

Check if the FIFO of an endpoint of the USB device is empty and ready to write data.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
Returns
1 if ready, 0 if not ready.

◆ usb_device_iso_update_enable()

int usb_device_iso_update_enable ( uint64_t  husb)

Enable ISO update for the USB device.

Parameters
husbThe USB device handle.
Returns
0 on success, -1 on failure.

◆ usb_device_query_power_status()

uint32_t usb_device_query_power_status ( uint64_t  husb)

Query the power status of the USB device.

Parameters
husbThe USB device handle.
Returns
The power status.

◆ usb_device_query_transfer_mode()

uint32_t usb_device_query_transfer_mode ( uint64_t  husb)

Query the transfer mode of the USB device.

Parameters
husbThe USB device handle.
Returns
The transfer mode.

◆ usb_device_read_data_complete()

static int usb_device_read_data_complete ( uint32_t  addr,
uint32_t  ep_type 
)
inlinestatic

Reads the rest of the data from the specified endpoint of the USB device.

Parameters
addrThe address of the usb device.
ep_typeThe type of endpoint to read from.
Returns
Returns 0 if successful, -1 otherwise.

◆ usb_device_read_data_half()

static int usb_device_read_data_half ( uint32_t  addr,
uint32_t  ep_type 
)
inlinestatic

Reads half of the data from the specified endpoint of the USB device.

Parameters
addrThe address of the usb device.
ep_typeThe type of endpoint to read from.
Returns
Returns 0 if successful, -1 otherwise.

◆ usb_device_read_data_status()

int usb_device_read_data_status ( uint64_t  husb,
uint32_t  ep_type,
uint32_t  complete 
)

Check the read data status of an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
completeWhether the read operation is complete (1) or not (0).
Returns
0 on success, -1 on failure.

◆ usb_device_rx_clear_ep_dma()

static void usb_device_rx_clear_ep_dma ( uint32_t  addr)
inlinestatic

Clears the DMA configuration for the receive endpoint of the USB device.

Parameters
addrThe address of the usb device.

◆ usb_device_rx_clear_stall()

static void usb_device_rx_clear_stall ( uint32_t  addr)
inlinestatic

Clears the stall on the specified endpoint of the USB device.

Parameters
addrThe address of the usb device.

◆ usb_device_rx_config_ep()

static void usb_device_rx_config_ep ( uint32_t  addr,
uint32_t  ts_type,
uint32_t  is_double_fifo,
uint32_t  ep_maxpkt 
)
inlinestatic

Configures the receive endpoint of the USB device.

Parameters
addrThe address of the usb device.
ts_typeThe transfer type of the endpoint.
is_double_fifoFlag indicating whether the endpoint has a double FIFO.
ep_maxpktThe maximum packet size of the endpoint.

◆ usb_device_rx_config_ep_default()

static void usb_device_rx_config_ep_default ( uint32_t  addr)
inlinestatic

Configure the default settings for the receive endpoint (EP) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_rx_config_ep_dma()

static void usb_device_rx_config_ep_dma ( uint32_t  addr)
inlinestatic

Configures the DMA for the receive endpoint of the USB device.

Parameters
addrThe address of the usb device.

◆ usb_device_rx_enable_bulk_ep()

static void usb_device_rx_enable_bulk_ep ( uint32_t  addr)
inlinestatic

Enable the bulk transfer type for the receive endpoint (EP) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_rx_enable_int_ep()

static void usb_device_rx_enable_int_ep ( uint32_t  addr)
inlinestatic

Enable the interrupt transfer type for the receive endpoint (EP) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_rx_enable_iso_ep()

static void usb_device_rx_enable_iso_ep ( uint32_t  addr)
inlinestatic

Enable the isochronous transfer type for the receive endpoint (EP) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_rx_flush_fifo()

static void usb_device_rx_flush_fifo ( uint32_t  addr)
inlinestatic

Flushes the receive FIFO for the specified endpoint of the USB device.

Parameters
addrThe address of the usb device.

◆ usb_device_rx_get_ep_stall()

static uint32_t usb_device_rx_get_ep_stall ( uint32_t  addr)
inlinestatic

Gets the stall status of the specified endpoint of the USB device.

Parameters
addrThe address of the usb device.
Returns
Returns 1 if stalled, 0 otherwise.

◆ usb_device_rx_get_read_data_ready()

static uint32_t usb_device_rx_get_read_data_ready ( uint32_t  addr)
inlinestatic

Checks if there is data ready to be read from the receive endpoint of the USB device.

Parameters
addrThe address of the usb device.
Returns
Returns 1 if data is ready, 0 otherwise.

◆ usb_device_rx_read_data_complete()

static void usb_device_rx_read_data_complete ( uint32_t  addr)
inlinestatic

Reads the rest of the data from the receive endpoint of the USB device.

Parameters
addrThe address of the usb device.

◆ usb_device_rx_read_data_half()

static void usb_device_rx_read_data_half ( uint32_t  addr)
inlinestatic

Reads half of the data from the receive endpoint of the USB device.

Parameters
addrThe address of the usb device.

◆ usb_device_rx_send_stall()

static void usb_device_rx_send_stall ( uint32_t  addr)
inlinestatic

Sends a stall on the receive endpoint of the USB device.

Parameters
addrThe address of the usb device.

◆ usb_device_set_address()

void usb_device_set_address ( uint64_t  husb,
uint8_t  address 
)

Set the address for the USB device.

Parameters
husbThe USB device handle.
addressThe address to set.

◆ usb_device_set_address_default()

void usb_device_set_address_default ( uint64_t  husb)

Set the default address for the USB device.

Parameters
husbThe USB device handle.

◆ usb_device_transfer_mode_default()

static void usb_device_transfer_mode_default ( uint32_t  addr)
inlinestatic

Disable all transfer modes for the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_transfer_mode_fs()

static void usb_device_transfer_mode_fs ( uint32_t  addr)
inlinestatic

Set the mode to Full Speed (FS) for the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_transfer_mode_hs()

static void usb_device_transfer_mode_hs ( uint32_t  addr)
inlinestatic

Set the mode to High Speed (HS) for the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_transfer_mode_ls()

static void usb_device_transfer_mode_ls ( uint32_t  addr)
inlinestatic

Set the mode to Low Speed (LS) for the USB device.

Notice: This is Fake LS, we use it as FS

Parameters
addrThe address of the USB device.

◆ usb_device_transfer_type_bulk()

static void usb_device_transfer_type_bulk ( uint32_t  addr)
inlinestatic

Set the bulk transfer type for the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_transfer_type_ctrl()

static void usb_device_transfer_type_ctrl ( uint32_t  addr)
inlinestatic

Set the control transfer type for the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_transfer_type_default()

static void usb_device_transfer_type_default ( uint32_t  addr)
inlinestatic

Disable all transfer types for the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_transfer_type_int()

static void usb_device_transfer_type_int ( uint32_t  addr)
inlinestatic

Set the interrupt transfer type for the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_transfer_type_iso()

static void usb_device_transfer_type_iso ( uint32_t  addr)
inlinestatic

Set the ISO transfer type for the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_tx_bulk_ep_enable()

static void usb_device_tx_bulk_ep_enable ( uint32_t  addr)
inlinestatic

Enable bulk transfer for the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_tx_clear_ep_dma()

static void usb_device_tx_clear_ep_dma ( uint32_t  addr)
inlinestatic

Clear the DMA transfer flag for the transmit endpoint (EP) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_tx_clear_stall()

static void usb_device_tx_clear_stall ( uint32_t  addr)
inlinestatic

Clear the stall signal and reset the FIFO of the transmit endpoint (EP) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_tx_config_ep()

static void usb_device_tx_config_ep ( uint32_t  addr,
uint32_t  ts_type,
uint32_t  is_double_fifo,
uint32_t  ep_maxpkt 
)
inlinestatic

Configure the transmit endpoint (EP) of the USB device.

Parameters
addrThe address of the USB device.
ts_typeThe transfer type of the EP.
is_double_fifoIndicates if the EP has double buffer FIFO.
ep_maxpktThe maximum packet size of the EP.

◆ usb_device_tx_config_ep_default()

static void usb_device_tx_config_ep_default ( uint32_t  addr)
inlinestatic

Configure the default settings for the transmit endpoint (EP) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_tx_config_ep_dma()

static void usb_device_tx_config_ep_dma ( uint32_t  addr)
inlinestatic

Configure the DMA transfer settings for the transmit endpoint (EP) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_tx_flush_fifo()

static void usb_device_tx_flush_fifo ( uint32_t  addr)
inlinestatic

Flushes the transmit FIFO for the specified endpoint of the USB device.

Parameters
addrThe address of the usb device.

◆ usb_device_tx_get_ep_stall()

static uint32_t usb_device_tx_get_ep_stall ( uint32_t  addr)
inlinestatic

Check if the transmit endpoint (EP) of the USB device is stalled.

Parameters
addrThe address of the USB device.
Returns
Returns the status of the stall flag.

◆ usb_device_tx_get_write_data_ready()

static uint32_t usb_device_tx_get_write_data_ready ( uint32_t  addr)
inlinestatic

Check if the transmit endpoint (EP) is ready to write data for the USB device.

Parameters
addrThe address of the USB device.
Returns
Returns the status of the write data ready flag.

◆ usb_device_tx_get_write_data_ready_fifo_empty()

static uint32_t usb_device_tx_get_write_data_ready_fifo_empty ( uint32_t  addr)
inlinestatic

Check if the FIFO of the transmit endpoint (EP) is empty for the USB device.

Parameters
addrThe address of the USB device.
Returns
Returns the status of the FIFO empty flag.

◆ usb_device_tx_int_ep_enable()

static void usb_device_tx_int_ep_enable ( uint32_t  addr)
inlinestatic

Enable interrupt transfer for the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_tx_iso_ep_enable()

static void usb_device_tx_iso_ep_enable ( uint32_t  addr)
inlinestatic

Enable ISO transfer for the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_tx_send_stall()

static void usb_device_tx_send_stall ( uint32_t  addr)
inlinestatic

Send a stall signal and flush the FIFO of the transmit endpoint (EP) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_tx_write_data_complete()

static void usb_device_tx_write_data_complete ( uint32_t  addr)
inlinestatic

Write all of the data to the transmit endpoint (EP) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_tx_write_data_half()

static void usb_device_tx_write_data_half ( uint32_t  addr)
inlinestatic

Write half of the data to the transmit endpoint (EP) of the USB device.

Parameters
addrThe address of the USB device.

◆ usb_device_write_data_complete()

static int usb_device_write_data_complete ( uint32_t  addr,
uint32_t  ep_type 
)
inlinestatic

Writes the rest of the data to the specified endpoint of the USB device.

Parameters
addrThe address of the usb device.
ep_typeThe type of endpoint to write to.
Returns
Returns 0 if successful, -1 otherwise.

◆ usb_device_write_data_half()

static int usb_device_write_data_half ( uint32_t  addr,
uint32_t  ep_type 
)
inlinestatic

Writes half of the data to the specified endpoint of the USB device.

Parameters
addrThe address of the usb device.
ep_typeThe type of endpoint to write to.
Returns
Returns 0 if successful, -1 otherwise.

◆ usb_device_write_data_status()

int usb_device_write_data_status ( uint64_t  husb,
uint32_t  ep_type,
uint32_t  complete 
)

Check the write data status of an endpoint of the USB device.

Parameters
husbThe USB device handle.
ep_typeThe endpoint type.
completeWhether the write operation is complete (1) or not (0).
Returns
0 on success, -1 on failure.