Add fault modes and start implementation of backup SRAM. However, this will probably never be used
This commit is contained in:
parent
627da0def5
commit
149c5715c6
@ -35,7 +35,7 @@ DEFINES += -DSHELLMATTA_HELP_ALIAS=\"?\"
|
||||
|
||||
# RCC Manager
|
||||
CFILES += stm-periph/clock-enable-manager.c
|
||||
CFILES += stm-periph/uart.c stm-periph/dma-ring-buffer.c
|
||||
CFILES += stm-periph/uart.c stm-periph/dma-ring-buffer.c stm-periph/backup-ram.c
|
||||
CFILES += digio.c
|
||||
CFILES += stm-periph/unique-id.c
|
||||
CFILES += calibration.c
|
||||
@ -43,12 +43,11 @@ CFILES += temp-converter.c
|
||||
CFILES += rotary-encoder.c button.c
|
||||
CFILES += stack-check.c
|
||||
CFILES += ui/lcd.c ui/menu.c reflow-menu.c
|
||||
#CFILES += onewire-temp-sensors.c
|
||||
CFILES += fatfs/diskio.c fatfs/ff.c fatfs/ffsystem.c fatfs/ffunicode.c fatfs/shimatta_sdio_driver/shimatta_sdio.c
|
||||
CFILES += pid-controller.c oven-driver.c
|
||||
CFILES += settings/settings.c settings/settings-sd-card.c
|
||||
|
||||
CFILES += safety/safety-adc.c safety/safety-controller.c safety/watchdog.c
|
||||
CFILES += safety/safety-adc.c safety/safety-controller.c safety/watchdog.c safety/fault.c
|
||||
|
||||
DEBUG_DEFINES = -DDEBUGBUILD
|
||||
RELEASE_DEFINES =
|
||||
|
28
stm-firmware/include/reflow-controller/safety/fault.h
Normal file
28
stm-firmware/include/reflow-controller/safety/fault.h
Normal file
@ -0,0 +1,28 @@
|
||||
/* 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief This function implements the panic mode
|
||||
*
|
||||
* This function will never return and ensures that the controller goes in a safe operating state
|
||||
* The watchdog will eventually reset the controller from this state. Therefore, this function sets
|
||||
* a flag in the backup SRAM that will prevent the controller from booting in normal operation.
|
||||
*/
|
||||
void panic_mode(void);
|
51
stm-firmware/include/stm-periph/backup-ram.h
Normal file
51
stm-firmware/include/stm-periph/backup-ram.h
Normal file
@ -0,0 +1,51 @@
|
||||
/* 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 <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief Init the backup ram and make it accesible
|
||||
*/
|
||||
void backup_ram_init();
|
||||
|
||||
/**
|
||||
* @brief Disable access to the backup RAM. This saves power
|
||||
*/
|
||||
void backup_ram_disable();
|
||||
|
||||
/**
|
||||
* @brief Whis function overwrites the backup RAM with 0x00
|
||||
*/
|
||||
void backup_ram_wipe();
|
||||
|
||||
/**
|
||||
* @brief Read data from the backup RAM
|
||||
* @param addr Address offset inside memory
|
||||
* @param data read 32bit data
|
||||
*/
|
||||
int backup_ram_get_data(uint32_t addr, uint32_t *data);
|
||||
|
||||
/**
|
||||
* @brief Write data structure to backup RAM
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
int backup_ram_write_data(uint32_t addr, uint32_t data);
|
||||
|
@ -26,8 +26,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
/* #include <arm_math.h> */
|
||||
#include <stm32/stm32f4xx.h>
|
||||
#include <cmsis/core_cm4.h>
|
||||
#include <setup/system_stm32f4xx.h>
|
||||
|
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);
|
||||
}
|
54
stm-firmware/stm-periph/backup-ram.c
Normal file
54
stm-firmware/stm-periph/backup-ram.c
Normal file
@ -0,0 +1,54 @@
|
||||
/* 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 <stm-periph/backup-ram.h>
|
||||
#include <stm-periph/clock-enable-manager.h>
|
||||
#include <stm32/stm32f4xx.h>
|
||||
|
||||
void backup_ram_init()
|
||||
{
|
||||
rcc_manager_enable_clock(&RCC->APB1ENR, BITMASK_TO_BITNO(RCC_APB1ENR_PWREN));
|
||||
|
||||
/* Enable access to backup RAM register set */
|
||||
PWR->CR |= PWR_CR_DBP;
|
||||
|
||||
/* Enable clock for backup ram interface */
|
||||
rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(RCC_AHB1ENR_BKPSRAMEN));
|
||||
}
|
||||
|
||||
void backup_ram_disable()
|
||||
{
|
||||
rcc_manager_disable_clock(&RCC->APB1ENR, BITMASK_TO_BITNO(RCC_APB1ENR_PWREN));
|
||||
}
|
||||
|
||||
void backup_ram_wipe()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int backup_ram_get_data(uint32_t addr, uint32_t *data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int backup_ram_write_data(uint32_t addr, uint32_t data)
|
||||
{
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user