Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 9 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /** |
1 | /** |
2 | ****************************************************************************** |
2 | ****************************************************************************** |
3 | * @file usbd_cdc.h |
3 | * @file usbd_cdc.h |
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @version V2.4.2 |
- | |
6 | * @date 11-December-2015 |
- | |
7 | * @brief header file for the usbd_cdc.c file. |
5 | * @brief header file for the usbd_cdc.c file. |
8 | ****************************************************************************** |
6 | ****************************************************************************** |
9 | * @attention |
7 | * @attention |
10 | * |
8 | * |
11 | * <h2><center>© COPYRIGHT 2015 STMicroelectronics</center></h2> |
9 | * <h2><center>© Copyright (c) 2015 STMicroelectronics. |
- | 10 | * All rights reserved.</center></h2> |
|
12 | * |
11 | * |
13 | * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); |
12 | * This software component is licensed by ST under Ultimate Liberty license |
14 | * You may not use this file except in compliance with the License. |
13 | * SLA0044, the "License"; You may not use this file except in compliance with |
15 | * You may obtain a copy of the License at: |
14 | * the License. You may obtain a copy of the License at: |
16 | * |
- | |
17 | * http://www.st.com/software_license_agreement_liberty_v2 |
- | |
18 | * |
- | |
19 | * Unless required by applicable law or agreed to in writing, software |
- | |
20 | * distributed under the License is distributed on an "AS IS" BASIS, |
- | |
21 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
- | |
22 | * See the License for the specific language governing permissions and |
- | |
23 | * limitations under the License. |
15 | * www.st.com/SLA0044 |
24 | * |
16 | * |
25 | ****************************************************************************** |
17 | ****************************************************************************** |
26 | */ |
18 | */ |
27 | 19 | ||
28 | /* Define to prevent recursive inclusion -------------------------------------*/ |
20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
29 | #ifndef __USB_CDC_H |
21 | #ifndef __USB_CDC_H |
30 | #define __USB_CDC_H |
22 | #define __USB_CDC_H |
31 | 23 | ||
32 | #ifdef __cplusplus |
24 | #ifdef __cplusplus |
33 | extern "C" { |
25 | extern "C" { |
34 | #endif |
26 | #endif |
35 | 27 | ||
36 | /* Includes ------------------------------------------------------------------*/ |
28 | /* Includes ------------------------------------------------------------------*/ |
37 | #include "usbd_ioreq.h" |
29 | #include "usbd_ioreq.h" |
38 | 30 | ||
39 | /** @addtogroup STM32_USB_DEVICE_LIBRARY |
31 | /** @addtogroup STM32_USB_DEVICE_LIBRARY |
40 | * @{ |
32 | * @{ |
41 | */ |
33 | */ |
42 | 34 | ||
43 | /** @defgroup usbd_cdc |
35 | /** @defgroup usbd_cdc |
44 | * @brief This file is the Header file for usbd_cdc.c |
36 | * @brief This file is the Header file for usbd_cdc.c |
45 | * @{ |
37 | * @{ |
46 | */ |
38 | */ |
47 | 39 | ||
48 | 40 | ||
49 | /** @defgroup usbd_cdc_Exported_Defines |
41 | /** @defgroup usbd_cdc_Exported_Defines |
50 | * @{ |
42 | * @{ |
51 | */ |
43 | */ |
52 | #define CDC_IN_EP 0x81 /* EP1 for data IN */ |
44 | #define CDC_IN_EP 0x81U /* EP1 for data IN */ |
53 | #define CDC_OUT_EP 0x01 /* EP1 for data OUT */ |
45 | #define CDC_OUT_EP 0x01U /* EP1 for data OUT */ |
54 | #define CDC_CMD_EP 0x82 /* EP2 for CDC commands */ |
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 | 55 | ||
56 | /* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */ |
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 512 /* Endpoint IN & OUT Packet size */ |
57 | #define CDC_DATA_HS_MAX_PACKET_SIZE 512U /* Endpoint IN & OUT Packet size */ |
58 | #define CDC_DATA_FS_MAX_PACKET_SIZE 64 /* 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 8 /* Control Endpoint Packet size */ |
59 | #define CDC_CMD_PACKET_SIZE 8U /* Control Endpoint Packet size */ |
60 | 60 | ||
61 | #define USB_CDC_CONFIG_DESC_SIZ 67 |
61 | #define USB_CDC_CONFIG_DESC_SIZ 67U |
62 | #define CDC_DATA_HS_IN_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE |
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 |
63 | #define CDC_DATA_HS_OUT_PACKET_SIZE CDC_DATA_HS_MAX_PACKET_SIZE |
64 | 64 | ||
65 | #define CDC_DATA_FS_IN_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE |
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 |
66 | #define CDC_DATA_FS_OUT_PACKET_SIZE CDC_DATA_FS_MAX_PACKET_SIZE |
67 | 67 | ||
68 | /*---------------------------------------------------------------------*/ |
68 | /*---------------------------------------------------------------------*/ |
69 | /* CDC definitions */ |
69 | /* CDC definitions */ |
70 | /*---------------------------------------------------------------------*/ |
70 | /*---------------------------------------------------------------------*/ |
71 | #define CDC_SEND_ENCAPSULATED_COMMAND 0x00 |
71 | #define CDC_SEND_ENCAPSULATED_COMMAND 0x00U |
72 | #define CDC_GET_ENCAPSULATED_RESPONSE 0x01 |
72 | #define CDC_GET_ENCAPSULATED_RESPONSE 0x01U |
73 | #define CDC_SET_COMM_FEATURE 0x02 |
73 | #define CDC_SET_COMM_FEATURE 0x02U |
74 | #define CDC_GET_COMM_FEATURE 0x03 |
74 | #define CDC_GET_COMM_FEATURE 0x03U |
75 | #define CDC_CLEAR_COMM_FEATURE 0x04 |
75 | #define CDC_CLEAR_COMM_FEATURE 0x04U |
76 | #define CDC_SET_LINE_CODING 0x20 |
76 | #define CDC_SET_LINE_CODING 0x20U |
77 | #define CDC_GET_LINE_CODING 0x21 |
77 | #define CDC_GET_LINE_CODING 0x21U |
78 | #define CDC_SET_CONTROL_LINE_STATE 0x22 |
78 | #define CDC_SET_CONTROL_LINE_STATE 0x22U |
79 | #define CDC_SEND_BREAK 0x23 |
79 | #define CDC_SEND_BREAK 0x23U |
80 | 80 | ||
81 | /** |
81 | /** |
82 | * @} |
82 | * @} |
83 | */ |
83 | */ |
84 | 84 | ||
85 | 85 | ||
86 | /** @defgroup USBD_CORE_Exported_TypesDefinitions |
86 | /** @defgroup USBD_CORE_Exported_TypesDefinitions |
87 | * @{ |
87 | * @{ |
88 | */ |
88 | */ |
89 | 89 | ||
90 | /** |
90 | /** |
91 | * @} |
91 | * @} |
92 | */ |
92 | */ |
93 | typedef struct |
93 | typedef struct |
94 | { |
94 | { |
95 | uint32_t bitrate; |
95 | uint32_t bitrate; |
96 | uint8_t format; |
96 | uint8_t format; |
97 | uint8_t paritytype; |
97 | uint8_t paritytype; |
98 | uint8_t datatype; |
98 | uint8_t datatype; |
99 | }USBD_CDC_LineCodingTypeDef; |
99 | } USBD_CDC_LineCodingTypeDef; |
100 | 100 | ||
101 | typedef struct _USBD_CDC_Itf |
101 | typedef struct _USBD_CDC_Itf |
102 | { |
102 | { |
103 | int8_t (* Init) (void); |
103 | int8_t (* Init)(void); |
104 | int8_t (* DeInit) (void); |
104 | int8_t (* DeInit)(void); |
105 | int8_t (* Control) (uint8_t, uint8_t * , uint16_t); |
105 | int8_t (* Control)(uint8_t cmd, uint8_t *pbuf, uint16_t length); |
106 | int8_t (* Receive) (uint8_t *, uint32_t *); |
106 | int8_t (* Receive)(uint8_t *Buf, uint32_t *Len); |
107 | 107 | ||
108 | }USBD_CDC_ItfTypeDef; |
108 | } USBD_CDC_ItfTypeDef; |
109 | 109 | ||
110 | 110 | ||
111 | typedef struct |
111 | typedef struct |
112 | { |
112 | { |
113 | uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE/4]; /* Force 32bits alignment */ |
113 | uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE / 4U]; /* Force 32bits alignment */ |
114 | uint8_t CmdOpCode; |
114 | uint8_t CmdOpCode; |
115 | uint8_t CmdLength; |
115 | uint8_t CmdLength; |
116 | uint8_t *RxBuffer; |
116 | uint8_t *RxBuffer; |
117 | uint8_t *TxBuffer; |
117 | uint8_t *TxBuffer; |
118 | uint32_t RxLength; |
118 | uint32_t RxLength; |
119 | uint32_t TxLength; |
119 | uint32_t TxLength; |
120 | 120 | ||
121 | __IO uint32_t TxState; |
121 | __IO uint32_t TxState; |
122 | __IO uint32_t RxState; |
122 | __IO uint32_t RxState; |
123 | } |
123 | } |
124 | USBD_CDC_HandleTypeDef; |
124 | USBD_CDC_HandleTypeDef; |
125 | 125 | ||
126 | 126 | ||
127 | 127 | ||
128 | /** @defgroup USBD_CORE_Exported_Macros |
128 | /** @defgroup USBD_CORE_Exported_Macros |
129 | * @{ |
129 | * @{ |
130 | */ |
130 | */ |
131 | 131 | ||
132 | /** |
132 | /** |
133 | * @} |
133 | * @} |
134 | */ |
134 | */ |
135 | 135 | ||
136 | /** @defgroup USBD_CORE_Exported_Variables |
136 | /** @defgroup USBD_CORE_Exported_Variables |
137 | * @{ |
137 | * @{ |
138 | */ |
138 | */ |
139 | 139 | ||
140 | extern USBD_ClassTypeDef USBD_CDC; |
140 | extern USBD_ClassTypeDef USBD_CDC; |
141 | #define USBD_CDC_CLASS &USBD_CDC |
141 | #define USBD_CDC_CLASS &USBD_CDC |
142 | /** |
142 | /** |
143 | * @} |
143 | * @} |
144 | */ |
144 | */ |
145 | 145 | ||
146 | /** @defgroup USB_CORE_Exported_Functions |
146 | /** @defgroup USB_CORE_Exported_Functions |
147 | * @{ |
147 | * @{ |
148 | */ |
148 | */ |
149 | uint8_t USBD_CDC_RegisterInterface (USBD_HandleTypeDef *pdev, |
149 | uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev, |
150 | USBD_CDC_ItfTypeDef *fops); |
150 | USBD_CDC_ItfTypeDef *fops); |
151 | 151 | ||
152 | uint8_t USBD_CDC_SetTxBuffer (USBD_HandleTypeDef *pdev, |
152 | uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, |
153 | uint8_t *pbuff, |
153 | uint8_t *pbuff, |
154 | uint16_t length); |
154 | uint16_t length); |
155 | 155 | ||
156 | uint8_t USBD_CDC_SetRxBuffer (USBD_HandleTypeDef *pdev, |
156 | uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, |
157 | uint8_t *pbuff); |
157 | uint8_t *pbuff); |
158 | - | ||
159 | uint8_t USBD_CDC_ReceivePacket (USBD_HandleTypeDef *pdev); |
- | |
160 | 158 | ||
- | 159 | uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev); |
|
- | 160 | ||
161 | uint8_t USBD_CDC_TransmitPacket (USBD_HandleTypeDef *pdev); |
161 | uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev); |
162 | /** |
162 | /** |
163 | * @} |
163 | * @} |
164 | */ |
164 | */ |
165 | 165 | ||
166 | #ifdef __cplusplus |
166 | #ifdef __cplusplus |
167 | } |
167 | } |
168 | #endif |
168 | #endif |
169 | 169 | ||
170 | #endif /* __USB_CDC_H */ |
170 | #endif /* __USB_CDC_H */ |
171 | /** |
171 | /** |
172 | * @} |
172 | * @} |
173 | */ |
173 | */ |
174 | 174 | ||
175 | /** |
175 | /** |
176 | * @} |
176 | * @} |
177 | */ |
177 | */ |
178 | 178 | ||
179 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
179 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |