Line data Source code
1 : #include "AP_BattMonitor_config.h" 2 : 3 : #if AP_BATTERY_SMBUS_ROTOYE_ENABLED 4 : 5 : #include "AP_BattMonitor_SMBus_Rotoye.h" 6 : 7 : #include <AP_HAL/AP_HAL.h> 8 : 9 : // Specific to Rotoye Batmon 10 : #define BATTMONITOR_SMBUS_TEMP_EXT 0x48 11 : 12 : // return the maximum of the internal and external temperature sensors 13 0 : void AP_BattMonitor_SMBus_Rotoye::read_temp(void) { 14 0 : uint16_t t_int = 0; 15 0 : uint16_t t_ext = 0; 16 : 17 : /* Both internal and external values will always be sent by Batmon. 18 : If no external thermistor is used, a zero-value is sent. */ 19 0 : const bool have_temp_internal = read_word(BATTMONITOR_SMBUS_TEMP, t_int); 20 0 : const bool have_temp_external = read_word(BATTMONITOR_SMBUS_TEMP_EXT, t_ext); 21 : 22 0 : if (!have_temp_internal && !have_temp_external) { 23 0 : _has_temperature = (AP_HAL::millis() - _state.temperature_time) <= AP_BATT_MONITOR_TIMEOUT; 24 0 : return; 25 : } 26 : 27 0 : _has_temperature = true; 28 : 29 0 : _state.temperature_time = AP_HAL::millis(); 30 0 : _state.temperature = KELVIN_TO_C(0.1f * float(MAX(t_int, t_ext))); 31 : } 32 : 33 : #endif // AP_BATTERY_SMBUS_ROTOYE_ENABLED