CMSIS-Driver  
Peripheral Interface for Middleware and Application Code
 
Loading...
Searching...
No Matches
USB Host Interface

Driver API for USB Host Peripheral (Driver_USBH.h) More...

Content

 USBH Port Events
 The USB Host driver generates Port call back events that are notified via the function ARM_USBH_SignalPortEvent.
 
 USBH Pipe Events
 The USB Host driver generates Pipe call back events that are notified via the function ARM_USBH_SignalPipeEvent.
 
 USBH Packet Information
 Specify USB packet information used by the function ARM_USBH_PipeTransfer.
 

Data Structures

struct  ARM_DRIVER_USBH
 Access structure of USB Host Driver. More...
 
struct  ARM_USBH_CAPABILITIES
 USB Host Driver Capabilities. More...
 
struct  ARM_USBH_PORT_STATE
 USB Host Port State. More...
 

Typedefs

typedef uint32_t ARM_USBH_PIPE_HANDLE
 USB Host Pipe Handle.
 
typedef void(* ARM_USBH_SignalPortEvent_t) (uint8_t port, uint32_t event)
 Pointer to ARM_USBH_SignalPortEvent : Signal Root HUB Port Event.
 
typedef void(* ARM_USBH_SignalPipeEvent_t) (ARM_USBH_PIPE_HANDLE pipe_hndl, uint32_t event)
 Pointer to ARM_USBH_SignalPipeEvent : Signal Pipe Event.
 

Functions

ARM_DRIVER_VERSION ARM_USBH_GetVersion (void)
 Get driver version.
 
ARM_USBH_CAPABILITIES ARM_USBH_GetCapabilities (void)
 Get driver capabilities.
 
int32_t ARM_USBH_Initialize (ARM_USBH_SignalPortEvent_t cb_port_event, ARM_USBH_SignalPipeEvent_t cb_pipe_event)
 Initialize USB Host Interface.
 
int32_t ARM_USBH_Uninitialize (void)
 De-initialize USB Host Interface.
 
int32_t ARM_USBH_PowerControl (ARM_POWER_STATE state)
 Control USB Host Interface Power.
 
int32_t ARM_USBH_PortVbusOnOff (uint8_t port, bool vbus)
 Root HUB Port VBUS on/off.
 
int32_t ARM_USBH_PortReset (uint8_t port)
 Do Root HUB Port Reset.
 
int32_t ARM_USBH_PortSuspend (uint8_t port)
 Suspend Root HUB Port (stop generating SOFs).
 
int32_t ARM_USBH_PortResume (uint8_t port)
 Resume Root HUB Port (start generating SOFs).
 
ARM_USBH_PORT_STATE ARM_USBH_PortGetState (uint8_t port)
 Get current Root HUB Port State.
 
ARM_USBH_PIPE_HANDLE ARM_USBH_PipeCreate (uint8_t dev_addr, uint8_t dev_speed, uint8_t hub_addr, uint8_t hub_port, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_max_packet_size, uint8_t ep_interval)
 Create Pipe in System.
 
int32_t ARM_USBH_PipeModify (ARM_USBH_PIPE_HANDLE pipe_hndl, uint8_t dev_addr, uint8_t dev_speed, uint8_t hub_addr, uint8_t hub_port, uint16_t ep_max_packet_size)
 Modify Pipe in System.
 
int32_t ARM_USBH_PipeDelete (ARM_USBH_PIPE_HANDLE pipe_hndl)
 Delete Pipe from System.
 
int32_t ARM_USBH_PipeReset (ARM_USBH_PIPE_HANDLE pipe_hndl)
 Reset Pipe.
 
int32_t ARM_USBH_PipeTransfer (ARM_USBH_PIPE_HANDLE pipe_hndl, uint32_t packet, uint8_t *data, uint32_t num)
 Transfer packets through USB Pipe.
 
uint32_t ARM_USBH_PipeTransferGetResult (ARM_USBH_PIPE_HANDLE pipe_hndl)
 Get result of USB Pipe transfer.
 
int32_t ARM_USBH_PipeTransferAbort (ARM_USBH_PIPE_HANDLE pipe_hndl)
 Abort current USB Pipe transfer.
 
uint16_t ARM_USBH_GetFrameNumber (void)
 Get current USB Frame Number.
 
