diff --git a/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp b/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp index ea55e7140f08a9..d972bffaddea9d 100644 --- a/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp +++ b/libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp @@ -251,6 +251,8 @@ static void main_loop() g_callbacks->setup(); + peripheral_io_output_enable(); + #if HAL_ENABLE_SAVE_PERSISTENT_PARAMS utilInstance.apply_persistent_params(); #endif diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c index c91e68930f547f..52fe1a8486d9c9 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c @@ -350,6 +350,22 @@ void peripheral_power_enable(void) #endif } +/* + PWM OUTPUT ENABLE control. + It can be used to prevent PWM output from being output during initialization. +*/ +void peripheral_io_output_enable(void) +{ +#if defined(HAL_GPIO_PIN_PWM_OE) || defined(HAL_GPIO_PIN_PWM_OE2) +#ifdef HAL_GPIO_PIN_PWM_OE + palWriteLine(HAL_GPIO_PIN_PWM_OE, 1); +#endif +#ifdef HAL_GPIO_PIN_PWM_OE2 + palWriteLine(HAL_GPIO_PIN_PWM_OE2, 1); +#endif +#endif +} + #if defined(STM32F7) || defined(STM32H7) || defined(STM32F4) || defined(STM32F3) || defined(STM32G4) || defined(STM32L4) || defined(STM32L4PLUS) /* read mode of a pin. This allows a pin config to be read, changed and diff --git a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.h b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.h index 828ceed09ca69a..2d51ee6afb2588 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.h +++ b/libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.h @@ -98,6 +98,9 @@ void set_fast_reboot(enum rtc_boot_magic v); // enable peripheral power if needed void peripheral_power_enable(void); +// enable peripheral io output if needed +void peripheral_io_output_enable(void); + // initialise allocation subsystem void malloc_init(void);