You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2021/02/28 20:45:31 UTC

[mynewt-core] branch master updated: bsp/stm32f4discovery: Add UART_1 support.

This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 8bcb70b  bsp/stm32f4discovery: Add UART_1 support.
8bcb70b is described below

commit 8bcb70b9f1df64c28cee1e4a5dcfea8d316f8d9e
Author: Per <pe...@stuffmatic.com>
AuthorDate: Sun Feb 28 14:13:25 2021 +0100

    bsp/stm32f4discovery: Add UART_1 support.
    
    Adds os_bsp_uart1_cfg using USART2. This makes it possible to use the ST-LINK virtual com port for logging if
    1. Flying wires have been connected according to figure 6 (ST-LINK VCP connection to USART2) in the STM32F4DISCOVERY user manual
    2. UART_1 and CONSOLE_UART_DEV are set to 1 and uart1 respectively
---
 hw/bsp/stm32f4discovery/src/hal_bsp.c | 19 +++++++++++++++++++
 hw/bsp/stm32f4discovery/syscfg.yml    |  2 ++
 2 files changed, 21 insertions(+)

diff --git a/hw/bsp/stm32f4discovery/src/hal_bsp.c b/hw/bsp/stm32f4discovery/src/hal_bsp.c
index 4680dd0..9fc921c 100644
--- a/hw/bsp/stm32f4discovery/src/hal_bsp.c
+++ b/hw/bsp/stm32f4discovery/src/hal_bsp.c
@@ -72,6 +72,25 @@ const struct stm32_uart_cfg os_bsp_uart0_cfg = {
 };
 #endif
 
+#if MYNEWT_VAL(UART_1)
+/*
+   If flying wires are connected as in the discovery kit user manual
+   (Figure 6. ST-LINK VCP connection to USART2), logging via the ST-LINK
+   virtual COM port can be achieved by setting CONSOLE_UART_DEV to uart1.
+ */
+const struct stm32_uart_cfg os_bsp_uart1_cfg = {
+    .suc_uart = USART2,
+    .suc_rcc_reg = &RCC->APB1ENR,
+    .suc_rcc_dev = RCC_APB1ENR_USART2EN,
+    .suc_pin_tx = MYNEWT_VAL(UART_1_PIN_TX),
+    .suc_pin_rx = MYNEWT_VAL(UART_1_PIN_RX),
+    .suc_pin_rts = MYNEWT_VAL(UART_1_PIN_RTS),
+    .suc_pin_cts = MYNEWT_VAL(UART_1_PIN_CTS),
+    .suc_pin_af = GPIO_AF7_USART2,
+    .suc_irqn = USART2_IRQn,
+};
+#endif
+
 #if MYNEWT_VAL(I2C_0)
 const struct stm32_hal_i2c_cfg os_bsp_i2c0_cfg = {
     .hic_i2c = I2C1,
diff --git a/hw/bsp/stm32f4discovery/syscfg.yml b/hw/bsp/stm32f4discovery/syscfg.yml
index 2607fff..1e07cb7 100644
--- a/hw/bsp/stm32f4discovery/syscfg.yml
+++ b/hw/bsp/stm32f4discovery/syscfg.yml
@@ -49,6 +49,8 @@ syscfg.vals:
     STM32_DATA_CACHE_ENABLE: 1
     UART_0_PIN_TX: 'MCU_GPIO_PORTC(6)'
     UART_0_PIN_RX: 'MCU_GPIO_PORTC(7)'
+    UART_1_PIN_TX: 'MCU_GPIO_PORTA(2)'
+    UART_1_PIN_RX: 'MCU_GPIO_PORTA(3)'
     SPI_0_PIN_SS: 'MCU_GPIO_PORTA(4)'
     SPI_0_PIN_SCK: 'MCU_GPIO_PORTA(5)'
     SPI_0_PIN_MISO: 'MCU_GPIO_PORTA(6)'