File tree Expand file tree Collapse file tree 3 files changed +38
-4
lines changed
Expand file tree Collapse file tree 3 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,12 @@ void CDC_deInit(void);
5353bool CDC_connected (void );
5454void CDC_enableDTR (bool enable );
5555
56+ // getters for CDC line codings. Do not expose struct directly
57+ uint32_t CDC_getBaudrate (void );
58+ uint8_t CDC_getStopBits (void );
59+ uint8_t CDC_getParity (void );
60+ uint8_t CDC_getDataBits (void );
61+
5662#ifdef __cplusplus
5763}
5864#endif
Original file line number Diff line number Diff line change @@ -158,22 +158,26 @@ void USBSerial::flush(void)
158158
159159uint32_t USBSerial::baud ()
160160{
161- return 115200 ;
161+ // return (virtual) CDC line setting coding
162+ return CDC_getBaudrate ();
162163}
163164
164165uint8_t USBSerial::stopbits ()
165166{
166- return ONE_STOP_BIT;
167+ // return (virtual) CDC line setting coding
168+ return CDC_getStopBits ();
167169}
168170
169171uint8_t USBSerial::paritytype ()
170172{
171- return NO_PARITY;
173+ // return (virtual) CDC line setting coding
174+ return CDC_getParity ();
172175}
173176
174177uint8_t USBSerial::numbits ()
175178{
176- return 8 ;
179+ // return (virtual) CDC line setting coding
180+ return CDC_getDataBits ();
177181}
178182
179183void USBSerial::dtr (bool enable)
Original file line number Diff line number Diff line change @@ -379,6 +379,30 @@ void CDC_enableDTR(bool enable)
379379 CDC_DTR_enabled = enable ;
380380}
381381
382+ // getter for CDC baudrate
383+ uint32_t CDC_getBaudrate ()
384+ {
385+ return linecoding .bitrate ;
386+ }
387+
388+ // getter for CDC stop bits. Note: CDC definition identical to USBSerial.h
389+ uint8_t CDC_getStopBits (void )
390+ {
391+ return linecoding .format ;
392+ }
393+
394+ // getter for CDC parity. Note: CDC definition identical to USBSerial.h
395+ uint8_t CDC_getParity (void )
396+ {
397+ return linecoding .paritytype ;
398+ }
399+
400+ // getter for CDC data bits. Note: CDC definition identical to USBSerial.h
401+ uint8_t CDC_getDataBits (void )
402+ {
403+ return linecoding .datatype ;
404+ }
405+
382406#endif /* USBD_USE_CDC */
383407#endif /* USBCON */
384408/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
You can’t perform that action at this time.
0 commit comments