NUC472_NUC442_BSP V3.03.004
The Board Support Package for NUC472/NUC442
Functions | Variables
Collaboration diagram for USBH Exported Functions:

Functions

int32_t USBH_Open (void)
 Open USB Host controller function. More...
 
int USBH_ProcessHubEvents ()
 Processed USB hub device events. User application must invoke this routine in the main while loop. Device enumeration is done in this routine. More...
 
URB_TUSBH_AllocUrb ()
 Allocate an URB from USB Core driver internal URB pool. More...
 
void USBH_FreeUrb (URB_T *urb)
 Free the URB allocated from USBH_AllocUrb() More...
 
int32_t USBH_SubmitUrb (URB_T *urb)
 Submit an URB to USB core for transfer data. More...
 
int32_t USBH_UnlinkUrb (URB_T *urb)
 Cancel an URB which has been submit to USB core. More...
 
int32_t USBH_SendCtrlMsg (USB_DEV_T *dev, uint32_t pipe, uint8_t request, uint8_t requesttype, uint16_t value, uint16_t index, void *data, uint16_t size, int timeout)
 Execute a control transfer. More...
 
int32_t USBH_SendBulkMsg (USB_DEV_T *usb_dev, uint32_t pipe, void *data, int len, int *actual_length, int timeout)
 Execute a bulk transfer. More...
 
int32_t USBH_RegisterDriver (USB_DRIVER_T *new_driver)
 Register a device driver to USB Host Core driver. More...
 
int32_t USBH_GetDescriptor (USB_DEV_T *dev, uint8_t type, uint8_t index, void *buf, int size)
 Get a descriptor from device. More...
 
int32_t USBH_SetConfiguration (USB_DEV_T *dev, int configuration)
 Select USB device configuration. More...
 
int32_t USBH_SetInterface (USB_DEV_T *dev, char interface, char alternate)
 Set USB device interface. More...
 
int32_t USBH_ClearHalt (USB_DEV_T *dev, int pipe)
 Clear the halt state of an endpoint. More...
 
int32_t USBH_Suspend (void)
 Suspend USB Host Controller and devices. More...
 
int32_t USBH_Resume (void)
 Resume USB Host controller and devices. More...
 
int32_t USBH_Close (void)
 Disable USB Host controller function. More...
 

Variables

uint32_t iso_pkt_t::offset
 
uint32_t iso_pkt_t::length
 
uint32_t iso_pkt_t::actual_length
 
int iso_pkt_t::status
 
URB_PRIV_T urb_t::urb_hcpriv
 
USB_LIST_T urb_t::urb_list
 
struct urb_turb_t::next
 
struct usb_deviceurb_t::dev
 
uint32_t urb_t::pipe
 
int urb_t::status
 
uint32_t urb_t::transfer_flags
 
void * urb_t::transfer_buffer
 
int urb_t::transfer_buffer_length
 
int urb_t::actual_length
 
uint8_t * urb_t::setup_packet
 
int urb_t::start_frame
 
int urb_t::number_of_packets
 
int urb_t::interval
 
int urb_t::error_count
 
int urb_t::timeout
 
void * urb_t::context
 
void(* urb_t::complete )(struct urb_t *)
 
ISO_PACKET_DESCRIPTOR_T urb_t::iso_frame_desc [8]
 
USB_DEV_DESC_T usb_device::descriptor
 
int usb_device::devnum
 
int usb_device::slow
 
int usb_device::speed
 
uint32_t usb_device::toggle [2]
 
uint32_t usb_device::halted [2]
 
struct usb_deviceusb_device::parent
 
int usb_device::hub_port
 
USB_BUS_T * usb_device::bus
 
signed char usb_device::act_config
 
char usb_device::act_iface
 
char usb_device::iface_alternate
 
EP_INFO_T usb_device::ep_list [MAX_ENDPOINTS]
 
int usb_device::ep_list_cnt
 
int usb_device::have_langid
 
int usb_device::string_langid
 
void * usb_device::hcpriv
 
int usb_device::maxchild
 
struct usb_deviceusb_device::children [USB_MAXCHILDREN]
 
USB_DRIVER_T * usb_device::driver [MAX_DRIVER_PER_DEV]
 
int usb_device::driver_cnt
 

Detailed Description

