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:
parent
f46750c4df
commit
051b086c0f
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue