Path: blob/master/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Rotoye.cpp
9317 views
#include "AP_BattMonitor_config.h"12#if AP_BATTERY_SMBUS_ROTOYE_ENABLED34#include "AP_BattMonitor_SMBus_Rotoye.h"56#include <AP_HAL/AP_HAL.h>78// Specific to Rotoye Batmon9#define BATTMONITOR_SMBUS_TEMP_EXT 0x481011// return the maximum of the internal and external temperature sensors12void AP_BattMonitor_SMBus_Rotoye::read_temp(void) {13uint16_t t_int = 0;14uint16_t t_ext = 0;1516/* Both internal and external values will always be sent by Batmon.17If no external thermistor is used, a zero-value is sent. */18const bool have_temp_internal = read_word(BATTMONITOR_SMBUS_TEMP, t_int);19const bool have_temp_external = read_word(BATTMONITOR_SMBUS_TEMP_EXT, t_ext);2021if (!have_temp_internal && !have_temp_external) {22_has_temperature = (AP_HAL::millis() - _state.temperature_time) <= AP_BATT_MONITOR_TIMEOUT;23return;24}2526_has_temperature = true;2728_state.temperature_time = AP_HAL::millis();29_state.temperature = KELVIN_TO_C(0.1f * float(MAX(t_int, t_ext)));30}3132#endif // AP_BATTERY_SMBUS_ROTOYE_ENABLED333435