temperature.h
1 /*
2  * EEZ PSU Firmware
3  * Copyright (C) 2015-present, Envox d.o.o.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include "temp_sensor.h"
22 
23 namespace eez {
24 namespace psu {
25 
26 class Channel;
27 
29 namespace temperature {
30 
33  int8_t sensor;
34  float delay;
35  float level;
36  bool state;
37 };
38 
39 void init();
40 bool test();
41 void tick(uint32_t tick_usec);
42 
43 bool isChannelSensorInstalled(Channel *channel);
44 #if EEZ_PSU_SELECTED_REVISION == EEZ_PSU_REVISION_R3B4 || EEZ_PSU_SELECTED_REVISION == EEZ_PSU_REVISION_R5B12
45 bool getChannelSensorState(Channel *channel);
46 float getChannelSensorLevel(Channel *channel);
47 float getChannelSensorDelay(Channel *channel);
48 #endif
49 
50 bool isAnySensorTripped(Channel *channel);
51 
52 void clearChannelProtection(Channel *channel);
53 void disableChannelProtection(Channel *channel);
54 
55 float getMaxChannelTemperature();
56 bool isAllowedToPowerUp();
57 
59 public:
60  ProtectionConfiguration prot_conf;
61  float temperature;
62 
63  TempSensorTemperature(int sensorIndex);
64 
65  bool isInstalled();
66  bool isTestOK();
67  void tick(uint32_t tick_usec);
68  bool isChannelSensor(Channel *channel);
69  float measure();
70  void clearProtection();
71  bool isTripped();
72 
73 private:
74  int sensorIndex;
75 
76  bool otp_alarmed;
77  uint32_t otp_alarmed_started_tick;
78  bool otp_tripped;
79 
80  void set_otp_reg(bool on);
81  void protection_check(uint32_t tick_usec);
82  static void protection_enter(TempSensorTemperature& sensor);
83  void protection_enter();
84 };
85 
86 extern TempSensorTemperature sensors[temp_sensor::NUM_TEMP_SENSORS];
87 
88 }
89 }
90 } // namespace eez::psu::temperature
Namespace for the everything from the EEZ.
Definition: actions.cpp:41
PSU channel.
Definition: channel.h:62
Configuration data for the temperature protection.
Definition: temperature.h:32