This is an automated email from the ASF dual-hosted git repository. janc 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 3657f7e77 hw/bsp/arduino-zero: route default UART to debugger, add UART1 3657f7e77 is described below commit 3657f7e77884b7e0fd1b5eb0c5b5143f78bd081f Author: Wiktor Kwiatkowski <wiktorkwiatkowski...@gmail.com> AuthorDate: Tue Jul 29 09:48:11 2025 +0200 hw/bsp/arduino-zero: route default UART to debugger, add UART1 The default UART used for logging (console_printf) is now routed through the debugger interface instead of external TX/RX pins, making serial output easier to access via USB cable. Additionally, UART1 has been configured and exposed on external pins for user applications. --- hw/bsp/arduino_zero/pkg.yml | 4 +++ hw/bsp/arduino_zero/src/hal_bsp.c | 53 ++++++++++++++++++++++++++------------- hw/bsp/arduino_zero/syscfg.yml | 3 +++ 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/hw/bsp/arduino_zero/pkg.yml b/hw/bsp/arduino_zero/pkg.yml index d518cc239..6a91b1b18 100644 --- a/hw/bsp/arduino_zero/pkg.yml +++ b/hw/bsp/arduino_zero/pkg.yml @@ -29,5 +29,9 @@ pkg.deps.UART_0: - "@apache-mynewt-core/hw/drivers/uart" - "@apache-mynewt-core/hw/drivers/uart/uart_hal" +pkg.deps.UART_1: + - "@apache-mynewt-core/hw/drivers/uart" + - "@apache-mynewt-core/hw/drivers/uart/uart_hal" + pkg.cflags: - -D__SAMD21G18A__ diff --git a/hw/bsp/arduino_zero/src/hal_bsp.c b/hw/bsp/arduino_zero/src/hal_bsp.c index 06b9fe602..30db63dff 100644 --- a/hw/bsp/arduino_zero/src/hal_bsp.c +++ b/hw/bsp/arduino_zero/src/hal_bsp.c @@ -46,12 +46,11 @@ #include <usart.h> #include <os/os_dev.h> -#if MYNEWT_VAL(UART_0) +#if MYNEWT_VAL(UART_0) || MYNEWT_VAL(UART_1) #include <uart/uart.h> #include <uart_hal/uart_hal.h> #include <mcu/hal_uart.h> -static struct uart_dev hal_uart0; #endif #if MYNEWT_VAL(SPI_0) /* configure the SPI port for arduino external spi */ @@ -84,18 +83,31 @@ struct samd21_i2c_config i2c_config = { #endif #if MYNEWT_VAL(UART_0) -static const struct samd21_uart_config uart_cfgs[] = { - [0] = { - .suc_sercom = SERCOM2, - .suc_mux_setting = USART_RX_3_TX_2_XCK_3, - .suc_generator_source = GCLK_GENERATOR_0, - .suc_sample_rate = USART_SAMPLE_RATE_16X_ARITHMETIC, - .suc_sample_adjustment = USART_SAMPLE_ADJUSTMENT_7_8_9, - .suc_pad0 = 0, - .suc_pad1 = 0, - .suc_pad2 = PINMUX_PA10D_SERCOM2_PAD2, - .suc_pad3 = PINMUX_PA11D_SERCOM2_PAD3 - } +static const struct samd21_uart_config uart0_cfg = { + .suc_sercom = SERCOM5, + .suc_mux_setting = USART_RX_3_TX_2_XCK_3, + .suc_generator_source = GCLK_GENERATOR_0, + .suc_sample_rate = USART_SAMPLE_RATE_16X_ARITHMETIC, + .suc_sample_adjustment = USART_SAMPLE_ADJUSTMENT_7_8_9, + .suc_pad0 = PINMUX_UNUSED, + .suc_pad1 = PINMUX_UNUSED, + .suc_pad2 = PINMUX_PB22D_SERCOM5_PAD2, + .suc_pad3 = PINMUX_PB23D_SERCOM5_PAD3, +}; +#endif + +#if MYNEWT_VAL(UART_1) +static const struct samd21_uart_config uart1_cfg = { + .suc_sercom = SERCOM2, + .suc_mux_setting = USART_RX_3_TX_2_XCK_3, + .suc_generator_source = GCLK_GENERATOR_0, + .suc_sample_rate = USART_SAMPLE_RATE_16X_ARITHMETIC, + .suc_sample_adjustment = USART_SAMPLE_ADJUSTMENT_7_8_9, + .suc_pad0 = PINMUX_UNUSED, + .suc_pad1 = PINMUX_UNUSED, + .suc_pad2 = PINMUX_PA10D_SERCOM2_PAD2, + .suc_pad3 = PINMUX_PA11D_SERCOM2_PAD3 + }; #endif @@ -129,7 +141,6 @@ hal_bsp_core_dump(int *area_cnt) return dump_cfg; } - /** * Returns the configured priority for the given interrupt. If no priority * configured, return the priority passed in @@ -157,8 +168,16 @@ hal_bsp_init(void) #endif #if MYNEWT_VAL(UART_0) - rc = os_dev_create((struct os_dev *) &hal_uart0, "uart0", - OS_DEV_INIT_PRIMARY, 0, uart_hal_init, (void *)&uart_cfgs[0]); + static struct uart_dev hal_uart0; + rc = os_dev_create((struct os_dev *)&hal_uart0, "uart0", OS_DEV_INIT_PRIMARY, + 0, uart_hal_init, (void *)&uart0_cfg); + SYSINIT_PANIC_ASSERT(rc == 0); +#endif + +#if MYNEWT_VAL(UART_1) + static struct uart_dev hal_uart1; + rc = os_dev_create((struct os_dev *)&hal_uart1, "uart1", OS_DEV_INIT_PRIMARY, + 0, uart_hal_init, (void *)&uart1_cfg); SYSINIT_PANIC_ASSERT(rc == 0); #endif diff --git a/hw/bsp/arduino_zero/syscfg.yml b/hw/bsp/arduino_zero/syscfg.yml index 9d6296381..75d5ca0c7 100644 --- a/hw/bsp/arduino_zero/syscfg.yml +++ b/hw/bsp/arduino_zero/syscfg.yml @@ -25,6 +25,9 @@ syscfg.defs: UART_0: description: 'Whether to enable UART0' value: 1 + UART_1: + description: 'Whether to enable UART1' + value: 0 TIMER_0: description: 'Arduino zero Timer 0.'