mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-26 09:43:57 -04:00
AP_IOMCU_FW: autodetect active high/low on heater control pin
This commit is contained in:
parent
aa32a0d143
commit
f23746053d
@ -171,6 +171,15 @@ void AP_IOMCU_FW::init()
|
|||||||
has_heater = true;
|
has_heater = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Set Heater PWM Polarity, 0 for Active Low and 1 for Active High
|
||||||
|
heater_pwm_polarity = !palReadLine(HAL_GPIO_PIN_HEATER);
|
||||||
|
//Set Heater pin mode
|
||||||
|
if (heater_pwm_polarity) {
|
||||||
|
palSetLineMode(HAL_GPIO_PIN_HEATER, PAL_MODE_OUTPUT_PUSHPULL);
|
||||||
|
} else {
|
||||||
|
palSetLineMode(HAL_GPIO_PIN_HEATER, PAL_MODE_OUTPUT_OPENDRAIN);
|
||||||
|
}
|
||||||
|
|
||||||
adc_init();
|
adc_init();
|
||||||
rcin_serial_init();
|
rcin_serial_init();
|
||||||
|
|
||||||
@ -284,10 +293,11 @@ void AP_IOMCU_FW::heater_update()
|
|||||||
}
|
}
|
||||||
} else if (reg_setup.heater_duty_cycle == 0 || (now - last_heater_ms > 3000UL)) {
|
} else if (reg_setup.heater_duty_cycle == 0 || (now - last_heater_ms > 3000UL)) {
|
||||||
// turn off the heater
|
// turn off the heater
|
||||||
HEATER_SET(0);
|
HEATER_SET(!heater_pwm_polarity);
|
||||||
} else {
|
} else {
|
||||||
uint8_t cycle = ((now / 10UL) % 100U);
|
uint8_t cycle = ((now / 10UL) % 100U);
|
||||||
HEATER_SET(!(cycle >= reg_setup.heater_duty_cycle));
|
//Turn off heater when cycle is greater than specified duty cycle
|
||||||
|
HEATER_SET((cycle >= reg_setup.heater_duty_cycle) ? !heater_pwm_polarity : heater_pwm_polarity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +126,7 @@ private:
|
|||||||
bool update_default_rate;
|
bool update_default_rate;
|
||||||
bool update_rcout_freq;
|
bool update_rcout_freq;
|
||||||
bool has_heater;
|
bool has_heater;
|
||||||
|
bool heater_pwm_polarity;
|
||||||
uint32_t last_blue_led_ms;
|
uint32_t last_blue_led_ms;
|
||||||
uint32_t safety_update_ms;
|
uint32_t safety_update_ms;
|
||||||
uint32_t safety_button_counter;
|
uint32_t safety_button_counter;
|
||||||
@ -144,7 +145,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
// GPIO macros
|
// GPIO macros
|
||||||
#define HEATER_SET(on) palWriteLine(HAL_GPIO_PIN_HEATER, !(on));
|
#define HEATER_SET(on) palWriteLine(HAL_GPIO_PIN_HEATER, (on));
|
||||||
#define BLUE_TOGGLE() palToggleLine(HAL_GPIO_PIN_HEATER);
|
#define BLUE_TOGGLE() palToggleLine(HAL_GPIO_PIN_HEATER);
|
||||||
#define AMBER_SET(on) palWriteLine(HAL_GPIO_PIN_AMBER_LED, !(on));
|
#define AMBER_SET(on) palWriteLine(HAL_GPIO_PIN_AMBER_LED, !(on));
|
||||||
#define SPEKTRUM_POWER(on) palWriteLine(HAL_GPIO_PIN_SPEKTRUM_PWR_EN, on);
|
#define SPEKTRUM_POWER(on) palWriteLine(HAL_GPIO_PIN_SPEKTRUM_PWR_EN, on);
|
||||||
|
Loading…
Reference in New Issue
Block a user