TM STM32Fxxx HAL Libraries  v1.0.0
Libraries for STM32Fxxx (F0, F4 and F7 series) devices based on HAL drivers from ST from Tilen Majerle
tm_stm32_usb_device_cdc.h
1 
37 #ifndef TM_USBD_CDC_H
38 #define TM_USBD_CDC_H 100
39 
40 /* C++ detection */
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
137 #include "stm32fxxx_hal.h"
138 #include "defines.h"
139 #include "tm_stm32_delay.h"
140 #include "tm_stm32_buffer.h"
141 #include "tm_stm32_usb.h"
142 #include "tm_stm32_usb_device.h"
143 #include "usbd_core.h"
144 #include "usbd_cdc.h"
145 #include "usbd_cdc_if.h"
146 #include "string.h"
147 
154 /* Receive & transmit buffer size for both USB modes */
155 #ifndef USBD_CDC_BUFFER_SIZE
156 #define USBD_CDC_BUFFER_SIZE 256
157 #endif
158 
159 /* Receive buffer size for FS mode */
160 #ifndef USBD_CDC_RECEIVE_BUFFER_SIZE_FS
161 #define USBD_CDC_RECEIVE_BUFFER_SIZE_FS USBD_CDC_BUFFER_SIZE
162 #endif
163 /* Receive buffer size for HS mode */
164 #ifndef USBD_CDC_RECEIVE_BUFFER_SIZE_HS
165 #define USBD_CDC_RECEIVE_BUFFER_SIZE_HS USBD_CDC_BUFFER_SIZE
166 #endif
167 /* Transmit buffer size for FS mode */
168 #ifndef USBD_CDC_TRANSMIT_BUFFER_SIZE_FS
169 #define USBD_CDC_TRANSMIT_BUFFER_SIZE_FS USBD_CDC_BUFFER_SIZE
170 #endif
171 /* Transmit buffer size for HS mode */
172 #ifndef USBD_CDC_TRANSMIT_BUFFER_SIZE_HS
173 #define USBD_CDC_TRANSMIT_BUFFER_SIZE_HS USBD_CDC_BUFFER_SIZE
174 #endif
175 /* Temporary buffer TX size for USB transmissions */
176 #ifndef USBD_CDC_TMP_TRANSMIT_BUFFER_SIZE
177 #define USBD_CDC_TMP_TRANSMIT_BUFFER_SIZE USBD_CDC_BUFFER_SIZE
178 #endif
179 /* Temporary buffer RX size for USB transmissions */
180 #ifndef USBD_CDC_TMP_RECEIVE_BUFFER_SIZE
181 #define USBD_CDC_TMP_RECEIVE_BUFFER_SIZE USBD_CDC_BUFFER_SIZE
182 #endif
183 
197 typedef struct {
198  uint32_t Baudrate;
200  uint8_t Stopbits;
205  uint8_t DataBits;
212  uint8_t Parity;
219  uint8_t Updated;
223 
240 
246 void TM_USBD_CDC_Process(TM_USB_t USB_Mode);
247 
254 uint16_t TM_USBD_CDC_Putc(TM_USB_t USB_Mode, char ch);
255 
262 uint16_t TM_USBD_CDC_Puts(TM_USB_t USB_Mode, const char* str);
263 
271 uint16_t TM_USBD_CDC_PutArray(TM_USB_t USB_Mode, uint8_t* buff, uint16_t count);
272 
279 uint8_t TM_USBD_CDC_Getc(TM_USB_t USB_Mode, char* ch);
280 
289 uint16_t TM_USBD_CDC_Gets(TM_USB_t USB_Mode, char* buff, uint16_t buffsize);
290 
298 uint16_t TM_USBD_CDC_GetArray(TM_USB_t USB_Mode, uint8_t* buff, uint16_t count);
299 
307 
308 /* Private functions */
309 void TM_USBD_CDC_INT_AddToBuffer(USBD_HandleTypeDef* pdev, uint8_t* Values, uint16_t Num);
310 
323 /* C++ detection */
324 #ifdef __cplusplus
325 }
326 #endif
327 
328 #endif
uint16_t TM_USBD_CDC_PutArray(TM_USB_t USB_Mode, uint8_t *buff, uint16_t count)
Puts array of data from USB CDC RX buffer.
TM_USBD_Result_t
USB Device result enumeration.
Definition: tm_stm32_usb_device.h:119
void TM_USBD_CDC_GetSettings(TM_USB_t USB_Mode, TM_USBD_CDC_Settings_t *Settings)
Reads current settings set from user terminal.
uint16_t TM_USBD_CDC_GetArray(TM_USB_t USB_Mode, uint8_t *buff, uint16_t count)
Gets array of data from USB CDC RX buffer.
TM_USBD_Result_t TM_USBD_CDC_Init(TM_USB_t USB_Mode)
Initializes USB DEVICE for CDC class on specific USB mode.
uint16_t TM_USBD_CDC_Putc(TM_USB_t USB_Mode, char ch)
Puts character over USB CDC.
TM_USB_t
USB modes enumeration.
Definition: tm_stm32_usb.h:351
uint8_t Updated
Definition: tm_stm32_usb_device_cdc.h:219
uint16_t TM_USBD_CDC_Gets(TM_USB_t USB_Mode, char *buff, uint16_t buffsize)
Gets string from USB CDC RX buffer.
void TM_USBD_CDC_Process(TM_USB_t USB_Mode)
Sends all remaining data from CDC TX buffer to USB out.
uint8_t Parity
Definition: tm_stm32_usb_device_cdc.h:212
Settings structure for USB CDC.
Definition: tm_stm32_usb_device_cdc.h:197
uint8_t Stopbits
Definition: tm_stm32_usb_device_cdc.h:200
uint32_t Baudrate
Definition: tm_stm32_usb_device_cdc.h:198
uint16_t TM_USBD_CDC_Puts(TM_USB_t USB_Mode, const char *str)
Puts string over USB CDC.
uint8_t TM_USBD_CDC_Getc(TM_USB_t USB_Mode, char *ch)
Gets character from USB CDC RX buffer.
uint8_t DataBits
Definition: tm_stm32_usb_device_cdc.h:205