Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 1 | #pragma once |
Ed Tanous | 9b4a20e | 2022-09-06 08:47:11 -0700 | [diff] [blame] | 2 | #include <boost/asio/steady_timer.hpp> |
Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 3 | #include <boost/container/flat_map.hpp> |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 4 | #include <sensor.hpp> |
James Feist | 38fb598 | 2020-05-28 10:09:54 -0700 | [diff] [blame] | 5 | |
Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 6 | #include <chrono> |
| 7 | #include <limits> |
Patrick Venture | fd6ba73 | 2019-10-31 14:27:39 -0700 | [diff] [blame] | 8 | #include <memory> |
| 9 | #include <string> |
Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 10 | #include <vector> |
| 11 | |
| 12 | struct MCUTempSensor : public Sensor |
| 13 | { |
| 14 | MCUTempSensor(std::shared_ptr<sdbusplus::asio::connection>& conn, |
Ed Tanous | 1f97863 | 2023-02-28 18:16:39 -0800 | [diff] [blame] | 15 | boost::asio::io_context& io, const std::string& name, |
Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 16 | const std::string& sensorConfiguration, |
| 17 | sdbusplus::asio::object_server& objectServer, |
Ed Tanous | 2049bd2 | 2022-07-09 07:20:26 -0700 | [diff] [blame] | 18 | std::vector<thresholds::Threshold>&& thresholdData, |
Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 19 | uint8_t busId, uint8_t mcuAddress, uint8_t tempReg); |
Ed Tanous | 8a57ec0 | 2020-10-09 12:46:52 -0700 | [diff] [blame] | 20 | ~MCUTempSensor() override; |
Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 21 | |
Ed Tanous | 201a101 | 2024-04-03 18:07:28 -0700 | [diff] [blame^] | 22 | void checkThresholds() override; |
| 23 | void read(); |
| 24 | void init(); |
Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 25 | |
| 26 | uint8_t busId; |
| 27 | uint8_t mcuAddress; |
| 28 | uint8_t tempReg; |
| 29 | |
| 30 | private: |
Saitwal, Meghan | f1169f7 | 2023-04-23 05:14:14 +0000 | [diff] [blame] | 31 | int getMCURegsInfoWord(uint8_t regs, int32_t* pu32data) const; |
Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 32 | sdbusplus::asio::object_server& objectServer; |
Ed Tanous | 9b4a20e | 2022-09-06 08:47:11 -0700 | [diff] [blame] | 33 | boost::asio::steady_timer waitTimer; |
Yuan Li | 445efe3 | 2019-06-14 22:58:32 +0800 | [diff] [blame] | 34 | }; |