NetBurner 3.5.7
PDF Version
usb_host.h
1/*
2 * Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
3 * Copyright 2016 - 2019 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _USB_HOST_H_
10#define _USB_HOST_H_
11
12#include "nxp_usb.h"
13#include "usb_misc.h"
14#include "usb_spec.h"
15
16/*******************************************************************************
17 * Definitions
18 ******************************************************************************/
19
20struct _usb_host_transfer; /* for cross reference */
21
29
32
35
38
41
43typedef enum _usb_host_event
44{
59#if ((defined(USB_HOST_CONFIG_LOW_POWER_MODE)) && (USB_HOST_CONFIG_LOW_POWER_MODE > 0U))
60 kUSB_HostEventNotSuspended,
61 kUSB_HostEventSuspended,
62 kUSB_HostEventNotResumed,
63 kUSB_HostEventDetectResume,
64 kUSB_HostEventResumed,
65 kUSB_HostEventL1Sleeped,
66 kUSB_HostEventL1SleepNYET,
67 kUSB_HostEventL1SleepNotSupport,
68 kUSB_HostEventL1SleepError,
69 kUSB_HostEventL1NotResumed,
70 kUSB_HostEventL1DetectResume,
71 kUSB_HostEventL1Resumed,
72#endif
74
126
134
141
164 usb_host_configuration_handle configurationHandle,
165 uint32_t eventCode);
166
178typedef void (*transfer_callback_t)(void *param, uint8_t *data, uint32_t dataLen, usb_status_t status);
179
190typedef void (*host_inner_transfer_callback_t)(void *param, struct _usb_host_transfer *transfer, usb_status_t status);
191
193typedef struct _usb_host_ep
194{
195 usb_descriptor_endpoint_t *epDesc;
196 uint8_t *epExtension;
199
202{
203 usb_host_ep_t epList[USB_HOST_CONFIG_INTERFACE_MAX_EP];
204 usb_descriptor_interface_t *interfaceDesc;
209 uint8_t epCount;
211
214{
215 usb_host_interface_t interfaceList[USB_HOST_CONFIG_CONFIGURATION_MAX_INTERFACE];
216 usb_descriptor_configuration_t *configurationDesc;
221
238
240typedef struct _usb_host_transfer
241{
243 uint8_t *transferBuffer;
244 uint32_t transferLength;
245 uint32_t transferSofar;
249 usb_setup_struct_t *setupPacket;
250 uint8_t direction;
251 uint8_t setupStatus;
252 union
253 {
254 uint32_t unitHead;
256 } union1;
257
258 union
259 {
260 uint32_t unitTail;
261 uint32_t frame;
262 } union2;
263
264#if USB_HOST_CONFIG_KHCI
265 uint16_t nakTimeout;
266 uint16_t retry;
267#endif
269
283
290
291/*******************************************************************************
292 * API
293 ******************************************************************************/
294
295#ifdef __cplusplus
296extern "C" {
297#endif
298
321extern usb_status_t USB_HostInit(uint8_t controllerId, usb_host_handle *hostHandle, host_callback_t callbackFn);
322
335
350 uint32_t infoCode,
351 uint32_t *infoValue);
352
369 uint8_t alternateSetting,
370 usb_host_interface_t *interface);
371
386#if (defined(USB_HOST_CONFIG_KHCI) && (USB_HOST_CONFIG_KHCI > 0U))
396extern void USB_HostKhciTaskFunction(void *hostHandle);
397#endif
398#if (defined(USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI > 0U))
408extern void USB_HostEhciTaskFunction(void *hostHandle);
409#endif
410#if (defined(USB_HOST_CONFIG_OHCI) && (USB_HOST_CONFIG_OHCI > 0U))
420extern void USB_HostOhciTaskFunction(void *hostHandle);
421#endif
422#if (defined(USB_HOST_CONFIG_IP3516HS) && (USB_HOST_CONFIG_IP3516HS > 0U))
432extern void USB_HostIp3516HsTaskFunction(void *hostHandle);
433#endif
434#if (defined(USB_HOST_CONFIG_KHCI) && (USB_HOST_CONFIG_KHCI > 0U))
442extern void USB_HostKhciIsrFunction(void *hostHandle);
443#endif
444#if (defined(USB_HOST_CONFIG_EHCI) && (USB_HOST_CONFIG_EHCI > 0U))
452extern void USB_HostEhciIsrFunction(void *hostHandle);
453#endif
454#if (defined(USB_HOST_CONFIG_OHCI) && (USB_HOST_CONFIG_OHCI > 0U))
462extern void USB_HostOhciIsrFunction(void *hostHandle);
463#endif
464#if (defined(USB_HOST_CONFIG_IP3516HS) && (USB_HOST_CONFIG_IP3516HS > 0U))
472extern void USB_HostIp3516HsIsrFunction(void *hostHandle);
473#endif
498 usb_host_pipe_handle *pipeHandle,
499 usb_host_pipe_init_t *pipeInit);
500
513
529 usb_host_pipe_handle pipeHandle,
530 usb_host_transfer_t *transfer);
531
547 usb_host_pipe_handle pipeHandle,
548 usb_host_transfer_t *transfer);
549
565 usb_host_pipe_handle pipeHandle,
566 usb_host_transfer_t *transfer);
567
581 usb_host_pipe_handle pipeHandle,
582 usb_host_transfer_t *transfer);
583
597
610
629 uint8_t usbRequest,
630 usb_host_transfer_t *transfer,
631 void *param);
632
645 usb_host_interface_handle interfaceHandle);
646
660 usb_host_interface_handle interfaceHandle);
661
670extern void USB_HostGetVersion(uint32_t *version);
671
672#if ((defined(USB_HOST_CONFIG_LOW_POWER_MODE)) && (USB_HOST_CONFIG_LOW_POWER_MODE > 0U))
687extern usb_status_t USB_HostSuspendDeviceResquest(usb_host_handle hostHandle, usb_device_handle deviceHandle);
688
703extern usb_status_t USB_HostResumeDeviceResquest(usb_host_handle hostHandle, usb_device_handle deviceHandle);
704#if ((defined(USB_HOST_CONFIG_LPM_L1)) && (USB_HOST_CONFIG_LPM_L1 > 0U))
720extern usb_status_t USB_HostL1SleepDeviceResquest(usb_host_handle hostHandle,
721 usb_device_handle deviceHandle,
722 uint8_t sleepType);
723
739extern usb_status_t USB_HostL1ResumeDeviceResquest(usb_host_handle hostHandle,
740 usb_device_handle deviceHandle,
741 uint8_t sleepType);
751extern usb_status_t USB_HostL1SleepDeviceResquestConfig(usb_host_handle hostHandle, uint8_t *lpmParam);
752#endif
762extern usb_status_t USB_HostUpdateHwTick(usb_host_handle hostHandle, uint64_t tick);
763
764#endif
765
766#if ((defined(USB_HOST_CONFIG_BATTERY_CHARGER)) && (USB_HOST_CONFIG_BATTERY_CHARGER > 0U))
776extern usb_status_t USB_HostSetChargerType(usb_host_handle hostHandle, uint8_t type);
777#endif
778
781#ifdef __cplusplus
782}
783#endif
784
787#endif /* _USB_HOST_H_ */
enum _usb_status usb_status_t
USB error code.
void * usb_host_handle
USB host handle type define.
Definition nxp_usb.h:70
void * usb_device_handle
USB device handle type define.
Definition nxp_usb.h:73
struct _usb_host_synch_frame_param usb_host_synch_frame_param_t
For USB_REQUEST_STANDARD_SYNCH_FRAME.
void * usb_host_configuration_handle
USB host configuration handle type define.
Definition usb_host.h:34
usb_status_t USB_HostHelperGetPeripheralInformation(usb_device_handle deviceHandle, uint32_t infoCode, uint32_t *infoValue)
Gets the device information.
Definition usb_host_hci.c:556
enum _usb_host_dev_info usb_host_dev_info_t
USB host device information code.
usb_status_t USB_HostRequestControl(usb_device_handle deviceHandle, uint8_t usbRequest, usb_host_transfer_t *transfer, void *param)
Requests the USB standard request.
Definition usb_host_framework.c:188
usb_status_t(* host_callback_t)(usb_device_handle deviceHandle, usb_host_configuration_handle configurationHandle, uint32_t eventCode)
Host callback function typedef.
Definition usb_host.h:163
usb_status_t USB_HostClosePipe(usb_host_handle hostHandle, usb_host_pipe_handle pipeHandle)
Closes the USB host pipe.
Definition usb_host_hci.c:360
struct _usb_host_get_interface_param usb_host_get_interface_param_t
For USB_REQUEST_STANDARD_GET_INTERFACE.
enum _usb_host_event usb_host_event_t
Event codes for device attach/detach.
_usb_host_event
Event codes for device attach/detach.
Definition usb_host.h:44
usb_status_t USB_HostInit(uint8_t controllerId, usb_host_handle *hostHandle, host_callback_t callbackFn)
Initializes the USB host stack.
Definition usb_host_hci.c:228
usb_status_t USB_HostCloseDeviceInterface(usb_device_handle deviceHandle, usb_host_interface_handle interfaceHandle)
Closes an interface.
Definition usb_host_devices.c:1374
struct _usb_host_process_feature_param usb_host_process_feature_param_t
For USB_REQUEST_STANDARD_CLEAR_FEATURE and USB_REQUEST_STANDARD_SET_FEATURE.
usb_status_t USB_HostOpenPipe(usb_host_handle hostHandle, usb_host_pipe_handle *pipeHandle, usb_host_pipe_init_t *pipeInit)
Opens the USB host pipe.
Definition usb_host_hci.c:342
struct _usb_host_pipe usb_host_pipe_t
USB host pipe common structure.
usb_status_t USB_HostRemoveDevice(usb_host_handle hostHandle, usb_device_handle deviceHandle)
Removes the attached device.
Definition usb_host_devices.c:1457
struct _usb_host_interface usb_host_interface_t
USB host interface information structure.
void * usb_host_controller_handle
USB host controller handle type define.
Definition usb_host.h:31
usb_status_t USB_HostCancelTransfer(usb_host_handle hostHandle, usb_host_pipe_handle pipeHandle, usb_host_transfer_t *transfer)
Cancel the pipe's transfers.
Definition usb_host_hci.c:483
void * usb_host_pipe_handle
USB host pipe handle type define.
Definition usb_host.h:40
struct _usb_host_process_descriptor_param usb_host_process_descriptor_param_t
For USB_REQUEST_STANDARD_GET_DESCRIPTOR and USB_REQUEST_STANDARD_SET_DESCRIPTOR.
struct _usb_host_ep usb_host_ep_t
USB host endpoint information structure.
enum _usb_host_request_type usb_host_request_type_t
Request type.
void(* transfer_callback_t)(void *param, uint8_t *data, uint32_t dataLen, usb_status_t status)
Transfer callback function typedef.
Definition usb_host.h:178
usb_status_t USB_HostRecv(usb_host_handle hostHandle, usb_host_pipe_handle pipeHandle, usb_host_transfer_t *transfer)
Receives the data from the pipe.
Definition usb_host_hci.c:451
usb_status_t USB_HostOpenDeviceInterface(usb_device_handle deviceHandle, usb_host_interface_handle interfaceHandle)
Opens the interface.
Definition usb_host_devices.c:1324
usb_status_t USB_HostFreeTransfer(usb_host_handle hostHandle, usb_host_transfer_t *transfer)
Frees a transfer resource.
Definition usb_host_hci.c:535
struct _usb_host_configuration usb_host_configuration_t
USB host configuration information structure.
struct _usb_host_transfer usb_host_transfer_t
USB host transfer structure.
struct _usb_host_cancel_param usb_host_cancel_param_t
Cancel transfer parameter structure.
void(* host_inner_transfer_callback_t)(void *param, struct _usb_host_transfer *transfer, usb_status_t status)
Host stack inner transfer callback function typedef.
Definition usb_host.h:190
usb_status_t USB_HostSend(usb_host_handle hostHandle, usb_host_pipe_handle pipeHandle, usb_host_transfer_t *transfer)
Sends data to a pipe.
Definition usb_host_hci.c:376
usb_status_t USB_HostDeinit(usb_host_handle hostHandle)
Deinitializes the USB host stack.
Definition usb_host_hci.c:302
_usb_host_request_type
Request type.
Definition usb_host.h:96
void USB_HostGetVersion(uint32_t *version)
Gets a host stack version function.
Definition usb_host_hci.c:788
struct _usb_host_set_interface_param usb_host_set_interface_param_t
For USB_REQUEST_STANDARD_SET_INTERFACE.
void * usb_host_class_handle
USB host class handle type define.
Definition usb_host.h:28
usb_status_t USB_HostSendSetup(usb_host_handle hostHandle, usb_host_pipe_handle pipeHandle, usb_host_transfer_t *transfer)
Sends a setup transfer to the pipe.
Definition usb_host_hci.c:408
void * usb_host_interface_handle
USB host interface handle type define.
Definition usb_host.h:37
_usb_host_dev_info
USB host device information code.
Definition usb_host.h:77
struct _usb_host_get_status_param usb_host_get_status_param_t
For USB_REQUEST_STANDARD_GET_STATUS.
usb_status_t USB_HostHelperParseAlternateSetting(usb_host_interface_handle interfaceHandle, uint8_t alternateSetting, usb_host_interface_t *interface)
Parses the alternate interface descriptor.
Definition usb_host_hci.c:661
usb_status_t USB_HostMallocTransfer(usb_host_handle hostHandle, usb_host_transfer_t **transfer)
Allocates a transfer resource.
Definition usb_host_hci.c:509
struct _usb_host_pipe_init usb_host_pipe_init_t
USB host pipe information structure for opening pipe.
@ kUSB_HostEventEnumerationFail
Definition usb_host.h:58
@ kUSB_HostEventAttach
Definition usb_host.h:45
@ kUSB_HostEventDetach
Definition usb_host.h:46
@ kUSB_HostEventEnumerationDone
Definition usb_host.h:47
@ kUSB_HostEventNotSupported
Definition usb_host.h:48
@ kRequestDevice
Definition usb_host.h:97
@ kRequestInterface
Definition usb_host.h:98
@ kRequestEndpoint
Definition usb_host.h:99
@ kUSB_HostGetDeviceHSHubPort
Definition usb_host.h:83
@ kUSB_HostGetDeviceHubNumber
Definition usb_host.h:79
@ kUSB_HostGetDeviceAddress
Definition usb_host.h:78
@ kUSB_HostGetConfigurationDes
Definition usb_host.h:91
@ kUSB_HostGetDeviceHSHubNumber
Definition usb_host.h:82
@ kUSB_HostGetDeviceConfigIndex
Definition usb_host.h:90
@ kUSB_HostGetConfigurationLength
Definition usb_host.h:92
@ kUSB_HostGetHostHandle
Definition usb_host.h:85
@ kUSB_HostGetDeviceSpeed
Definition usb_host.h:81
@ kUSB_HostGetDeviceLevel
Definition usb_host.h:84
@ kUSB_HostGetDeviceControlPipe
Definition usb_host.h:86
@ kUSB_HostGetDevicePortNumber
Definition usb_host.h:80
@ kUSB_HostGetDevicePID
Definition usb_host.h:87
@ kUSB_HostGetDeviceVID
Definition usb_host.h:88
@ kUSB_HostGetHubThinkTime
Definition usb_host.h:89
Cancel transfer parameter structure.
Definition usb_host.h:286
usb_host_transfer_t * transfer
Definition usb_host.h:288
usb_host_pipe_handle pipeHandle
Definition usb_host.h:287
USB host configuration information structure.
Definition usb_host.h:214
usb_host_interface_t interfaceList[USB_HOST_CONFIG_CONFIGURATION_MAX_INTERFACE]
Definition usb_host.h:215
uint8_t interfaceCount
Definition usb_host.h:219
usb_descriptor_configuration_t * configurationDesc
Definition usb_host.h:216
uint8_t * configurationExtension
Definition usb_host.h:217
uint16_t configurationExtensionLength
Definition usb_host.h:218
USB host endpoint information structure.
Definition usb_host.h:194
usb_descriptor_endpoint_t * epDesc
Definition usb_host.h:195
uint8_t * epExtension
Definition usb_host.h:196
uint16_t epExtensionLength
Definition usb_host.h:197
For USB_REQUEST_STANDARD_GET_INTERFACE.
Definition usb_host.h:122
uint8_t interface
Definition usb_host.h:123
uint8_t * alternateInterfaceBuffer
Definition usb_host.h:124
For USB_REQUEST_STANDARD_GET_STATUS.
Definition usb_host.h:129
uint8_t requestType
Definition usb_host.h:131
uint8_t * statusBuffer
Definition usb_host.h:132
uint16_t statusSelector
Definition usb_host.h:130
USB host interface information structure.
Definition usb_host.h:202
uint8_t interfaceIndex
Definition usb_host.h:207
uint16_t interfaceExtensionLength
Definition usb_host.h:206
uint8_t epCount
Definition usb_host.h:209
usb_host_ep_t epList[USB_HOST_CONFIG_INTERFACE_MAX_EP]
Definition usb_host.h:203
uint8_t * interfaceExtension
Definition usb_host.h:205
usb_descriptor_interface_t * interfaceDesc
Definition usb_host.h:204
uint8_t alternateSettingNumber
Definition usb_host.h:208
USB host pipe information structure for opening pipe.
Definition usb_host.h:272
uint16_t maxPacketSize
Definition usb_host.h:275
uint8_t direction
Definition usb_host.h:278
uint8_t endpointAddress
Definition usb_host.h:277
uint8_t interval
Definition usb_host.h:276
uint8_t pipeType
Definition usb_host.h:279
void * devInstance
Definition usb_host.h:273
uint16_t nakCount
Definition usb_host.h:274
uint8_t numberPerUframe
Definition usb_host.h:281
USB host pipe common structure.
Definition usb_host.h:224
uint16_t interval
Definition usb_host.h:230
usb_device_handle deviceHandle
Definition usb_host.h:226
uint16_t maxPacketSize
Definition usb_host.h:229
uint8_t endpointAddress
Definition usb_host.h:233
uint8_t direction
Definition usb_host.h:234
uint8_t nextdata01
Definition usb_host.h:232
uint8_t open
Definition usb_host.h:231
uint8_t numberPerUframe
Definition usb_host.h:236
struct _usb_host_pipe * next
Definition usb_host.h:225
uint16_t nakCount
Definition usb_host.h:228
uint8_t pipeType
Definition usb_host.h:235
uint16_t currentCount
Definition usb_host.h:227
For USB_REQUEST_STANDARD_GET_DESCRIPTOR and USB_REQUEST_STANDARD_SET_DESCRIPTOR.
Definition usb_host.h:103
uint8_t descriptorType
Definition usb_host.h:104
uint16_t descriptorLength
Definition usb_host.h:111
uint8_t descriptorIndex
Definition usb_host.h:105
uint16_t languageId
Definition usb_host.h:108
uint8_t * descriptorBuffer
Definition usb_host.h:110
For USB_REQUEST_STANDARD_CLEAR_FEATURE and USB_REQUEST_STANDARD_SET_FEATURE.
Definition usb_host.h:115
uint8_t interfaceOrEndpoint
Definition usb_host.h:118
uint8_t featureSelector
Definition usb_host.h:117
uint8_t requestType
Definition usb_host.h:116
For USB_REQUEST_STANDARD_SET_INTERFACE.
Definition usb_host.h:137
uint8_t alternateSetting
Definition usb_host.h:138
uint8_t interface
Definition usb_host.h:139
For USB_REQUEST_STANDARD_SYNCH_FRAME.
Definition usb_host.h:144
uint8_t endpoint
Definition usb_host.h:145
uint8_t * frameNumberBuffer
Definition usb_host.h:146
USB host transfer structure.
Definition usb_host.h:241
void * callbackParam
Definition usb_host.h:247
uint8_t * transferBuffer
Definition usb_host.h:243
uint32_t unitHead
Definition usb_host.h:254
uint32_t unitTail
Definition usb_host.h:260
uint8_t setupStatus
Definition usb_host.h:251
usb_host_pipe_t * transferPipe
Definition usb_host.h:248
uint8_t direction
Definition usb_host.h:250
host_inner_transfer_callback_t callbackFn
Definition usb_host.h:246
uint32_t transferSofar
Definition usb_host.h:245
usb_setup_struct_t * setupPacket
Definition usb_host.h:249
int32_t transferResult
Definition usb_host.h:255
uint32_t transferLength
Definition usb_host.h:244
uint32_t frame
Definition usb_host.h:261
struct _usb_host_transfer * next
Definition usb_host.h:242