Driver API for USB Host. More...
ARM_DRIVER_VERSION ARM_USBH_GetVersion (void) Get driver version. More...Driver API for USB Host.
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:
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.
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_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.
struct ARM_USBH_CAPABILITIESUSB 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:
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 ARM_USBH_SignalPortEvent_t ARM_USBH_SignalPipeEvent_tGet driver version.
The function ARM_USBH_GetVersion returns version information of the driver implementation in ARM_DRIVER_VERSION
Example:
void setup_usbh (void) {
drv_info = &Driver_USBH0;
if(version.
api< 0x10A) {
return;
}
}
Get driver 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:
void read_capabilities (void) {
drv_info = &Driver_USBH0;
}
Initialize USB Host Interface.
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:
De-initialize USB Host Interface.
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.
Control USB Host Interface Power.
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:
Refer to Function Call Sequence for more information.
int32_t ARM_USBH_PortVbusOnOff ( uint8_t port, bool vbus )Root HUB Port VBUS on/off.
The function ARM_USBH_PortVbusOnOff controls the VBUS signal of the specified port.
int32_t ARM_USBH_PortReset ( uint8_t port )Do Root HUB Port Reset.
Executes reset signalling on the specified port.
int32_t ARM_USBH_PortSuspend ( uint8_t port )Suspend Root HUB Port (stop generating SOFs).
The function ARM_USBH_PortSuspend auspends USB signaling on the specified port.
int32_t ARM_USBH_PortResume ( uint8_t port )Resume Root HUB Port (start generating SOFs).
The function ARM_USBH_PortResume resumes USB signaling on the specified port.
Get current Root HUB Port State.
The function ARM_USBH_PortGetState returns the current state of the specified port.
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.
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):
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.
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.
The function ARM_USBH_PipeModify modifies a pipe configuration that was created with ARM_USBH_PipeCreate.
Delete Pipe from System.
The function ARM_USBH_PipeDelete deletes a pipe that was created with ARM_USBH_PipeCreate (deactivates the pipe and releases used resources).
Reset Pipe.
The function ARM_USBH_PipeReset clears Halt condition and resets data toggle on the specified 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.
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.
Get result of USB Pipe transfer.
The function ARM_USBH_PipeTransferGetResult returns the number of successfully transferred data bytes started by ARM_USBH_PipeTransfer operation.
Abort current USB Pipe transfer.
The function ARM_USBH_PipeTransferAbort aborts an active pipe transfer started by ARM_USBH_PipeTransfer.
uint16_t ARM_USBH_GetFrameNumber ( void )Get current USB Frame Number.
The function ARM_USBH_GetFrameNumber returns the sequential 11-bit frame number of the last Start of Frame (SOF) packet.
void ARM_USBH_SignalPortEvent ( uint8_t port, uint32_t event )Signal Root HUB Port Event.
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:
Signal Pipe Event.
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:
See also:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4