snickerdoodle Platform Controller
firmware for STM32F0 platform controller

Functions

uint8_t sd_cdc_transmit (uint8_t *buf, uint16_t len)
 USB Communications Class Device Transmit Data send over USB IN endpoint are sent over CDC interface through this function. More...
 
uint8_t sd_cdc_get_state (void)
 
static int8_t sd_cdc_init (void)
 CDC_Init_FS Initializes the CDC media low layer over the FS USB IP. More...
 
static int8_t sd_cdc_deinit (void)
 CDC_DeInit_FS DeInitializes the CDC media low layer. More...
 
static int8_t sd_cdc_control (uint8_t cmd, uint8_t *pbuf, uint16_t length)
 USB Communications Class Device Control Request Manage the CDC class requests. More...
 
static int8_t sd_cdc_receive (uint8_t *buf, uint32_t *len)
 USB Communications Class Device Receive Data received over USB OUT endpoint are sent over CDC interface through this function. More...
 

Detailed Description

Function Documentation

◆ sd_cdc_control()

static int8_t sd_cdc_control ( uint8_t  cmd,
uint8_t *  pbuf,
uint16_t  length 
)
static

#include <Src/sd_usbd_cdc_if.c>

USB Communications Class Device Control Request Manage the CDC class requests.

Parameters
cmdCommand code
pbufBuffer containing command data (request parameters)
lengthNumber of data to be sent (in bytes)
Return values
USBD_OKif all operations are successful else USBD_FAIL or USBD_BUSY
168 {
169  switch (cmd) {
170  case CDC_SEND_ENCAPSULATED_COMMAND:
171 
172  break;
173 
174  case CDC_GET_ENCAPSULATED_RESPONSE:
175 
176  break;
177 
178  case CDC_SET_COMM_FEATURE:
179 
180  break;
181 
182  case CDC_GET_COMM_FEATURE:
183 
184  break;
185 
186  case CDC_CLEAR_COMM_FEATURE:
187 
188  break;
189 
190 /********************************************************************************/
191 /* Line Coding Structure */
192 /*------------------------------------------------------------------------------*/
193 /* Offset | Field | Size | Value | Description */
194 /* 0 | dwDTERate | 4 | Number |Data terminal rate, in bits per second */
195 /* 4 | bCharFormat | 1 | Number | Stop bits */
196 /* 0 - 1 Stop bit */
197 /* 1 - 1.5 Stop bits */
198 /* 2 - 2 Stop bits */
199 /* 5 | bParityType | 1 | Number | Parity */
200 /* 0 - None */
201 /* 1 - Odd */
202 /* 2 - Even */
203 /* 3 - Mark */
204 /* 4 - Space */
205 /* 6 | bDataBits | 1 | Number Data bits (5, 6, 7, 8 or 16). */
206 /********************************************************************************/
207  case CDC_SET_LINE_CODING:
208 
209  break;
210 
211  case CDC_GET_LINE_CODING:
212 
213  break;
214 
215  case CDC_SET_CONTROL_LINE_STATE:
216 
217  break;
218 
219  case CDC_SEND_BREAK:
220 
221  break;
222 
223  default:
224  break;
225  }
226 
227  return (USBD_OK);

◆ sd_cdc_deinit()

static int8_t sd_cdc_deinit ( void  )
static

#include <Src/sd_usbd_cdc_if.c>

CDC_DeInit_FS DeInitializes the CDC media low layer.

Parameters
None
Return values
USBD_OKif all operations are successful else USBD_FAIL or USBD_BUSY
152 {
153  hUsbDevice_0 = NULL;
154  return (USBD_OK);

◆ sd_cdc_init()

static int8_t sd_cdc_init ( void  )
static

#include <Src/sd_usbd_cdc_if.c>

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

Parameters
None
Return values
USBD_OKif all operations are successful else USBD_FAIL or USBD_BUSY
131 {
132  hUsbDevice_0 = &hUsbDeviceFS;
133 
134  /* Set Application Buffers */
135  USBD_CDC_SetTxBuffer(hUsbDevice_0, UserTxBufferFS, 0);
136  USBD_CDC_SetRxBuffer(hUsbDevice_0, UserRxBufferFS);
137 
138  USBD_CDC_ReceivePacket(hUsbDevice_0);
139 
140  return (USBD_OK);

◆ sd_cdc_receive()

static int8_t sd_cdc_receive ( uint8_t *  buf,
uint32_t *  len 
)
static

#include <Src/sd_usbd_cdc_if.c>

USB Communications Class Device Receive 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 until 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
USBD_OKif all operations are successful else USBD_FAIL or USBD_BUSY
247 {
248  uint8_t result;
249 
250  HAL_UART_Transmit((&uart1_dev)->uart, buf, *len, 1000); /* Bridge to UART */
251  result = USBD_CDC_ReceivePacket(hUsbDevice_0);
252 
253  return result;
struct sd_uart_dev uart1_dev
Definition: sd_uart.c:81
uint32_t len
Definition: sd_buffer.h:106

◆ sd_cdc_transmit()

uint8_t sd_cdc_transmit ( uint8_t *  buf,
uint16_t  len 
)

#include <Src/sd_usbd_cdc_if.c>

USB Communications Class Device Transmit Data send over USB IN endpoint are sent over CDC interface through this function.

Parameters
bufBuffer of data to be send
lenNumber of data to be send (in bytes)
Return values
USBD_OKif all operations are successful else USBD_FAIL or USBD_BUSY
267 {
268  uint8_t result = USBD_OK;
269 
270  if (hUsbDevice_0 == NULL)
271  return USBD_FAIL;
272 
273  USBD_CDC_SetTxBuffer(hUsbDevice_0, buf, len);
274  result = USBD_CDC_TransmitPacket(hUsbDevice_0);
275 
276  return result;
uint32_t len
Definition: sd_buffer.h:106