2020-07-06 21:12:18 +02:00
|
|
|
/* Reflow Oven Controller
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
|
|
|
*
|
|
|
|
* This file is part of the Reflow Oven Controller Project.
|
|
|
|
*
|
|
|
|
* The reflow oven controller is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with the reflow oven controller project.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-07-07 19:26:00 +02:00
|
|
|
/**
|
|
|
|
* @addtogroup safety-controller
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2020-07-06 21:12:18 +02:00
|
|
|
#ifndef __SAFETY_CONTROLLER_H__
|
|
|
|
#define __SAFETY_CONTROLLER_H__
|
|
|
|
|
2020-07-07 20:47:22 +02:00
|
|
|
#include <reflow-controller/safety/safety-config.h>
|
|
|
|
#include <stdbool.h>
|
2020-07-27 21:29:15 +02:00
|
|
|
#include <stdint.h>
|
2020-07-28 22:55:02 +02:00
|
|
|
#include <stddef.h>
|
2020-07-07 19:26:00 +02:00
|
|
|
|
2020-07-09 22:31:42 +02:00
|
|
|
enum analog_monitor_status {ANALOG_MONITOR_OK = 0,
|
|
|
|
ANALOG_MONITOR_ERROR,
|
|
|
|
ANALOG_MONITOR_INACTIVE,
|
|
|
|
ANALOG_MONITOR_OVER,
|
|
|
|
ANALOG_MONITOR_UNDER};
|
|
|
|
|
2020-07-07 19:26:00 +02:00
|
|
|
/**
|
|
|
|
* @brief Initialize the safety controller
|
|
|
|
*
|
|
|
|
* After a call to this function the controller is iniotlaized and the watchdog is set up.
|
|
|
|
* You have to call safety_controller_handle
|
|
|
|
* If this function fails, it will hang, because errors in the safety controller are not recoverable
|
|
|
|
*/
|
|
|
|
void safety_controller_init();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Handle the safety controller.
|
|
|
|
* @note This function must be executed periodically in order to prevent the watchdog from resetting the firmware
|
|
|
|
* @return 0 if successful
|
|
|
|
*/
|
|
|
|
int safety_controller_handle();
|
|
|
|
|
2020-07-07 20:47:22 +02:00
|
|
|
int safety_controller_report_error(enum safety_flag flag);
|
|
|
|
|
2020-07-27 22:15:01 +02:00
|
|
|
int safety_controller_report_error_with_key(enum safety_flag flag, uint32_t key);
|
|
|
|
|
2020-07-07 20:47:22 +02:00
|
|
|
void safety_controller_report_timing(enum timing_monitor monitor);
|
2020-07-06 21:12:18 +02:00
|
|
|
|
2020-07-09 22:31:42 +02:00
|
|
|
void safety_controller_report_analog_value(enum analog_value_monitor monitor, float value);
|
|
|
|
|
2020-07-07 20:47:22 +02:00
|
|
|
int safety_controller_enable_timing_mon(enum timing_monitor monitor, bool enable);
|
2020-07-06 21:12:18 +02:00
|
|
|
|
2020-07-09 22:31:42 +02:00
|
|
|
enum analog_monitor_status safety_controller_get_analog_mon_value(enum analog_value_monitor monitor, float *value);
|
|
|
|
|
2020-07-26 21:40:09 +02:00
|
|
|
int safety_controller_get_flag(enum safety_flag flag, bool *status, bool try_ack);
|
|
|
|
|
|
|
|
int safety_controller_ack_flag(enum safety_flag flag);
|
2020-07-09 22:31:42 +02:00
|
|
|
|
2020-07-27 21:29:15 +02:00
|
|
|
int safety_controller_ack_flag_with_key(enum safety_flag flag, uint32_t key);
|
|
|
|
|
2020-07-27 22:15:01 +02:00
|
|
|
bool safety_controller_get_flags_by_mask(enum safety_flag mask);
|
|
|
|
|
2020-07-28 22:55:02 +02:00
|
|
|
uint32_t safety_controller_get_flag_count();
|
|
|
|
|
|
|
|
int safety_controller_get_flag_name_by_index(uint32_t index, char *buffer, size_t buffsize);
|
|
|
|
|
|
|
|
int safety_controller_get_flag_by_index(uint32_t index, bool *status, enum safety_flag *flag_enum);
|
|
|
|
|
2020-07-06 21:12:18 +02:00
|
|
|
#endif /* __SAFETY_CONTROLLER_H__ */
|
2020-07-07 19:26:00 +02:00
|
|
|
|
|
|
|
/** @} */
|