Prusa MINI Firmware overview
usbd_cdc.h
Go to the documentation of this file.
1 /**
2  ******************************************************************************
3  * @file usbd_cdc.h
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.
8  ******************************************************************************
9  * @attention
10  *
11  * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
12  *
13  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14  * You may not use this file except in compliance with the License.
15  * 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.
24  *
25  ******************************************************************************
26  */
27 
28 /* Define to prevent recursive inclusion -------------------------------------*/
29 #ifndef __USB_CDC_H
30 #define __USB_CDC_H
31 
32 #ifdef __cplusplus
33  extern "C" {
34 #endif
35 
36 /* Includes ------------------------------------------------------------------*/
37 #include "usbd_ioreq.h"
38 
39 /** @addtogroup STM32_USB_DEVICE_LIBRARY
40  * @{
41  */
42 
43 /** @defgroup usbd_cdc
44  * @brief This file is the Header file for usbd_cdc.c
45  * @{
46  */
47 
48 
49 /** @defgroup usbd_cdc_Exported_Defines
50  * @{
51  */
52 #define CDC_IN_EP 0x81 /* EP1 for data IN */
53 #define CDC_OUT_EP 0x01 /* EP1 for data OUT */
54 #define CDC_CMD_EP 0x82 /* EP2 for CDC commands */
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 512 /* Endpoint IN & OUT Packet size */
58 #define CDC_DATA_FS_MAX_PACKET_SIZE 64 /* Endpoint IN & OUT Packet size */
59 #define CDC_CMD_PACKET_SIZE 8 /* Control Endpoint Packet size */
60 
61 #define USB_CDC_CONFIG_DESC_SIZ 67
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 0x00
72 #define CDC_GET_ENCAPSULATED_RESPONSE 0x01
73 #define CDC_SET_COMM_FEATURE 0x02
74 #define CDC_GET_COMM_FEATURE 0x03
75 #define CDC_CLEAR_COMM_FEATURE 0x04
76 #define CDC_SET_LINE_CODING 0x20
77 #define CDC_GET_LINE_CODING 0x21
78 #define CDC_SET_CONTROL_LINE_STATE 0x22
79 #define CDC_SEND_BREAK 0x23
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;
100 
101 typedef struct _USBD_CDC_Itf
102 {
103  int8_t (* Init) (void);
104  int8_t (* DeInit) (void);
105  int8_t (* Control) (uint8_t, uint8_t * , uint16_t);
106  int8_t (* Receive) (uint8_t *, uint32_t *);
107 
109 
110 
111 typedef struct
112 {
113  uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE/4]; /* Force 32bits alignment */
118  uint32_t RxLength;
119  uint32_t TxLength;
120 
121  __IO uint32_t TxState;
122  __IO uint32_t RxState;
123 }
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 
141 #define USBD_CDC_CLASS &USBD_CDC
142 /**
143  * @}
144  */
145 
146 /** @defgroup USB_CORE_Exported_Functions
147  * @{
148  */
150  USBD_CDC_ItfTypeDef *fops);
151 
153  uint8_t *pbuff,
154  uint16_t length);
155 
157  uint8_t *pbuff);
158 
160 
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****/
USBD_CDC_SetTxBuffer
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, uint16_t length)
USBD_CDC_SetTxBuffer.
Definition: usbd_cdc.c:810
USBD_CDC_LineCodingTypeDef::bitrate
uint32_t bitrate
Definition: usbd_cdc.h:95
_USBD_CDC_Itf::Control
int8_t(* Control)(uint8_t, uint8_t *, uint16_t)
Definition: usbd_cdc.h:105
USBD_CDC_ReceivePacket
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev)
USBD_CDC_ReceivePacket prepare OUT Endpoint for reception.
Definition: usbd_cdc.c:883
USBD_CDC_HandleTypeDef::RxState
__IO uint32_t RxState
Definition: usbd_cdc.h:122
USBD_CDC_ItfTypeDef
struct _USBD_CDC_Itf USBD_CDC_ItfTypeDef
USBD_CDC_HandleTypeDef::RxBuffer
uint8_t * RxBuffer
Definition: usbd_cdc.h:116
data
uint8_t data[8]
Definition: masstorage.h:49
USBD_CDC_LineCodingTypeDef::format
uint8_t format
Definition: usbd_cdc.h:96
USBD_CDC_HandleTypeDef::CmdLength
uint8_t CmdLength
Definition: usbd_cdc.h:115
USBD_CDC_HandleTypeDef::TxState
__IO uint32_t TxState
Definition: usbd_cdc.h:121
_USBD_CDC_Itf::DeInit
int8_t(* DeInit)(void)
Definition: usbd_cdc.h:104
_USBD_HandleTypeDef
Definition: usbd_def.h:225
USBD_CDC_LineCodingTypeDef::paritytype
uint8_t paritytype
Definition: usbd_cdc.h:97
USBD_CDC
USBD_ClassTypeDef USBD_CDC
Definition: usbd_cdc.c:159
void
void
Definition: png.h:1083
_Device_cb
Definition: usbd_def.h:160
_USBD_CDC_Itf
Definition: usbd_cdc.h:101
usbd_ioreq.h
Header file for the usbd_ioreq.c file.
USBD_CDC_HandleTypeDef
Definition: usbd_cdc.h:111
uint8_t
const uint8_t[]
Definition: 404_html.c:3
USBD_CDC_TransmitPacket
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev)
USBD_CDC_DataOut Data received on non-control Out endpoint.
Definition: usbd_cdc.c:846
CDC_DATA_HS_MAX_PACKET_SIZE
#define CDC_DATA_HS_MAX_PACKET_SIZE
Definition: usbd_cdc.h:57
USBD_CDC_RegisterInterface
uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev, USBD_CDC_ItfTypeDef *fops)
USBD_CDC_RegisterInterface.
Definition: usbd_cdc.c:790
USBD_CDC_HandleTypeDef::TxBuffer
uint8_t * TxBuffer
Definition: usbd_cdc.h:117
USBD_CDC_HandleTypeDef::RxLength
uint32_t RxLength
Definition: usbd_cdc.h:118
USBD_CDC_SetRxBuffer
uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
USBD_CDC_SetRxBuffer.
Definition: usbd_cdc.c:829
USBD_CDC_HandleTypeDef::CmdOpCode
uint8_t CmdOpCode
Definition: usbd_cdc.h:114
length
png_uint_32 length
Definition: png.c:2247
USBD_CDC_HandleTypeDef::TxLength
uint32_t TxLength
Definition: usbd_cdc.h:119
USBD_CDC_LineCodingTypeDef
Definition: usbd_cdc.h:93
USBD_CDC_LineCodingTypeDef::datatype
uint8_t datatype
Definition: usbd_cdc.h:98
_USBD_CDC_Itf::Receive
int8_t(* Receive)(uint8_t *, uint32_t *)
Definition: usbd_cdc.h:106
_USBD_CDC_Itf::Init
int8_t(* Init)(void)
Definition: usbd_cdc.h:103