From 79010723b11379bb560b21dfed0f3fce54afb2e4 Mon Sep 17 00:00:00 2001 From: Nico Tonnhofer Date: Sat, 7 Nov 2015 00:20:47 +0100 Subject: [PATCH] STM32F411: simplify serial and get rid of mbed-pinmap_common.c. We have only one UART, we use only one UART, so it's pointless to do pin mapping calculations at runtime. SIZES ARM... stm32f411 FLASH : 4832 bytes 1% RAM : 404 bytes 1% EEPROM : 0 bytes 0% --- mbed-serial_api_stm32.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/mbed-serial_api_stm32.c b/mbed-serial_api_stm32.c index 8dbbdec..c21e848 100644 --- a/mbed-serial_api_stm32.c +++ b/mbed-serial_api_stm32.c @@ -88,12 +88,9 @@ static void mbed_init_uart(serial_t *obj) void mbed_serial_init(serial_t *obj, PinName tx, PinName rx) { - // Determine the UART to use (UART_1, UART_2, ...) - UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX); - UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX); // Get the peripheral name (UART_1, UART_2, ...) from the pin and assign it to the object - obj->uart = (UARTName)pinmap_merge(uart_tx, uart_rx); + obj->uart = UART_2; // Enable USART clock switch (obj->uart) { @@ -144,14 +141,10 @@ void mbed_serial_init(serial_t *obj, PinName tx, PinName rx) } // Configure the UART pins - pinmap_pinout(tx, PinMap_UART_TX); - pinmap_pinout(rx, PinMap_UART_RX); - if (tx != NC) { - pin_mode(tx, PullUp); - } - if (rx != NC) { - pin_mode(rx, PullUp); - } + pin_function(tx, 0x393); + pin_mode(tx, PullUp); + pin_function(rx, 0x393); + pin_mode(rx, PullUp); // Configure UART obj->baudrate = 9600; @@ -477,11 +470,6 @@ void mbed_serial_clear(serial_t *obj) __HAL_UART_CLEAR_FLAG(&UartHandle, UART_FLAG_RXNE); } -void mbed_serial_pinout_tx(PinName tx) -{ - pinmap_pinout(tx, PinMap_UART_TX); -} - void mbed_serial_break_set(serial_t *obj) { UartHandle.Instance = (USART_TypeDef *)(obj->uart);