Line data Source code
1 : /* 2 : * Copyright (C) 2022 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 I2C driver for Microchip MCP9600 digital thermocouple EMF to Temperature converter 21 : */ 22 : 23 : #pragma once 24 : #include "AP_TemperatureSensor_Backend.h" 25 : 26 : #ifndef AP_TEMPERATURE_SENSOR_MCP9600_ENABLED 27 : #define AP_TEMPERATURE_SENSOR_MCP9600_ENABLED AP_TEMPERATURE_SENSOR_ENABLED 28 : #endif 29 : 30 : #if AP_TEMPERATURE_SENSOR_MCP9600_ENABLED 31 : 32 : 33 : class AP_TemperatureSensor_MCP9600 : public AP_TemperatureSensor_Backend { 34 : using AP_TemperatureSensor_Backend::AP_TemperatureSensor_Backend; 35 : public: 36 : 37 : enum class ThermocoupleType : uint8_t { 38 : K = 0, 39 : J = 1, 40 : T = 2, 41 : N = 3, 42 : S = 4, 43 : E = 5, 44 : B = 6, 45 : R = 7, 46 : }; 47 : 48 : __INITFUNC__ void init(void) override; 49 : 50 0 : void update(void) override {}; 51 : 52 : private: 53 : 54 : void _timer(void); 55 : 56 : bool read_temperature(float &temperature); 57 : 58 : bool set_config(const ThermocoupleType type, const uint8_t filter); 59 : }; 60 : 61 : #endif // AP_TEMPERATURE_SENSOR_MCP9600_ENABLED