34static struct k_thread thermal_thread_data;
36 CONFIG_THERMAL_MONITOR_THREAD_STACK_SIZE);
38thermal::thermal() : m_uhf_triggered(false), m_sband_triggered(false) {}
47 m_tid = k_thread_create(&thermal_thread_data, thermal_thread_stack,
48 K_THREAD_STACK_SIZEOF(thermal_thread_stack),
49 thermal_thread, NULL, NULL, NULL,
50 CONFIG_THERMAL_MONITOR_THREAD_PRIORITY, 0, K_NO_WAIT);
54 k_thread_name_set(m_tid,
"thermal_monitor");
58thermal::thermal_thread(
void *arg1,
void *arg2,
void *arg3)
60 static_assert(task_wdg_period / 2 > CONFIG_THERMAL_MONITOR_PERIOD_SECS * 1000,
61 "Wrong configuration");
66 task_wdt_feed(task_wdt_id);
67 k_sleep(K_SECONDS(CONFIG_THERMAL_MONITOR_PERIOD_SECS));
81 if (std::isfinite(t) &&
85 if (th.m_state.uhf_sensor_valid ==
false) {
86 th.m_uhf_temp.reset(t);
90 th.m_state.uhf_sensor_valid =
true;
93 th.m_state.uhf_sensor_valid =
false;
96 th.m_state.uhf_sensor_valid =
false;
103 if (std::isfinite(t) &&
104 t > s.get<settings::param::THERMAL_MIN_VALID_TEMP>() &&
105 t < s.get<settings::param::THERMAL_MAX_VALID_TEMP>()) {
107 if (th.m_state.sband_sensor_valid ==
false) {
108 th.m_sband_temp.reset(t);
112 th.m_state.sband_sensor_valid =
true;
115 th.m_state.sband_sensor_valid =
false;
118 th.m_state.sband_sensor_valid =
false;
125 if (std::isfinite(t) &&
126 t > s.get<settings::param::THERMAL_MIN_VALID_TEMP>() &&
127 t < s.get<settings::param::THERMAL_MAX_VALID_TEMP>()) {
129 if (th.m_state.pcb_sensor_valid ==
false) {
130 th.m_pcb_temp.reset(t);
134 th.m_state.pcb_sensor_valid =
true;
137 th.m_state.pcb_sensor_valid =
false;
140 th.m_state.pcb_sensor_valid =
false;
146 if (th.m_state.uhf_sensor_valid) {
147 if (th.m_state.uhf_triggered) {
148 if (th.m_uhf_temp() <
149 s.get<settings::param::THERMAL_UHF_ENABLE_TEMP>()) {
150 th.m_state.uhf_triggered =
false;
151 log.log(
"Thermal UHF: Re-enabling UHF interface");
155 if (th.m_uhf_temp() >
156 s.get<settings::param::THERMAL_UHF_SHUTDOWN_TEMP>()) {
157 th.m_state.uhf_triggered =
true;
158 log.log(
"Thermal UHF: Disabling UHF interface");
164 else if (th.m_state.pcb_sensor_valid) {
165 if (th.m_state.uhf_triggered) {
166 if (th.m_pcb_temp() <
167 s.get<settings::param::THERMAL_PCB_ENABLE_TEMP>()) {
168 th.m_state.uhf_triggered =
false;
169 log.log(
"Thermal UHF: Re-enabling UHF interface from backup sensor");
173 if (th.m_pcb_temp() >
174 s.get<settings::param::THERMAL_PCB_SHUTDOWN_TEMP>()) {
175 th.m_state.uhf_triggered =
true;
176 log.log(
"Thermal UHF: Disabling UHF interface from backup sensor");
183 if (th.m_state.uhf_triggered) {
184 th.m_state.uhf_triggered =
false;
185 log.log(
"Thermal UHF: Re-enabling UHF interface. Lost all sensors");
191 if (th.m_state.sband_sensor_valid) {
192 if (th.m_state.sband_triggered) {
193 if (th.m_sband_temp() <
194 s.get<settings::param::THERMAL_SBAND_ENABLE_TEMP>()) {
195 th.m_state.sband_triggered =
false;
196 log.log(
"Thermal S-band: Re-enabling S-band interface");
200 if (th.m_sband_temp() >
201 s.get<settings::param::THERMAL_SBAND_SHUTDOWN_TEMP>()) {
202 th.m_state.sband_triggered =
true;
203 log.log(
"Thermal S-band: Disabling S-band interface");
209 else if (th.m_state.pcb_sensor_valid) {
210 if (th.m_state.sband_triggered) {
211 if (th.m_pcb_temp() <
212 s.get<settings::param::THERMAL_PCB_ENABLE_TEMP>()) {
213 th.m_state.sband_triggered =
false;
214 log.log(
"Thermal S-band: Re-enabling S-band interface from backup "
219 if (th.m_pcb_temp() >
220 s.get<settings::param::THERMAL_PCB_SHUTDOWN_TEMP>()) {
221 th.m_state.sband_triggered =
true;
223 "Thermal S-band: Disabling S-band interface from backup sensor");
230 if (th.m_state.sband_triggered) {
231 th.m_state.sband_triggered =
false;
233 "Thermal S-band: Re-enabling S-band interface. Lost all sensors");
static io & get_instance()
static board & get_instance()
Gets a reference to the single instance of the Board interface class.
float temperature(temperature_sensor s) const
Gets the temperature from a specific sensor.
static logger & get_instance()
Singleton access to the logger subsystem.
static settings & get_instance()
Get a singleton access to the settings subsystem.
void start()
Activates and starts the thermal monitoring mechanism.
static thermal & get_instance()
@ PCB
PCB temperature sensor.
@ UHF_PA
UHF PA temperature sensor.
@ SBAND_PA
S-Band PA temperature sensor.
void task_wdt_callback(int channel_id, void *user_data)
K_THREAD_STACK_DEFINE(radio_rx_thread_stack, CONFIG_RADIO_RX_THREAD_STACK_SIZE)