FreeRTOS: Common I/O
AWS IoT Common I/O library
Return to main page ↑
usb device Abstraction APIs.

Data Structures

struct  IotUsbDeviceEndpointConfig_t
 Endpoint configuration structure. More...
 
struct  IotUsbDeviceEndpointInfo_t
 Endpoint status structure. More...
 

Typedefs

typedef struct IotUsbDevice * IotUsbDeviceHandle_t
 IotUsbDeviceHandle_t is the handle type returned by calling iot_usb_device_open(). This is initialized in open and returned to caller. The caller must pass this pointer to the rest of APIs.
 
typedef int32_t(* IotUsbDeviceCallback_t) (IotUsbDeviceHandle_t const pxUsbDevice, uint32_t ulDeviceEvent, void *pvUserContext)
 The callback function for USB device event operation. This callback is passed to driver by using iot_usb_device_set_callback API. It's called when one of the events (IotUsbDeviceEvent_t) happen. This callback is used by upper layer to set up upper layer callback by calling iot_usb_device_set_device_callback. It is used when the bus state changes and an event is generated, e.g. an bus reset event happened, usb class layer needs to know such event and react accordingly. More...
 
typedef int32_t(* IotUsbDeviceEndpointCallbackFn_t) (IotUsbDeviceOperationStatus_t xStatus, void *pvUserContext)
 The callback typedef for USB device endpoint. For each endpoint, it's passed when user set endpoint callback by iot_usb_device_set_endpoint_callback API. This callback is used to notify the upper layer about the endpoint tranafer result. More...
 

Enumerations

enum  IotUsbDeviceEvent_t {
  eUSBDeviceBusResetEvent, eUSBDeviceLPMState1Event, eUSBDeviceLPMState2Event, eUSBDeviceLPMState3Event,
  eUSBDeviceLPMState1ResumeEvent, eUSBDeviceLPMState2ResumeEvent, eUSBDeviceLPMState3ResumeEvent, eUSBDeviceErrorEvent,
  eUSBDeviceDetachEvent, eUSBDeviceAttachEvent
}
 common notify event types in device callback. More...
 
enum  IotUsbDeviceIoctlRequest_t {
  eUSBDeviceGetSpeed, eUSBDeviceGetAddress, eUSBDeviceSetAddress, eUSBDeviceGetEndpointStatus,
  eUSBDeviceGetState, eUSBDeviceGetStatus, eUSBDeviceGetSyncFrame, eUSBDeviceSetTestMode,
  eUSBDeviceSetState, eUSBDeviceLPMState1Suspend, eUSBDeviceLPMState1Resume, eUSBDeviceLPMState2Suspend,
  eUSBDeviceLPMState2Resume, eUSBDeviceLPMState3Suspend, eUSBDeviceLPMState3Resume, eUSBDeviceRemoteWakeup
}
 Ioctl request types. More...
 
enum  IotUsbDeviceState_t {
  eUsbDeviceStateConfigured, eUsbDeviceStateAddress, eUsbDeviceStateDefault, eUsbDeviceStateAddressing,
  eUsbDeviceStateTestMode
}
 USB device state. More...
 
enum  IotUsbDeviceEndpointStatus_t { eUsbDeviceEndpointStateIdle, eUsbDeviceEndpointStateStalled, eUsbDeviceEndpointStateBusy, eUsbDeviceEndpointStateClosed }
 Defines endpoint state. More...
 
enum  IotUsbHostController_t { eUsbDeviceControllerOHCI, eUsbDeviceControllerUHCI, eUsbDeviceControllerEHCI, eUsbDeviceControllerXHCI }
 Define device controller ID. More...
 
enum  IotUsbDeviceOperationStatus_t { eUsbDeviceCompleted = IOT_USB_DEVICE_SUCCESS, eUsbDeviceReadFailed = IOT_USB_DEVICE_READ_FAILED, eUsbDeviceWriteFailed = IOT_USB_DEVICE_WRITE_FAILED }
 USB device driver operation status. More...
 

Functions

