diff --git a/libraries/AP_IOMCU/AP_IOMCU.cpp b/libraries/AP_IOMCU/AP_IOMCU.cpp index 4f76f45625..2a75fab3ce 100644 --- a/libraries/AP_IOMCU/AP_IOMCU.cpp +++ b/libraries/AP_IOMCU/AP_IOMCU.cpp @@ -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 @@ -198,6 +200,13 @@ void AP_IOMCU::thread_main(void) continue; } } + + 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(); @@ -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 diff --git a/libraries/AP_IOMCU/AP_IOMCU.h b/libraries/AP_IOMCU/AP_IOMCU.h index 7c97824913..366813fa5d 100644 --- a/libraries/AP_IOMCU/AP_IOMCU.h +++ b/libraries/AP_IOMCU/AP_IOMCU.h @@ -63,7 +63,10 @@ public: get rssi voltage */ 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; @@ -173,6 +176,9 @@ private: uint16_t default_freq = 50; uint16_t sbus_rate_hz; } rate; + + // IMU heater duty cycle + uint8_t heater_duty_cycle; bool corked; };