Browse Source

AP_BoardConfig: add support for PWM Voltage level setting

master
Siddharth Purohit 6 years ago committed by Andrew Tridgell
parent
commit
c0036cbbdd
  1. 11
      libraries/AP_BoardConfig/AP_BoardConfig.cpp
  2. 4
      libraries/AP_BoardConfig/AP_BoardConfig.h
  3. 8
      libraries/AP_BoardConfig/board_drivers.cpp

11
libraries/AP_BoardConfig/AP_BoardConfig.cpp

@ -220,7 +220,16 @@ const AP_Param::GroupInfo AP_BoardConfig::var_info[] = { @@ -220,7 +220,16 @@ const AP_Param::GroupInfo AP_BoardConfig::var_info[] = {
// @User: Advanced
AP_GROUPINFO("SD_SLOWDOWN", 17, AP_BoardConfig, _sdcard_slowdown, 0),
#endif
#ifdef HAL_GPIO_PWM_VOLT_PIN
// @Param: PWM_VOLT_SEL
// @DisplayName: Set PWM Out Voltage
// @Description: This sets the voltage max for PWM output pulses. 0 for 3.3V and 1 for 5V output.
//@Values: 0:3.3V,1:5V
// @User: Advanced
AP_GROUPINFO("PWM_VOLT_SEL", 18, AP_BoardConfig, _pwm_volt_sel, 0),
#endif
AP_GROUPEND
};

4
libraries/AP_BoardConfig/AP_BoardConfig.h

@ -216,6 +216,10 @@ private: @@ -216,6 +216,10 @@ private:
AP_Float _vservo_min;
#endif
#ifdef HAL_GPIO_PWM_VOLT_PIN
AP_Int8 _pwm_volt_sel;
#endif
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
AP_Int8 _sdcard_slowdown;
#endif

8
libraries/AP_BoardConfig/board_drivers.cpp

@ -345,6 +345,14 @@ void AP_BoardConfig::board_setup() @@ -345,6 +345,14 @@ void AP_BoardConfig::board_setup()
hal.rcin->init();
hal.rcout->init();
#endif
#if HAL_GPIO_PWM_VOLT_PIN
if (_pwm_volt_sel == 0) {
hal.gpio->write(HAL_GPIO_PWM_VOLT_PIN, 1); //set pin for 3.3V PWM Output
} else if (_pwm_volt_sel == 1) {
hal.gpio->write(HAL_GPIO_PWM_VOLT_PIN, 0); //set pin for 5V PWM Output
}
#endif
board_setup_uart();
board_setup_sbus();
#if AP_FEATURE_BOARD_DETECT

Loading…
Cancel
Save