IotUsbDeviceHandle_t iot_usb_device_open (int32_t lUsbDeviceControllerInstance)
 Initiates the usb device controller interface. More...
 
int32_t iot_usb_device_connect (IotUsbDeviceHandle_t const pxUsbDevice)
 Connect the USB device. More...
 
int32_t iot_usb_device_disconnect (IotUsbDeviceHandle_t const pxUsbDevice)
 Disconnect the USB device. More...
 
void iot_usb_device_set_device_callback (IotUsbDeviceHandle_t const pxUsbDevice, IotUsbDeviceCallback_t xCallback, void *pvUserContext)
 Sets the application callback to be called on device event. More...
 
int32_t iot_usb_device_endpoint_open (IotUsbDeviceHandle_t const pxUsbDevice, IotUsbDeviceEndpointConfig_t *pxEpConfig)
 Initiates the usb device specific endpoint. More...
 
void iot_usb_device_set_endpoint_callback (IotUsbDeviceHandle_t const pxUsbDevice, uint8_t ucEndpointAddress, IotUsbDeviceEndpointCallbackFn_t xCallback, void *pvUserContext)
 Sets the endpoint callback to be called on endpoint transfer. More...
 
int32_t iot_usb_device_endpoint_close (IotUsbDeviceHandle_t const pxUsbDevice, uint8_t ucEndpointAddress)
 De-initializes the usb device specific endpoint. More...
 
int32_t iot_usb_device_endpoint_stall (IotUsbDeviceHandle_t const pxUsbDevice, uint8_t ucEndpointAddress)
 Stall the usb device specific endpoint. This function is to set stall conditions for the specific endpoint. The STALL packet indicates that the endpoint has halted, or a control pipe does not support a certain request. A function uses the STALL handshake packet to indicate that it is unable to transmit or receive data. Besides the default control pipe, all of a function's endpoints are in an undefined state after the device issues a STALL handshake packet. The host must never issue a STALL handshake packet. Typically, the STALL handshake indicates a functional stall. A functional stall occurs when the halt feature of an endpoint is set. In this circumstance, host intervention is required via the default control pipe to clear the halt feature of the halted endpoint. Less often, the function returns a STALL handshake during a SETUP or DATA stage of a control transfer. This is called a protocol stall and is resolved when the host issues the next SETUP transaction. More...
 
int32_t iot_usb_device_endpoint_unstall (IotUsbDeviceHandle_t const pxUsbDevice, uint8_t ucEndpointAddress)
 Unstall the usb device specific endpoint. More...
 
int32_t iot_usb_device_read_sync (IotUsbDeviceHandle_t const pxUsbDevice, uint8_t ucEndpointAddress, uint8_t *const pvBuffer, size_t xBytes)
 Starts the USB device read operation in blocking mode. More...
 
int32_t iot_usb_device_write_sync (IotUsbDeviceHandle_t const pxUsbDevice, uint8_t ucEndpointAddress, uint8_t *const pvBuffer, size_t xBytes)
 Starts the USB device write operation in blocking mode. More...
 
int32_t iot_usb_device_read_async (IotUsbDeviceHandle_t const pxUsbDevice, uint8_t ucEndpointAddress, uint8_t *const pvBuffer, size_t xBytes)
 Starts the USB device read operation in non-blocking mode. More...
 
int32_t iot_usb_device_write_async (IotUsbDeviceHandle_t const pxUsbDevice, uint8_t ucEndpointAddress, uint8_t *const pvBuffer, size_t xBytes)
 Starts the USB device write operation in non-blocking mode. More...
 
int32_t iot_usb_device_ioctl (IotUsbDeviceHandle_t const pxUsbDevice, IotUsbDeviceIoctlRequest_t xUsbDeviceRequest, void *const pvBuffer)
 Used for various USB device control function. More...
 
int32_t iot_usb_device_endpoint_cancel_transfer (IotUsbDeviceHandle_t const pxUsbDevice, uint8_t ucEndpointAddress)
 This function is used to cancel the pending transfer for given endpoint. More...
 
