STSW-STLKT01: Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc/usbd_cdc.h Source File

STSW-STLKT01

usbd_cdc.h
Go to the documentation of this file.
1 
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 
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 
93 typedef struct
94 {
95  uint32_t bitrate;
96  uint8_t format;
97  uint8_t paritytype;
98  uint8_t datatype;
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 */
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 }
125 
126 
127 
140 extern USBD_ClassTypeDef USBD_CDC;
141 #define USBD_CDC_CLASS &USBD_CDC
142 
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);
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 #endif /* __USB_CDC_H */
171 
179 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff, uint16_t length)
USBD_CDC_SetTxBuffer.
Definition: usbd_cdc.c:810
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev)
USBD_CDC_ReceivePacket prepare OUT Endpoint for reception.
Definition: usbd_cdc.c:883
uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev)
USBD_CDC_DataOut Data received on non-control Out endpoint.
Definition: usbd_cdc.c:846
uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
USBD_CDC_SetRxBuffer.
Definition: usbd_cdc.c:829
uint8_t USBD_CDC_RegisterInterface(USBD_HandleTypeDef *pdev, USBD_CDC_ItfTypeDef *fops)
USBD_CDC_RegisterInterface.
Definition: usbd_cdc.c:790
Generated by   doxygen 1.8.13