void ARM_USBH_SignalPortEvent (uint8_t port, uint32_t event)
 Signal Root HUB Port Event.
 
void ARM_USBH_SignalPipeEvent (ARM_USBH_PIPE_HANDLE pipe_hndl, uint32_t event)
 Signal Pipe Event.
 

Description

Driver API for USB Host Peripheral (Driver_USBH.h)

USB Host API

The header file Driver_USBH.h defines the API for the USB Host Driver interface used by middleware components. The driver implementation itself is a typical part of the Device Family Pack, which provides entry points to the interface as function pointers in the struct ARM_DRIVER_USBH. This structure can be available several times in each interface to control multiple USBH interfaces.

Driver_USBH.h also defines callback routines, which are categorized in port event callbacks and pipe event callbacks. Callbacks are called by the driver, in interrupt context when an appropriate event occurs, to signal port related events (ARM_USBH_SignalPortEvent) and pipe related events (ARM_USBH_SignalPipeEvent).


Data Structure Documentation

◆ ARM_DRIVER_USBH

struct ARM_DRIVER_USBH

Access structure of USB Host Driver.

The functions of the USB Host driver are accessed by function pointers. Refer to Common Driver Functions for overview information.

Each instance of an USBH provides such an access struct. The instance is indicated by a postfix in the symbol name of the access struct, for example:

  • Driver_USBH0 is the name of the access struct of the first instance (no. 0).
  • Driver_USBH1 is the name of the access struct of the second instance (no. 1).

A configuration setting in the middleware allows connecting the middleware to a specific driver instance Driver_USBHn. The default is 0, which connects a middleware to the first instance of a driver.

Note
The struct must remain unchanged.

Data Fields

ARM_DRIVER_VERSION(* GetVersion )(void)
 Pointer to ARM_USBH_GetVersion : Get driver version.
 
ARM_USBH_CAPABILITIES(* GetCapabilities )(void)
 Pointer to ARM_USBH_GetCapabilities : Get driver capabilities.
 
int32_t(* Initialize )(ARM_USBH_SignalPortEvent_t cb_port_event, ARM_USBH_SignalPipeEvent_t cb_pipe_event)
 Pointer to ARM_USBH_Initialize : Initialize USB Host Interface.
 
int32_t(* Uninitialize )(void)
 Pointer to ARM_USBH_Uninitialize : De-initialize USB Host Interface.
 
int32_t(* PowerControl )(ARM_POWER_STATE state)
 Pointer to ARM_USBH_PowerControl : Control USB Host Interface Power.
 
int32_t(* PortVbusOnOff )(uint8_t port, bool vbus)
 Pointer to ARM_USBH_PortVbusOnOff : Root HUB Port VBUS on/off.
 
int32_t(* PortReset )(uint8_t port)
 Pointer to ARM_USBH_PortReset : Do Root HUB Port Reset.
 
int32_t(* PortSuspend )(uint8_t port)
 Pointer to ARM_USBH_PortSuspend : Suspend Root HUB Port (stop generating SOFs).
 
int32_t(* PortResume )(uint8_t port)
 Pointer to ARM_USBH_PortResume : Resume Root HUB Port (start generating SOFs).
 
ARM_USBH_PORT_STATE(* PortGetState )(uint8_t port)
 Pointer to ARM_USBH_PortGetState : Get current Root HUB Port State.
 
ARM_USBH_PIPE_HANDLE(* PipeCreate )(uint8_t dev_addr, uint8_t dev_speed, uint8_t hub_addr, uint8_t hub_port, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_max_packet_size, uint8_t ep_interval)
 Pointer to ARM_USBH_PipeCreate : Create Pipe in System.
 
int32_t(* PipeModify )(ARM_USBH_PIPE_HANDLE pipe_hndl, uint8_t dev_addr, uint8_t dev_speed, uint8_t hub_addr, uint8_t hub_port, uint16_t ep_max_packet_size)
 Pointer to ARM_USBH_PipeModify : Modify Pipe in System.
 
int32_t(* PipeDelete )(ARM_USBH_PIPE_HANDLE pipe_hndl)
 Pointer to ARM_USBH_PipeDelete : Delete Pipe from System.
 
int32_t(* PipeReset )(ARM_USBH_PIPE_HANDLE pipe_hndl)
 Pointer to ARM_USBH_PipeReset : Reset Pipe.
 
int32_t(* PipeTransfer )(ARM_USBH_PIPE_HANDLE pipe_hndl, uint32_t packet, uint8_t *data, uint32_t num)
 Pointer to ARM_USBH_PipeTransfer : Transfer packets through USB Pipe.
 
uint32_t(* PipeTransferGetResult )(ARM_USBH_PIPE_HANDLE pipe_hndl)
 Pointer to ARM_USBH_PipeTransferGetResult : Get result of USB Pipe transfer.
 
int32_t(* PipeTransferAbort )(ARM_USBH_PIPE_HANDLE pipe_hndl)
 Pointer to ARM_USBH_PipeTransferAbort : Abort current USB Pipe transfer.
 
uint16_t(* GetFrameNumber )(void)
 Pointer to ARM_USBH_GetFrameNumber : Get current USB Frame Number.

 

Field Documentation

◆ GetVersion

ARM_DRIVER_VERSION(* GetVersion) (void)

Pointer to ARM_USBH_GetVersion : Get driver version.

◆ GetCapabilities

ARM_USBH_CAPABILITIES(* GetCapabilities) (void)

Pointer to ARM_USBH_GetCapabilities : Get driver capabilities.

◆ Initialize

int32_t(* Initialize) (ARM_USBH_SignalPortEvent_t cb_port_event, ARM_USBH_SignalPipeEvent_t cb_pipe_event)

Pointer to ARM_USBH_Initialize : Initialize USB Host Interface.

◆ Uninitialize

int32_t(* Uninitialize) (void)

Pointer to ARM_USBH_Uninitialize : De-initialize USB Host Interface.

◆ PowerControl

int32_t(* PowerControl) (ARM_POWER_STATE state)

Pointer to ARM_USBH_PowerControl : Control USB Host Interface Power.

◆ PortVbusOnOff

int32_t(* PortVbusOnOff) (uint8_t port, bool vbus)

Pointer to ARM_USBH_PortVbusOnOff : Root HUB Port VBUS on/off.

◆ PortReset

int32_t(* PortReset) (uint8_t port)

Pointer to ARM_USBH_PortReset : Do Root HUB Port Reset.

◆ PortSuspend

int32_t(* PortSuspend) (uint8_t port)

Pointer to ARM_USBH_PortSuspend : Suspend Root HUB Port (stop generating SOFs).

◆ PortResume

int32_t(* PortResume) (uint8_t port)

Pointer to ARM_USBH_PortResume : Resume Root HUB Port (start generating SOFs).

◆ PortGetState

ARM_USBH_PORT_STATE(* PortGetState) (uint8_t port)

Pointer to ARM_USBH_PortGetState : Get current Root HUB Port State.

◆ PipeCreate

ARM_USBH_PIPE_HANDLE(* PipeCreate) (uint8_t dev_addr, uint8_t dev_speed, uint8_t hub_addr, uint8_t hub_port, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_max_packet_size, uint8_t ep_interval)

Pointer to ARM_USBH_PipeCreate : Create Pipe in System.

◆ PipeModify

int32_t(* PipeModify) (ARM_USBH_PIPE_HANDLE pipe_hndl, uint8_t dev_addr, uint8_t dev_speed, uint8_t hub_addr, uint8_t hub_port, uint16_t ep_max_packet_size)

Pointer to ARM_USBH_PipeModify : Modify Pipe in System.

◆ PipeDelete

int32_t(* PipeDelete) (ARM_USBH_PIPE_HANDLE pipe_hndl)

Pointer to ARM_USBH_PipeDelete : Delete Pipe from System.

◆ PipeReset

int32_t(* PipeReset) (ARM_USBH_PIPE_HANDLE pipe_hndl)

Pointer to ARM_USBH_PipeReset : Reset Pipe.

◆ PipeTransfer

int32_t(* PipeTransfer) (ARM_USBH_PIPE_HANDLE pipe_hndl, uint32_t packet, uint8_t *data, uint32_t num)

Pointer to ARM_USBH_PipeTransfer : Transfer packets through USB Pipe.

◆ PipeTransferGetResult

uint32_t(* PipeTransferGetResult) (ARM_USBH_PIPE_HANDLE pipe_hndl)

Pointer to ARM_USBH_PipeTransferGetResult : Get result of USB Pipe transfer.

◆ PipeTransferAbort