int32_t iot_usb_device_close (IotUsbDeviceHandle_t const pxUsbDevice)
 Close the USB device peripheral. More...
 

Detailed Description

Typedef Documentation

◆ IotUsbDeviceCallback_t

typedef int32_t(* IotUsbDeviceCallback_t) (IotUsbDeviceHandle_t const pxUsbDevice, uint32_t ulDeviceEvent, void *pvUserContext)

The callback function for USB device event operation. This callback is passed to driver by using iot_usb_device_set_callback API. It's called when one of the events (IotUsbDeviceEvent_t) happen. This callback is used by upper layer to set up upper layer callback by calling iot_usb_device_set_device_callback. It is used when the bus state changes and an event is generated, e.g. an bus reset event happened, usb class layer needs to know such event and react accordingly.

Parameters
[in]pxUsbDeviceThe usb device peripheral handle returned in the open() call.
[in]ulDeviceEventUSB device asynchronous event.
[in]pvUserContextUser Context passed when setting the callback. This is not used or modified by the driver. The context is provided by the caller when setting the callback, and is passed back to the caller in the callback.

◆ IotUsbDeviceEndpointCallbackFn_t

typedef int32_t(* IotUsbDeviceEndpointCallbackFn_t) (IotUsbDeviceOperationStatus_t xStatus, void *pvUserContext)

The callback typedef for USB device endpoint. For each endpoint, it's passed when user set endpoint callback by iot_usb_device_set_endpoint_callback API. This callback is used to notify the upper layer about the endpoint tranafer result.

Parameters
[out]xStatusUsb device asynchronous operation status.
[in]pvUserContextUser Context passed when setting the callback. This is not used or modified by the driver. The context is provided by the caller when setting the callback, and is passed back to the caller in the callback.

Enumeration Type Documentation

◆ IotUsbDeviceEvent_t

common notify event types in device callback.

Enumerator
eUSBDeviceBusResetEvent 

USB bus reset signal detected. Signal is initiated from USB Host.

eUSBDeviceLPMState1Event 

USB LPM (link power management) state 1 event: for usb 2.0, correspond to L1 sleep, host initialize LPM extended transaction; for usb 3.0, correspond to U1 standby, both device and host can initialize.

eUSBDeviceLPMState2Event 

USB LPM state 2 event: for usb 2.0, correspond to L2 suspend, host nees to support to trigger it after 3ms of inactivity; for usb 3.0, correspond to U2 standby, both device and host can initialize.

eUSBDeviceLPMState3Event 

USB LPM state 3 event: for usb 2.0, correspond to L3 off, disconnect or power off will trigger it; for usb 3.0, correspond to U3 suspend, it can only be initialized by host.

eUSBDeviceLPMState1ResumeEvent 

USB resume event from LPM state 1: for usb 2.0 and 3.0, both device and host can initialize resume signaling.

eUSBDeviceLPMState2ResumeEvent 

USB resume event from LPM state 2: for usb 2.0 and 3.0, both device and host can initialize resume signaling.

eUSBDeviceLPMState3ResumeEvent 

USB resume event from LPM state 3: for usb 2.0, L3 is off state, port needs reset or power on; for usb 3.0, both device and host can initialize resume signaling.

eUSBDeviceErrorEvent 

An error is happened in the bus.

eUSBDeviceDetachEvent 

USB device is disconnected from a host.

eUSBDeviceAttachEvent 

USB device is connected to a host.

◆ IotUsbDeviceIoctlRequest_t

Ioctl request types.

Enumerator
eUSBDeviceGetSpeed 

Get device speed. Return uint8_t integer.

eUSBDeviceGetAddress 

Get device address. Return an uint8_t integer range from 1~127.

eUSBDeviceSetAddress 

Set device address. Take an uint8_t integer to set it as address.

eUSBDeviceGetEndpointStatus 

Get endpoint status. Return IotUsbDeviceEndpointStatus_t type.

eUSBDeviceGetState 

Get device state. Return IotUsbDeviceState_t.

eUSBDeviceGetStatus 

