Line data Source code
1 : /* 2 : * Copyright (C) 2023 Kraus Hamdani Aerospace Inc. All rights reserved. 3 : * 4 : * This file is free software: you can redistribute it and/or modify it 5 : * under the terms of the GNU General Public License as published by the 6 : * Free Software Foundation, either version 3 of the License, or 7 : * (at your option) any later version. 8 : * 9 : * This file is distributed in the hope that it will be useful, but 10 : * WITHOUT ANY WARRANTY; without even the implied warranty of 11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 : * See the GNU General Public License for more details. 13 : * 14 : * You should have received a copy of the GNU General Public License along 15 : * with this program. If not, see <http://www.gnu.org/licenses/>. 16 : * 17 : * Code by Tom Pittenger 18 : */ 19 : /* 20 : Implements SPI driver for MAX31865 digital RTD Temperature converter 21 : */ 22 : 23 : #pragma once 24 : #include "AP_TemperatureSensor_Backend.h" 25 : 26 : #if AP_TEMPERATURE_SENSOR_MAX31865_ENABLED 27 : 28 : class AP_TemperatureSensor_MAX31865 : public AP_TemperatureSensor_Backend { 29 : public: 30 : AP_TemperatureSensor_MAX31865(AP_TemperatureSensor &front, AP_TemperatureSensor::TemperatureSensor_State &state, AP_TemperatureSensor_Params ¶ms); 31 : 32 : __INITFUNC__ void init(void) override; 33 : 34 0 : void update(void) override {}; 35 : 36 : static const struct AP_Param::GroupInfo var_info[]; 37 : 38 : private: 39 : 40 : // Vbias = ON (must be on for automatic mode) 41 : // Conversion mode: Auto 42 : // Fault Status: 1set 1 to Clear all latched faults 43 : uint8_t config_register = 0b11000010; 44 : 45 : AP_Float nominal_resistance; 46 : AP_Float reference_resistance; 47 : 48 : // Convert raw value in to temperature in deg celsius 49 : float calculate_temperature(const uint16_t raw) const; 50 : 51 : void thread_tick(void); 52 : }; 53 : 54 : #endif // AP_TEMPERATURE_SENSOR_MAX31865_ENABLED