Skip to content

Commit

Permalink
AP_HAL_ChibiOS: add pwm output enable control
Browse files Browse the repository at this point in the history
  • Loading branch information
jfbblue0922 committed Apr 2, 2024
1 parent f9cb380 commit c70cea9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libraries/AP_HAL_ChibiOS/HAL_ChibiOS_Class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions libraries/AP_HAL_ChibiOS/hwdef/common/stm32_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit c70cea9

Please sign in to comment.