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 <jukka.laitinen@tii.ae>
This commit is contained in:
Jukka Laitinen
2026-04-23 10:22:33 +03:00
committed by Xiang Xiao
parent 101ff2c2bb
commit 66f3b66eda
6 changed files with 141 additions and 0 deletions
@@ -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
@@ -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 */
+4
View File
@@ -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
@@ -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
*
@@ -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 */
@@ -0,0 +1,100 @@
/****************************************************************************
* boards/arm64/imx9/imx93-evk/src/imx9_dshot.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/timers/dshot.h>
#include <arch/board/board.h>
#include <errno.h>
#include "imx9_flexio_dshot.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: imx9_dshot_setup
*
* Description:
*
* Initialize DShot and register DShot devices
*
* Input Parameters:
* None
*
* Returned Value:
* 0 on success, negated error value on error
*
****************************************************************************/
int imx9_dshot_setup(void)
{
struct dshot_lowerhalf_s *lower_half = NULL;
int ret = 0;
#ifdef CONFIG_IMX9_FLEXIO1_DSHOT
lower_half = imx9_flexio_dshot_init(DSHOT_FLEXIO1);
if (lower_half)
{
ret = dshot_register("/dev/dshot0", lower_half);
}
else
{
ret = -ENODEV;
}
if (ret < 0)
{
return ret;
}
#endif
#ifdef CONFIG_IMX9_FLEXIO2_DSHOT
lower_half = imx9_flexio_dshot_init(DSHOT_FLEXIO2);
if (lower_half)
{
ret = dshot_register("/dev/dshot1", lower_half);
}
else
{
ret = -ENODEV;
}
if (ret < 0)
{
return ret;
}
#endif
return ret;
}