Issue #18: Implement CRC calculation module
This commit is contained in:
parent
928dbfb9f3
commit
04008a07c0
@ -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.
|
which forces the output zero, but does not allow any further interaction.
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 3
|
||||||
|
|
||||||
flags
|
flags
|
||||||
backup-ram
|
backup-ram
|
||||||
|
@ -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 += 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 += pid-controller.c oven-driver.c
|
||||||
CFILES += settings/settings.c settings/settings-sd-card.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
|
CFILES += safety/safety-adc.c safety/safety-controller.c safety/watchdog.c safety/fault.c safety/safety-memory.c
|
||||||
|
|
||||||
DEBUG_DEFINES = -DDEBUGBUILD
|
DEBUG_DEFINES = -DDEBUGBUILD
|
||||||
|
@ -52,5 +52,4 @@ struct safety_memory_boot_status {
|
|||||||
uint32_t code_updated;
|
uint32_t code_updated;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* __SAFETY_MEMORY_H__ */
|
#endif /* __SAFETY_MEMORY_H__ */
|
||||||
|
38
stm-firmware/include/stm-periph/crc-unit.h
Normal file
38
stm-firmware/include/stm-periph/crc-unit.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/* 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.
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __CRC_UNIT_H__
|
||||||
|
#define __CRC_UNIT_H__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
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__ */
|
59
stm-firmware/stm-periph/crc-unit.c
Normal file
59
stm-firmware/stm-periph/crc-unit.c
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/* 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.
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stm-periph/crc-unit.h>
|
||||||
|
#include <stm-periph/clock-enable-manager.h>
|
||||||
|
#include <stm32/stm32f4xx.h>
|
||||||
|
|
||||||
|
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]);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user