usbd_cdc_if_template.c
Go to the documentation of this file.
1 
28 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
29 #pragma data_alignment = 4
30 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
31 
32 /* Includes ------------------------------------------------------------------*/
33 #include "usbd_cdc_if_template.h"
34 
35 /* Private typedef -----------------------------------------------------------*/
36 /* Private define ------------------------------------------------------------*/
37 /* Private macro -------------------------------------------------------------*/
38 /* Private variables ---------------------------------------------------------*/
39 /* These are external variables imported from CDC core to be used for IN
40  transfer management. */
41 extern uint8_t APP_Rx_Buffer []; /* Write CDC received data in this buffer.
42  These data will be sent over USB IN endpoint
43  in the CDC core functions. */
44 extern uint32_t APP_Rx_ptr_in; /* Increment this pointer or roll it back to
45  start address when writing received data
46  in the buffer APP_Rx_Buffer. */
47 
48 /* Private function prototypes -----------------------------------------------*/
49 static uint16_t TEMPLATE_Init (void);
50 static uint16_t TEMPLATE_DeInit (void);
51 static uint16_t TEMPLATE_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len);
52 static uint16_t TEMPLATE_DataTx (uint8_t* Buf, uint32_t Len);
53 static uint16_t TEMPLATE_DataRx (uint8_t* Buf, uint32_t Len);
54 
56 {
62 };
63 
64 /* Private functions ---------------------------------------------------------*/
65 
72 static uint16_t TEMPLATE_Init(void)
73 {
74  /*
75  Add your initialization code here
76  */
77  return USBD_OK;
78 }
79 
86 static uint16_t TEMPLATE_DeInit(void)
87 {
88  /*
89  Add your deinitialization code here
90  */
91  return USBD_OK;
92 }
93 
94 
103 static uint16_t TEMPLATE_Ctrl (uint32_t Cmd, uint8_t* Buf, uint32_t Len)
104 {
105  switch (Cmd)
106  {
108  /* Add your code here */
109  break;
110 
112  /* Add your code here */
113  break;
114 
115  case SET_COMM_FEATURE:
116  /* Add your code here */
117  break;
118 
119  case GET_COMM_FEATURE:
120  /* Add your code here */
121  break;
122 
123  case CLEAR_COMM_FEATURE:
124  /* Add your code here */
125  break;
126 
127  case SET_LINE_CODING:
128  /* Add your code here */
129  break;
130 
131  case GET_LINE_CODING:
132  /* Add your code here */
133  break;
134 
136  /* Add your code here */
137  break;
138 
139  case SEND_BREAK:
140  /* Add your code here */
141  break;
142 
143  default:
144  break;
145  }
146 
147  return USBD_OK;
148 }
149 
158 static uint16_t TEMPLATE_DataTx (uint8_t* Buf, uint32_t Len)
159 {
160 
161  /* Get the data to be sent */
162  for (i = 0; i < Len; i++)
163  {
164  /* APP_Rx_Buffer[APP_Rx_ptr_in] = XXX_ReceiveData(XXX); */
165  }
166 
167  /* Increment the in pointer */
168  APP_Rx_ptr_in++;
169 
170  /* To avoid buffer overflow */
172  {
173  APP_Rx_ptr_in = 0;
174  }
175 
176  return USBD_OK;
177 }
178 
194 static uint16_t TEMPLATE_DataRx (uint8_t* Buf, uint32_t Len)
195 {
196  uint32_t i;
197 
198  /* Send the received buffer */
199  for (i = 0; i < Len; i++)
200  {
201  /* XXXX_SendData(XXXX, *(Buf + i) ); */
202  }
203 
204  return USBD_OK;
205 }
206 
207 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
static uint16_t TEMPLATE_Ctrl(uint32_t Cmd, uint8_t *Buf, uint32_t Len)
TEMPLATE_Ctrl Manage the CDC class requests.
#define GET_LINE_CODING
Definition: usbd_cdc_core.h:80
static uint16_t TEMPLATE_DataTx(uint8_t *Buf, uint32_t Len)
TEMPLATE_DataTx CDC received data to be send over USB IN endpoint are managed in this function...
#define GET_ENCAPSULATED_RESPONSE
Definition: usbd_cdc_core.h:75
static uint16_t TEMPLATE_Init(void)
TEMPLATE_Init Initializes the CDC media low layer.
static uint16_t TEMPLATE_DataRx(uint8_t *Buf, uint32_t Len)
TEMPLATE_DataRx Data received over USB OUT endpoint are sent over CDC interface through this function...
static uint16_t TEMPLATE_DeInit(void)
TEMPLATE_DeInit DeInitializes the CDC media low layer.
Header for dfu_mal.c file.
#define GET_COMM_FEATURE
Definition: usbd_cdc_core.h:77
#define SEND_ENCAPSULATED_COMMAND
Definition: usbd_cdc_core.h:74
#define APP_RX_DATA_SIZE
Definition: usbd_conf.h:60
#define SEND_BREAK
Definition: usbd_cdc_core.h:82
uint8_t APP_Rx_Buffer[]
#define CLEAR_COMM_FEATURE
Definition: usbd_cdc_core.h:78
CDC_IF_Prop_TypeDef TEMPLATE_fops
#define SET_LINE_CODING
Definition: usbd_cdc_core.h:79
#define SET_CONTROL_LINE_STATE
Definition: usbd_cdc_core.h:81
uint32_t APP_Rx_ptr_in
#define SET_COMM_FEATURE
Definition: usbd_cdc_core.h:76


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:26