|
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 | | - * <h2><center>© Copyright (c) 2015 STMicroelectronics. |
10 | | - * All rights reserved.</center></h2> |
11 | | - * |
12 | | - * This software component is licensed by ST under Ultimate Liberty license |
13 | | - * SLA0044, the "License"; You may not use this file except in compliance with |
14 | | - * the License. You may obtain a copy of the License at: |
15 | | - * http://www.st.com/SLA0044 |
16 | | - * |
17 | | - ****************************************************************************** |
18 | | - */ |
19 | | - |
20 | | -/* Define to prevent recursive inclusion -------------------------------------*/ |
21 | | -#ifndef USB_CDC_H_ |
22 | | -#define USB_CDC_H_ |
23 | | - |
24 | | -#ifdef __cplusplus |
25 | | - extern "C" { |
26 | | -#endif |
27 | | - |
28 | | -/* Includes ------------------------------------------------------------------*/ |
29 | | -#include "usbd_ioreq.h" |
30 | | - |
31 | | -/** @addtogroup STM32_USB_DEVICE_LIBRARY |
32 | | - * @{ |
33 | | - */ |
34 | | - |
35 | | -/** @defgroup usbd_cdc |
36 | | - * @brief This file is the Header file for usbd_cdc.c |
37 | | - * @{ |
38 | | - */ |
39 | | - |
40 | | - |
41 | | -/** @defgroup usbd_cdc_Exported_Defines |
42 | | - * @{ |
43 | | - */ |
44 | | -#define CDC_IN_EP 0x81U /* EP1 for data IN */ |
45 | | -#define CDC_OUT_EP 0x01U /* EP1 for data OUT */ |
46 | | -#define CDC_CMD_EP 0x82U /* EP2 for CDC commands */ |
47 | | - |
48 | | -#ifndef CDC_HS_BINTERVAL |
49 | | - #define CDC_HS_BINTERVAL 0x10U |
50 | | -#endif /* CDC_HS_BINTERVAL */ |
51 | | - |
52 | | -#ifndef CDC_FS_BINTERVAL |
53 | | - #define CDC_FS_BINTERVAL 0x10U |
54 | | -#endif /* CDC_FS_BINTERVAL */ |
55 | | - |
56 | | -/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ |
57 | | -#define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */ |
58 | | -#define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */ |
59 | | -#define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */ |
60 | | - |
61 | | -#define USB_CDC_CONFIG_DESC_SIZ 67U |
62 | | -#define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE |
63 | | -#define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE |
64 | | - |
65 | | -#define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE |
66 | | -#define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE |
67 | | - |
68 | | -/*---------------------------------------------------------------------*/ |
69 | | -/* CDC definitions */ |
70 | | -/*---------------------------------------------------------------------*/ |
71 | | -#define CDC_SEND_ENCAPSULATED_COMMAND 0x00U |
72 | | -#define CDC_GET_ENCAPSULATED_RESPONSE 0x01U |
73 | | -#define CDC_SET_COMM_FEATURE 0x02U |
74 | | -#define CDC_GET_COMM_FEATURE 0x03U |
75 | | -#define CDC_CLEAR_COMM_FEATURE 0x04U |
76 | | -#define CDC_SET_LINE_CODING 0x20U |
77 | | -#define CDC_GET_LINE_CODING 0x21U |
78 | | -#define CDC_SET_CONTROL_LINE_STATE 0x22U |
79 | | -#define CDC_SEND_BREAK 0x23U |
80 | | - |
81 | | -/** |
82 | | - * @} |
83 | | - */ |
84 | | - |
85 | | - |
86 | | -/** @defgroup USBD_CORE_Exported_TypesDefinitions |
87 | | - * @{ |
88 | | - */ |
89 | | - |
90 | | -/** |
91 | | - * @} |
92 | | - */ |
93 | | -typedef struct |
94 | | -{ |
95 | | - uint32_t bitrate; |
96 | | - uint8_t format; |
97 | | - uint8_t paritytype; |
98 | | - uint8_t datatype; |
99 | | -}USBD_CDC_LineCodingTypeDef; |
100 | | - |
101 | | -typedef struct |
102 | | -{ |
103 | | - int8_t (* Init) (void); |
104 | | - int8_t (* DeInit) (void); |
105 | | - int8_t (* Control) (uint8_t cmd, uint8_t* pbuf, uint16_t length); |
106 | | - int8_t (* Receive) (uint8_t* Buf, uint32_t *Len); |
107 | | - |
108 | | -} USBD_CDC_ItfTypeDef; |
109 | | - |
110 | | - |
111 | | -typedef struct |
112 | | -{ |
113 | | - uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32bits alignment */ |
114 | | - uint8_t CmdOpCode; |
115 | | - uint8_t CmdLength; |
116 | | - uint8_t *RxBuffer; |
117 | | - uint8_t *TxBuffer; |
118 | | - uint32_t RxLength; |
119 | | - uint32_t TxLength; |
120 | | - |
121 | | - __IO uint32_t TxState; |
122 | | - __IO uint32_t RxState; |
123 | | -} |
124 | | -USBD_CDC_HandleTypeDef; |
125 | | - |
126 | | - |
127 | | - |
128 | | -/** @defgroup USBD_CORE_Exported_Macros |
129 | | - * @{ |
130 | | - */ |
131 | | - |
132 | | -/** |
133 | | - * @} |
134 | | - */ |
135 | | - |
136 | | -/** @defgroup USBD_CORE_Exported_Variables |
137 | | - * @{ |
138 | | - */ |
139 | | - |
140 | | -extern USBD_ClassTypeDef USBD_CDC; |
141 | | -#define USBD_CDC_CLASS &USBD_CDC |
142 | | -/** |
143 | | - * @} |
144 | | - */ |
145 | | - |
146 | | -/** @defgroup USB_CORE_Exported_Functions |
147 | | - * @{ |
148 | | - */ |
149 | | -uint8_t USBD_CDC_RegisterInterface (USBD_HandleTypeDef *pdev, |
150 | | - USBD_CDC_ItfTypeDef *fops); |
151 | | - |
152 | | -uint8_t USBD_CDC_SetTxBuffer (USBD_HandleTypeDef *pdev, |
153 | | - uint8_t *pbuff, |
154 | | - uint16_t length); |
155 | | - |
156 | | -uint8_t USBD_CDC_SetRxBuffer (USBD_HandleTypeDef *pdev, |
157 | | - uint8_t *pbuff); |
158 | | - |
159 | | -uint8_t USBD_CDC_ReceivePacket (USBD_HandleTypeDef *pdev); |
160 | | - |
161 | | -uint8_t USBD_CDC_TransmitPacket (USBD_HandleTypeDef *pdev); |
162 | | -/** |
163 | | - * @} |
164 | | - */ |
165 | | - |
166 | | -#ifdef __cplusplus |
167 | | -} |
168 | | -#endif |
169 | | - |
170 | | -#endif /* USB_CDC_H_ */ |
171 | | -/** |
172 | | - * @} |
173 | | - */ |
174 | | - |
175 | | -/** |
176 | | - * @} |
177 | | - */ |
178 | | - |
179 | | -/************************ (C) COPYRIGHT STMicroelectronics *****END OF 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 |
| 24 | +extern "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 | +/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ |
| 62 | +#define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */ |
| 63 | +#define CDC_DATA_FS_MAX_PACKET_SIZE 64U /* Endpoint IN & OUT Packet size */ |
| 64 | +#define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */ |
| 65 | + |
| 66 | +#define USB_CDC_CONFIG_DESC_SIZ 67U |
| 67 | +#define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE |
| 68 | +#define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE |
| 69 | + |
| 70 | +#define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE |
| 71 | +#define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE |
| 72 | + |
| 73 | +#define CDC_REQ_MAX_DATA_SIZE 0x7U |
| 74 | +/*---------------------------------------------------------------------*/ |
| 75 | +/* CDC definitions */ |
| 76 | +/*---------------------------------------------------------------------*/ |
| 77 | +#define CDC_SEND_ENCAPSULATED_COMMAND 0x00U |
| 78 | +#define CDC_GET_ENCAPSULATED_RESPONSE 0x01U |
| 79 | +#define CDC_SET_COMM_FEATURE 0x02U |
| 80 | +#define CDC_GET_COMM_FEATURE 0x03U |
| 81 | +#define CDC_CLEAR_COMM_FEATURE 0x04U |
| 82 | +#define CDC_SET_LINE_CODING 0x20U |
| 83 | +#define CDC_GET_LINE_CODING 0x21U |
| 84 | +#define CDC_SET_CONTROL_LINE_STATE 0x22U |
| 85 | +#define CDC_SEND_BREAK 0x23U |
| 86 | + |
| 87 | +/** |
| 88 | + * @} |
| 89 | + */ |
| 90 | + |
| 91 | + |
| 92 | +/** @defgroup USBD_CORE_Exported_TypesDefinitions |
| 93 | + * @{ |
| 94 | + */ |
| 95 | + |
| 96 | +/** |
| 97 | + * @} |
| 98 | + */ |
| 99 | +typedef struct |
| 100 | +{ |
| 101 | + uint32_t bitrate; |
| 102 | + uint8_t format; |
| 103 | + uint8_t paritytype; |
| 104 | + uint8_t datatype; |
| 105 | +} USBD_CDC_LineCodingTypeDef; |
| 106 | + |
| 107 | +typedef struct _USBD_CDC_Itf |
| 108 | +{ |
| 109 | + int8_t (* Init)(void); |
| 110 | + int8_t (* DeInit)(void); |
| 111 | + int8_t (* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length); |
| 112 | + int8_t (* Receive)(uint8_t *Buf, uint32_t *Len); |
| 113 | + int8_t (* TransmitCplt)(uint8_t *Buf, uint32_t *Len, uint8_t epnum); |
| 114 | +} USBD_CDC_ItfTypeDef; |
| 115 | + |
| 116 | + |
| 117 | +typedef struct |
| 118 | +{ |
| 119 | + uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32-bit alignment */ |
| 120 | + uint8_t CmdOpCode; |
| 121 | + uint8_t CmdLength; |
| 122 | + uint8_t *RxBuffer; |
| 123 | + uint8_t *TxBuffer; |
| 124 | + uint32_t RxLength; |
| 125 | + uint32_t TxLength; |
| 126 | + |
| 127 | + __IO uint32_t TxState; |
| 128 | + __IO uint32_t RxState; |
| 129 | +} USBD_CDC_HandleTypeDef; |
| 130 | + |
| 131 | + |
| 132 | + |
| 133 | +/** @defgroup USBD_CORE_Exported_Macros |
| 134 | + * @{ |
| 135 | + */ |
| 136 | + |
| 137 | +/** |
| 138 | + * @} |
| 139 | + */ |
| 140 | + |
| 141 | +/** @defgroup USBD_CORE_Exported_Variables |
| 142 | + * @{ |
| 143 | + */ |
| 144 | + |
| 145 | +extern USBD_ClassTypeDef USBD_CDC; |
| 146 | +#define USBD_CDC_CLASS &USBD_CDC |
| 147 | +/** |
| 148 | + * @} |
| 149 | + */ |
| 150 | + |
| 151 | +/** @defgroup USB_CORE_Exported_Functions |
| 152 | + * @{ |
| 153 | + */ |
| 154 | +uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev, |
| 155 | + USBD_CDC_ItfTypeDef *fops); |
| 156 | + |
| 157 | +#ifdef USE_USBD_COMPOSITE |
| 158 | +uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, |
| 159 | + uint32_t length, uint8_t ClassId); |
| 160 | +uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev, uint8_t ClassId); |
| 161 | +#else |
| 162 | +uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, |
| 163 | + uint32_t length); |
| 164 | +uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev); |
| 165 | +#endif /* USE_USBD_COMPOSITE */ |
| 166 | +uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff); |
| 167 | +uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev); |
| 168 | +/** |
| 169 | + * @} |
| 170 | + */ |
| 171 | + |
| 172 | +#ifdef __cplusplus |
| 173 | +} |
| 174 | +#endif |
| 175 | + |
| 176 | +#endif /* __USB_CDC_H */ |
| 177 | +/** |
| 178 | + * @} |
| 179 | + */ |
| 180 | + |
| 181 | +/** |
| 182 | + * @} |
| 183 | + */ |
| 184 | + |
0 commit comments