int32_t(* PipeTransferAbort) (ARM_USBH_PIPE_HANDLE pipe_hndl)

Pointer to ARM_USBH_PipeTransferAbort : Abort current USB Pipe transfer.

◆ GetFrameNumber

uint16_t(* GetFrameNumber) (void)

Pointer to ARM_USBH_GetFrameNumber : Get current USB Frame Number.

◆ ARM_USBH_CAPABILITIES

struct ARM_USBH_CAPABILITIES

USB Host Driver Capabilities.


A USB Host driver can be implemented with different capabilities. The data fields of this structure encode the capabilities implemented by this driver.

Returned by:

Note
The struct must remain unchanged.
Data Fields
uint32_t port_mask: 15 Root HUB available Ports Mask.
uint32_t auto_split: 1 Automatic SPLIT packet handling.
uint32_t event_connect: 1 Signal Connect event.
uint32_t event_disconnect: 1 Signal Disconnect event.
uint32_t event_overcurrent: 1 Signal Overcurrent event.
uint32_t reserved: 13 Reserved (must be zero)

◆ ARM_USBH_PORT_STATE

struct ARM_USBH_PORT_STATE

USB Host Port State.

This structure stores information about the state of the USB Host Port. The data fields encode whether a device is connected to the port, if port overcurrent is detected, and the port speed.

Returned by:

Data Fields
uint32_t connected: 1 USB Host Port connected flag.
uint32_t overcurrent: 1 USB Host Port overcurrent flag.
uint32_t speed: 2 USB Host Port speed setting (ARM_USB_SPEED_xxx)
uint32_t reserved: 28

Typedef Documentation

◆ ARM_USBH_PIPE_HANDLE

USB Host Pipe Handle.

Each pipe is identified through a unique number, which is created by the function ARM_USBH_PipeCreate.

Parameter for:

Retruned by:

◆ ARM_USBH_SignalPortEvent_t

ARM_USBH_SignalPortEvent_t

Pointer to ARM_USBH_SignalPortEvent : Signal Root HUB Port Event.

Provides the typedef for the callback function ARM_USBH_SignalPortEvent.

Parameter for:

◆ ARM_USBH_SignalPipeEvent_t

ARM_USBH_SignalPipeEvent_t

Pointer to ARM_USBH_SignalPipeEvent : Signal Pipe Event.

Provides the typedef for the callback function ARM_USBH_SignalPipeEvent.

Parameter for:

Function Documentation

◆ ARM_USBH_GetVersion()

ARM_DRIVER_VERSION ARM_USBH_GetVersion ( void  )

Get driver version.

Returns
ARM_DRIVER_VERSION

The function ARM_USBH_GetVersion returns version information of the driver implementation in ARM_DRIVER_VERSION

  • API version is the version of the CMSIS-Driver specification used to implement this driver.
  • Driver version is source code version of the actual driver implementation.

Example:

extern ARM_DRIVER_USBH Driver_USBH0;
ARM_DRIVER_USBH *drv_info;
void setup_usbh (void) {
drv_info = &Driver_USBH0;
version = drv_info->GetVersion ();
if (version.api < 0x10A) { // requires at minimum API version 1.10 or higher
// error handling
return;
}
}
uint16_t api
API version.
Definition: Driver_Common.h:47
Driver Version.
Definition: Driver_Common.h:46
ARM_DRIVER_VERSION(* GetVersion)(void)
Pointer to ARM_USBH_GetVersion : Get driver version.
Definition: Driver_USBH.h:308
Access structure of USB Host Driver.
Definition: Driver_USBH.h:307

◆ ARM_USBH_GetCapabilities()

ARM_USBH_CAPABILITIES ARM_USBH_GetCapabilities ( void  )

Get driver capabilities.

Returns
ARM_USBH_CAPABILITIES

The function ARM_USBH_GetCapabilities returns information about capabilities in this driver implementation. The data fields of the structure ARM_USBH_CAPABILITIES encode various capabilities, for example available HUB ports or if the hardware can generate signal events using the ARM_USBH_SignalPortEvent callback function.

Example:

extern ARM_DRIVER_USBH Driver_USBH0;
ARM_DRIVER_USBH *drv_info;
void read_capabilities (void) {
ARM_USBH_CAPABILITIES drv_capabilities;
drv_info = &Driver_USBH0;
drv_capabilities = drv_info->GetCapabilities ();
// interrogate capabilities
}
ARM_USBH_CAPABILITIES(* GetCapabilities)(void)
Pointer to ARM_USBH_GetCapabilities : Get driver capabilities.
Definition: Driver_USBH.h:309
USB Host Driver Capabilities.
Definition: Driver_USBH.h:294

◆ ARM_USBH_Initialize()

int32_t ARM_USBH_Initialize ( ARM_USBH_SignalPortEvent_t  cb_port_event,
ARM_USBH_SignalPipeEvent_t  cb_pipe_event 
)

Initialize USB Host Interface.

Parameters
[in]cb_port_eventPointer to ARM_USBH_SignalPortEvent
[in]cb_pipe_eventPointer to ARM_USBH_SignalPipeEvent
Returns
Status Error Codes

The function ARM_USBH_Initialize initializes the USB Host interface. It is called when the middleware component starts operation.

The function performs the following operations:

The parameter cb_port_event is a pointer to the ARM_USBH_SignalPortEvent callback function; use a NULL pointer when no port callback signals are required.

The parameter cb_pipe_event is a pointer to the ARM_USBH_SignalPipeEvent callback function.

Example:

◆ ARM_USBH_Uninitialize()

int32_t ARM_USBH_Uninitialize ( void  )

De-initialize USB Host Interface.

Returns
Status Error Codes

The function ARM_USBH_Uninitialize de-initializes the resources of USB Host interface.

It is called when the middleware component stops operation and releases the software resources used by the interface.

◆ ARM_USBH_PowerControl()

int32_t ARM_USBH_PowerControl ( ARM_POWER_STATE  state)

Control USB Host Interface Power.

Parameters
[in]statePower state
Returns
Status Error Codes

The function ARM_USBH_PowerControl operates the power modes of the USB Host interface.

The parameter state sets the operation and can have the following values:

  • ARM_POWER_FULL : set-up peripheral for data transfers, enable interrupts (NVIC) and optionally DMA. Can be called multiple times. If the peripheral is already in this mode the function performs no operation and returns with ARM_DRIVER_OK.
  • ARM_POWER_LOW : may use power saving. Returns ARM_DRIVER_ERROR_UNSUPPORTED when not implemented.
  • ARM_POWER_OFF : terminates any pending data transfers, disables peripheral, disables related interrupts and DMA.

Refer to Function Call Sequence for more information.

◆ ARM_USBH_PortVbusOnOff()

int32_t ARM_USBH_PortVbusOnOff ( uint8_t  port,
bool  vbus 
)

Root HUB Port VBUS on/off.

Parameters
[in]portRoot HUB Port Number
[in]vbus
  • false VBUS off
  • true VBUS on
Returns
Status Error Codes

The function ARM_USBH_PortVbusOnOff controls the VBUS signal of the specified port.

◆ ARM_USBH_PortReset()

int32_t ARM_USBH_PortReset ( uint8_t  port)

Do Root HUB Port Reset.

Parameters
[in]portRoot HUB Port Number
Returns
Status Error Codes

Executes reset signalling on the specified port.

◆ ARM_USBH_PortSuspend()

int32_t ARM_USBH_PortSuspend ( uint8_t  port)

Suspend Root HUB Port (stop generating SOFs).

Parameters
[in]portRoot HUB Port Number
Returns
Status Error Codes

The function ARM_USBH_PortSuspend auspends USB signaling on the specified port.

◆ ARM_USBH_PortResume()

int32_t ARM_USBH_PortResume ( uint8_t  port)

Resume Root HUB Port (start generating SOFs).

Parameters
[in]portRoot HUB Port Number
Returns
Status Error Codes

The function ARM_USBH_PortResume resumes USB signaling on the specified port.

◆ ARM_USBH_PortGetState()

ARM_USBH_PORT_STATE ARM_USBH_PortGetState ( uint8_t  port)

Get current Root HUB Port State.

Parameters
[in]portRoot HUB Port Number
Returns
Port State ARM_USBH_PORT_STATE

The function ARM_USBH_PortGetState returns the current state of the specified port.

◆ ARM_USBH_PipeCreate()

