2020-08-23 21:40:16 +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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <reflow-controller/oven-driver.h>
|
|
|
|
#include <reflow-controller/digio.h>
|
|
|
|
#include <reflow-controller/safety/fault.h>
|
2020-09-05 16:32:31 +02:00
|
|
|
#include <reflow-controller/safety/safety-memory.h>
|
|
|
|
#include <helper-macros/helper-macros.h>
|
2020-08-23 21:40:16 +02:00
|
|
|
|
|
|
|
void HardFault_Handler(void)
|
|
|
|
{
|
2020-09-08 18:23:47 +02:00
|
|
|
/* This is a non recoverable fault. Stop the oven */
|
2020-08-23 21:40:16 +02:00
|
|
|
|
|
|
|
oven_driver_set_power(0);
|
|
|
|
oven_driver_apply_power_level();
|
|
|
|
|
2020-09-08 18:23:47 +02:00
|
|
|
/* Set the error led */
|
2020-08-23 21:40:16 +02:00
|
|
|
led_set(0, 1);
|
|
|
|
|
2020-09-08 18:23:47 +02:00
|
|
|
/* Try the real panic mode */
|
|
|
|
panic_mode();
|
2020-08-23 21:40:16 +02:00
|
|
|
}
|
|
|
|
|
2020-09-05 18:23:17 +02:00
|
|
|
/* Overwrite default handler. Go to panic mode */
|
|
|
|
void __int_default_handler(void)
|
|
|
|
{
|
|
|
|
panic_mode();
|
|
|
|
}
|
|
|
|
|
2020-08-23 21:40:16 +02:00
|
|
|
void panic_mode(void)
|
|
|
|
{
|
2020-09-08 18:23:47 +02:00
|
|
|
/* This variable is static, because I don't want it to be on the stack */
|
2020-09-05 16:32:31 +02:00
|
|
|
static struct safety_memory_boot_status IN_SECTION(.ccm.bss) boot_status;
|
|
|
|
|
2020-08-23 21:40:16 +02:00
|
|
|
oven_driver_set_power(0);
|
|
|
|
oven_driver_apply_power_level();
|
|
|
|
|
|
|
|
/* TODO: implement panic mode */
|
2020-09-05 16:32:31 +02:00
|
|
|
if (!safety_memory_get_boot_status(&boot_status)) {
|
|
|
|
boot_status.reset_from_panic = 0xFFFFFFFF;
|
|
|
|
(void)safety_memory_set_boot_status(&boot_status);
|
|
|
|
}
|
|
|
|
|
2020-09-08 18:23:47 +02:00
|
|
|
/* Let the watchdog do the rest */
|
2020-08-23 21:40:16 +02:00
|
|
|
while (1);
|
|
|
|
}
|