fix: PWM gimbals initialisation and inversion (#3745)
* fix: PWM gimbals initialisation and inversion * feat: add periph clock support in PWM stick driver
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
AddHWGenTarget(${HW_DESC_JSON} stm32_keys stm32_keys.inc)
|
||||
AddHWGenTarget(${HW_DESC_JSON} stm32_switches stm32_switches.inc)
|
||||
AddHWGenTarget(${HW_DESC_JSON} stm32_adc_inputs stm32_adc_inputs.inc)
|
||||
AddHWGenTarget(${HW_DESC_JSON} stm32_pwm_inputs stm32_pwm_inputs.inc)
|
||||
AddHWGenTarget(${HW_DESC_JSON} hal_adc_inputs hal_adc_inputs.inc)
|
||||
|
||||
# Dependencies common to bootloader and firmware
|
||||
@@ -17,6 +18,7 @@ set(MINIMAL_BOARD_LIB_SRC
|
||||
set(BOARD_LIB_SRC
|
||||
${CMAKE_CURRENT_BINARY_DIR}/stm32_switches.inc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/stm32_adc_inputs.inc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/stm32_pwm_inputs.inc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/hal_adc_inputs.inc
|
||||
|
||||
boards/generic_stm32/module_ports.cpp
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "analog_inputs.h"
|
||||
#include "stm32_adc.h"
|
||||
#include "stm32_spi_adc.h"
|
||||
#include "sticks_pwm_driver.h"
|
||||
|
||||
#include "hal.h"
|
||||
|
||||
@@ -38,6 +39,7 @@
|
||||
|
||||
// generated files
|
||||
#include "stm32_adc_inputs.inc"
|
||||
#include "stm32_pwm_inputs.inc"
|
||||
#include "hal_adc_inputs.inc"
|
||||
|
||||
constexpr uint8_t n_ADC = DIM(_ADC_adc);
|
||||
@@ -83,3 +85,35 @@ const etx_hal_adc_driver_t _adc_driver = {
|
||||
adc_wait_completion
|
||||
};
|
||||
|
||||
#if defined(PWM_STICKS)
|
||||
|
||||
static const stick_pwm_timer_t _sticks_timer = {
|
||||
PWM_GPIO,
|
||||
PWM_GPIOA_PINS,
|
||||
PWM_GPIO_AF,
|
||||
PWM_TIMER,
|
||||
PWM_IRQn,
|
||||
};
|
||||
|
||||
#if !defined(PWM_IRQHandler)
|
||||
#error "Missing PWM_IRQHandler"
|
||||
#endif
|
||||
|
||||
extern "C" void PWM_IRQHandler(void)
|
||||
{
|
||||
sticks_pwm_isr(&_sticks_timer, _PWM_inputs, DIM(_PWM_inputs));
|
||||
}
|
||||
|
||||
bool sticksPwmDetect()
|
||||
{
|
||||
return sticks_pwm_detect(&_sticks_timer, _PWM_inputs, DIM(_PWM_inputs));
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
bool sticksPwmDetect()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,3 +22,5 @@
|
||||
#include "hal/adc_driver.h"
|
||||
|
||||
extern const etx_hal_adc_driver_t _adc_driver;
|
||||
|
||||
bool sticksPwmDetect();
|
||||
|
||||
Reference in New Issue
Block a user