USB device structure

Function Documentation

◆ USBH_AllocUrb()

HIDDEN_SYMBOLS URB_T * USBH_AllocUrb ( void  )

Allocate an URB from USB Core driver internal URB pool.

Returns
URB or NULL.
Return values
NULLOut of URB.
OtherwiseThe pointer refer to the newly allocated URB.

Definition at line 90 of file usbh_support.c.

Here is the caller graph for this function:

◆ USBH_ClearHalt()

HIDDEN_SYMBOLS int32_t USBH_ClearHalt ( USB_DEV_T dev,
int  pipe 
)

Clear the halt state of an endpoint.

Parameters
[in]devThe USB device.
[in]pipePipe description of the endpoint.
Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 900 of file usbh_core.c.

Here is the call graph for this function:

◆ USBH_Close()

int32_t USBH_Close ( void  )

Disable USB Host controller function.

Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 1319 of file usbh_core.c.

◆ USBH_FreeUrb()

void USBH_FreeUrb ( URB_T urb)

Free the URB allocated from USBH_AllocUrb()

Parameters
[in]urbThe URB to be freed.
Returns
None

Definition at line 113 of file usbh_support.c.

Here is the caller graph for this function:

◆ USBH_GetDescriptor()

HIDDEN_SYMBOLS int32_t USBH_GetDescriptor ( USB_DEV_T dev,
uint8_t  type,
uint8_t  index,
void *  buf,
int  size 
)

Get a descriptor from device.

Parameters
[in]devThe USB devise.
[in]typeDescriptor type.
[in]indexIndex of the descriptor.
[out]bufBuffer to store the descriptor.
[in]sizeAvailable size of buf.
Returns
Length of the descriptor or error code.
Return values
>=0Length of the descriptor.
OtherwiseFailed

Definition at line 822 of file usbh_core.c.

Here is the call graph for this function:

◆ USBH_Open()

HIDDEN_SYMBOLS int32_t USBH_Open ( void  )

Open USB Host controller function.

Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 1270 of file usbh_core.c.

◆ USBH_ProcessHubEvents()

HIDDEN_SYMBOLS int USBH_ProcessHubEvents ( void  )

Processed USB hub device events. User application must invoke this routine in the main while loop. Device enumeration is done in this routine.

Returns
Have hub events or not.
Return values
0No hub events
1Have hub events

Definition at line 113 of file usbh_hub.c.

◆ USBH_RegisterDriver()

int32_t USBH_RegisterDriver ( USB_DRIVER_T *  new_driver)

Register a device driver to USB Host Core driver.

Parameters
[in]new_driverThe USB device driver.
Returns
Success or not.
Return values
0Success
otherwiseFailed

Definition at line 78 of file usbh_core.c.

Here is the caller graph for this function:

◆ USBH_Resume()

int32_t USBH_Resume ( void  )

Resume USB Host controller and devices.

Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 1378 of file usbh_core.c.

◆ USBH_SendBulkMsg()

int32_t USBH_SendBulkMsg ( USB_DEV_T usb_dev,
uint32_t  pipe,
void *  data,
int  len,
int *  actual_length,
int  timeout 
)

Execute a bulk transfer.

Parameters
[in]usb_devPointer to the usb device to send the message to.
[in]pipeEndpoint pipe to send the message to.
[in,out]dataPointer to the data to send or to receive.
[in]lenLength in bytes of the data to send or receive.
[out]actual_lengthActual length of data transferred.
[in]timeoutTime in millisecond to wait for the message to complete before timing out (if 0 the wait is forever).
Returns
Data transfer length or error code.
Return values
>=0The actual bytes of data be transferred.
OtherwiseFailed

This function sends a simple bulk message to a specified endpoint and waits for the message to complete, or timeout.

If successful, it returns 0, otherwise a negative error number. The number of actual bytes transferred will be placed in the actual_timeout parameter.

Don't use this function from within an interrupt context, like a bottom half handler. If you need a asynchronous message, or need to send a message from within interrupt context, use USBH_SubmitUrb()

Definition at line 416 of file usbh_core.c.

◆ USBH_SendCtrlMsg()

HIDDEN_SYMBOLS int32_t USBH_SendCtrlMsg ( USB_DEV_T dev,
uint32_t  pipe,
uint8_t  request,
uint8_t  requesttype,
uint16_t  value,
uint16_t  index,
void *  data,
uint16_t  size,
int  timeout 
)

Execute a control transfer.

Parameters
[in]devPointer to the usb device to send the message to.
[in]pipeEndpoint pipe to send the message to.
[in]requestUSB message request value
[in]requesttypeUSB message request type value
[in]valueUSB message value
[in]indexUSB message index value
[in,out]dataMemory buffer of the data to be send with this transfer or to hold the data received from this transfer.
[in]sizeLength in bytes of the data to send.
[in]timeoutTime in millisecond to wait for the message to complete before timing out (if 0 the wait is forever).
Returns
Data transfer length or error code.
Return values
>=0The actual bytes of data be transferred.
OtherwiseFailed

This function sends a simple control message to a specified endpoint and waits for the message to complete, or timeout.

If successful, it returns 0, otherwise a negative error number.

Don't use this function from within an interrupt context, like a bottom half handler. If you need a asynchronous message, or need to send a message from within interrupt context, use USBH_SubmitUrb()

Definition at line 378 of file usbh_core.c.

Here is the caller graph for this function:

◆ USBH_SetConfiguration()

int32_t USBH_SetConfiguration ( USB_DEV_T dev,
int  configuration 
)

Select USB device configuration.

Parameters
[in]devThe USB device.
[in]configurationConfiguration number.
Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 973 of file usbh_core.c.

Here is the call graph for this function:

◆ USBH_SetInterface()

int32_t USBH_SetInterface ( USB_DEV_T dev,
char  interface,
char  alternate 
)

Set USB device interface.

Parameters
[in]devThe USB device.
[in]interfaceInterface number.
[in]alternateInterface alternate setting number.
Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 948 of file usbh_core.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBH_SubmitUrb()

HIDDEN_SYMBOLS int32_t USBH_SubmitUrb ( URB_T urb)

Submit an URB to USB core for transfer data.

Parameters
[in]urbThe USB transfer request to be processed.
Returns
Success or not.
Return values
0Success
otherwiseFailed

Definition at line 218 of file usbh_core.c.

Here is the caller graph for this function:

◆ USBH_Suspend()

int32_t USBH_Suspend ( void  )

Suspend USB Host Controller and devices.

Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 1336 of file usbh_core.c.

Here is the call graph for this function:

◆ USBH_UnlinkUrb()

int32_t USBH_UnlinkUrb ( URB_T urb)

Cancel an URB which has been submit to USB core.

Parameters
[in]urbThe USB to be canceled.
Returns
Success or not.
Return values
0Success
otherwiseFailed

Definition at line 236 of file usbh_core.c.

Here is the caller graph for this function:

Variable Documentation

◆ act_config

signed char usb_device::act_config

Active configuration number

Definition at line 681 of file usbh_core.h.

◆ act_iface

char usb_device::act_iface

Active interface number

Definition at line 682 of file usbh_core.h.

◆ actual_length [1/2]

uint32_t iso_pkt_t::actual_length

Actual transfer length

Definition at line 529 of file usbh_core.h.

◆ actual_length [2/2]

int urb_t::actual_length

actual data buffer length

Definition at line 547 of file usbh_core.h.

◆ bus

USB_BUS_T* usb_device::bus

Bus we're part of

Definition at line 679 of file usbh_core.h.

◆ children

struct usb_device* usb_device::children[USB_MAXCHILDREN]

Child device list

Definition at line 702 of file usbh_core.h.

◆ complete

void(* urb_t::complete) (struct urb_t *)

USB transfer complete callback function

Definition at line 555 of file usbh_core.h.

◆ context

void* urb_t::context

USB Driver internal used

Definition at line 554 of file usbh_core.h.

◆ descriptor

USB_DEV_DESC_T usb_device::descriptor

Device descriptor.

Definition at line 667 of file usbh_core.h.

◆ dev

struct usb_device* urb_t::dev

pointer to associated USB device

Definition at line 541 of file usbh_core.h.

◆ devnum

int usb_device::devnum

Device number on USB bus

Definition at line 669 of file usbh_core.h.

◆ driver

USB_DRIVER_T* usb_device::driver[MAX_DRIVER_PER_DEV]

Driver list

Definition at line 704 of file usbh_core.h.

