From 252f63cb487217fe2e18c64b94c26fbb478eef31 Mon Sep 17 00:00:00 2001 From: FrancescoFerraro Date: Tue, 19 Oct 2021 08:29:12 +0200 Subject: [PATCH] imx8mm-var-dart: assign PWM3 to M4 using RDC This fix the PWM3 behaviour after linux boot The PWM is corrupted while linux is booting Signed-off-by: FrancescoFerraro --- boards/dart_mx8mm/driver_examples/pwm/pwm.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/boards/dart_mx8mm/driver_examples/pwm/pwm.c b/boards/dart_mx8mm/driver_examples/pwm/pwm.c index f0d87871d..f32bccd4e 100644 --- a/boards/dart_mx8mm/driver_examples/pwm/pwm.c +++ b/boards/dart_mx8mm/driver_examples/pwm/pwm.c @@ -13,6 +13,8 @@ #include "fsl_pwm.h" #include "fsl_common.h" +#include "fsl_rdc.h" + /******************************************************************************* * Definitions ******************************************************************************/ @@ -21,6 +23,7 @@ #define DEMO_PWM_IRQHandler PWM3_IRQHandler /*! @brief PWM period value. PWMO (Hz) = PCLK(Hz) / (period +2) */ #define PWM_PERIOD_VALUE 30 +#define APP_RDC_PERIPH_PWM3 kRDC_Periph_PWM3 /******************************************************************************* * Prototypes @@ -31,6 +34,8 @@ ******************************************************************************/ volatile uint32_t pwmDutycycle = 0U; volatile bool pwmDutyUp = true; /* Indicate PWM Duty cycle is increase or decrease */ +rdc_domain_assignment_t assignment; +rdc_periph_access_config_t periphConfig; /******************************************************************************* * Code @@ -66,6 +71,21 @@ void DEMO_PWM_IRQHandler(void) SDK_ISR_EXIT_BARRIER; } +static void APP_RDC_Periph(void) +{ + PRINTF("RDC Peripheral access control\r\n"); + + /* + * Make PWM3 accessible only by M4 + */ + RDC_GetDefaultPeriphAccessConfig(&periphConfig); + periphConfig.periph = APP_RDC_PERIPH_PWM3; + periphConfig.policy = RDC_ACCESS_POLICY(1, kRDC_ReadWrite); + /* Set peripheral to accessible by M4 domain only. */ + RDC_SetPeriphAccessConfig(RDC, &periphConfig); +} + + /*! * @brief Main function */ @@ -81,6 +101,7 @@ int main(void) BOARD_BootClockRUN(); BOARD_InitDebugConsole(); BOARD_InitMemory(); + APP_RDC_Periph(); PRINTF("\r\nPWM driver example.\r\n");