mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/serial_api.c
- Revision:
- 242:7074e42da0b2
- Parent:
- 227:7bd0639b8911
diff -r ffe41b0c8126 -r 7074e42da0b2 targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/serial_api.c --- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/serial_api.c Thu Jun 26 10:30:09 2014 +0100 +++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/serial_api.c Fri Jun 27 07:30:09 2014 +0100 @@ -73,7 +73,14 @@ UartHandle.Init.StopBits = obj->stopbits; UartHandle.Init.Parity = obj->parity; UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE; - UartHandle.Init.Mode = UART_MODE_TX_RX; + + if (obj->pin_rx == NC) { + UartHandle.Init.Mode = UART_MODE_TX; + } else if (obj->pin_tx == NC) { + UartHandle.Init.Mode = UART_MODE_RX; + } else { + UartHandle.Init.Mode = UART_MODE_TX_RX; + } HAL_UART_Init(&UartHandle); } @@ -157,10 +164,10 @@ } void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) { - if (data_bits == 8) { + if (data_bits == 9) { + obj->databits = UART_WORDLENGTH_9B; + } else { obj->databits = UART_WORDLENGTH_8B; - } else { - obj->databits = UART_WORDLENGTH_9B; } switch (parity) {