ARM_USBH_PIPE_HANDLE ARM_USBH_PipeCreate ( uint8_t  dev_addr,
uint8_t  dev_speed,
uint8_t  hub_addr,
uint8_t  hub_port,
uint8_t  ep_addr,
uint8_t  ep_type,
uint16_t  ep_max_packet_size,
uint8_t  ep_interval 
)

Create Pipe in System.

Parameters
[in]dev_addrDevice Address
[in]dev_speedDevice Speed
[in]hub_addrHub Address
[in]hub_portHub Port
[in]ep_addrEndpoint Address
  • ep_addr.0..3: Address
  • ep_addr.7: Direction
[in]ep_typeEndpoint Type (ARM_USB_ENDPOINT_xxx)
[in]ep_max_packet_sizeEndpoint Maximum Packet Size
[in]ep_intervalEndpoint Polling Interval
Returns
Pipe Handle ARM_USBH_PIPE_HANDLE

The function ARM_USBH_PipeCreate creates a pipe for transfers (allocates required resources and configures the pipe).

The parameters specify pipe information (connection between host and device endpoint):

  • device: address and speed
  • hub (optional): hub address and number of the hub port to which the device is connected
  • endpoint: address, type, maximum packet size and polling interval

The function returns an pipe handle that is used for all subsequent operations on that pipe. In case of errors an invalid handle (NULL) is returned.

◆ ARM_USBH_PipeModify()

int32_t ARM_USBH_PipeModify ( ARM_USBH_PIPE_HANDLE  pipe_hndl,
uint8_t  dev_addr,
uint8_t  dev_speed,
uint8_t  hub_addr,
uint8_t  hub_port,
uint16_t  ep_max_packet_size 
)

Modify Pipe in System.

Parameters
[in]pipe_hndlPipe Handle
[in]dev_addrDevice Address
[in]dev_speedDevice Speed
[in]hub_addrHub Address
[in]hub_portHub Port
[in]ep_max_packet_sizeEndpoint Maximum Packet Size
Returns
Status Error Codes

The function ARM_USBH_PipeModify modifies a pipe configuration that was created with ARM_USBH_PipeCreate.

◆ ARM_USBH_PipeDelete()

int32_t ARM_USBH_PipeDelete ( ARM_USBH_PIPE_HANDLE  pipe_hndl)

Delete Pipe from System.

Parameters
[in]pipe_hndlPipe Handle
Returns
Status Error Codes

The function ARM_USBH_PipeDelete deletes a pipe that was created with ARM_USBH_PipeCreate (deactivates the pipe and releases used resources).

◆ ARM_USBH_PipeReset()

int32_t ARM_USBH_PipeReset ( ARM_USBH_PIPE_HANDLE  pipe_hndl)

Reset Pipe.

Parameters
[in]pipe_hndlPipe Handle
Returns
Status Error Codes

The function ARM_USBH_PipeReset clears Halt condition and resets data toggle on the specified pipe.

◆ ARM_USBH_PipeTransfer()

int32_t ARM_USBH_PipeTransfer ( ARM_USBH_PIPE_HANDLE  pipe_hndl,
uint32_t  packet,
uint8_t *  data,
uint32_t  num 
)

Transfer packets through USB Pipe.

Parameters
[in]pipe_hndlPipe Handle
[in]packetPacket information
[in]dataPointer to buffer with data to send or for data to receive
[in]numNumber of data bytes to transfer
Returns
Status Error Codes

The function ARM_USBH_PipeTransfer generates packets for sending or receiving data from an USB Endpoint.

The function specifies the buffer with data to send or for data to receive and the number of bytes to transfer (must be multiple of device endpoint maximum packet size for receive). It also specifies USBH Packet Information with parameter packet.

The function is non-blocking and returns as soon as the driver starts the operation on the specified pipe. During the operation it is not allowed to call this function again on the same pipe. Also the data buffer must stay allocated and the contents of data must not be modified.

Operation is completed when the the requested number of data bytes have been transferred and is indicated with ARM_USBH_EVENT_TRANSFER_COMPLETE event. It can also finish earlier on reception of different handshake tokens which are also indicated through USBH Pipe Events.

Transfer operation can be aborted by calling ARM_USBH_PipeTransferAbort.

◆ ARM_USBH_PipeTransferGetResult()

uint32_t ARM_USBH_PipeTransferGetResult ( ARM_USBH_PIPE_HANDLE  pipe_hndl)

Get result of USB Pipe transfer.

