diff --git a/doc/source/firmware/safety.rst b/doc/source/firmware/safety.rst index ba22094..5a7d945 100644 --- a/doc/source/firmware/safety.rst +++ b/doc/source/firmware/safety.rst @@ -13,7 +13,7 @@ On the other hand, fatal errors like an over-temperature error, or memory proble which forces the output zero, but does not allow any further interaction. .. toctree:: - :maxdepth: 2 + :maxdepth: 3 flags backup-ram diff --git a/stm-firmware/Makefile b/stm-firmware/Makefile index 67b2f40..88cab6d 100644 --- a/stm-firmware/Makefile +++ b/stm-firmware/Makefile @@ -46,7 +46,7 @@ CFILES += ui/lcd.c ui/menu.c reflow-menu.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 += stm-periph/crc-unit.c CFILES += safety/safety-adc.c safety/safety-controller.c safety/watchdog.c safety/fault.c safety/safety-memory.c DEBUG_DEFINES = -DDEBUGBUILD diff --git a/stm-firmware/include/reflow-controller/safety/safety-memory.h b/stm-firmware/include/reflow-controller/safety/safety-memory.h index 1f8a43a..cbfacd5 100644 --- a/stm-firmware/include/reflow-controller/safety/safety-memory.h +++ b/stm-firmware/include/reflow-controller/safety/safety-memory.h @@ -52,5 +52,4 @@ struct safety_memory_boot_status { uint32_t code_updated; }; - #endif /* __SAFETY_MEMORY_H__ */ diff --git a/stm-firmware/include/stm-periph/crc-unit.h b/stm-firmware/include/stm-periph/crc-unit.h new file mode 100644 index 0000000..b9b5158 --- /dev/null +++ b/stm-firmware/include/stm-periph/crc-unit.h @@ -0,0 +1,38 @@ +/* Reflow Oven Controller + * + * Copyright (C) 2020 Mario Hüttel + * + * 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. + * + * GDSII-Converter 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 . + */ + +#ifndef __CRC_UNIT_H__ +#define __CRC_UNIT_H__ + +#include + +void crc_unit_init(void); + +void crc_unit_deinit(void); + +void crc_unit_reset(void); + +uint32_t crc_unit_get_crc(void); + +void crc_unit_input(uint32_t data); + +void crc_unit_input_array(const uint32_t *data, uint32_t len); + +#endif /* __CRC_UNIT_H__ */ diff --git a/stm-firmware/stm-periph/crc-unit.c b/stm-firmware/stm-periph/crc-unit.c new file mode 100644 index 0000000..672315b --- /dev/null +++ b/stm-firmware/stm-periph/crc-unit.c @@ -0,0 +1,59 @@ +/* Reflow Oven Controller + * + * Copyright (C) 2020 Mario Hüttel + * + * 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. + * + * GDSII-Converter 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 . + */ + +#include +#include +#include + +void crc_unit_init(void) +{ + rcc_manager_enable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(RCC_AHB1ENR_CRCEN)); + crc_unit_reset(); +} + +void crc_unit_deinit(void) +{ + rcc_manager_disable_clock(&RCC->AHB1ENR, BITMASK_TO_BITNO(RCC_AHB1ENR_CRCEN)); +} + +void crc_unit_reset(void) +{ + CRC->CR = CRC_CR_RESET; +} + +uint32_t crc_unit_get_crc(void) +{ + return CRC->DR; +} + +void crc_unit_input(uint32_t data) +{ + CRC->DR = data; +} + +void crc_unit_input_array(const uint32_t *data, uint32_t len) +{ + uint32_t i; + + if (!data) + return; + for (i = 0; i < len; i++) + crc_unit_input(data[i]); +}