|
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 |
| -#include "usbd_ep_conf.h" |
31 |
| - |
32 |
| -/** @addtogroup STM32_USB_DEVICE_LIBRARY |
33 |
| - * @{ |
34 |
| - */ |
35 |
| - |
36 |
| -/** @defgroup usbd_cdc |
37 |
| - * @brief This file is the Header file for usbd_cdc.c |
38 |
| - * @{ |
39 |
| - */ |
40 |
| - |
41 |
| -/** @defgroup usbd_cdc_Exported_Defines |
42 |
| - * @{ |
43 |
| - */ |
44 |
| -#ifndef CDC_HS_BINTERVAL |
45 |
| -#define CDC_HS_BINTERVAL 0x10U |
46 |
| -#endif /* CDC_HS_BINTERVAL */ |
47 |
| - |
48 |
| -#ifndef CDC_FS_BINTERVAL |
49 |
| -#define CDC_FS_BINTERVAL 0x10U |
50 |
| -#endif /* CDC_FS_BINTERVAL */ |
51 |
| - |
52 |
| -/* CDC Endpoints parameters */ |
53 |
| - |
54 |
| -#define USB_CDC_CONFIG_DESC_SIZ 67U |
55 |
| -#define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE |
56 |
| -#define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE |
57 |
| - |
58 |
| -#define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE |
59 |
| -#define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE |
60 |
| - |
61 |
| -/*---------------------------------------------------------------------*/ |
62 |
| -/* CDC definitions */ |
63 |
| -/*---------------------------------------------------------------------*/ |
64 |
| -#define CDC_SEND_ENCAPSULATED_COMMAND 0x00U |
65 |
| -#define CDC_GET_ENCAPSULATED_RESPONSE 0x01U |
66 |
| -#define CDC_SET_COMM_FEATURE 0x02U |
67 |
| -#define CDC_GET_COMM_FEATURE 0x03U |
68 |
| -#define CDC_CLEAR_COMM_FEATURE 0x04U |
69 |
| -#define CDC_SET_LINE_CODING 0x20U |
70 |
| -#define CDC_GET_LINE_CODING 0x21U |
71 |
| -#define CDC_SET_CONTROL_LINE_STATE 0x22U |
72 |
| -#define CDC_SEND_BREAK 0x23U |
73 |
| - |
74 |
| -/** |
75 |
| - * @} |
76 |
| - */ |
77 |
| - |
78 |
| - |
79 |
| -/** @defgroup USBD_CORE_Exported_TypesDefinitions |
80 |
| - * @{ |
81 |
| - */ |
82 |
| - |
83 |
| -/** |
84 |
| - * @} |
85 |
| - */ |
86 |
| -typedef struct { |
87 |
| - uint32_t bitrate; |
88 |
| - uint8_t format; |
89 |
| - uint8_t paritytype; |
90 |
| - uint8_t datatype; |
91 |
| -} USBD_CDC_LineCodingTypeDef; |
92 |
| - |
93 |
| -typedef struct _USBD_CDC_Itf { |
94 |
| - int8_t (* Init)(void); |
95 |
| - int8_t (* DeInit)(void); |
96 |
| - int8_t (* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length); |
97 |
| - int8_t (* Receive)(uint8_t *Buf, uint32_t *Len); |
98 |
| - int8_t (* Transferred)(void); |
99 |
| - |
100 |
| -} USBD_CDC_ItfTypeDef; |
101 |
| - |
102 |
| - |
103 |
| -typedef struct { |
104 |
| - uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32bits alignment */ |
105 |
| - uint8_t CmdOpCode; |
106 |
| - uint8_t CmdLength; |
107 |
| - uint8_t *RxBuffer; |
108 |
| - uint8_t *TxBuffer; |
109 |
| - uint32_t RxLength; |
110 |
| - uint32_t TxLength; |
111 |
| - |
112 |
| - __IO uint32_t TxState; |
113 |
| - __IO uint32_t RxState; |
114 |
| -} |
115 |
| -USBD_CDC_HandleTypeDef; |
116 |
| - |
117 |
| - |
118 |
| - |
119 |
| -/** @defgroup USBD_CORE_Exported_Macros |
120 |
| - * @{ |
121 |
| - */ |
122 |
| - |
123 |
| -/** |
124 |
| - * @} |
125 |
| - */ |
126 |
| - |
127 |
| -/** @defgroup USBD_CORE_Exported_Variables |
128 |
| - * @{ |
129 |
| - */ |
130 |
| - |
131 |
| -extern USBD_ClassTypeDef USBD_CDC; |
132 |
| -#define USBD_CDC_CLASS &USBD_CDC |
133 |
| -/** |
134 |
| - * @} |
135 |
| - */ |
136 |
| - |
137 |
| -/** @defgroup USB_CORE_Exported_Functions |
138 |
| - * @{ |
139 |
| - */ |
140 |
| -uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev, |
141 |
| - USBD_CDC_ItfTypeDef *fops); |
142 |
| - |
143 |
| -uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, |
144 |
| - uint8_t *pbuff, |
145 |
| - uint16_t length); |
146 |
| - |
147 |
| -uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, |
148 |
| - uint8_t *pbuff); |
149 |
| - |
150 |
| -uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev); |
151 |
| - |
152 |
| -uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev); |
153 |
| - |
154 |
| -uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev); |
155 |
| -/** |
156 |
| - * @} |
157 |
| - */ |
158 |
| - |
159 |
| -#ifdef __cplusplus |
160 |
| -} |
161 |
| -#endif |
162 |
| - |
163 |
| -#endif /* __USB_CDC_H */ |
164 |
| -/** |
165 |
| - * @} |
166 |
| - */ |
167 |
| - |
168 |
| -/** |
169 |
| - * @} |
170 |
| - */ |
171 |
| - |
172 |
| -/************************ (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 | + * <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 | +#include "usbd_ep_conf.h" |
| 31 | + |
| 32 | +/** @addtogroup STM32_USB_DEVICE_LIBRARY |
| 33 | + * @{ |
| 34 | + */ |
| 35 | + |
| 36 | +/** @defgroup usbd_cdc |
| 37 | + * @brief This file is the Header file for usbd_cdc.c |
| 38 | + * @{ |
| 39 | + */ |
| 40 | + |
| 41 | +/** @defgroup usbd_cdc_Exported_Defines |
| 42 | + * @{ |
| 43 | + */ |
| 44 | +#ifndef CDC_HS_BINTERVAL |
| 45 | +#define CDC_HS_BINTERVAL 0x10U |
| 46 | +#endif /* CDC_HS_BINTERVAL */ |
| 47 | + |
| 48 | +#ifndef CDC_FS_BINTERVAL |
| 49 | +#define CDC_FS_BINTERVAL 0x10U |
| 50 | +#endif /* CDC_FS_BINTERVAL */ |
| 51 | + |
| 52 | +/* CDC Endpoints parameters */ |
| 53 | + |
| 54 | +#define USB_CDC_CONFIG_DESC_SIZ 67U |
| 55 | +#define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE |
| 56 | +#define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE |
| 57 | + |
| 58 | +#define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE |
| 59 | +#define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE |
| 60 | + |
| 61 | +/*---------------------------------------------------------------------*/ |
| 62 | +/* CDC definitions */ |
| 63 | +/*---------------------------------------------------------------------*/ |
| 64 | +#define CDC_SEND_ENCAPSULATED_COMMAND 0x00U |
| 65 | +#define CDC_GET_ENCAPSULATED_RESPONSE 0x01U |
| 66 | +#define CDC_SET_COMM_FEATURE 0x02U |
| 67 | +#define CDC_GET_COMM_FEATURE 0x03U |
| 68 | +#define CDC_CLEAR_COMM_FEATURE 0x04U |
| 69 | +#define CDC_SET_LINE_CODING 0x20U |
| 70 | +#define CDC_GET_LINE_CODING 0x21U |
| 71 | +#define CDC_SET_CONTROL_LINE_STATE 0x22U |
| 72 | +#define CDC_SEND_BREAK 0x23U |
| 73 | + |
| 74 | +/** |
| 75 | + * @} |
| 76 | + */ |
| 77 | + |
| 78 | + |
| 79 | +/** @defgroup USBD_CORE_Exported_TypesDefinitions |
| 80 | + * @{ |
| 81 | + */ |
| 82 | + |
| 83 | +/** |
| 84 | + * @} |
| 85 | + */ |
| 86 | +typedef struct { |
| 87 | + uint32_t bitrate; |
| 88 | + uint8_t format; |
| 89 | + uint8_t paritytype; |
| 90 | + uint8_t datatype; |
| 91 | +} USBD_CDC_LineCodingTypeDef; |
| 92 | + |
| 93 | +typedef struct _USBD_CDC_Itf { |
| 94 | + int8_t (* Init)(void); |
| 95 | + int8_t (* DeInit)(void); |
| 96 | + int8_t (* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length); |
| 97 | + int8_t (* Receive)(uint8_t *Buf, uint32_t *Len); |
| 98 | + int8_t (* Transferred)(void); |
| 99 | + |
| 100 | +} USBD_CDC_ItfTypeDef; |
| 101 | + |
| 102 | + |
| 103 | +typedef struct { |
| 104 | + uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32bits alignment */ |
| 105 | + uint8_t CmdOpCode; |
| 106 | + uint8_t CmdLength; |
| 107 | + uint8_t *RxBuffer; |
| 108 | + uint8_t *TxBuffer; |
| 109 | + uint32_t RxLength; |
| 110 | + uint32_t TxLength; |
| 111 | + |
| 112 | + __IO uint32_t TxState; |
| 113 | + __IO uint32_t RxState; |
| 114 | +} |
| 115 | +USBD_CDC_HandleTypeDef; |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | +/** @defgroup USBD_CORE_Exported_Macros |
| 120 | + * @{ |
| 121 | + */ |
| 122 | + |
| 123 | +/** |
| 124 | + * @} |
| 125 | + */ |
| 126 | + |
| 127 | +/** @defgroup USBD_CORE_Exported_Variables |
| 128 | + * @{ |
| 129 | + */ |
| 130 | + |
| 131 | +extern USBD_ClassTypeDef USBD_CDC; |
| 132 | +#define USBD_CDC_CLASS &USBD_CDC |
| 133 | +/** |
| 134 | + * @} |
| 135 | + */ |
| 136 | + |
| 137 | +/** @defgroup USB_CORE_Exported_Functions |
| 138 | + * @{ |
| 139 | + */ |
| 140 | +uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev, |
| 141 | + USBD_CDC_ItfTypeDef *fops); |
| 142 | + |
| 143 | +uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, |
| 144 | + uint8_t *pbuff, |
| 145 | + uint16_t length); |
| 146 | + |
| 147 | +uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, |
| 148 | + uint8_t *pbuff); |
| 149 | + |
| 150 | +uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev); |
| 151 | + |
| 152 | +uint8_t USBD_CDC_ClearBuffer(USBD_HandleTypeDef *pdev); |
| 153 | + |
| 154 | +uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev); |
| 155 | +/** |
| 156 | + * @} |
| 157 | + */ |
| 158 | + |
| 159 | +#ifdef __cplusplus |
| 160 | +} |
| 161 | +#endif |
| 162 | + |
| 163 | +#endif /* __USB_CDC_H */ |
| 164 | +/** |
| 165 | + * @} |
| 166 | + */ |
| 167 | + |
| 168 | +/** |
| 169 | + * @} |
| 170 | + */ |
| 171 | + |
| 172 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
0 commit comments