libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
crc_common_all.c
Go to the documentation of this file.
1/** @addtogroup crc_file CRC peripheral API
2@ingroup peripheral_apis
3
4@author @htmlonly &copy; @endhtmlonly 2012 Karl Palsson <karlp@remake.is>
5
6*/
7
8/*
9 * This file is part of the libopencm3 project.
10 *
11 * Copyright (C) 2012 Karl Palsson <karlp@remake.is>
12 *
13 * This library is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU Lesser General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License for more details.
22 *
23 * You should have received a copy of the GNU Lesser General Public License
24 * along with this library. If not, see <http://www.gnu.org/licenses/>.
25 */
26
28
29/**@{*/
30
31void crc_reset(void)
32{
34}
35
36uint32_t crc_calculate(uint32_t data)
37{
38 CRC_DR = data;
39 /* Data sheet says this blocks until it's ready.... */
40 return CRC_DR;
41}
42
43uint32_t crc_calculate_block(uint32_t *datap, int size)
44{
45 int i;
46
47 for (i = 0; i < size; i++) {
48 CRC_DR = datap[i];
49 }
50
51 return CRC_DR;
52}
53/**@}*/
54
#define CRC_CR_RESET
CRC_CR_RESET reset the CRC peripheral.
uint32_t crc_calculate_block(uint32_t *datap, int size)
Add a block of data to the CRC calculator and return the final result.
void crc_reset(void)
Reset the CRC calculator to initial values.
uint32_t crc_calculate(uint32_t data)
Writes a data word to the register, the write operation stalling until the computation is complete.
#define CRC_CR
CRC_CR Control register.
#define CRC_DR
CRC_DR Data register.