blob: 2948af331852f917e20dcca79037482e72ba5732 [file] [log] [blame]
Yuan Li445efe32019-06-14 22:58:32 +08001#pragma once
Ed Tanous9b4a20e2022-09-06 08:47:11 -07002#include <boost/asio/steady_timer.hpp>
Yuan Li445efe32019-06-14 22:58:32 +08003#include <boost/container/flat_map.hpp>
Ed Tanous8a57ec02020-10-09 12:46:52 -07004#include <sensor.hpp>
James Feist38fb5982020-05-28 10:09:54 -07005
Yuan Li445efe32019-06-14 22:58:32 +08006#include <chrono>
7#include <limits>
Patrick Venturefd6ba732019-10-31 14:27:39 -07008#include <memory>
9#include <string>
Yuan Li445efe32019-06-14 22:58:32 +080010#include <vector>
11
12struct MCUTempSensor : public Sensor
13{
14 MCUTempSensor(std::shared_ptr<sdbusplus::asio::connection>& conn,
Ed Tanous1f978632023-02-28 18:16:39 -080015 boost::asio::io_context& io, const std::string& name,
Yuan Li445efe32019-06-14 22:58:32 +080016 const std::string& sensorConfiguration,
17 sdbusplus::asio::object_server& objectServer,
Ed Tanous2049bd22022-07-09 07:20:26 -070018 std::vector<thresholds::Threshold>&& thresholdData,
Yuan Li445efe32019-06-14 22:58:32 +080019 uint8_t busId, uint8_t mcuAddress, uint8_t tempReg);
Ed Tanous8a57ec02020-10-09 12:46:52 -070020 ~MCUTempSensor() override;
Yuan Li445efe32019-06-14 22:58:32 +080021
Ed Tanous201a1012024-04-03 18:07:28 -070022 void checkThresholds() override;
23 void read();
24 void init();
Yuan Li445efe32019-06-14 22:58:32 +080025
26 uint8_t busId;
27 uint8_t mcuAddress;
28 uint8_t tempReg;
29
30 private:
Saitwal, Meghanf1169f72023-04-23 05:14:14 +000031 int getMCURegsInfoWord(uint8_t regs, int32_t* pu32data) const;
Yuan Li445efe32019-06-14 22:58:32 +080032 sdbusplus::asio::object_server& objectServer;
Ed Tanous9b4a20e2022-09-06 08:47:11 -070033 boost::asio::steady_timer waitTimer;
Yuan Li445efe32019-06-14 22:58:32 +080034};