Add fault modes and start implementation of backup SRAM. However, this will probably never be used
This commit is contained in:
		
							
								
								
									
										49
									
								
								stm-firmware/safety/fault.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								stm-firmware/safety/fault.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
			
		||||
/* 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>
 | 
			
		||||
 | 
			
		||||
void HardFault_Handler(void)
 | 
			
		||||
{
 | 
			
		||||
	/* This is a non recoverable fault. Hang here */
 | 
			
		||||
 | 
			
		||||
	oven_driver_set_power(0);
 | 
			
		||||
	oven_driver_apply_power_level();
 | 
			
		||||
 | 
			
		||||
	led_set(0, 1);
 | 
			
		||||
 | 
			
		||||
	while (1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void panic_mode(void)
 | 
			
		||||
{
 | 
			
		||||
	/* Panic mode is esentially the same as a hardfault,
 | 
			
		||||
	 * but it can be expected, that more functionality is still usable
 | 
			
		||||
	 */
 | 
			
		||||
 | 
			
		||||
	oven_driver_set_power(0);
 | 
			
		||||
	oven_driver_apply_power_level();
 | 
			
		||||
 | 
			
		||||
	/* TODO: implement panic mode */
 | 
			
		||||
 | 
			
		||||
	while (1);
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user