Get device status. Return uint16_t.

eUSBDeviceGetSyncFrame 

Get Sync frame. Returns the frame number of synchronization frame as uint16_t.

eUSBDeviceSetTestMode 

Set device in test mode. For compliance testing defined in usb protocol.

Warning
Device needs to power cycle to exit test mode.
eUSBDeviceSetState 

Set device state. Take IotUsbDeviceState_t and set it

eUSBDeviceLPMState1Suspend 

Suspend usb to LPM state 1: for usb 2.0, it is L1 state; for usb 3.0, it is U1 state.

eUSBDeviceLPMState1Resume 

Resume usb from LPM state 1: for usb 2.0, it is exit L1 state; for usb 3.0, it is exit U1 state.

eUSBDeviceLPMState2Suspend 

Suspend usb to LPM state 2: for usb 2.0, it is L2 state; for usb 3.0, it is U2 state.

eUSBDeviceLPMState2Resume 

Resume usb from LPM state 2: for usb 2.0, it is exit L2 state; for usb 3.0, it is exit U2 state.

eUSBDeviceLPMState3Suspend 

Suspend usb to LPM state 3: for usb 2.0, it is L3 state; for usb 3.0, it is U3 state.

eUSBDeviceLPMState3Resume 

Resume usb from LPM state 3: for usb 2.0, it is exit L3 state; for usb 3.0, it is exit U3 state.

eUSBDeviceRemoteWakeup 

Remote wakeup host.

◆ IotUsbDeviceState_t

USB device state.

Enumerator
eUsbDeviceStateConfigured 

Device state, usb device is configured and ready for use by host

eUsbDeviceStateAddress 

Device state, usb device Address assigned

eUsbDeviceStateDefault 

Device state, usb device is reset, but address not assigned yet

eUsbDeviceStateAddressing 

Device state, usb device is undergoing assigning address

eUsbDeviceStateTestMode 

Device state, usb device is in test mode

◆ IotUsbDeviceEndpointStatus_t

Defines endpoint state.

Enumerator
eUsbDeviceEndpointStateIdle 

Endpoint state, idle

eUsbDeviceEndpointStateStalled 

Endpoint state, stalled

eUsbDeviceEndpointStateBusy 

Endpoint state, busy

eUsbDeviceEndpointStateClosed 

Endpoint state, Closed, not configured

◆ IotUsbHostController_t

Define device controller ID.

Enumerator
eUsbDeviceControllerOHCI 

Open Device Controller Interface

eUsbDeviceControllerUHCI 

Universal Device Controller Interface

eUsbDeviceControllerEHCI 

Enhanced Device Controller Interface

eUsbDeviceControllerXHCI 

Extensible Device Controller Interface

◆ IotUsbDeviceOperationStatus_t

USB device driver operation status.

Enumerator
eUsbDeviceCompleted 

Device operation completed successfully.

eUsbDeviceReadFailed 

Device read operation failed.

eUsbDeviceWriteFailed 

Device write operation failed.

Function Documentation

◆ iot_usb_device_open()

IotUsbDeviceHandle_t iot_usb_device_open ( int32_t  lUsbDeviceControllerInstance)

Initiates the usb device controller interface.

The instance of USB device controller to initialize.

Returns
  • The handle to the USB device if SUCCESS
  • NULL if
    • invalid lUsbDeviceControllerInstance
    • already open

◆ iot_usb_device_connect()

int32_t iot_usb_device_connect ( IotUsbDeviceHandle_t const  pxUsbDevice)

Connect the USB device.

The function enables the device functionality, so that the device can be recognized by the host when the device detects that it has been connected to a host.

Warning
this function must be called in order for USB to be recognized but not necessarily enumerated which requires the class to exchange control packets.
Parameters
[in]pxUsbDeviceThe usb device peripheral handle returned in the open() call.
Returns
  • IOT_USB_DEVICE_SUCCESS on success
  • IOT_USB_DEVICE_INVALID_VALUE if pxUsbDevice is NULL.

◆ iot_usb_device_disconnect()

