STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
usbd_template.c
Go to the documentation of this file.
1 
46 /* Includes ------------------------------------------------------------------*/
47 #include "usbd_template.h"
48 #include "usbd_desc.h"
49 #include "usbd_ctlreq.h"
50 
51 
95 static uint8_t USBD_TEMPLATE_Init (USBD_HandleTypeDef *pdev,
96  uint8_t cfgidx);
97 
98 static uint8_t USBD_TEMPLATE_DeInit (USBD_HandleTypeDef *pdev,
99  uint8_t cfgidx);
100 
101 static uint8_t USBD_TEMPLATE_Setup (USBD_HandleTypeDef *pdev,
102  USBD_SetupReqTypedef *req);
103 
104 static uint8_t *USBD_TEMPLATE_GetCfgDesc (uint16_t *length);
105 
106 static uint8_t *USBD_TEMPLATE_GetDeviceQualifierDesc (uint16_t *length);
107 
108 static uint8_t USBD_TEMPLATE_DataIn (USBD_HandleTypeDef *pdev, uint8_t epnum);
109 
110 static uint8_t USBD_TEMPLATE_DataOut (USBD_HandleTypeDef *pdev, uint8_t epnum);
111 
112 static uint8_t USBD_TEMPLATE_EP0_RxReady (USBD_HandleTypeDef *pdev);
113 
114 static uint8_t USBD_TEMPLATE_EP0_TxReady (USBD_HandleTypeDef *pdev);
115 
116 static uint8_t USBD_TEMPLATE_SOF (USBD_HandleTypeDef *pdev);
117 
118 static uint8_t USBD_TEMPLATE_IsoINIncomplete (USBD_HandleTypeDef *pdev, uint8_t epnum);
119 
120 static uint8_t USBD_TEMPLATE_IsoOutIncomplete (USBD_HandleTypeDef *pdev, uint8_t epnum);
121 
131 {
132  USBD_TEMPLATE_Init,
133  USBD_TEMPLATE_DeInit,
134  USBD_TEMPLATE_Setup,
135  USBD_TEMPLATE_EP0_TxReady,
136  USBD_TEMPLATE_EP0_RxReady,
137  USBD_TEMPLATE_DataIn,
138  USBD_TEMPLATE_DataOut,
139  USBD_TEMPLATE_SOF,
140  USBD_TEMPLATE_IsoINIncomplete,
141  USBD_TEMPLATE_IsoOutIncomplete,
142  USBD_TEMPLATE_GetCfgDesc,
143  USBD_TEMPLATE_GetCfgDesc,
144  USBD_TEMPLATE_GetCfgDesc,
145  USBD_TEMPLATE_GetDeviceQualifierDesc,
146 };
147 
148 #if defined ( __ICCARM__ )
149  #pragma data_alignment=4
150 #endif
151 /* USB TEMPLATE device Configuration Descriptor */
152 static uint8_t USBD_TEMPLATE_CfgDesc[USB_TEMPLATE_CONFIG_DESC_SIZ] =
153 {
154  0x09, /* bLength: Configuation Descriptor size */
155  USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION, /* bDescriptorType: Configuration */
157  /* wTotalLength: Bytes returned */
158  0x00,
159  0x01, /*bNumInterfaces: 1 interface*/
160  0x01, /*bConfigurationValue: Configuration value*/
161  0x02, /*iConfiguration: Index of string descriptor describing the configuration*/
162  0xC0, /*bmAttributes: bus powered and Supports Remote Wakeup */
163  0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/
164  /* 09 */
165 
166  /********** Descriptor of TEMPLATE interface 0 Alternate setting 0 **************/
167 
168 };
169 
170 #if defined ( __ICCARM__ )
171  #pragma data_alignment=4
172 #endif
173 /* USB Standard Device Descriptor */
174 static uint8_t USBD_TEMPLATE_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] =
175 {
178  0x00,
179  0x02,
180  0x00,
181  0x00,
182  0x00,
183  0x40,
184  0x01,
185  0x00,
186 };
187 
203 static uint8_t USBD_TEMPLATE_Init (USBD_HandleTypeDef *pdev,
204  uint8_t cfgidx)
205 {
206  uint8_t ret = 0;
207 
208 
209  return ret;
210 }
211 
219 static uint8_t USBD_TEMPLATE_DeInit (USBD_HandleTypeDef *pdev,
220  uint8_t cfgidx)
221 {
222 
223  return USBD_OK;
224 }
225 
233 static uint8_t USBD_TEMPLATE_Setup (USBD_HandleTypeDef *pdev,
235 {
236 
237  switch (req->bmRequest & USB_REQ_TYPE_MASK)
238  {
239  case USB_REQ_TYPE_CLASS :
240  switch (req->bRequest)
241  {
242 
243  default:
244  USBD_CtlError (pdev, req);
245  return USBD_FAIL;
246  }
247  break;
248 
250  switch (req->bRequest)
251  {
252 
253  default:
254  USBD_CtlError (pdev, req);
255  return USBD_FAIL;
256  }
257  }
258  return USBD_OK;
259 }
260 
261 
268 static uint8_t *USBD_TEMPLATE_GetCfgDesc (uint16_t *length)
269 {
270  *length = sizeof (USBD_TEMPLATE_CfgDesc);
271  return USBD_TEMPLATE_CfgDesc;
272 }
273 
280 uint8_t *USBD_TEMPLATE_DeviceQualifierDescriptor (uint16_t *length)
281 {
282  *length = sizeof (USBD_TEMPLATE_DeviceQualifierDesc);
283  return USBD_TEMPLATE_DeviceQualifierDesc;
284 }
285 
286 
294 static uint8_t USBD_TEMPLATE_DataIn (USBD_HandleTypeDef *pdev,
295  uint8_t epnum)
296 {
297 
298  return USBD_OK;
299 }
300 
307 static uint8_t USBD_TEMPLATE_EP0_RxReady (USBD_HandleTypeDef *pdev)
308 {
309 
310  return USBD_OK;
311 }
318 static uint8_t USBD_TEMPLATE_EP0_TxReady (USBD_HandleTypeDef *pdev)
319 {
320 
321  return USBD_OK;
322 }
329 static uint8_t USBD_TEMPLATE_SOF (USBD_HandleTypeDef *pdev)
330 {
331 
332  return USBD_OK;
333 }
341 static uint8_t USBD_TEMPLATE_IsoINIncomplete (USBD_HandleTypeDef *pdev, uint8_t epnum)
342 {
343 
344  return USBD_OK;
345 }
353 static uint8_t USBD_TEMPLATE_IsoOutIncomplete (USBD_HandleTypeDef *pdev, uint8_t epnum)
354 {
355 
356  return USBD_OK;
357 }
365 static uint8_t USBD_TEMPLATE_DataOut (USBD_HandleTypeDef *pdev,
366  uint8_t epnum)
367 {
368 
369  return USBD_OK;
370 }
371 
378 uint8_t *USBD_TEMPLATE_GetDeviceQualifierDesc (uint16_t *length)
379 {
380  *length = sizeof (USBD_TEMPLATE_DeviceQualifierDesc);
381  return USBD_TEMPLATE_DeviceQualifierDesc;
382 }
383 
398 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION
Definition: usbd_def.h:101
uint8_t bmRequest
Definition: usbd_def.h:151
uint8_t bRequest
Definition: usbd_def.h:152
#define USB_LEN_DEV_QUALIFIER_DESC
Definition: usbd_def.h:57
#define USB_TEMPLATE_CONFIG_DESC_SIZ
Definition: usbd_template.h:55
uint8_t * USBD_TEMPLATE_DeviceQualifierDescriptor(uint16_t *length)
DeviceQualifierDescriptor return Device Qualifier descriptor.
void USBD_CtlError(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
USBD_CtlError Handle USB low level Error.
Definition: usbd_ctlreq.c:716
#define USB_REQ_TYPE_CLASS
Definition: usbd_def.h:74
#define USB_REQ_TYPE_STANDARD
Definition: usbd_def.h:73
#define USB_DESC_TYPE_DEVICE_QUALIFIER
Definition: usbd_def.h:100
#define USB_REQ_TYPE_MASK
Definition: usbd_def.h:76
USBD_ClassTypeDef USBD_TEMPLATE_ClassDriver