usbdevicepriv.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // usbdevicepriv.h - Private header file used to share internal variables and
4 // function prototypes between the various device-related
5 // modules in the USB library. This header MUST NOT be
6 // used by application code.
7 //
8 // Copyright (c) 2008-2017 Texas Instruments Incorporated. All rights reserved.
9 // Software License Agreement
10 //
11 // Texas Instruments (TI) is supplying this software for use solely and
12 // exclusively on TI's microcontroller products. The software is owned by
13 // TI and/or its suppliers, and is protected under applicable copyright
14 // laws. You may not combine this software with "viral" open-source
15 // software in order to form a larger program.
16 //
17 // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
18 // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
19 // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
21 // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
22 // DAMAGES, FOR ANY REASON WHATSOEVER.
23 //
24 //*****************************************************************************
25 
26 #ifndef __USBDEVICEPRIV_H__
27 #define __USBDEVICEPRIV_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
36 extern "C"
37 {
38 #endif
39 
40 //*****************************************************************************
41 //
42 // The states for endpoint zero during enumeration.
43 //
44 //*****************************************************************************
45 typedef enum
46 {
47  //
48  // The USB device is waiting on a request from the host controller on
49  // endpoint zero.
50  //
52 
53  //
54  // The USB device is sending data back to the host due to an IN request.
55  //
57 
58  //
59  // The USB device is sending the configuration descriptor back to the host
60  // due to an IN request.
61  //
63 
64  //
65  // The USB device is receiving data from the host due to an OUT
66  // request from the host.
67  //
69 
70  //
71  // The USB device has completed the IN or OUT request and is now waiting
72  // for the host to acknowledge the end of the IN/OUT transaction. This
73  // is the status phase for a USB control transaction.
74  //
76 
77  //
78  // This endpoint has signaled a stall condition and is waiting for the
79  // stall to be acknowledged by the host controller.
80  //
82 }
83 tEP0State;
84 
85 typedef struct tDeviceInfo tDeviceInfo;
86 
87 //*****************************************************************************
88 //
89 // The USB controller device information.
90 //
91 //*****************************************************************************
92 typedef struct
93 {
94  //
95  // The current state of endpoint zero.
96  //
97  volatile tEP0State iEP0State;
98 
99  //
100  // The devices current address, this also has a change pending bit in the
101  // MSB of this value specified by DEV_ADDR_PENDING.
102  //
103  volatile uint32_t ui32DevAddress;
104 
105  //
106  // This holds the current active configuration for this device.
107  //
109 
110  //
111  // This holds the configuration id that will take effect after a reset.
112  //
114 
115  //
116  // This holds the current alternate interface for this device.
117  //
118  uint8_t pui8AltSetting[USB_MAX_INTERFACES_PER_DEVICE];
119 
120  //
121  // This is the pointer to the current data being sent out or received
122  // on endpoint zero.
123  //
124  uint8_t *pui8EP0Data;
125 
126  //
127  // This is the number of bytes that remain to be sent from or received
128  // into the g_sUSBDeviceState.pui8EP0Data data buffer.
129  //
130  volatile uint32_t ui32EP0DataRemain;
131 
132  //
133  // The amount of data being sent/received due to a custom request.
134  //
135  uint32_t ui32OUTDataSize;
136 
137  //
138  // Holds the current device status.
139  //
140  uint8_t ui8Status;
141 
142  //
143  // Holds the endpoint status for the HALT condition. This array is sized
144  // to hold halt status for all IN and OUT endpoints.
145  //
146  uint8_t ppui8Halt[2][USBLIB_NUM_EP - 1];
147 
148  //
149  // Holds the configuration descriptor section number currently being sent
150  // to the host.
151  //
153 
154  //
155  // Holds the offset within the configuration descriptor section currently
156  // being sent to the host.
157  //
159 
160  //
161  // Holds the index of the configuration that we are currently sending back
162  // to the host.
163  //
164  uint8_t ui8ConfigIndex;
165 
166  //
167  // This flag is set to true if the client has called USBDPowerStatusSet()
168  // and tells the USB library not to try to determine the current power
169  // status from the configuration descriptor.
170  //
172 
173  //
174  // This flag indicates whether or not remote wake up signaling is in
175  // progress.
176  //
178 
179  //
180  // During remote wake up signaling, this counter is used to track the
181  // number of milliseconds since the signaling was initiated.
182  //
184 
185  //
186  // The DMA instance information for this USB controller.
187  //
189 
190  //
191  // The interrupt number for this instance.
192  //
193  uint32_t ui32IntNum;
194 
195  //
196  // Pointer to the device supplied call back data.
197  //
198  void *pvCBData;
199 
200  //
201  // This holds the state of the LPM support for the device.
202  //
203  uint32_t ui32LPMState;
204 
205  //
206  // Device feature flags.
207  //
208  uint32_t ui32Features;
209 }
211 
212 extern tDCDInstance g_psDCDInst[];
213 extern tDeviceInfo *g_ppsDevInfo[];
214 
215 //*****************************************************************************
216 //
217 // Device enumeration functions provided by device/usbenum.c and called from
218 // the interrupt handler in device/usbhandler.c
219 //
220 //*****************************************************************************
221 extern bool USBDeviceConfig(tDCDInstance *psDevInst,
222  const tConfigHeader *psConfig);
223 extern bool USBDeviceConfigAlternate(tDCDInstance *psDevInst,
224  const tConfigHeader *psConfig,
225  uint8_t ui8InterfaceNum,
226  uint8_t ui8AlternateSetting);
227 
228 extern void USBDCDDeviceInfoInit(uint32_t ui32Index, tDeviceInfo *psDevice);
229 
230 //*****************************************************************************
231 //
232 // Macro access function to device information.
233 //
234 //*****************************************************************************
235 #define DCDGetDMAInstance(psDevInfo) (&(psDevInfo->psDCDInst->sDMAInstance))
236 
237 //*****************************************************************************
238 //
239 // Mark the end of the C bindings section for C++ compilers.
240 //
241 //*****************************************************************************
242 #ifdef __cplusplus
243 }
244 #endif
245 
246 #endif // __USBDEVICEPRIV_H__
Definition: usblib.h:1077
#define USBLIB_NUM_EP
Definition: usblib.h:57
uint32_t ui32LPMState
Definition: usbdevicepriv.h:203
uint8_t ui8ConfigSection
Definition: usbdevicepriv.h:152
bool USBDeviceConfig(tDCDInstance *psDevInst, const tConfigHeader *psConfig)
Definition: usbdconfig.c:184
uint32_t ui32IntNum
Definition: usbdevicepriv.h:193
bool USBDeviceConfigAlternate(tDCDInstance *psDevInst, const tConfigHeader *psConfig, uint8_t ui8InterfaceNum, uint8_t ui8AlternateSetting)
Definition: usbdconfig.c:446
volatile uint32_t ui32EP0DataRemain
Definition: usbdevicepriv.h:130
Definition: usbdevicepriv.h:62
#define USB_MAX_INTERFACES_PER_DEVICE
Definition: usbdevice.h:53
void * pvCBData
Definition: usbdevicepriv.h:198
uint32_t ui32OUTDataSize
Definition: usbdevicepriv.h:135
uint32_t ui32DefaultConfiguration
Definition: usbdevicepriv.h:113
uint8_t ui8ConfigIndex
Definition: usbdevicepriv.h:164
void USBDCDDeviceInfoInit(uint32_t ui32Index, tDeviceInfo *psDevice)
Definition: usbdenum.c:222
Definition: usbdevicepriv.h:81
Definition: usbdevicepriv.h:68
uint8_t ui8RemoteWakeupCount
Definition: usbdevicepriv.h:183
tEP0State
Definition: usbdevicepriv.h:45
Definition: usbdevicepriv.h:92
uint16_t ui16SectionOffset
Definition: usbdevicepriv.h:158
uint8_t * pui8EP0Data
Definition: usbdevicepriv.h:124
uint32_t ui32Configuration
Definition: usbdevicepriv.h:108
uint32_t ui32Features
Definition: usbdevicepriv.h:208
bool bRemoteWakeup
Definition: usbdevicepriv.h:177
Definition: usbdevicepriv.h:75
tUSBDMAInstance * psDMAInstance
Definition: usbdevicepriv.h:188
Definition: usbdevice.h:66
Definition: usblibpriv.h:177
bool bPwrSrcSet
Definition: usbdevicepriv.h:171
tDeviceInfo * g_ppsDevInfo[]
Definition: usbdenum.c:169
Definition: usbdevicepriv.h:51
tDCDInstance g_psDCDInst[]
Definition: usbdenum.c:161
uint8_t ui8Status
Definition: usbdevicepriv.h:140
volatile uint32_t ui32DevAddress
Definition: usbdevicepriv.h:103
volatile tEP0State iEP0State
Definition: usbdevicepriv.h:97
Definition: usbdevicepriv.h:56
Copyright 2018, Texas Instruments Incorporated