int32_t iot_usb_device_disconnect ( IotUsbDeviceHandle_t const  pxUsbDevice)

Disconnect the USB device.

The function disables the device functionality, after this function called, even the device is attached to the host, and the device can't work.

Parameters
[in]pxUsbDeviceThe usb device peripheral handle returned in the open() call.
Returns
  • IOT_USB_DEVICE_SUCCESS on success
  • IOT_USB_DEVICE_INVALID_VALUE if pxUsbDevice is NULL.

◆ iot_usb_device_set_device_callback()

void iot_usb_device_set_device_callback ( IotUsbDeviceHandle_t const  pxUsbDevice,
IotUsbDeviceCallback_t  xCallback,
void *  pvUserContext 
)

Sets the application callback to be called on device event.

Note
Single callback is used, per instance.
Newly set callback overrides the one previously set
Warning
If input handle or if callback function is NULL, this function silently takes no action.
Parameters
[in]pxUsbDeviceThe usb device peripheral handle returned in the open() call.
[in]xCallbackThe callback function to be called on device event.
[in]pvUserContextThe user context to be passed back when callback is called.

◆ iot_usb_device_endpoint_open()

int32_t iot_usb_device_endpoint_open ( IotUsbDeviceHandle_t const  pxUsbDevice,
IotUsbDeviceEndpointConfig_t pxEpConfig 
)

Initiates the usb device specific endpoint.

Warning
: Its the class codes responsibility to make sure the endpoint address is only opened once.
Parameters
[in]pxUsbDeviceThe USB device handle returned in open() call.
[in]pxEpConfigEndpoint configuration.
Returns
  • IOT_USB_DEVICE_SUCCESS on success
  • IOT_USB_DEVICE_INVALID_VALUE if
    • pxUsbDevice is NULL.
    • pxEpConfig is NULL.
    • endpoint address is already open
    • endpoint config parameter is not supported
    • endpoint address is invalid
  • IOT_USB_DEVICE_ERROR if an error occurred with the device

◆ iot_usb_device_set_endpoint_callback()

void iot_usb_device_set_endpoint_callback ( IotUsbDeviceHandle_t const  pxUsbDevice,
uint8_t  ucEndpointAddress,
IotUsbDeviceEndpointCallbackFn_t  xCallback,
void *  pvUserContext 
)

Sets the endpoint callback to be called on endpoint transfer.

Note
Single callback is used, per instance.
Newly set callback overrides the one previously set
Warning
If input handle or if callback function is NULL, or invalid EndpointAddress issued, this function silently takes no action.
Parameters
[in]pxUsbDeviceThe usb device peripheral handle returned in the open() call.
[in]ucEndpointAddressEndpoint Address.
[in]xCallbackThe callback function to be called on endpoint transfer.
[in]pvUserContextThe user context to be passed back when callback is called.

◆ iot_usb_device_endpoint_close()

int32_t iot_usb_device_endpoint_close ( IotUsbDeviceHandle_t const  pxUsbDevice,
uint8_t  ucEndpointAddress 
)

De-initializes the usb device specific endpoint.

Parameters
[in]pxUsbDeviceThe USB device handle returned in open() call.
[in]ucEndpointAddressEndpoint Address.
Returns
  • IOT_USB_DEVICE_SUCCESS on success
  • IOT_USB_DEVICE_INVALID_VALUE if
    • pxUsbDevice is NULL.
    • invalid ucEndpointAddress

◆ iot_usb_device_endpoint_stall()

int32_t iot_usb_device_endpoint_stall ( IotUsbDeviceHandle_t const  pxUsbDevice,
uint8_t  ucEndpointAddress 
)

