This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 66f3b66edafba1e0385ceb5dcfe48cac671cb5f0 Author: Jukka Laitinen <[email protected]> AuthorDate: Thu Apr 23 10:22:33 2026 +0300 boards/imx93-evk: Add initialization of DShot driver This adds initialization of the flexio_dshot driver to the imx93-evk:nsh target. Signed-off-by: Jukka Laitinen <[email protected]> --- boards/arm64/imx9/imx93-evk/configs/nsh/defconfig | 1 + boards/arm64/imx9/imx93-evk/include/board.h | 14 +++ boards/arm64/imx9/imx93-evk/src/Makefile | 4 + boards/arm64/imx9/imx93-evk/src/imx93-evk.h | 12 +++ boards/arm64/imx9/imx93-evk/src/imx9_bringup.c | 10 ++ .../imx93-evk/src/{imx9_bringup.c => imx9_dshot.c} | 102 +++++++-------------- 6 files changed, 73 insertions(+), 70 deletions(-) diff --git a/boards/arm64/imx9/imx93-evk/configs/nsh/defconfig b/boards/arm64/imx9/imx93-evk/configs/nsh/defconfig index 09f153f038c..c663f70c537 100644 --- a/boards/arm64/imx9/imx93-evk/configs/nsh/defconfig +++ b/boards/arm64/imx9/imx93-evk/configs/nsh/defconfig @@ -49,6 +49,7 @@ CONFIG_IMX9_ENET1_RGMII=y CONFIG_IMX9_ENET1_RGMII_ID=y CONFIG_IMX9_ENET=y CONFIG_IMX9_ENET_USE_OTP_MAC=y +CONFIG_IMX9_FLEXIO1_DSHOT=y CONFIG_IMX9_FLEXIO1_PWM=y CONFIG_IMX9_GPIO_IRQ=y CONFIG_IMX9_LPI2C1=y diff --git a/boards/arm64/imx9/imx93-evk/include/board.h b/boards/arm64/imx9/imx93-evk/include/board.h index bcb6fbb6261..d0fecda3b23 100644 --- a/boards/arm64/imx9/imx93-evk/include/board.h +++ b/boards/arm64/imx9/imx93-evk/include/board.h @@ -60,6 +60,20 @@ #define FLEXIO1_PWM2_MUX IOMUX_CFG(IOMUXC_PAD_GPIO_IO06_FLEXIO1_FLEXIO06, IOMUXC_PAD_FSEL_SFAST | IOMUXC_PAD_DSE_X6, 0) #define FLEXIO1_PWM3_MUX IOMUX_CFG(IOMUXC_PAD_GPIO_IO07_FLEXIO1_FLEXIO07, IOMUXC_PAD_FSEL_SFAST | IOMUXC_PAD_DSE_X6, 0) +/* FLEXIO to DSHOT pin muxings */ + +/* EVK signals + * GPIO_IO04 -> FLEXIO1_04 + * GPIO_IO05 -> FLEXIO1_05 + * GPIO_IO06 -> FLEXIO1_06 + * GPIO_IO07 -> FLEXIO1_07 + */ + +#define FLEXIO1_DSHOT0_MUX IOMUX_CFG(IOMUXC_PAD_GPIO_IO04_FLEXIO1_FLEXIO04, IOMUXC_PAD_FSEL_SFAST | IOMUXC_PAD_DSE_X4 | IOMUXC_PAD_PU_ON | IOMUXC_PAD_HYS_ST_ON, IOMUXC_MUX_SION_ON) +#define FLEXIO1_DSHOT1_MUX IOMUX_CFG(IOMUXC_PAD_GPIO_IO05_FLEXIO1_FLEXIO05, IOMUXC_PAD_FSEL_SFAST | IOMUXC_PAD_DSE_X4 | IOMUXC_PAD_PU_ON | IOMUXC_PAD_HYS_ST_ON, IOMUXC_MUX_SION_ON) +#define FLEXIO1_DSHOT2_MUX IOMUX_CFG(IOMUXC_PAD_GPIO_IO06_FLEXIO1_FLEXIO06, IOMUXC_PAD_FSEL_SFAST | IOMUXC_PAD_DSE_X4 | IOMUXC_PAD_PU_ON | IOMUXC_PAD_HYS_ST_ON, IOMUXC_MUX_SION_ON) +#define FLEXIO1_DSHOT3_MUX IOMUX_CFG(IOMUXC_PAD_GPIO_IO07_FLEXIO1_FLEXIO07, IOMUXC_PAD_FSEL_SFAST | IOMUXC_PAD_DSE_X4 | IOMUXC_PAD_PU_ON | IOMUXC_PAD_HYS_ST_ON, IOMUXC_MUX_SION_ON) + /* LPI2Cs */ /* TPM3 ch3 to PWM pin GPIO_IO24 muxing */ diff --git a/boards/arm64/imx9/imx93-evk/src/Makefile b/boards/arm64/imx9/imx93-evk/src/Makefile index defc57b93bb..d938b626dc0 100644 --- a/boards/arm64/imx9/imx93-evk/src/Makefile +++ b/boards/arm64/imx9/imx93-evk/src/Makefile @@ -32,6 +32,10 @@ ifeq ($(CONFIG_PWM),y) CSRCS += imx9_pwm.c endif +ifeq ($(CONFIG_DSHOT),y) +CSRCS += imx9_dshot.c +endif + ifeq ($(CONFIG_IMX9_LPI2C),y) CSRCS += imx9_i2c.c endif diff --git a/boards/arm64/imx9/imx93-evk/src/imx93-evk.h b/boards/arm64/imx9/imx93-evk/src/imx93-evk.h index d0584c113d5..072dcc50241 100644 --- a/boards/arm64/imx9/imx93-evk/src/imx93-evk.h +++ b/boards/arm64/imx9/imx93-evk/src/imx93-evk.h @@ -87,6 +87,18 @@ int imx9_bringup(void); int imx9_pwm_setup(void); #endif +/**************************************************************************** + * Name: imx9_dshot_setup + * + * Description: + * Initialize DShot outputs + * + ****************************************************************************/ + +#if defined(CONFIG_DSHOT) +int imx9_dshot_setup(void); +#endif + /**************************************************************************** * Name: imx9_i2c_setup * diff --git a/boards/arm64/imx9/imx93-evk/src/imx9_bringup.c b/boards/arm64/imx9/imx93-evk/src/imx9_bringup.c index 8a4e69b0dd9..84a73c81cab 100644 --- a/boards/arm64/imx9/imx93-evk/src/imx9_bringup.c +++ b/boards/arm64/imx9/imx93-evk/src/imx9_bringup.c @@ -104,6 +104,16 @@ int imx9_bringup(void) } #endif +#ifdef CONFIG_DSHOT + /* Configure DSHOT outputs */ + + ret = imx9_dshot_setup(); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed initialize DShot outputs: %d\n", ret); + } +#endif + #if defined(CONFIG_I2C_DRIVER) /* Configure I2C peripheral interfaces */ diff --git a/boards/arm64/imx9/imx93-evk/src/imx9_bringup.c b/boards/arm64/imx9/imx93-evk/src/imx9_dshot.c similarity index 50% copy from boards/arm64/imx9/imx93-evk/src/imx9_bringup.c copy to boards/arm64/imx9/imx93-evk/src/imx9_dshot.c index 8a4e69b0dd9..062c6ac19eb 100644 --- a/boards/arm64/imx9/imx93-evk/src/imx9_bringup.c +++ b/boards/arm64/imx9/imx93-evk/src/imx9_dshot.c @@ -1,5 +1,5 @@ /**************************************************************************** - * boards/arm64/imx9/imx93-evk/src/imx9_bringup.c + * boards/arm64/imx9/imx93-evk/src/imx9_dshot.c * * SPDX-License-Identifier: Apache-2.0 * @@ -25,114 +25,76 @@ ****************************************************************************/ #include <nuttx/config.h> +#include <nuttx/timers/dshot.h> +#include <arch/board/board.h> -#include <sys/types.h> -#include <syslog.h> +#include <errno.h> -#include <nuttx/fs/fs.h> - -#include "imx9_dma_alloc.h" - -#include "imx93-evk.h" - -#ifdef CONFIG_IMX9_BIN_ROMFS -#include <nuttx/drivers/ramdisk.h> -#include <arch/board/bin_romfsimg.h> +#include "imx9_flexio_dshot.h" /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -#define SECTORSIZE 512 -#define NSECTORS(b) (((b) + SECTORSIZE - 1) / SECTORSIZE) -#endif /* CONFIG_IMX9_BIN_ROMFS */ - /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: imx_bringup + * Name: imx9_dshot_setup * * Description: - * Bring up board features + * + * Initialize DShot and register DShot devices + * + * Input Parameters: + * None + * + * Returned Value: + * 0 on success, negated error value on error * ****************************************************************************/ -int imx9_bringup(void) +int imx9_dshot_setup(void) { - int ret; - -#ifdef CONFIG_FS_PROCFS - /* Mount the procfs file system */ - - ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); - if (ret < 0) - { - syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret); - } -#endif - -#ifdef CONFIG_IMX9_BIN_ROMFS - /* Create a ROM disk for the /bin filesystem */ + struct dshot_lowerhalf_s *lower_half = NULL; + int ret = 0; - ret = romdisk_register(0, romfs_img, NSECTORS(romfs_img_len), SECTORSIZE); +#ifdef CONFIG_IMX9_FLEXIO1_DSHOT + lower_half = imx9_flexio_dshot_init(DSHOT_FLEXIO1); - if (ret < 0) + if (lower_half) { - syslog(LOG_ERR, "Failed to register ROMFS at /dev/ram0: %d\n", ret); + ret = dshot_register("/dev/dshot0", lower_half); } -#endif - -#ifdef CONFIG_IMX9_DMA_ALLOC - /* Initialize the DMA memory allocator */ - - ret = imx9_dma_alloc_init(); - if (ret < 0) + else { - syslog(LOG_ERR, "ERROR: Failed initialize DMA allocator: %d\n", ret); + ret = -ENODEV; } -#endif - -#ifdef CONFIG_PWM - /* Configure PWM outputs */ - ret = imx9_pwm_setup(); if (ret < 0) { - syslog(LOG_ERR, "ERROR: Failed initialize PWM outputs: %d\n", ret); + return ret; } #endif -#if defined(CONFIG_I2C_DRIVER) - /* Configure I2C peripheral interfaces */ +#ifdef CONFIG_IMX9_FLEXIO2_DSHOT + lower_half = imx9_flexio_dshot_init(DSHOT_FLEXIO2); - ret = imx9_i2c_initialize(); - if (ret < 0) + if (lower_half) { - syslog(LOG_ERR, "Failed to initialize I2C driver: %d\n", ret); + ret = dshot_register("/dev/dshot1", lower_half); } -#endif - -#if defined(CONFIG_SPI_DRIVER) - /* Configure SPI peripheral interfaces */ - - ret = imx9_spi_initialize(); - if (ret < 0) + else { - syslog(LOG_ERR, "Failed to initialize SPI driver: %d\n", ret); + ret = -ENODEV; } -#endif - -#ifdef CONFIG_MMCSD - ret = imx9_usdhc_init(); if (ret < 0) { - syslog(LOG_ERR, "Failed to init MMCSD driver: %d\n", ret); + return ret; } #endif - UNUSED(ret); - return OK; + return ret; }
