STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
usbd_cdc.h
Go to the documentation of this file.
1/**
2 ******************************************************************************
3 * @file usbd_cdc.h
4 * @author MCD Application Team
5 * @brief header file for the usbd_cdc.c file.
6 ******************************************************************************
7 * @attention
8 *
9 * Copyright (c) 2015 STMicroelectronics.
10 * All rights reserved.
11 *
12 * This software is licensed under terms that can be found in the LICENSE file
13 * in the root directory of this software component.
14 * If no LICENSE file comes with this software, it is provided AS-IS.
15 *
16 ******************************************************************************
17 */
18
19/* Define to prevent recursive inclusion -------------------------------------*/
20#ifndef __USB_CDC_H
21#define __USB_CDC_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* Includes ------------------------------------------------------------------*/
28#include "usbd_ioreq.h"
29
30/** @addtogroup STM32_USB_DEVICE_LIBRARY
31 * @{
32 */
33
34/** @defgroup usbd_cdc
35 * @brief This file is the Header file for usbd_cdc.c
36 * @{
37 */
38
39
40/** @defgroup usbd_cdc_Exported_Defines
41 * @{
42 */
43#ifndef CDC_IN_EP
44#define CDC_IN_EP 0x81U /* EP1 for data IN */
45#endif /* CDC_IN_EP */
46#ifndef CDC_OUT_EP
47#define CDC_OUT_EP 0x01U /* EP1 for data OUT */
48#endif /* CDC_OUT_EP */
49#ifndef CDC_CMD_EP
50#define CDC_CMD_EP 0x82U /* EP2 for CDC commands */
51#endif /* CDC_CMD_EP */
52
53#ifndef CDC_HS_BINTERVAL
54#define CDC_HS_BINTERVAL 0x10U
55#endif /* CDC_HS_BINTERVAL */
56
57#ifndef CDC_FS_BINTERVAL
58#define CDC_FS_BINTERVAL 0x10U
59#endif /* CDC_FS_BINTERVAL */
60
61#ifndef CDC_CMD_PACKET_SIZE
62#define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */
63#endif /* CDC_CMD_PACKET_SIZE */
64
65/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
66#define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */
67#define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */
68
69#define USB_CDC_CONFIG_DESC_SIZ 67U
70#define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
71#define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE
72
73#define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
74#define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE
75
76#define CDC_REQ_MAX_DATA_SIZE 0x7U
77/*---------------------------------------------------------------------*/
78/* CDC definitions */
79/*---------------------------------------------------------------------*/
80#define CDC_SEND_ENCAPSULATED_COMMAND 0x00U
81#define CDC_GET_ENCAPSULATED_RESPONSE 0x01U
82#define CDC_SET_COMM_FEATURE 0x02U
83#define CDC_GET_COMM_FEATURE 0x03U
84#define CDC_CLEAR_COMM_FEATURE 0x04U
85#define CDC_SET_LINE_CODING 0x20U
86#define CDC_GET_LINE_CODING 0x21U
87#define CDC_SET_CONTROL_LINE_STATE 0x22U
88#define CDC_SEND_BREAK 0x23U
89
90/**
91 * @}
92 */
93
94
95/** @defgroup USBD_CORE_Exported_TypesDefinitions
96 * @{
97 */
98
99/**
100 * @}
101 */
102typedef struct
103{
104 uint32_t bitrate;
105 uint8_t format;
106 uint8_t paritytype;
107 uint8_t datatype;
109
110typedef struct _USBD_CDC_Itf
111{
112 int8_t (* Init)(void);
113 int8_t (* DeInit)(void);
114 int8_t (* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length);
115 int8_t (* Receive)(uint8_t *Buf, uint32_t *Len);
116 int8_t (* TransmitCplt)(uint8_t *Buf, uint32_t *Len, uint8_t epnum);
118
119
120typedef struct
121{
122 uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32-bit alignment */
123 uint8_t CmdOpCode;
124 uint8_t CmdLength;
125 uint8_t *RxBuffer;
126 uint8_t *TxBuffer;
127 uint32_t RxLength;
128 uint32_t TxLength;
129
130 __IO uint32_t TxState;
131 __IO uint32_t RxState;
133
134
135
136/** @defgroup USBD_CORE_Exported_Macros
137 * @{
138 */
139
140/**
141 * @}
142 */
143
144/** @defgroup USBD_CORE_Exported_Variables
145 * @{
146 */
147
149#define USBD_CDC_CLASS &USBD_CDC
150/**
151 * @}
152 */
153
154/** @defgroup USB_CORE_Exported_Functions
155 * @{
156 */
158 USBD_CDC_ItfTypeDef *fops);
159
160#ifdef USE_USBD_COMPOSITE
161uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
162 uint32_t length, uint8_t ClassId);
163uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId);
164#else
165uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff,
166 uint32_t length);
168#endif /* USE_USBD_COMPOSITE */
169uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff);
171/**
172 * @}
173 */
174
175#ifdef __cplusplus
176}
177#endif
178
179#endif /* __USB_CDC_H */
180/**
181 * @}
182 */
183
184/**
185 * @}
186 */
187
#define __IO
Defines 'read / write' permissions.
USBD_ClassTypeDef USBD_CDC
Definition usbd_cdc.c:141
struct _USBD_HandleTypeDef USBD_HandleTypeDef
struct _Device_cb USBD_ClassTypeDef
uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev, USBD_CDC_ItfTypeDef *fops)
USBD_CDC_RegisterInterface.
Definition usbd_cdc.c:738
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev)
USBD_CDC_ReceivePacket prepare OUT Endpoint for reception.
Definition usbd_cdc.c:856
uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
USBD_CDC_SetRxBuffer.
Definition usbd_cdc.c:789
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev)
USBD_CDC_TransmitPacket Transmit packet on IN endpoint.
Definition usbd_cdc.c:816
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, uint32_t length)
USBD_CDC_SetTxBuffer.
Definition usbd_cdc.c:766
#define CDC_DATA_HS_MAX_PACKET_SIZE
Definition usbd_cdc.h:66
struct _USBD_CDC_Itf USBD_CDC_ItfTypeDef
__IO uint32_t TxState
Definition usbd_cdc.h:130
uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE/4U]
Definition usbd_cdc.h:122
__IO uint32_t RxState
Definition usbd_cdc.h:131
int8_t(* Receive)(uint8_t *Buf, uint32_t *Len)
Definition usbd_cdc.h:115
int8_t(* Init)(void)
Definition usbd_cdc.h:112
int8_t(* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length)
Definition usbd_cdc.h:114
int8_t(* TransmitCplt)(uint8_t *Buf, uint32_t *Len, uint8_t epnum)
Definition usbd_cdc.h:116
int8_t(* DeInit)(void)
Definition usbd_cdc.h:113
Header file for the usbd_ioreq.c file.