Compare commits
4 Commits
v0.3
...
f9b9a3c685
Author | SHA1 | Date | |
---|---|---|---|
f9b9a3c685 | |||
aaed95cc95 | |||
6ac108e1b2 | |||
7a36b597be |
@@ -27,6 +27,10 @@
|
||||
#include <stm-periph/rcc-manager.h>
|
||||
#include <stm32/stm32f4xx.h>
|
||||
|
||||
#if HW_REV_DETECT_PIN_LOW > HW_REV_DETECT_PIN_HIGH
|
||||
#error Configuration error for Hardware derection pins. Lowest position must be less than the highest pin position.
|
||||
#endif
|
||||
|
||||
enum hw_revision get_pcb_hardware_version(void)
|
||||
{
|
||||
uint8_t current_pin;
|
||||
|
@@ -48,7 +48,6 @@
|
||||
*/
|
||||
#define HW_REV_DETECT_PIN_HIGH (15U)
|
||||
|
||||
|
||||
/**
|
||||
* @brief PCB/Hardware Revision Type
|
||||
*/
|
||||
|
@@ -27,6 +27,15 @@
|
||||
#ifndef __SAFETY_CONFIG_H__
|
||||
#define __SAFETY_CONFIG_H__
|
||||
|
||||
/**
|
||||
* @brief Weights of error flags.
|
||||
*/
|
||||
enum config_weight {
|
||||
SAFETY_FLAG_CONFIG_WEIGHT_NONE = 0, /**< @brief This flag has no global error consequence, but might be respected by certain software modules. */
|
||||
SAFETY_FLAG_CONFIG_WEIGHT_PID = 1, /**< @brief This flag will force a stop of the temperature PID controller */
|
||||
SAFETY_FLAG_CONFIG_WEIGHT_PANIC = 2, /**< @brief This flag will trigger the panic mode */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Enum type representing safety flags.
|
||||
*
|
||||
|
@@ -75,9 +75,9 @@ void safety_controller_init(void);
|
||||
/**
|
||||
* @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
|
||||
* @returns Worst flag weigth that is currently set.
|
||||
*/
|
||||
int safety_controller_handle(void);
|
||||
enum config_weight safety_controller_handle(void);
|
||||
|
||||
/**
|
||||
* @brief Report one or multiple errors to the safety controller
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <reflow-controller/safety/safety-config.h>
|
||||
|
||||
/** @addtogroup safety-memory
|
||||
* @{
|
||||
@@ -131,15 +132,6 @@ enum config_override_entry_type {
|
||||
SAFETY_MEMORY_CONFIG_OVERRIDE_PERSISTENCE = 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Weights of error flags.
|
||||
*/
|
||||
enum config_weight {
|
||||
SAFETY_FLAG_CONFIG_WEIGHT_NONE = 0, /**< @brief This flag has no global error consequence, but might be respected by certain software modules. */
|
||||
SAFETY_FLAG_CONFIG_WEIGHT_PID = 1, /**< @brief This flag will force a stop of the temperature PID controller */
|
||||
SAFETY_FLAG_CONFIG_WEIGHT_PANIC = 2, /**< @brief This flag will trigger the panic mode */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief representation of a config override memory entry
|
||||
*/
|
||||
|
@@ -286,6 +286,7 @@ int main(void)
|
||||
shellmatta_handle_t shell_handle;
|
||||
int menu_wait_request;
|
||||
uint64_t quarter_sec_timestamp = 0ULL;
|
||||
enum config_weight worst_safety_flag = SAFETY_FLAG_CONFIG_WEIGHT_NONE;
|
||||
|
||||
/** - Setup all the peripherals and external componets like LCD, EEPROM etc. and the safety controller */
|
||||
setup_system();
|
||||
@@ -312,7 +313,7 @@ int main(void)
|
||||
* it is tried to load it from SD card.
|
||||
*/
|
||||
if (systick_ticks_have_passed(quarter_sec_timestamp, 250)) {
|
||||
led_set(1, 0);
|
||||
led_set(1u, 0);
|
||||
sd_old = sd_card_mounted;
|
||||
sd_card_mounted = mount_sd_card_if_avail(sd_card_mounted);
|
||||
|
||||
@@ -325,6 +326,14 @@ int main(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if any flags are present, that disable the PID controller. Blink
|
||||
* LED 0 in this case
|
||||
*/
|
||||
if (worst_safety_flag >= SAFETY_FLAG_CONFIG_WEIGHT_PID)
|
||||
led_set(0u, led_get(0u) ? 0 : 1);
|
||||
else
|
||||
led_set(0u, 0);
|
||||
|
||||
quarter_sec_timestamp = systick_get_global_tick();
|
||||
}
|
||||
|
||||
@@ -338,7 +347,7 @@ int main(void)
|
||||
temp_profile_executer_handle();
|
||||
|
||||
/** - Handle the safety controller. This must be called! Otherwise a watchdog reset will occur */
|
||||
safety_controller_handle();
|
||||
worst_safety_flag = safety_controller_handle();
|
||||
|
||||
/** - If the Oven PID controller is running, we handle its sample function */
|
||||
if (oven_pid_get_status() == OVEN_PID_RUNNING)
|
||||
|
@@ -364,6 +364,10 @@ static void set_overtemp_config(float over_temperature)
|
||||
safety_controller_overtemp_config.crc = crc_unit_get_crc();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check the overtemperature config structure's CRC
|
||||
* @return true if check failed. false if CRC check successful
|
||||
*/
|
||||
static bool over_temperature_config_check(void)
|
||||
{
|
||||
if (safety_controller_overtemp_config.crc_dummy_seed != 0xA4F5C7E6UL)
|
||||
@@ -1113,12 +1117,15 @@ static void safety_controller_do_systick_checking(void)
|
||||
* is set, the appropriate action defined by the flag weight is executed.
|
||||
* @note If no flag weigth is present for a given error flag, it is treated as the most critical category
|
||||
* (@ref SAFETY_FLAG_CONFIG_WEIGHT_PANIC)
|
||||
*
|
||||
* @returns Worst config weight set
|
||||
*/
|
||||
static void safety_controller_handle_weighted_flags(void)
|
||||
static enum config_weight safety_controller_handle_weighted_flags(void)
|
||||
{
|
||||
uint32_t flag_index;
|
||||
volatile struct error_flag *current_flag;
|
||||
enum config_weight flag_weigth;
|
||||
enum config_weight worst = SAFETY_FLAG_CONFIG_WEIGHT_NONE;
|
||||
|
||||
for (flag_index = 0u; flag_index < COUNT_OF(flags); flag_index++) {
|
||||
current_flag = &flags[flag_index];
|
||||
@@ -1128,6 +1135,11 @@ static void safety_controller_handle_weighted_flags(void)
|
||||
continue;
|
||||
|
||||
flag_weigth = get_flag_weight(current_flag);
|
||||
|
||||
/* Override the worst flag weigt set, if it is worse than the previous ones */
|
||||
if (flag_weigth > worst)
|
||||
worst = flag_weigth;
|
||||
|
||||
switch (flag_weigth) {
|
||||
case SAFETY_FLAG_CONFIG_WEIGHT_NONE:
|
||||
break;
|
||||
@@ -1143,6 +1155,8 @@ static void safety_controller_handle_weighted_flags(void)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return worst;
|
||||
}
|
||||
|
||||
#ifndef DEBUGBUILD
|
||||
@@ -1152,9 +1166,9 @@ static void external_watchdog_toggle(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
int safety_controller_handle(void)
|
||||
enum config_weight safety_controller_handle(void)
|
||||
{
|
||||
int ret = 0;
|
||||
enum config_weight worst_weight_set;
|
||||
#ifndef DEBUGBUILD
|
||||
static uint32_t watchdog_counter = 0UL;
|
||||
#endif
|
||||
@@ -1164,9 +1178,10 @@ int safety_controller_handle(void)
|
||||
safety_controller_handle_memory_checks();
|
||||
safety_controller_do_systick_checking();
|
||||
safety_controller_process_monitor_checks();
|
||||
safety_controller_handle_weighted_flags();
|
||||
worst_weight_set = safety_controller_handle_weighted_flags();
|
||||
|
||||
ret |= watchdog_ack(WATCHDOG_MAGIC_KEY);
|
||||
/* Ignore error here. Will trigger restart anyway */
|
||||
(void)watchdog_ack(WATCHDOG_MAGIC_KEY);
|
||||
|
||||
#ifndef DEBUGBUILD
|
||||
if (get_pcb_hardware_version() != HW_REV_V1_2) {
|
||||
@@ -1177,7 +1192,8 @@ int safety_controller_handle(void)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return (ret ? -1 : 0);
|
||||
|
||||
return worst_weight_set;
|
||||
}
|
||||
|
||||
int safety_controller_enable_timing_mon(enum timing_monitor monitor, bool enable)
|
||||
|
Reference in New Issue
Block a user