◆ driver_cnt

int usb_device::driver_cnt

Total number of driver list

Definition at line 705 of file usbh_core.h.

◆ ep_list

EP_INFO_T usb_device::ep_list[MAX_ENDPOINTS]

Endpoint list

Definition at line 685 of file usbh_core.h.

◆ ep_list_cnt

int usb_device::ep_list_cnt

Total number of ep_list[]

Definition at line 686 of file usbh_core.h.

◆ error_count

int urb_t::error_count

number of errors in this transfer (iso only)

Definition at line 552 of file usbh_core.h.

◆ halted

uint32_t usb_device::halted[2]

endpoint halts; one bit per endpoint # & direction; [0] = IN, [1] = OUT

Definition at line 674 of file usbh_core.h.

◆ have_langid

int usb_device::have_langid

whether string_langid is valid yet

Definition at line 688 of file usbh_core.h.

◆ hcpriv

void* usb_device::hcpriv

Host Controller private data

Definition at line 691 of file usbh_core.h.

◆ hub_port

int usb_device::hub_port

The hub port that this device connected on

Definition at line 678 of file usbh_core.h.

◆ iface_alternate

char usb_device::iface_alternate

Active interface alternate setting

Definition at line 683 of file usbh_core.h.

◆ interval

int urb_t::interval

polling interval (irq only)

Definition at line 551 of file usbh_core.h.

◆ iso_frame_desc

ISO_PACKET_DESCRIPTOR_T urb_t::iso_frame_desc[8]

isochronous transfer descriptor

Definition at line 556 of file usbh_core.h.

◆ length

uint32_t iso_pkt_t::length

Length in transfer buffer

Definition at line 528 of file usbh_core.h.

◆ maxchild

int usb_device::maxchild

Number of ports if hub

Definition at line 701 of file usbh_core.h.

◆ next

struct urb_t* urb_t::next

pointer to next URB

Definition at line 540 of file usbh_core.h.

◆ number_of_packets

int urb_t::number_of_packets

number of packets in this request (iso)

Definition at line 550 of file usbh_core.h.

◆ offset

uint32_t iso_pkt_t::offset

Start offset in transfer buffer

Definition at line 527 of file usbh_core.h.

◆ parent

struct usb_device* usb_device::parent

parent device

Definition at line 677 of file usbh_core.h.

◆ pipe

uint32_t urb_t::pipe

pipe information

Definition at line 542 of file usbh_core.h.

◆ setup_packet

uint8_t* urb_t::setup_packet

setup packet (control only)

Definition at line 548 of file usbh_core.h.

◆ slow

int usb_device::slow

Is slow device.

Definition at line 670 of file usbh_core.h.

◆ speed

int usb_device::speed

Device speed.

Definition at line 671 of file usbh_core.h.

◆ start_frame

int urb_t::start_frame

start frame (iso/irq only)

Definition at line 549 of file usbh_core.h.

◆ status [1/2]

int iso_pkt_t::status

Transfer status

Definition at line 530 of file usbh_core.h.

◆ status [2/2]

int urb_t::status

returned status

Definition at line 543 of file usbh_core.h.

◆ string_langid

int usb_device::string_langid

language ID for strings

Definition at line 689 of file usbh_core.h.

◆ timeout

int urb_t::timeout

timeout (in jiffies)

Definition at line 553 of file usbh_core.h.

◆ toggle

uint32_t usb_device::toggle[2]

toggle bit ([0] = IN, [1] = OUT)

Definition at line 673 of file usbh_core.h.

◆ transfer_buffer

void* urb_t::transfer_buffer

associated data buffer

Definition at line 545 of file usbh_core.h.

◆ transfer_buffer_length

int urb_t::transfer_buffer_length

data buffer length

Definition at line 546 of file usbh_core.h.

◆ transfer_flags

uint32_t urb_t::transfer_flags

USB_DISABLE_SPD | USB_ISO_ASAP | etc.

Definition at line 544 of file usbh_core.h.

◆ urb_hcpriv

URB_PRIV_T urb_t::urb_hcpriv

private data for host controller

Definition at line 538 of file usbh_core.h.

◆ urb_list

USB_LIST_T urb_t::urb_list

list pointer to all active urbs

Definition at line 539 of file usbh_core.h.