60 lines
1.4 KiB
C
60 lines
1.4 KiB
C
/* 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/rcc-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]);
|
|
}
|