mirror of
https://github.com/mik3y/usb-serial-for-android
synced 2025-06-07 16:06:10 +00:00
Correct USART init for stm32 autobauding
Hello, I had some headache trying to figure out the issue when flashing some stm32 mcu over uart [1] With the above changes i can now flash stm32 devices correctly. regards, 1 : http://www.st.com/web/en/resource/technical/document/application_note/CD00264342.pdf
This commit is contained in:
parent
09c84a4a3c
commit
8f439384a7
@ -249,47 +249,43 @@ public class Cp21xxSerialDriver implements UsbSerialDriver {
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
setBaudRate(baudRate);
|
setBaudRate(baudRate);
|
||||||
|
|
||||||
int configDataBits = 0;
|
int configDataBits = 0;
|
||||||
switch (dataBits) {
|
switch (dataBits) {
|
||||||
case DATABITS_5:
|
case DATABITS_5:
|
||||||
configDataBits |= 0x0500;
|
configDataBits |= 0x0500;
|
||||||
break;
|
break;
|
||||||
case DATABITS_6:
|
case DATABITS_6:
|
||||||
configDataBits |= 0x0600;
|
configDataBits |= 0x0600;
|
||||||
break;
|
break;
|
||||||
case DATABITS_7:
|
case DATABITS_7:
|
||||||
configDataBits |= 0x0700;
|
configDataBits |= 0x0700;
|
||||||
break;
|
break;
|
||||||
case DATABITS_8:
|
case DATABITS_8:
|
||||||
configDataBits |= 0x0800;
|
configDataBits |= 0x0800;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
configDataBits |= 0x0800;
|
configDataBits |= 0x0800;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
setConfigSingle(SILABSER_SET_LINE_CTL_REQUEST_CODE, configDataBits);
|
|
||||||
|
switch (parity) {
|
||||||
int configParityBits = 0; // PARITY_NONE
|
case PARITY_ODD:
|
||||||
switch (parity) {
|
configDataBits |= 0x0010;
|
||||||
case PARITY_ODD:
|
break;
|
||||||
configParityBits |= 0x0010;
|
case PARITY_EVEN:
|
||||||
break;
|
configDataBits |= 0x0020;
|
||||||
case PARITY_EVEN:
|
break;
|
||||||
configParityBits |= 0x0020;
|
}
|
||||||
break;
|
|
||||||
}
|
switch (stopBits) {
|
||||||
setConfigSingle(SILABSER_SET_LINE_CTL_REQUEST_CODE, configParityBits);
|
case STOPBITS_1:
|
||||||
|
configDataBits |= 0;
|
||||||
int configStopBits = 0;
|
break;
|
||||||
switch (stopBits) {
|
case STOPBITS_2:
|
||||||
case STOPBITS_1:
|
configDataBits |= 2;
|
||||||
configStopBits |= 0;
|
break;
|
||||||
break;
|
}
|
||||||
case STOPBITS_2:
|
setConfigSingle(SILABSER_SET_LINE_CTL_REQUEST_CODE, configDataBits);
|
||||||
configStopBits |= 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
setConfigSingle(SILABSER_SET_LINE_CTL_REQUEST_CODE, configStopBits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user