Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libraries/USBDevice/inc/usbd_cdc_if.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ void CDC_deInit(void);
bool CDC_connected(void);
void CDC_enableDTR(bool enable);

// getters for CDC line codings. Do not expose struct directly
uint32_t CDC_getBaudrate(void);
uint8_t CDC_getStopBits(void);
uint8_t CDC_getParity(void);
uint8_t CDC_getDataBits(void);

#ifdef __cplusplus
}
#endif
Expand Down
12 changes: 8 additions & 4 deletions libraries/USBDevice/src/USBSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,22 +158,26 @@ void USBSerial::flush(void)

uint32_t USBSerial::baud()
{
return 115200;
// return (virtual) CDC line setting coding
return CDC_getBaudrate();
}

uint8_t USBSerial::stopbits()
{
return ONE_STOP_BIT;
// return (virtual) CDC line setting coding
return CDC_getStopBits();
}

uint8_t USBSerial::paritytype()
{
return NO_PARITY;
// return (virtual) CDC line setting coding
return CDC_getParity();
}

uint8_t USBSerial::numbits()
{
return 8;
// return (virtual) CDC line setting coding
return CDC_getDataBits();
}

void USBSerial::dtr(bool enable)
Expand Down
24 changes: 24 additions & 0 deletions libraries/USBDevice/src/cdc/usbd_cdc_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,30 @@ void CDC_enableDTR(bool enable)
CDC_DTR_enabled = enable;
}

// getter for CDC baudrate
uint32_t CDC_getBaudrate()
{
return linecoding.bitrate;
}

// getter for CDC stop bits. Note: CDC definition identical to USBSerial.h
uint8_t CDC_getStopBits(void)
{
return linecoding.format;
}

// getter for CDC parity. Note: CDC definition identical to USBSerial.h
uint8_t CDC_getParity(void)
{
return linecoding.paritytype;
}

// getter for CDC data bits. Note: CDC definition identical to USBSerial.h
uint8_t CDC_getDataBits(void)
{
return linecoding.datatype;
}

#endif /* USBD_USE_CDC */
#endif /* USBCON */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Expand Down