[Nuvoton] Check configuration option for default UART baudrate setting

pull/8900/head
ccli8 2018-11-28 16:59:15 +08:00
parent ae98b94a10
commit a937a62bff
5 changed files with 65 additions and 10 deletions

View File

@ -221,8 +221,19 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
pinmap_pinout(tx, PinMap_UART_TX);
pinmap_pinout(rx, PinMap_UART_RX);
// Configure the UART module and set its baudrate
serial_baud(obj, 9600);
// Configure baudrate
int baudrate = 9600;
if (obj->serial.uart == STDIO_UART) {
#if MBED_CONF_PLATFORM_STDIO_BAUD_RATE
baudrate = MBED_CONF_PLATFORM_STDIO_BAUD_RATE;
#endif
} else {
#if MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE
baudrate = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE;
#endif
}
serial_baud(obj, baudrate);
// Configure data bits, parity, and stop bits
serial_format(obj, 8, ParityNone, 1);
}

View File

@ -181,8 +181,19 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
pinmap_pinout(tx, PinMap_UART_TX);
pinmap_pinout(rx, PinMap_UART_RX);
// Configure the UART module and set its baudrate
serial_baud(obj, 9600);
// Configure baudrate
int baudrate = 9600;
if (obj->serial.uart == STDIO_UART) {
#if MBED_CONF_PLATFORM_STDIO_BAUD_RATE
baudrate = MBED_CONF_PLATFORM_STDIO_BAUD_RATE;
#endif
} else {
#if MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE
baudrate = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE;
#endif
}
serial_baud(obj, baudrate);
// Configure data bits, parity, and stop bits
serial_format(obj, 8, ParityNone, 1);
}

View File

@ -211,8 +211,19 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
pinmap_pinout(tx, PinMap_UART_TX);
pinmap_pinout(rx, PinMap_UART_RX);
// Configure the UART module and set its baudrate
serial_baud(obj, 9600);
// Configure baudrate
int baudrate = 9600;
if (obj->serial.uart == STDIO_UART) {
#if MBED_CONF_PLATFORM_STDIO_BAUD_RATE
baudrate = MBED_CONF_PLATFORM_STDIO_BAUD_RATE;
#endif
} else {
#if MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE
baudrate = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE;
#endif
}
serial_baud(obj, baudrate);
// Configure data bits, parity, and stop bits
serial_format(obj, 8, ParityNone, 1);
}

View File

@ -146,8 +146,19 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
pinmap_pinout(tx, PinMap_UART_TX);
pinmap_pinout(rx, PinMap_UART_RX);
// Configure the UART module and set its baudrate
serial_baud(obj, 9600);
// Configure baudrate
int baudrate = 9600;
if (obj->serial.uart == STDIO_UART) {
#if MBED_CONF_PLATFORM_STDIO_BAUD_RATE
baudrate = MBED_CONF_PLATFORM_STDIO_BAUD_RATE;
#endif
} else {
#if MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE
baudrate = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE;
#endif
}
serial_baud(obj, baudrate);
// Configure data bits, parity, and stop bits
serial_format(obj, 8, ParityNone, 1);
}

View File

@ -211,8 +211,19 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
pinmap_pinout(tx, PinMap_UART_TX);
pinmap_pinout(rx, PinMap_UART_RX);
// Configure the UART module and set its baudrate
serial_baud(obj, 9600);
// Configure baudrate
int baudrate = 9600;
if (obj->serial.uart == STDIO_UART) {
#if MBED_CONF_PLATFORM_STDIO_BAUD_RATE
baudrate = MBED_CONF_PLATFORM_STDIO_BAUD_RATE;
#endif
} else {
#if MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE
baudrate = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE;
#endif
}
serial_baud(obj, baudrate);
// Configure data bits, parity, and stop bits
serial_format(obj, 8, ParityNone, 1);
}