+/rtos
git clone https://git.julia.blue/+/rtos
326af29
master
1//***************************************************************************** 2// 3// usbhost.h - Host specific definitions for the USB host library. 4// 5// Copyright (c) 2008-2017 Texas Instruments Incorporated. All rights reserved. 6// Software License Agreement 7// 8// Texas Instruments (TI) is supplying this software for use solely and 9// exclusively on TI's microcontroller products. The software is owned by 10// TI and/or its suppliers, and is protected under applicable copyright 11// laws. You may not combine this software with "viral" open-source 12// software in order to form a larger program. 13// 14// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. 15// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT 16// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY 18// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL 19// DAMAGES, FOR ANY REASON WHATSOEVER. 20// 21// This is part of revision 2.1.4.178 of the Tiva USB Library. 22// 23//***************************************************************************** 24 25#ifndef __USBHOST_H__ 26#define __USBHOST_H__ 27#include "usblib/usblib.h" 28 29//***************************************************************************** 30// 31// If building with a C++ compiler, make all of the definitions in this header 32// have a C binding. 33// 34//***************************************************************************** 35#ifdef __cplusplus 36extern "C" { 37#endif 38 39//***************************************************************************** 40// 41//! \addtogroup usblib_hcd 42//! @{ 43// 44//***************************************************************************** 45 46//***************************************************************************** 47// 48// This is the type used to identify what the pipe is currently in use for. 49// 50//***************************************************************************** 51#define USBHCD_PIPE_UNUSED 0x00100000 52#define USBHCD_PIPE_CONTROL 0x00130000 53#define USBHCD_PIPE_BULK_OUT 0x00210000 54#define USBHCD_PIPE_BULK_IN 0x00220000 55#define USBHCD_PIPE_INTR_OUT 0x00410000 56#define USBHCD_PIPE_INTR_IN 0x00420000 57#define USBHCD_PIPE_ISOC_OUT 0x00810000 58#define USBHCD_PIPE_ISOC_IN 0x00820000 59#define USBHCD_PIPE_ISOC_OUT_DMA 0x01810000 60#define USBHCD_PIPE_ISOC_IN_DMA 0x01820000 61#define USBHCD_PIPE_BULK_OUT_DMA 0x01210000 62#define USBHCD_PIPE_BULK_IN_DMA 0x01220000 63 64//***************************************************************************** 65// 66// These are the defines that are used with USBHCDPowerConfigInit(). 67// 68//***************************************************************************** 69#define USBHCD_FAULT_LOW 0x00000010 70#define USBHCD_FAULT_HIGH 0x00000030 71#define USBHCD_FAULT_VBUS_NONE 0x00000000 72#define USBHCD_FAULT_VBUS_TRI 0x00000140 73#define USBHCD_FAULT_VBUS_DIS 0x00000400 74#define USBHCD_VBUS_MANUAL 0x00000004 75#define USBHCD_VBUS_AUTO_LOW 0x00000002 76#define USBHCD_VBUS_AUTO_HIGH 0x00000003 77#define USBHCD_VBUS_FILTER 0x00010000 78 79//***************************************************************************** 80// 81// These are the defines that are used with USBHCDLPMStatus(). 82// 83//***************************************************************************** 84#define USBHCD_LPM_AVAIL 0x00000000 85#define USBHCD_LPM_ERROR 0x00000001 86#define USBHCD_LPM_PENDING 0x00000002 87 88//***************************************************************************** 89// 90//! This macro is used to declare an instance of an Event driver for the USB 91//! library. 92//! 93//! \param VarName is the name of the variable. 94//! \param pfnOpen is the callback for the Open call to this driver. This 95//! value is currently reserved and should be set to 0. 96//! \param pfnClose is the callback for the Close call to this driver. This 97//! value is currently reserved and should be set to 0. 98//! \param pfnEvent is the callback that will be called for various USB events. 99//! 100//! The first parameter is the actual name of the variable that will 101//! be declared by this macro. The second and third parameter are reserved 102//! for future functionality and are unused and should be set to zero. The 103//! last parameter is the actual callback function and is specified as 104//! a function pointer of the type: 105//! 106//! \verbatim 107//! void (*pfnEvent)(void *pvData); 108//! \endverbatim 109//! 110//! When the \e pfnEvent function is called the void pointer that is passed in 111//! as a parameter should be cast to a pointer to a structure of type 112//! tEventInfo. This will contain the event that caused the pfnEvent function 113//! to be called. 114// 115//***************************************************************************** 116#define DECLARE_EVENT_DRIVER (VarName ,pfnOpen ,pfnClose ,pfnEvent ) \ 117 void IntFn(void* pvData); \ 118 const tUSBHostClassDriver VarName = {USB_CLASS_EVENTS, 0, 0, pfnEvent} 119 120//***************************************************************************** 121// 122// This is the type definition a callback for events on USB Pipes allocated 123// by USBHCDPipeAlloc(). 124// 125// \param ui32Pipe is well the pipe 126// \param ui32Event is well the event 127// 128// This prototype is used by any Pipe callbacks that are used in the host 129// class drivers. These functions typically handle data events like 130// USB_EVENT_RX_AVAILABLE or USB_EVENT_TX_COMPLETE but can be sent other events 131// depending on the USB host class in use. See the documentation for the 132// individual classes for the valid events for that class. 133// 134// \return None. 135// 136//***************************************************************************** 137typedef void (* tHCDPipeCallback )(uint32_t ui32Pipe ,uint32_t ui32Event ); 138 139//***************************************************************************** 140// 141// Predeclare the private tUSBHostDevice structure. 142// 143//***************************************************************************** 144typedef struct tUSBHostDevice tUSBHostDevice ; 145 146//***************************************************************************** 147// 148//! This structure defines a USB host class driver interface, it is parsed to 149//! find a USB class driver once a USB device is enumerated. 150// 151//***************************************************************************** 152typedef struct { 153// 154//! The interface class that this device class driver supports. 155// 156uint32_t ui32InterfaceClass ; 157 158// 159//! The function is called when this class of device has been detected. 160// 161void * (* pfnOpen )(tUSBHostDevice * psDevice ); 162 163// 164//! The function is called when the device, originally opened with a call 165//! to the pfnOpen function, is disconnected. 166// 167void (* pfnClose )(void * pvInstance ); 168 169// 170//! This is the optional interrupt handler that will be called when an 171//! endpoint associated with this device instance generates an interrupt. 172// 173void (* pfnIntHandler )(void * pvInstance ); 174}tUSBHostClassDriver ; 175 176//***************************************************************************** 177// 178// Close the Doxygen group. 179//! @} 180// 181//***************************************************************************** 182 183//***************************************************************************** 184// 185// If the g_USBEventDriver is included in the host controller driver list then 186// this function must be provided by the application. 187// 188//***************************************************************************** 189extern void USBHCDEvents (void * pvData ); 190 191//***************************************************************************** 192// 193// Prototypes for the USB Host controller APIs. 194// 195//***************************************************************************** 196extern void USBHCDMain (void ); 197extern int32_t USBHCDEventEnable (uint32_t ui32Index ,void * pvEventDriver , 198uint32_t ui32Event ); 199extern int32_t USBHCDEventDisable (uint32_t ui32Index ,void * pvEventDriver , 200uint32_t ui32Event ); 201extern void USBHCDInit (uint32_t ui32Index ,void * pvData ,uint32_t ui32Size ); 202extern void USBHCDPowerConfigInit (uint32_t ui32Index ,uint32_t ui32Flags ); 203extern uint32_t USBHCDPowerConfigGet (uint32_t ui32Index ); 204extern uint32_t USBHCDPowerConfigSet (uint32_t ui32Index ,uint32_t ui32Config ); 205extern uint32_t USBHCDPowerAutomatic (uint32_t ui32Index ); 206extern void 207USBHCDRegisterDrivers (uint32_t ui32Index , 208const tUSBHostClassDriver * const * ppsHClassDrvrs , 209uint32_t ui32NumDrivers ); 210extern void USBHCDTerm (uint32_t ui32Index ); 211extern void USBHCDSetConfig (uint32_t ui32Index ,uint32_t ui32Device , 212uint32_t ui32Configuration ); 213extern void USBHCDSetInterface (uint32_t ui32Index ,uint32_t ui32Device , 214uint32_t ui32Interface ,uint32_t ui32AltSetting ); 215extern void USBHCDSuspend (uint32_t ui32Index ); 216extern void USBHCDResume (uint32_t ui32Index ); 217extern void USBHCDReset (uint32_t ui32Index ); 218extern void USBHCDPipeFree (uint32_t ui32Pipe ); 219extern uint32_t USBHCDPipeAlloc (uint32_t ui32Index ,uint32_t ui32EndpointType , 220tUSBHostDevice * psDevice , 221tHCDPipeCallback pfnCallback ); 222extern uint32_t USBHCDPipeAllocSize (uint32_t ui32Index , 223uint32_t ui32EndpointType , 224tUSBHostDevice * psDevice , 225uint32_t ui32FIFOSize , 226tHCDPipeCallback pfnCallback ); 227extern uint32_t USBHCDPipeConfig (uint32_t ui32Pipe ,uint32_t ui32MaxPayload , 228uint32_t ui32Interval , 229uint32_t ui32TargetEndpoint ); 230extern uint32_t USBHCDPipeStatus (uint32_t ui32Pipe ); 231extern uint32_t USBHCDPipeWrite (uint32_t ui32Pipe ,uint8_t * pui8Data , 232uint32_t ui32Size ); 233extern uint32_t USBHCDPipeRead (uint32_t ui32Pipe ,uint8_t * pui8Data , 234uint32_t ui32Size ); 235extern uint32_t USBHCDPipeSchedule (uint32_t ui32Pipe ,uint8_t * pui8Data , 236uint32_t ui32Size ); 237extern uint32_t USBHCDPipeTransferSizeGet (uint32_t ui32Pipe ); 238extern void USBHCDPipeDataAck (uint32_t ui32Pipe ); 239extern uint32_t USBHCDPipeReadNonBlocking (uint32_t ui32Pipe ,uint8_t * pui8Data , 240uint32_t ui32Size ); 241extern uint32_t USBHCDStringDescriptorGet (tUSBHostDevice * psDevice , 242uint8_t * pui8Buffer , 243uint32_t ui32Size , 244uint32_t ui32LangID , 245uint32_t ui32StringIndex ); 246extern uint32_t USBHCDControlTransfer (uint32_t ui32Index , 247tUSBRequest * psSetupPacket , 248tUSBHostDevice * psDevice , 249uint8_t * pui8Data ,uint32_t ui32Size , 250uint32_t ui32MaxPacketSize ); 251extern void USB0HostIntHandler (void ); 252 253extern uint8_t USBHCDDevHubPort (uint32_t ui32Instance ); 254extern uint8_t USBHCDDevAddress (uint32_t ui32Instance ); 255extern uint8_t USBHCDDevClass (uint32_t ui32Instance ,uint32_t ui32Interface ); 256extern uint8_t USBHCDDevSubClass (uint32_t ui32Instance ,uint32_t ui32Interface ); 257extern uint8_t USBHCDDevProtocol (uint32_t ui32Instance ,uint32_t ui32Interface ); 258extern bool USBHCDFeatureSet (uint32_t ui32Index ,uint32_t ui32Feature , 259void * pvFeature ); 260extern uint32_t USBHCDLPMSleep (tUSBHostDevice * psDevice ); 261extern void USBHCDLPMResume (uint32_t ui32Index ); 262 263//***************************************************************************** 264// 265// The host class drivers supported by the USB library. 266// 267//***************************************************************************** 268extern const tUSBHostClassDriver g_sUSBHostMSCClassDriver ; 269extern const tUSBHostClassDriver g_sUSBHIDClassDriver ; 270extern const tUSBHostClassDriver g_sUSBHostAudioClassDriver ; 271 272//***************************************************************************** 273// 274// Mark the end of the C bindings section for C++ compilers. 275// 276//***************************************************************************** 277#ifdef __cplusplus 278} 279#endif 280 281#endif // __USBHOST_H__