1
0
Fork 0

Assigns special baudrate '0' to skip uart speed setup

The MT7628 uartlite is janky, allow umcumgr to skip setup so that finer
grained adjustments can be done manually in the peripheral registers. umcumgr
then just uses these values.
This commit is contained in:
Shawn Nock 2020-01-16 11:03:01 -05:00
parent f46750c4df
commit 051b086c0f
1 changed files with 8 additions and 3 deletions

View File

@ -23,6 +23,8 @@ static speed_t speed_from_string(char const *s) {
return DEFAULT_SPEED;
}
switch (speed) {
case 0:
return B0;
case 9600:
return B9600;
case 115200:
@ -55,9 +57,12 @@ int serial_init(char const *serial_port, char const *speed) {
fprintf(stderr, "Failed to get termios attrs.\n");
}
if (cfsetspeed(&t_options, speed_from_string(speed)) < 0) {
fprintf(stderr, "Failed to set port speed.\n");
return 2;
speed_t s = speed_from_string(speed);
if (s != B0) {
if (cfsetspeed(&t_options, speed_from_string(speed)) < 0) {
fprintf(stderr, "Failed to set port speed.\n");
return 2;
}
}
t_options.c_lflag &= ~(ICANON | ECHO | ECHOE);