Stall the usb device specific endpoint. This function is to set stall conditions for the specific endpoint. The STALL packet indicates that the endpoint has halted, or a control pipe does not support a certain request. A function uses the STALL handshake packet to indicate that it is unable to transmit or receive data. Besides the default control pipe, all of a function's endpoints are in an undefined state after the device issues a STALL handshake packet. The host must never issue a STALL handshake packet. Typically, the STALL handshake indicates a functional stall. A functional stall occurs when the halt feature of an endpoint is set. In this circumstance, host intervention is required via the default control pipe to clear the halt feature of the halted endpoint. Less often, the function returns a STALL handshake during a SETUP or DATA stage of a control transfer. This is called a protocol stall and is resolved when the host issues the next SETUP transaction.

Parameters
[in]pxUsbDeviceThe USB device handle returned in open() call.
[in]ucEndpointAddressEndpoint Address.
Returns
  • IOT_USB_DEVICE_SUCCESS on success
  • IOT_USB_DEVICE_INVALID_VALUE if
    • pxUsbDevice is NULL.
    • invalid ucEndpointAddress

◆ iot_usb_device_endpoint_unstall()

int32_t iot_usb_device_endpoint_unstall ( IotUsbDeviceHandle_t const  pxUsbDevice,
uint8_t  ucEndpointAddress 
)

Unstall the usb device specific endpoint.

Parameters
[in]pxUsbDeviceThe USB device handle returned in open() call.
[in]ucEndpointAddressEndpoint Address.
Returns
  • IOT_USB_DEVICE_SUCCESS on success
  • IOT_USB_DEVICE_INVALID_VALUE if
    • pxUsbDevice is NULL.
    • invalid ucEndpointAddress

◆ iot_usb_device_read_sync()

int32_t iot_usb_device_read_sync ( IotUsbDeviceHandle_t const  pxUsbDevice,
uint8_t  ucEndpointAddress,
uint8_t *const  pvBuffer,
size_t  xBytes 
)

Starts the USB device read operation in blocking mode.

Note
This function will block until all xBytes have been read.
Parameters
[in]pxUsbDeviceThe USB device handle returned in open() call.
[in]ucEndpointAddressEndpoint index
[out]pvBufferThe receive buffer to read the data into
[in]xBytesThe number of bytes to read.
Returns
  • IOT_USB_DEVICE_SUCCESS on success
  • IOT_USB_DEVICE_INVALID_VALUE if
    • pxUsbDevice is NULL.
    • invalid ucEndpointAddress
    • pvBuffer is NULL
    • xBytes == 0
  • IOT_USB_DEVICE_BUSY if another operation is in progress on the same endpoint.
  • IOT_USB_DEVICE_READ_FAILED if unable to complete the read operation

◆ iot_usb_device_write_sync()

int32_t iot_usb_device_write_sync ( IotUsbDeviceHandle_t const  pxUsbDevice,
uint8_t  ucEndpointAddress,
uint8_t *const  pvBuffer,
size_t  xBytes 
)

Starts the USB device write operation in blocking mode.

note: this function will block until all xBytes have been written.

Parameters
[in]pxUsbDeviceThe USB device handle returned in open() call.
[in]ucEndpointAddressEndpoint index
[out]pvBufferThe receive buffer to read the data into
[in]xBytesThe number of bytes to read.
Returns
  • IOT_USB_DEVICE_SUCCESS on success
  • IOT_USB_DEVICE_INVALID_VALUE if
    • pxUsbDevice is NULL.
    • invalid ucEndpointAddress
    • pvBuffer is NULL
    • xBytes == 0
  • IOT_USB_DEVICE_BUSY if another operation is in progress on the same endpoint.
  • IOT_USB_DEVICE_WRITE_FAILED if unable to complete the write operation

◆ iot_usb_device_read_async()

int32_t iot_usb_device_read_async ( IotUsbDeviceHandle_t const  pxUsbDevice,
uint8_t  ucEndpointAddress,
uint8_t *const  pvBuffer,
size_t  xBytes 
)

Starts the USB device read operation in non-blocking mode.

Note
iot_usb_device_set_device_callback() must be called first in order for the callback function to be called to signal when the read is complete.
Parameters
[in]pxUsbDeviceThe USB device handle returned in open() call.
[in]ucEndpointAddressEndpoint index
[out]pvBufferThe receive buffer to read the data into
[in]xBytesThe number of bytes to read.
Returns
  • IOT_USB_DEVICE_SUCCESS on success
  • IOT_USB_DEVICE_INVALID_VALUE if
    • pxUsbDevice is NULL.
    • invalid ucEndpointAddress
    • pvBuffer is NULL
    • xBytes == 0
  • IOT_USB_DEVICE_BUSY if another operation is in progress on the same endpoint.
  • IOT_USB_DEVICE_READ_FAILED if unable to complete the read operation

◆ iot_usb_device_write_async()

int32_t iot_usb_device_write_async ( IotUsbDeviceHandle_t const  pxUsbDevice,
uint8_t  ucEndpointAddress,
uint8_t *const  pvBuffer,
size_t  xBytes 
)

Starts the USB device write operation in non-blocking mode.

Note
iot_usb_device_set_device_callback() must be called first in order for the callback function to be called to signal when the write is complete.
Parameters
[in]pxUsbDeviceThe USB device handle returned in open() call.
[in]ucEndpointAddressEndpoint index
[out]pvBufferThe receive buffer to read the data into
[in]xBytesThe number of bytes to read.
Returns
  • IOT_USB_DEVICE_SUCCESS on success
  • IOT_USB_DEVICE_INVALID_VALUE if
    • pxUsbDevice is NULL.
    • invalid ucEndpointAddress
    • pvBuffer is NULL
    • xBytes == 0
  • IOT_USB_DEVICE_BUSY if another operation is in progress on the same endpoint.
  • IOT_USB_DEVICE_WRITE_FAILED if unable to complete the write operation

◆ iot_usb_device_ioctl()

int32_t iot_usb_device_ioctl ( IotUsbDeviceHandle_t const  pxUsbDevice,
IotUsbDeviceIoctlRequest_t  xUsbDeviceRequest,
void *const  pvBuffer 
)

Used for various USB device control function.

Parameters
[in]pxUsbDeviceThe USB device handle returned in open() call.
[in]xUsbDeviceRequestShould be one of IotUsbDeviceIoctlRequest_t.
[in,out]pvBufferThe configuration values for the IOCTL request.
Returns
  • IOT_USB_DEVICE_SUCCESS on success
  • IOT_USB_DEVICE_INVALID_VALUE if
    • pxUsbDevice is NULL.
    • invalid xUsbDeviceRequest
  • IOT_USB_DEVICE_FUNCTION_NOT_SUPPORTED if ioctl request not suported.
    • Only valid for
    • eUSBDeviceSleepBus
    • eUSBDeviceSuspendBus
    • eUSBDeviceResumeBus
    • eUSBDeviceRemoteWakeup
    • eUSBDeviceGetSyncFrame
  • or other USB Error.

◆ iot_usb_device_endpoint_cancel_transfer()

int32_t iot_usb_device_endpoint_cancel_transfer ( IotUsbDeviceHandle_t const  pxUsbDevice,
uint8_t  ucEndpointAddress 
)

This function is used to cancel the pending transfer for given endpoint.

Parameters
[in]pxUsbDeviceThe USB device handle returned in open() call.
[in]ucEndpointAddressEndpoint Address.
Returns
  • IOT_USB_DEVICE_SUCCESS on success
  • IOT_USB_DEVICE_INVALID_VALUE if
    • pxUsbDevice is NULL.
    • invalid ucEndpointAddress
  • IOT_USB_DEVICE_FUNCTION_NOT_SUPPORTED if cancel transfer opertion not supported
  • IOT_USB_DEVICE_NOTHING_TO_CANCEL if nothing to cancel

◆ iot_usb_device_close()

int32_t iot_usb_device_close ( IotUsbDeviceHandle_t const  pxUsbDevice)

Close the USB device peripheral.

Parameters
[in]pxUsbDeviceThe USB device handle returned in open() call.
Returns
  • IOT_USB_DEVICE_SUCCESS on success
  • IOT_USB_DEVICE_INVALID_VALUE if
    • pxUsbDevice is NULL.
    • pxUsbDevice not open (already closed).