libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
crc_common_all.h
Go to the documentation of this file.
1/** @addtogroup crc_defines
2
3@author @htmlonly &copy; @endhtmlonly 2010 Thomas Otto <tommi@viadmin.org>
4
5*/
6
7/*
8 * This file is part of the libopencm3 project.
9 *
10 * Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
11 *
12 * This library is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This library is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with this library. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA CRC.H
27The order of header inclusion is important. crc.h includes the device
28specific memorymap.h header before including this header file.*/
29
30#pragma once
31/**@{*/
32
33/*****************************************************************************/
34/* Module definitions */
35/*****************************************************************************/
36
37/*****************************************************************************/
38/* Register definitions */
39/*****************************************************************************/
40
41/**@defgroup crc_registers CRC Registers
42 @{*/
43/** CRC_DR Data register */
44#define CRC_DR MMIO32(CRC_BASE + 0x00)
45
46/** CRC_IDR Independent data register */
47#define CRC_IDR MMIO32(CRC_BASE + 0x04)
48
49/** CRC_CR Control register */
50#define CRC_CR MMIO32(CRC_BASE + 0x08)
51/**@}*/
52
53/*****************************************************************************/
54/* Register values */
55/*****************************************************************************/
56
57/* --- CRC_DR values ------------------------------------------------------- */
58
59/* Bits [31:0]: Data register */
60
61/* --- CRC_IDR values ------------------------------------------------------ */
62
63/* Bits [31:8]: Reserved */
64
65/* Bits [7:0]: General-purpose 8-bit data register bits */
66
67
68/** @defgroup crc_cr_values CRC_CR values
69 @{*/
70/** CRC_CR_RESET reset the CRC peripheral */
71#define CRC_CR_RESET (1 << 0)
72/**@}*/
73
75
76
77/**
78 * Reset the CRC calculator to initial values.
79 */
80void crc_reset(void);
81
82/**
83 * Writes a data word to the register, the write operation stalling until
84 * the computation is complete.
85 * @param[in] data new word to add to the CRC calculator
86 * @returns int32 Computed CRC result
87 */
88uint32_t crc_calculate(uint32_t data);
89
90/**
91 * Add a block of data to the CRC calculator and return the final result.
92 * Writes data words consecutively to the register, the write operation
93 * stalling until the computation of each word is complete, then
94 * returns the final result
95 * @param[in] datap pointer to an array of 32 bit data words.
96 * @param[in] size length of data, in 32bit increments
97 * @return final CRC calculator value
98 */
99uint32_t crc_calculate_block(uint32_t *datap, int size);
100
102
103/**@}*/
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
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.