From ee9279c1a80288e2c10c8273af160ef1c9482db5 Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Wed, 15 Feb 2012 18:16:04 +0000 Subject: [PATCH] stm32l: set pin mux for USART1 When we are not running the ROM monitor first, we must set the pins used for USART1 (PA9/PA10) as alternate function. Signed-off-by: Vincent Palatin BUG=None TEST=Run firmware on the discovery board not from the monitor and see the traces. Change-Id: I32be3d5a88a3e71828d081d74503722331a649b8 --- board/daisy/board.c | 6 ++++++ board/discovery/board.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/board/daisy/board.c b/board/daisy/board.c index 40b4d6da86..7dac0b5d56 100644 --- a/board/daisy/board.c +++ b/board/daisy/board.c @@ -35,6 +35,12 @@ void configure_board(void) * TODO: more fine-grained enabling for power saving */ STM32L_RCC_AHBENR |= 0x3f; + + /* Select Alternate function for USART1 on pins PA9/PA10 */ + STM32L_GPIO_AFRH(A) = (STM32L_GPIO_AFRH(A) & ~0x00000FF0) | + (0x7 << 8) | (0x7 << 4); + STM32L_GPIO_MODER(A) = (STM32L_GPIO_MODER(A) & ~0x003C0000) | + 0x00280000; } /** diff --git a/board/discovery/board.c b/board/discovery/board.c index e6a360dbbd..e516dc4278 100644 --- a/board/discovery/board.c +++ b/board/discovery/board.c @@ -27,11 +27,19 @@ void configure_board(void) */ STM32L_RCC_AHBENR |= 0x3f; +#if CONFIG_CONSOLE_UART == 1 + /* Select Alternate function for USART1 on pins PA9/PA10 */ + STM32L_GPIO_AFRH(A) = (STM32L_GPIO_AFRH(A) & ~0x00000FF0) | + (0x7 << 8) | (0x7 << 4); + STM32L_GPIO_MODER(A) = (STM32L_GPIO_MODER(A) & ~0x003C0000) | + 0x00280000; +#elif CONFIG_CONSOLE_UART == 3 /* Select Alternate function for USART3 on pins PB10/PB11 */ STM32L_GPIO_AFRH(B) = (STM32L_GPIO_AFRH(B) & ~0x0000FF00) | (0x7 << 12) | (0x7 << 8); STM32L_GPIO_MODER(B) = (STM32L_GPIO_MODER(B) & ~0x00F00000) | 0x00A00000; +#endif } /**