Skip to content

Commit

Permalink
tropic: enable dshot
Browse files Browse the repository at this point in the history
  • Loading branch information
PetervdPerk-NXP committed Jul 1, 2024
1 parent d6935ec commit 81366eb
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
5 changes: 3 additions & 2 deletions boards/nxp/tropic/default.px4board
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CONFIG_DRIVERS_BAROMETER_DPS310=y
CONFIG_DRIVERS_CAMERA_CAPTURE=y
CONFIG_DRIVERS_CAMERA_TRIGGER=y
CONFIG_DRIVERS_DISTANCE_SENSOR_LIGHTWARE_LASER_I2C=y
CONFIG_DRIVERS_DSHOT=y
CONFIG_DRIVERS_GPS=y
CONFIG_DRIVERS_IMU_BOSCH_BMI088=y
CONFIG_DRIVERS_IMU_INVENSENSE_ICM20948=y
Expand All @@ -22,10 +23,10 @@ CONFIG_DRIVERS_POWER_MONITOR_INA238=y
CONFIG_DRIVERS_PWM_OUT=y
CONFIG_DRIVERS_RC_INPUT=y
CONFIG_DRIVERS_SAFETY_BUTTON=y
CONFIG_DRIVERS_UAVCAN=y
CONFIG_BOARD_UAVCAN_INTERFACES=1
CONFIG_COMMON_TELEMETRY=y
CONFIG_DRIVERS_TONE_ALARM=y
CONFIG_DRIVERS_UAVCAN=y
CONFIG_BOARD_UAVCAN_INTERFACES=1
CONFIG_MODULES_BATTERY_STATUS=y
CONFIG_MODULES_CAMERA_FEEDBACK=y
CONFIG_MODULES_COMMANDER=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
*(.text.imxrt_dispatch)
*(.text.arp_arpin)
*(.text.ipv4_input)
*(.text.flexio_irq_handler)


*(.text.work_thread)
Expand Down
21 changes: 21 additions & 0 deletions boards/nxp/tropic/src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#include <hardware/imxrt_lpuart.h>
#undef FLEXSPI_LUT_COUNT
#include <hardware/imxrt_flexspi.h>
#include <hardware/imxrt_ccm.h>

#include <arch/board/board.h>

Expand All @@ -91,6 +92,11 @@
* Pre-Processor Definitions
****************************************************************************/

/* 120Mhz clock for FlexIO using PLL3 */
#define CONFIG_FLEXIO1_CLK 3
#define CONFIG_FLEXIO1_PRED_DIVIDER 4
#define CONFIG_FLEXIO1_PODF_DIVIDER 1

/* Configuration ************************************************************/

