AP_IOMCU: support IMU heater

This commit is contained in:
Andrew Tridgell 2018-01-03 17:25:30 +11:00
parent 1568f578d7
commit d1fd843539
2 changed files with 23 additions and 1 deletions

View File

@ -71,6 +71,7 @@ enum ioevents {
IOEVENT_SET_RATES,
IOEVENT_GET_RCIN,
IOEVENT_ENABLE_SBUS,
IOEVENT_SET_HEATER_TARGET,
};
// setup page registers
@ -90,6 +91,7 @@ enum ioevents {
#define PAGE_REG_SETUP_DEFAULTRATE 3
#define PAGE_REG_SETUP_ALTRATE 4
#define PAGE_REG_SETUP_SBUS_RATE 19
#define PAGE_REG_SETUP_HEATER_DUTY_CYCLE 21
#define PAGE_REG_SETUP_FORCE_SAFETY_OFF 12
#define PAGE_REG_SETUP_FORCE_SAFETY_ON 14
@ -199,6 +201,13 @@ void AP_IOMCU::thread_main(void)
}
}
if (mask & EVENT_MASK(IOEVENT_SET_HEATER_TARGET)) {
if (!write_register(PAGE_SETUP, PAGE_REG_SETUP_HEATER_DUTY_CYCLE, heater_duty_cycle)) {
event_failed(IOEVENT_SET_HEATER_TARGET);
continue;
}
}
// check for regular timed events
uint32_t now = AP_HAL::millis();
if (now - last_rc_read_ms > 20) {
@ -513,4 +522,11 @@ bool AP_IOMCU::check_rcinput(uint32_t &last_frame_us, uint8_t &num_channels, uin
return false;
}
// set IMU heater target
void AP_IOMCU::set_heater_duty_cycle(uint8_t duty_cycle)
{
heater_duty_cycle = duty_cycle;
trigger_event(IOEVENT_SET_HEATER_TARGET);
}
#endif // HAL_WITH_IO_MCU

View File

@ -64,6 +64,9 @@ public:
*/
float get_vrssi(void) const { return reg_status.vrssi * 0.001; }
// set target for IMU heater
void set_heater_duty_cycle(uint8_t duty_cycle);
private:
AP_HAL::UARTDriver &uart;
@ -174,6 +177,9 @@ private:
uint16_t sbus_rate_hz;
} rate;
// IMU heater duty cycle
uint8_t heater_duty_cycle;
bool corked;
};