Parameters
[in]pipe_hndlPipe Handle
Returns
number of successfully transferred data bytes


The function ARM_USBH_PipeTransferGetResult returns the number of successfully transferred data bytes started by ARM_USBH_PipeTransfer operation.

◆ ARM_USBH_PipeTransferAbort()

int32_t ARM_USBH_PipeTransferAbort ( ARM_USBH_PIPE_HANDLE  pipe_hndl)

Abort current USB Pipe transfer.

Parameters
[in]pipe_hndlPipe Handle
Returns
Status Error Codes

The function ARM_USBH_PipeTransferAbort aborts an active pipe transfer started by ARM_USBH_PipeTransfer.

◆ ARM_USBH_GetFrameNumber()

uint16_t ARM_USBH_GetFrameNumber ( void  )

Get current USB Frame Number.

Returns
Frame Number

The function ARM_USBH_GetFrameNumber returns the sequential 11-bit frame number of the last Start of Frame (SOF) packet.

◆ ARM_USBH_SignalPortEvent()

void ARM_USBH_SignalPortEvent ( uint8_t  port,
uint32_t  event 
)

Signal Root HUB Port Event.

Parameters
[in]portRoot HUB Port Number
[in]eventUSBH Port Events

The function ARM_USBH_SignalPortEvent is a callback function registered by the function ARM_USBH_Initialize.

The parameter port specifies the root hub port number.
The parameter event indicates one or more events that occurred during driver operation. Each event is encoded in a separate bit and therefore it is possible to signal multiple events within the same call.

Not every event is necessarily generated by the driver. This depends on the implemented capabilities stored in the data fields of the structure ARM_USBH_CAPABILITIES, which can be retrieved with the function ARM_USBH_GetCapabilities.

The following events can be generated:

Parameter event Bit Description supported when ARM_USBH_CAPABILITIES
ARM_USBH_EVENT_CONNECT 0 Occurs when USB Device connects to the Host. data field event_connect= 1
ARM_USBH_EVENT_DISCONNECT 1 Occurs when USB Device disconnects from the Host. data field event_disconnect= 1
ARM_USBH_EVENT_OVERCURRENT 2 Occurs when USB Overcurrent it detected. data field event_overcurrent= 1
ARM_USBH_EVENT_RESET 3 Occurs when USB Reset is completed after calling ARM_USBH_PortReset. always supported
ARM_USBH_EVENT_SUSPEND 4 Occurs when USB Suspend is detected. always supported
ARM_USBH_EVENT_RESUME 5 Occurs when USB Resume is detected. always supported
ARM_USBH_EVENT_REMOTE_WAKEUP 6 Occurs when USB Remote wakeup is detected. always supported

◆ ARM_USBH_SignalPipeEvent()

void ARM_USBH_SignalPipeEvent ( ARM_USBH_PIPE_HANDLE  pipe_hndl,
uint32_t  event 
)

Signal Pipe Event.

Parameters
[in]pipe_hndlPipe Handle
[in]eventUSBH Pipe Events

The function ARM_USBH_SignalPipeEvent is a callback function registered by the function ARM_USBH_Initialize.

The parameter pipe_hndl specifies the pipe handle.
The parameter event indicates one or more events that occurred during driver operation. Each event is encoded in a separate bit and therefore it is possible to signal multiple events within the same call.

The following events can be generated:

Parameter event Bit Description
ARM_USBH_EVENT_TRANSFER_COMPLETE 0 Occurs after all the data has been transferred without errors.
ARM_USBH_EVENT_HANDSHAKE_NAK 1 Occurs when NAK Handshake is received before all the data is transferred.
ARM_USBH_EVENT_HANDSHAKE_NYET 2 Occurs when NYET Handshake is received before all the data is transferred.
ARM_USBH_EVENT_HANDSHAKE_MDATA 3 Occurs when MDATA Handshake is received before all the data is transferred.
ARM_USBH_EVENT_HANDSHAKE_STALL 4 Occurs when STALL Handshake is received before all the data is transferred.
ARM_USBH_EVENT_HANDSHAKE_ERR 5 Occurs when ERR Handshake is received before all the data is transferred.
ARM_USBH_EVENT_BUS_ERROR 6 Occurs when bus error is detected before all the data is transferred.

See also:

  • ARM_USBH_PipeCreate