/*
Expand Down Expand Up @@ -318,6 +324,20 @@ int imxrt_phy_boardinitialize(int intf)
return OK;
}

void imxrt_flexio_clocking(void) {
uint32_t reg;
reg = getreg32(IMXRT_CCM_CDCDR);
reg &= ~(CCM_CDCDR_FLEXIO1_CLK_SEL_MASK |
CCM_CDCDR_FLEXIO1_CLK_PODF_MASK |
CCM_CDCDR_FLEXIO1_CLK_PRED_MASK);
reg |= CCM_CDCDR_FLEXIO1_CLK_SEL(CONFIG_FLEXIO1_CLK);
reg |= CCM_CDCDR_FLEXIO1_CLK_PODF
(CCM_PODF_FROM_DIVISOR(CONFIG_FLEXIO1_PODF_DIVIDER));
reg |= CCM_CDCDR_FLEXIO1_CLK_PRED
(CCM_PRED_FROM_DIVISOR(CONFIG_FLEXIO1_PRED_DIVIDER));
putreg32(reg, IMXRT_CCM_CDCDR);
}


/****************************************************************************
* Name: board_app_initialize
Expand Down Expand Up @@ -345,6 +365,7 @@ int imxrt_phy_boardinitialize(int intf)
****************************************************************************/
__EXPORT int board_app_initialize(uintptr_t arg)
{
imxrt_flexio_clocking();

/* Power on Interfaces */

Expand Down
21 changes: 10 additions & 11 deletions boards/nxp/tropic/src/timer_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,27 +75,26 @@


constexpr io_timers_t io_timers[MAX_IO_TIMERS] = {
initIOPWM(PWM::FlexPWM2, PWM::Submodule0), // PWM_1, PMW_5
initIOPWM(PWM::FlexPWM2, PWM::Submodule1), // PWM_0
initIOPWMDshot(PWM::FlexPWM2, PWM::Submodule0), // PWM_1, PMW_5
initIOPWMDshot(PWM::FlexPWM2, PWM::Submodule1), // PWM_0
initIOPWM(PWM::FlexPWM2, PWM::Submodule2), // PWM_4
initIOPWM(PWM::FlexPWM4, PWM::Submodule2), // PWM_2, PWM_3
initIOPWMDshot(PWM::FlexPWM4, PWM::Submodule2), // PWM_2, PWM_3
};

/* Using PWM_4 and PWM_5 breaks PWM needs driver fixup */
#define FXIO_IOMUX (IOMUX_SLEW_FAST | IOMUX_DRIVE_130OHM | IOMUX_PULL_UP_47K | IOMUX_SCHMITT_TRIGGER)

constexpr timer_io_channels_t timer_io_channels[MAX_TIMER_IO_CHANNELS] = {
initIOTimerChannel(io_timers, {PWM::PWM2_PWM_A, PWM::Submodule0}, IOMUX::Pad::GPIO_EMC_06), /* RevA. PWM_1 RevB. PWM1 */
initIOTimerChannel(io_timers, {PWM::PWM2_PWM_B, PWM::Submodule0}, IOMUX::Pad::GPIO_EMC_07), /* RevA. PWM_5 RevB. PWM2 */
initIOTimerChannel(io_timers, {PWM::PWM2_PWM_A, PWM::Submodule1}, IOMUX::Pad::GPIO_EMC_08), /* RevA. PWM_0 RevB. PWM3 */
initIOTimerChannelDshot(io_timers, {PWM::PWM2_PWM_A, PWM::Submodule0}, IOMUX::Pad::GPIO_EMC_06, GPIO_FLEXIO1_FLEXIO06_1 | FXIO_IOMUX, 6), /* RevA. PWM_1 RevB. PWM1 */
initIOTimerChannelDshot(io_timers, {PWM::PWM2_PWM_B, PWM::Submodule0}, IOMUX::Pad::GPIO_EMC_07, GPIO_FLEXIO1_FLEXIO07_1 | FXIO_IOMUX, 7), /* RevA. PWM_5 RevB. PWM2 */
initIOTimerChannelDshot(io_timers, {PWM::PWM2_PWM_A, PWM::Submodule1}, IOMUX::Pad::GPIO_EMC_08, GPIO_FLEXIO1_FLEXIO08_1 | FXIO_IOMUX, 8), /* RevA. PWM_0 RevB. PWM3 */
initIOTimerChannel(io_timers, {PWM::PWM2_PWM_B, PWM::Submodule2}, IOMUX::Pad::GPIO_B0_11), /* RevA. PWM_4 RevB. PWM4 */
initIOTimerChannel(io_timers, {PWM::PWM4_PWM_A, PWM::Submodule2}, IOMUX::Pad::GPIO_EMC_04), /* RevA. PWM_3 RevB. PWM5 */
initIOTimerChannel(io_timers, {PWM::PWM4_PWM_B, PWM::Submodule2}, IOMUX::Pad::GPIO_EMC_05), /* RevA. PWM_2 RevB. PWM6 */
initIOTimerChannelDshot(io_timers, {PWM::PWM4_PWM_A, PWM::Submodule2}, IOMUX::Pad::GPIO_EMC_04, GPIO_FLEXIO1_FLEXIO04_1 | FXIO_IOMUX, 4), /* RevA. PWM_3 RevB. PWM5 */
initIOTimerChannelDshot(io_timers, {PWM::PWM4_PWM_B, PWM::Submodule2}, IOMUX::Pad::GPIO_EMC_05, GPIO_FLEXIO1_FLEXIO05_1 | FXIO_IOMUX, 5), /* RevA. PWM_2 RevB. PWM6 */
};


constexpr io_timers_channel_mapping_t io_timers_channel_mapping =
initIOTimerChannelMapping(io_timers, timer_io_channels);


constexpr io_timers_t led_pwm_timers[MAX_LED_TIMERS] = {
};

Expand Down

0 comments on commit 81366eb

Please sign in to comment.