Prusa MINI Firmware overview
USBD_CDC_IF_Private_FunctionPrototypes

Private functions declaration. More...

Collaboration diagram for USBD_CDC_IF_Private_FunctionPrototypes:

Functions

static int8_t CDC_Init_FS (void)
 Initializes the CDC media low layer over the FS USB IP. More...
 
static int8_t CDC_DeInit_FS (void)
 DeInitializes the CDC media low layer. More...
 
static int8_t CDC_Control_FS (uint8_t cmd, uint8_t *pbuf, uint16_t length)
 Manage the CDC class requests. More...
 
static int8_t CDC_Receive_FS (uint8_t *Buf, uint32_t *Len)
 Data received over USB OUT endpoint are sent over CDC interface through this function. More...
 

Detailed Description

Private functions declaration.

Function Documentation

◆ CDC_Init_FS()

static int8_t CDC_Init_FS ( void  )
static

Initializes the CDC media low layer over the FS USB IP.

Return values
USBD_OKif all operations are OK else USBD_FAIL
186  {
187  /* USER CODE BEGIN 3 */
188  /* Set Application Buffers */
192  return (USBD_OK);
193  /* USER CODE END 3 */
194 }
Here is the call graph for this function:

◆ CDC_DeInit_FS()

static int8_t CDC_DeInit_FS ( void  )
static

DeInitializes the CDC media low layer.

Return values
USBD_OKif all operations are OK else USBD_FAIL
200  {
201  /* USER CODE BEGIN 4 */
203  return (USBD_OK);
204  /* USER CODE END 4 */
205 }

◆ CDC_Control_FS()

static int8_t CDC_Control_FS ( uint8_t  cmd,
uint8_t pbuf,
uint16_t  length 
)
static

Manage the CDC class requests.

Parameters
cmdCommand code
pbufBuffer containing command data (request parameters)
lengthNumber of data to be sent (in bytes)
Return values
Resultof the operation: USBD_OK if all operations are OK else USBD_FAIL
214  {
215  /* USER CODE BEGIN 5 */
216  switch (cmd) {
218 
219  break;
220 
222 
223  break;
224 
226 
227  break;
228 
230 
231  break;
232 
234 
235  break;
236 
237  /*******************************************************************************/
238  /* Line Coding Structure */
239  /*-----------------------------------------------------------------------------*/
240  /* Offset | Field | Size | Value | Description */
241  /* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second*/
242  /* 4 | bCharFormat | 1 | Number | Stop bits */
243  /* 0 - 1 Stop bit */
244  /* 1 - 1.5 Stop bits */
245  /* 2 - 2 Stop bits */
246  /* 5 | bParityType | 1 | Number | Parity */
247  /* 0 - None */
248  /* 1 - Odd */
249  /* 2 - Even */
250  /* 3 - Mark */
251  /* 4 - Space */
252  /* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */
253  /*******************************************************************************/
254  case CDC_SET_LINE_CODING:
255 
256  break;
257 
258  case CDC_GET_LINE_CODING:
259  pbuf[0] = 0x20; // bits/second 115200
260  pbuf[1] = 0xc2;
261  pbuf[2] = 0x01;
262  pbuf[3] = 0x00;
263  pbuf[4] = 0x00; // 1 stop bit
264  pbuf[5] = 0x00; // parity none
265  pbuf[6] = 0x08; // 8 data bits
266  break;
267 
269  usbd_cdc_initialized = 1; //hack, we need enable usbd_cdc on reconnect
270  break;
271 
272  case CDC_SEND_BREAK:
273  break;
274 
275  default:
276  break;
277  }
278 
279  return (USBD_OK);
280  /* USER CODE END 5 */
281 }

◆ CDC_Receive_FS()

static int8_t CDC_Receive_FS ( uint8_t Buf,
uint32_t *  Len 
)
static

Data received over USB OUT endpoint are sent over CDC interface through this function.

Note
This function will block any OUT packet reception on USB endpoint untill exiting this function. If you exit this function before transfer is complete on CDC interface (ie. using DMA controller) it will result in receiving more data while previous ones are still not sent.
Parameters
BufBuffer of data to be received
LenNumber of data received (in bytes)
Return values
Resultof the operation: USBD_OK if all operations are OK else USBD_FAIL
297  {
298  /* USER CODE BEGIN 6 */
299  app_cdc_rx(Buf, *Len);
302  return (USBD_OK);
303  /* USER CODE END 6 */
304 }
Here is the call graph for this function:
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_ReceivePacket
uint8_t USBD_CDC_ReceivePacket(USBD_HandleTypeDef *pdev)
USBD_CDC_ReceivePacket prepare OUT Endpoint for reception.
Definition: usbd_cdc.c:883
CDC_SET_LINE_CODING
#define CDC_SET_LINE_CODING
Definition: usbd_cdc.h:76
CDC_CLEAR_COMM_FEATURE
#define CDC_CLEAR_COMM_FEATURE
Definition: usbd_cdc.h:75
CDC_GET_LINE_CODING
#define CDC_GET_LINE_CODING
Definition: usbd_cdc.h:77
UserRxBufferFS
uint8_t UserRxBufferFS[APP_RX_DATA_SIZE]
Definition: usbd_cdc_if.c:128
CDC_SET_COMM_FEATURE
#define CDC_SET_COMM_FEATURE
Definition: usbd_cdc.h:73
CDC_SEND_ENCAPSULATED_COMMAND
#define CDC_SEND_ENCAPSULATED_COMMAND
Definition: usbd_cdc.h:71
CDC_GET_COMM_FEATURE
#define CDC_GET_COMM_FEATURE
Definition: usbd_cdc.h:74
app_cdc_rx
void app_cdc_rx(uint8_t *buffer, uint32_t length)
Definition: appmain.cpp:153
usbd_cdc_initialized
int usbd_cdc_initialized
Definition: usbd_cdc_if.c:64
CDC_SET_CONTROL_LINE_STATE
#define CDC_SET_CONTROL_LINE_STATE
Definition: usbd_cdc.h:78
UserTxBufferFS
uint8_t UserTxBufferFS[APP_TX_DATA_SIZE]
Definition: usbd_cdc_if.c:131
Len
#define Len
Definition: deflate.h:82
USBD_CDC_SetRxBuffer
uint8_t USBD_CDC_SetRxBuffer(USBD_HandleTypeDef *pdev, uint8_t *pbuff)
USBD_CDC_SetRxBuffer.
Definition: usbd_cdc.c:829
CDC_SEND_BREAK
#define CDC_SEND_BREAK
Definition: usbd_cdc.h:79
hUsbDeviceFS
USBD_HandleTypeDef hUsbDeviceFS
Definition: usb_device.c:73
pbuf
Definition: pbuf.h:142
USBD_OK
Definition: usbd_def.h:195
CDC_GET_ENCAPSULATED_RESPONSE
#define CDC_GET_ENCAPSULATED_RESPONSE
Definition: usbd_cdc.h:72