Common IO - basic v1.0.0
Common IO - basic v1.0.0 Library
 
Loading...
Searching...
No Matches
iot_usb_host.h
Go to the documentation of this file.
1/*
2 * Common IO - basic V1.0.0
3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * http://aws.amazon.com/freertos
23 * http://www.FreeRTOS.org
24 */
25
31#ifndef _IOT_USB_HOST_H_
32#define _IOT_USB_HOST_H_
33
42#define IOT_USB_HOST_SUCCESS ( 0 )
43#define IOT_USB_HOST_ERROR ( 1 )
44#define IOT_USB_HOST_BUSY ( 2 )
45#define IOT_USB_HOST_INVALID_VALUE ( 3 )
46#define IOT_USB_HOST_WRITE_FAIL ( 4 )
47#define IOT_USB_HOST_READ_FAIL ( 5 )
48#define IOT_USB_HOST_CANCEL_FAILED ( 6 )
49#define IOT_USB_HOST_FUNCTION_NOT_SUPPORTED ( 7 )
50#define IOT_USB_HOST_NOTHING_TO_CANCEL ( 8 )
52#define IOT_USB_HOST_MAX_ENDPOINTS ( 4 )
57typedef enum
58{
67
71typedef enum
72{
84
88struct IotUsbHost;
89
93struct IotUsbDevice;
94struct IotUsbConfiguration;
95struct IotUsbInterface;
96struct IotUsbPipe;
97
103typedef struct IotUsbHost * IotUsbHostHandle_t;
104
109typedef struct IotUsbDevice * IotUsbDeviceHandle_t;
110
115typedef struct IotUsbConfiguration * IotUsbConfigHandle_t;
116
121typedef struct IotUsbInterface * IotUsbInterfaceHandle_t;
122
126typedef struct IotUsbPipe * IotPipeHandle_t;
127
138typedef void (* IotUsbHostCallback_t) ( IotUsbDeviceHandle_t const pxUsbDevice,
139 IotUsbHostEvent_t xEvent,
140 void * pvUserContext );
141
151typedef void (* IotUsbHostTransferCallback_t) ( void * pvUserContext,
152 uint8_t ucStatus );
153
157typedef struct
158{
159 uint16_t usMaxPacketSize;
176 uint8_t ucEndpointAddress;
177 uint8_t ucTransferType;
179 uint8_t ucZlt;
180 uint8_t ucInterval;
182
186typedef struct IotUsbInterfaceInfo
187{
190 uint8_t ucEpCount;
193
197typedef struct IotUsbConfigurationInfo
198{
202
206typedef struct IotUsbDeviceInfo
207{
208 uint8_t ucSpeed;
209 uint8_t ucDevAddress;
210 uint16_t usPid;
211 uint16_t usVid;
213
227IotUsbHostHandle_t iot_usb_host_open( int32_t lUsbHostControllerInstance );
228
239 IotUsbHostCallback_t xCallback,
240 void * pvUserContext );
241
254 IotPipeHandle_t pxPipe,
256 void * pvUserContext );
257
273 uint8_t ucDevAddress,
274 IotUsbDeviceEndpointConfig_t * pxEpConfig );
275
289 IotPipeHandle_t pxPipe );
290
313 IotPipeHandle_t pxPipe,
314 void * const pvBuffer,
315 size_t xBytes );
316
340 IotPipeHandle_t pxPipe,
341 void * const pvBuffer,
342 size_t xBytes );
343
365 IotPipeHandle_t pxPipe,
366 void * const pvBuffer,
367 size_t xBytes );
368
391 IotPipeHandle_t pxPipe,
392 void * const pvBuffer,
393 size_t xBytes );
394
410 IotPipeHandle_t pxPipe );
411
430 void * const pvBuffer );
431
450 IotPipeHandle_t pxPipe,
451 void * pvSetup,
452 uint8_t * pucData );
453
465int32_t iot_usb_host_close( IotUsbHostHandle_t const pxUsbHost );
466
470/* end of group iot_usb_host */
471
472#endif /* ifndef _IOT_USB_HOST_H_ */
struct IotUsbDevice * IotUsbDeviceHandle_t
IotUsbDeviceHandle_t is the handle type returned by calling iot_usb_device_open()....
Definition: iot_usb_device.h:171
struct IotUsbHost * IotUsbHostHandle_t
IotUsbHostHandle_t is the handle type returned by calling iot_usb_host_open(). This is initialized in...
Definition: iot_usb_host.h:103
IotUsbHostHandle_t iot_usb_host_open(int32_t lUsbHostControllerInstance)
iot_usb_host_open is used to initialize the usb host driver. This must be called before using any oth...
int32_t iot_usb_host_send_setup(IotUsbHostHandle_t const pxUsbHost, IotPipeHandle_t pxPipe, void *pvSetup, uint8_t *pucData)
Send setup packet to the pipe.
int32_t iot_usb_host_read_sync(IotUsbHostHandle_t const pxUsbHost, IotPipeHandle_t pxPipe, void *const pvBuffer, size_t xBytes)
Starts the usb host read operation in blocking mode.
struct IotUsbPipe * IotPipeHandle_t
IotPipeHandle_t is the pipe handle, which will be used for data and control transfer.
Definition: iot_usb_host.h:126
int32_t iot_usb_host_write_sync(IotUsbHostHandle_t const pxUsbHost, IotPipeHandle_t pxPipe, void *const pvBuffer, size_t xBytes)
Starts the usb host write operation in blocking mode.
IotUsbHostEvent_t
common host notify event types in host callback.
Definition: iot_usb_host.h:58
int32_t iot_usb_host_pipe_close(IotUsbHostHandle_t const pxUsbHost, IotPipeHandle_t pxPipe)
This function is used to close given pipe.
void(* IotUsbHostCallback_t)(IotUsbDeviceHandle_t const pxUsbDevice, IotUsbHostEvent_t xEvent, void *pvUserContext)
USB Host attach/detach notify callback type. This callback is passed to the driver by calling iot_usb...
Definition: iot_usb_host.h:138
int32_t iot_usb_host_write_async(IotUsbHostHandle_t const pxUsbHost, IotPipeHandle_t pxPipe, void *const pvBuffer, size_t xBytes)
Starts the usb host write operation in non-blocking mode.
struct IotUsbInterface * IotUsbInterfaceHandle_t
IotUsbInterfaceHandle_t is the interface handle, which can be extracted from config One device may ha...
Definition: iot_usb_host.h:121
int32_t iot_usb_host_close(IotUsbHostHandle_t const pxUsbHost)
Close the USB host peripheral.
struct IotUsbConfiguration * IotUsbConfigHandle_t
IotUsbConfigHandle_t is the configuration handle for device Only one configuration at run time.
Definition: iot_usb_host.h:115
void(* IotUsbHostTransferCallback_t)(void *pvUserContext, uint8_t ucStatus)
USB Host pipe transfer callback type. This callback is passed to the driver by calling iot_usb_host_s...
Definition: iot_usb_host.h:151
void iot_usb_host_set_host_callback(IotUsbHostHandle_t const pxUsbHost, IotUsbHostCallback_t xCallback, void *pvUserContext)
Set up usb host callback to be called on host event.
#define IOT_USB_HOST_MAX_ENDPOINTS
Definition: iot_usb_host.h:52
int32_t iot_usb_host_cancel(IotUsbHostHandle_t const pxUsbHost, IotPipeHandle_t pxPipe)
This function is used to cancel the current operation in progress.
void iot_usb_host_set_pipe_callback(IotUsbHostHandle_t const pxUsbHost, IotPipeHandle_t pxPipe, IotUsbHostTransferCallback_t xCallback, void *pvUserContext)
set up usb pipe callback to be called on pipe transfer.
IotUsbHostIoctlRequest_t
Ioctl standard device request for USB Host HAL.
Definition: iot_usb_host.h:72
int32_t iot_usb_host_read_async(IotUsbHostHandle_t const pxUsbHost, IotPipeHandle_t pxPipe, void *const pvBuffer, size_t xBytes)
Starts the usb host read operation in non-blocking mode.
int32_t iot_usb_host_ioctl(IotUsbDeviceHandle_t pxUsbDevice, IotUsbHostIoctlRequest_t xRequest, void *const pvBuffer)
Used for various usb host control function.
IotPipeHandle_t iot_usb_host_pipe_open(IotUsbHostHandle_t const pxUsbHost, uint8_t ucDevAddress, IotUsbDeviceEndpointConfig_t *pxEpConfig)
This function is used to open a pipe per given device and endpoint descriptor.
struct IotUsbDevice * IotUsbDeviceHandle_t
IotUsbDeviceHandle_t is the handle type returned when device attach and enumerated This device handle...
Definition: iot_usb_host.h:109
@ eUSBHostDetachEvent
Definition: iot_usb_host.h:60
@ eUSBHostResumeEvent
Definition: iot_usb_host.h:64
@ eUSBHostAttachEvent
Definition: iot_usb_host.h:59
@ eUSBHostResetEvent
Definition: iot_usb_host.h:62
@ eUSBHostEnumerationDoneEvent
Definition: iot_usb_host.h:61
@ eUSBHostSuspendEvent
Definition: iot_usb_host.h:63
@ eUSBHostRemoteWakeEvent
Definition: iot_usb_host.h:65
@ eUSBHostGetDeviceControlPipe
Definition: iot_usb_host.h:74
@ eUSBHostGetDeviceInfo
Definition: iot_usb_host.h:78
@ eUSBHostGetDeviceAddress
Definition: iot_usb_host.h:75
@ eUSBHostGetInterfaceDescriptor
Definition: iot_usb_host.h:80
@ eUSBHostOpenDeviceInterface
Definition: iot_usb_host.h:76
@ eUSBHostGetInterfaceHandle
Definition: iot_usb_host.h:82
@ eUSBHostCloseDeviceInterface
Definition: iot_usb_host.h:77
@ eUSBHostGetInterfaceInfo
Definition: iot_usb_host.h:79
@ eUSBHostGetHosthandle
Definition: iot_usb_host.h:73
@ eUSBHostGetConfigureHandle
Definition: iot_usb_host.h:81
Attached device configuration information.
Definition: iot_usb_host.h:198
IotUsbInterfaceInfo_t * pxInterface
Definition: iot_usb_host.h:199
uint8_t ucInterfaceCount
Definition: iot_usb_host.h:200
Endpoint configuration structure.
Definition: iot_usb_device.h:212
Attached device information.
Definition: iot_usb_host.h:207
uint16_t usPid
Definition: iot_usb_host.h:210
uint8_t ucDevAddress
Definition: iot_usb_host.h:209
uint16_t usVid
Definition: iot_usb_host.h:211
uint8_t ucSpeed
Definition: iot_usb_host.h:208
Attached device interface information.
Definition: iot_usb_host.h:187
uint8_t ucEpCount
Definition: iot_usb_host.h:190
uint8_t ucAlternateSettingNumber
Definition: iot_usb_host.h:191
uint8_t ucInterfaceIndex
Definition: iot_usb_host.h:189