STSW-STLKT01: Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc_if_template.c Source File

STSW-STLKT01

usbd_cdc_if_template.c
Go to the documentation of this file.
1 
28 /* Includes ------------------------------------------------------------------*/
29 #include "usbd_cdc_if_template.h"
30 
70 static int8_t TEMPLATE_Init (void);
71 static int8_t TEMPLATE_DeInit (void);
72 static int8_t TEMPLATE_Control (uint8_t cmd, uint8_t* pbuf, uint16_t length);
73 static int8_t TEMPLATE_Receive (uint8_t* pbuf, uint32_t *Len);
74 
75 USBD_CDC_ItfTypeDef USBD_CDC_Template_fops =
76 {
81 };
82 
83 USBD_CDC_LineCodingTypeDef linecoding =
84  {
85  115200, /* baud rate*/
86  0x00, /* stop bits-1*/
87  0x00, /* parity - none*/
88  0x08 /* nb. of bits 8*/
89  };
90 
91 /* Private functions ---------------------------------------------------------*/
92 
99 static int8_t TEMPLATE_Init(void)
100 {
101  /*
102  Add your initialization code here
103  */
104  return (0);
105 }
106 
113 static int8_t TEMPLATE_DeInit(void)
114 {
115  /*
116  Add your deinitialization code here
117  */
118  return (0);
119 }
120 
121 
130 static int8_t TEMPLATE_Control (uint8_t cmd, uint8_t* pbuf, uint16_t length)
131 {
132  switch (cmd)
133  {
134  case CDC_SEND_ENCAPSULATED_COMMAND:
135  /* Add your code here */
136  break;
137 
138  case CDC_GET_ENCAPSULATED_RESPONSE:
139  /* Add your code here */
140  break;
141 
142  case CDC_SET_COMM_FEATURE:
143  /* Add your code here */
144  break;
145 
146  case CDC_GET_COMM_FEATURE:
147  /* Add your code here */
148  break;
149 
150  case CDC_CLEAR_COMM_FEATURE:
151  /* Add your code here */
152  break;
153 
154  case CDC_SET_LINE_CODING:
155  linecoding.bitrate = (uint32_t)(pbuf[0] | (pbuf[1] << 8) |\
156  (pbuf[2] << 16) | (pbuf[3] << 24));
157  linecoding.format = pbuf[4];
158  linecoding.paritytype = pbuf[5];
159  linecoding.datatype = pbuf[6];
160 
161  /* Add your code here */
162  break;
163 
164  case CDC_GET_LINE_CODING:
165  pbuf[0] = (uint8_t)(linecoding.bitrate);
166  pbuf[1] = (uint8_t)(linecoding.bitrate >> 8);
167  pbuf[2] = (uint8_t)(linecoding.bitrate >> 16);
168  pbuf[3] = (uint8_t)(linecoding.bitrate >> 24);
169  pbuf[4] = linecoding.format;
170  pbuf[5] = linecoding.paritytype;
171  pbuf[6] = linecoding.datatype;
172 
173  /* Add your code here */
174  break;
175 
176  case CDC_SET_CONTROL_LINE_STATE:
177  /* Add your code here */
178  break;
179 
180  case CDC_SEND_BREAK:
181  /* Add your code here */
182  break;
183 
184  default:
185  break;
186  }
187 
188  return (0);
189 }
190 
207 static int8_t TEMPLATE_Receive (uint8_t* Buf, uint32_t *Len)
208 {
209 
210  return (0);
211 }
212 
225 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
226 
static int8_t TEMPLATE_Control(uint8_t cmd, uint8_t *pbuf, uint16_t length)
TEMPLATE_Control Manage the CDC class requests.
Header for usbd_cdc_if_template.c file.
static int8_t TEMPLATE_DeInit(void)
TEMPLATE_DeInit DeInitializes the CDC media low layer.
static int8_t TEMPLATE_Init(void)
TEMPLATE_Init Initializes the CDC media low layer.
static int8_t TEMPLATE_Receive(uint8_t *pbuf, uint32_t *Len)
TEMPLATE_Receive Data received over USB OUT endpoint are sent over CDC interface through this functio...
Generated by   doxygen 1.8.13