Code: Select all
// 9600, 8N1
SerialConfig SD1_cfg = {
9600,
0,
USART_CR2_STOP1_BITS,
0
};
The SerialDriver is initialized in this way:
Code: Select all
sdObjectInit(&SD1, NULL, NULL);
sdStart(&SD1, &SD1_cfg);
Opening the cdc usb-serial port and sending bytes
Code: Select all
$ picocom -b 9600 /dev/ttyACM0
works fine.
The problem is when I try to close that picocom connection, and re-open it with a different baudrate. To do that I have implemented these two cases in the custom requests_hook_cb callback of my USBDriver:
Code: Select all
case CDC_GET_LINE_CODING
usbSetupTransfer(usbp, (uint8_t *)&cdc_linecoding, sizeof(cdc_linecoding), NULL);
return true;
case CDC_SET_LINE_CODING:
usbSetupTransfer(usbp, (uint8_t *)&cdc_linecoding, sizeof(cdc_linecoding), NULL);
setLineCoding(&cdc_linecoding);
return true;
When I open the usb-serial port with a different baudrate:
Code: Select all
$ picocom -b 115200 /dev/ttyACM0
The setLineCoding function is called. I was expecting the new baudrate (115200) available in cdc_linecoding->dwDTERate, but is not. I am debugging this using a LED in this way:
Code: Select all
void setLineCoding(cdc_linecoding_t* lcp)
{
SD1_cfg.speed = (uint32_t)lcp->dwDTERate;
// DEBUG
if (SD1_cfg.speed == 115200) {
led_on(LED_A);
}
}
setLineCoding function is called but the SD1_cfg.speed value is not the expected value (115200), because LED_A is not switched on.
I am doing something wrong?