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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SAFETY_CONFIG_H__
|
|
|
|
#define __SAFETY_CONFIG_H__
|
|
|
|
|
2020-07-07 20:47:22 +02:00
|
|
|
|
|
|
|
enum safety_flag {
|
|
|
|
ERR_FLAG_MEAS_ADC_OFF = (1<<0),
|
|
|
|
ERR_FLAG_MEAS_ADC_OVERFLOW = (1<<1),
|
|
|
|
ERR_FLAG_MEAS_ADC_WATCHDOG = (1<<2),
|
|
|
|
ERR_FLAG_MEAS_ADC_UNSTABLE = (1<<3),
|
|
|
|
ERR_FLAG_TIMING_PID = (1<<4),
|
|
|
|
ERR_FLAG_TIMING_MEAS_ADC = (1<<5),
|
|
|
|
ERR_FLAG_AMON_VREF = (1<<6),
|
|
|
|
ERR_FLAG_AMON_UC_TEMP = (1<<7),
|
|
|
|
ERR_FLAG_STACK = (1<<8),
|
2020-07-26 21:40:09 +02:00
|
|
|
ERR_FLAG_SAFETY_ADC = (1<<9),
|
|
|
|
ERR_FLAG_SYSTICK = (1<<10),
|
2020-07-27 21:29:15 +02:00
|
|
|
ERR_FLAG_WTCHDG_FIRED = (1<<11),
|
2020-07-27 22:15:01 +02:00
|
|
|
ERR_FLAG_UNCAL = (1<<12),
|
2020-07-28 23:29:35 +02:00
|
|
|
ERR_FLAG_DEBUG = (1<<13),
|
2020-08-16 12:34:41 +02:00
|
|
|
ERR_FLAG_TIMING_MAIN_LOOP = (1<<14),
|
2020-07-07 20:47:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum timing_monitor {
|
|
|
|
ERR_TIMING_PID = (1<<0),
|
|
|
|
ERR_TIMING_MEAS_ADC = (1<<1),
|
|
|
|
ERR_TIMING_SAFETY_ADC = (1<<2),
|
2020-08-16 12:34:41 +02:00
|
|
|
ERR_TIMING_MAIN_LOOP = (1<<3),
|
2020-07-07 20:47:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum analog_value_monitor {
|
|
|
|
ERR_AMON_VREF = (1<<0),
|
|
|
|
ERR_AMON_UC_TEMP = (1<<1),
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-07-06 21:12:18 +02:00
|
|
|
/**
|
|
|
|
* @brief Magic key used to reset the watchdog using the @ref watchdog_ack function
|
|
|
|
*/
|
|
|
|
#define WATCHDOG_MAGIC_KEY 0x1a2c56F4
|
|
|
|
|
2020-07-26 21:40:09 +02:00
|
|
|
#ifdef DEBUGBUILD
|
2020-07-06 21:12:18 +02:00
|
|
|
/**
|
|
|
|
* @brief If one, the watchdog is halted whenever the core is halted by the debugger.
|
|
|
|
*
|
|
|
|
* This is only applicable in a debug build. In release mode, the watchdog stays always enabled
|
|
|
|
*/
|
|
|
|
#define WATCHDOG_HALT_DEBUG (1)
|
2020-07-26 21:40:09 +02:00
|
|
|
#else
|
|
|
|
#define WATCHDOG_HALT_DEBUG (0)
|
|
|
|
#endif
|
2020-07-06 21:12:18 +02:00
|
|
|
|
|
|
|
#define WATCHDOG_PRESCALER 4
|
|
|
|
|
2020-07-07 20:47:22 +02:00
|
|
|
#define SAFETY_MIN_STACK_FREE 0x100
|
|
|
|
|
|
|
|
#define PID_CONTROLLER_ERR_CAREMASK (ERR_FLAG_STACK | ERR_FLAG_AMON_UC_TEMP | ERR_FLAG_AMON_VREF | \
|
|
|
|
ERR_FLAG_TIMING_PID | ERR_FLAG_TIMING_MEAS_ADC | ERR_FLAG_MEAS_ADC_OFF | \
|
|
|
|
ERR_FLAG_MEAS_ADC_OVERFLOW)
|
|
|
|
|
|
|
|
#define HALTING_CAREMASK (ERR_FLAG_STACK | ERR_FLAG_AMON_UC_TEMP)
|
|
|
|
|
2020-07-09 22:31:42 +02:00
|
|
|
#define SAFETY_ADC_VREF_MVOLT (2500.0f)
|
|
|
|
#define SAFETY_ADC_VREF_TOL_MVOLT (100.0f)
|
|
|
|
#define SAFETY_ADC_TEMP_LOW_LIM (0.0f)
|
|
|
|
#define SAFETY_ADC_TEMP_HIGH_LIM (65.0f)
|
|
|
|
|
2020-07-27 22:15:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Key used to lock the safefety flags from external ack'ing
|
|
|
|
*/
|
|
|
|
#define MEAS_ADC_SAFETY_FLAG_KEY 0xe554dac3UL
|
|
|
|
|
2020-07-28 22:55:02 +02:00
|
|
|
#define SAFETY_CONTROLLER_ADC_DELAY_MS 120
|
|
|
|
|
2020-07-06 21:12:18 +02:00
|
|
|
#endif /* __SAFETY_CONFIG_H__ */
|