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
commit b65788b8422817d72bdbf06319bcf04a7f621cdf Author: Jerzy Kasenberg <[email protected]> AuthorDate: Mon Dec 14 12:42:42 2020 +0100 hw/mcu/da1469x: Add UART driver to MCU peripherals uart_hal driver was used for devices created in da1469x_periph_create(). Now da1469x_uart driver will be used by default. When UART_HAL syscfg value is set to 1 original uart_hal driver will be used instead. --- hw/mcu/dialog/da1469x/pkg.yml | 5 +++- hw/mcu/dialog/da1469x/src/da1469x_periph.c | 42 +++++++++++++++++++++++------- hw/mcu/dialog/da1469x/syscfg.yml | 4 +++ 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/hw/mcu/dialog/da1469x/pkg.yml b/hw/mcu/dialog/da1469x/pkg.yml index 1338720..ef753b1 100644 --- a/hw/mcu/dialog/da1469x/pkg.yml +++ b/hw/mcu/dialog/da1469x/pkg.yml @@ -39,9 +39,12 @@ pkg.deps.TRNG: pkg.deps.CRYPTO: - "@apache-mynewt-core/hw/drivers/crypto/crypto_da1469x" -pkg.deps.'UART_0 || UART_1 || UART_2': +pkg.deps.'(UART_0 || UART_1 || UART_2) && HAL_UART': - "@apache-mynewt-core/hw/drivers/uart/uart_hal" +pkg.deps.'(UART_0 || UART_1 || UART_2) && !HAL_UART': + - "@apache-mynewt-core/hw/drivers/uart/uart_da1469x" + pkg.deps.'(I2C_0 || I2C_1) && BUS_DRIVER_PRESENT': - "@apache-mynewt-core/hw/bus/drivers/i2c_hal" diff --git a/hw/mcu/dialog/da1469x/src/da1469x_periph.c b/hw/mcu/dialog/da1469x/src/da1469x_periph.c index 0e2945b..c75483f 100644 --- a/hw/mcu/dialog/da1469x/src/da1469x_periph.c +++ b/hw/mcu/dialog/da1469x/src/da1469x_periph.c @@ -27,7 +27,11 @@ #if MYNEWT_VAL(UART_0) || MYNEWT_VAL(UART_1) || MYNEWT_VAL(UART_2) #include "uart/uart.h" +#if MYNEWT_VAL(HAL_UART) #include "uart_hal/uart_hal.h" +#else +#include "uart_da1469x/uart_da1469x.h" +#endif #endif #if MYNEWT_VAL(BUS_DRIVER_PRESENT) #include "bus/bus.h" @@ -89,7 +93,11 @@ static struct crypto_dev os_bsp_crypto; #endif #if MYNEWT_VAL(UART_0) +#if MYNEWT_VAL(UART_HAL) static struct uart_dev os_bsp_uart0; +#else +static struct da1469x_uart_dev os_bsp_uart0; +#endif static const struct da1469x_uart_cfg os_bsp_uart0_cfg = { .pin_tx = MYNEWT_VAL(UART_0_PIN_TX), .pin_rx = MYNEWT_VAL(UART_0_PIN_RX), @@ -99,7 +107,11 @@ static const struct da1469x_uart_cfg os_bsp_uart0_cfg = { }; #endif #if MYNEWT_VAL(UART_1) +#if MYNEWT_VAL(UART_HAL) static struct uart_dev os_bsp_uart1; +#else +static struct da1469x_uart_dev os_bsp_uart1; +#endif static const struct da1469x_uart_cfg os_bsp_uart1_cfg = { .pin_tx = MYNEWT_VAL(UART_1_PIN_TX), .pin_rx = MYNEWT_VAL(UART_1_PIN_RX), @@ -109,7 +121,11 @@ static const struct da1469x_uart_cfg os_bsp_uart1_cfg = { }; #endif #if MYNEWT_VAL(UART_2) +#if MYNEWT_VAL(UART_HAL) static struct uart_dev os_bsp_uart2; +#else +static struct da1469x_uart_dev os_bsp_uart2; +#endif static const struct da1469x_uart_cfg os_bsp_uart2_cfg = { .pin_tx = MYNEWT_VAL(UART_2_PIN_TX), .pin_rx = MYNEWT_VAL(UART_2_PIN_RX), @@ -334,6 +350,20 @@ da1469x_periph_create_adc(void) #endif } +static int +da1469x_uart_create(struct da1469x_uart_dev *dev, const char *name, uint8_t priority, + const struct da1469x_uart_cfg *cfg) +{ +#if MYNEWT_VAL(HAL_UART) + return os_dev_create(&dev->ud_dev, "uart0", + OS_DEV_INIT_PRIMARY, priority, uart_hal_init, + (void *)&os_bsp_uart0_cfg); +#else + (void)priority; + return da1469x_uart_dev_create(dev, name, priority, cfg); +#endif +} + static void da1469x_periph_create_uart(void) { @@ -342,21 +372,15 @@ da1469x_periph_create_uart(void) (void)rc; #if MYNEWT_VAL(UART_0) - rc = os_dev_create(&os_bsp_uart0.ud_dev, "uart0", - OS_DEV_INIT_PRIMARY, 0, uart_hal_init, - (void *)&os_bsp_uart0_cfg); + rc = da1469x_uart_create(&os_bsp_uart0, "uart0", 0, &os_bsp_uart0_cfg); assert(rc == 0); #endif #if MYNEWT_VAL(UART_1) - rc = os_dev_create(&os_bsp_uart1.ud_dev, "uart1", - OS_DEV_INIT_PRIMARY, 1, uart_hal_init, - (void *)&os_bsp_uart1_cfg); + rc = da1469x_uart_create(&os_bsp_uart1, "uart1", 1, &os_bsp_uart1_cfg); assert(rc == 0); #endif #if MYNEWT_VAL(UART_2) - rc = os_dev_create(&os_bsp_uart1.ud_dev, "uart2", - OS_DEV_INIT_PRIMARY, 2, uart_hal_init, - (void *)&os_bsp_uart2_cfg); + rc = da1469x_uart_create(&os_bsp_uart2, "uart2", 2, &os_bsp_uart2_cfg); assert(rc == 0); #endif } diff --git a/hw/mcu/dialog/da1469x/syscfg.yml b/hw/mcu/dialog/da1469x/syscfg.yml index 6bfb1a7..aff0113 100644 --- a/hw/mcu/dialog/da1469x/syscfg.yml +++ b/hw/mcu/dialog/da1469x/syscfg.yml @@ -336,6 +336,10 @@ syscfg.defs: description: 'SS pin for SPI_1_SLAVE' value: '' + HAL_UART: + description: 'Use hal_uart driver instead of da1469x_uart.' + value: 0 + UART_0: description: Enable DA1469x UART 0 (UART peripheral) value: 1
