libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
crc_v2.h
Go to the documentation of this file.
1/** @addtogroup crc_defines
2
3 @author @htmlonly &copy; @endhtmlonly 2016 Cem Basoglu <cem.basoglu@web.de>
4
5 */
6
7/*
8 * This file is part of the libopencm3 project.
9 *
10 * Copyright (C) 2016 Cem Basoglu <cem.basoglu@web.de>
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
27 The order of header inclusion is important. crc.h includes the device
28 specific memorymap.h header before including this header file.*/
29
30#pragma once
31
32/**@{*/
33
35
36/*****************************************************************************/
37/* Module definitions */
38/*****************************************************************************/
39
40/*****************************************************************************/
41/* Register definitions */
42/*****************************************************************************/
43
44/** @addtogroup crc_registers CRC Registers
45@{*/
46/** CRC_DR Data register 8bit wide access */
47#define CRC_DR8 MMIO8(CRC_BASE + 0x00)
48/** CRC_DR Data register 16bit wide access */
49#define CRC_DR16 MMIO16(CRC_BASE + 0x00)
50
51/** CRC_INIT Initial CRC Value */
52#define CRC_INIT MMIO32(CRC_BASE + 0x10)
53
54/** CRC_POL CRC Polynomial */
55#define CRC_POL MMIO32(CRC_BASE + 0x14)
56/**@}*/
57
58/*****************************************************************************/
59/* Register values */
60/*****************************************************************************/
61/** @addtogroup crc_cr_values CRC_CR values
62 @{*/
63#define CRC_CR_REV_OUT (1 << 7)
64
65#define CRC_CR_REV_IN_SHIFT 5
66#define CRC_CR_REV_IN (3 << CRC_CR_REV_IN_SHIFT)
67/** @defgroup crc_rev_in CRC Reverse input options
68 @{*/
69#define CRC_CR_REV_IN_NONE (0 << CRC_CR_REV_IN_SHIFT)
70#define CRC_CR_REV_IN_BYTE (1 << CRC_CR_REV_IN_SHIFT)
71#define CRC_CR_REV_IN_HALF (2 << CRC_CR_REV_IN_SHIFT)
72#define CRC_CR_REV_IN_WORD (3 << CRC_CR_REV_IN_SHIFT)
73/**@}*/
74
75#define CRC_CR_POLYSIZE_SHIFT 3
76#define CRC_CR_POLYSIZE (3 << CRC_CR_POLYSIZE_SHIFT)
77/**
78 * @defgroup crc_polysize CRC Polynomial size
79 * @{
80 */
81#define CRC_CR_POLYSIZE_32 (0 << CRC_CR_POLYSIZE_SHIFT)
82#define CRC_CR_POLYSIZE_16 (1 << CRC_CR_POLYSIZE_SHIFT)
83#define CRC_CR_POLYSIZE_8 (2 << CRC_CR_POLYSIZE_SHIFT)
84#define CRC_CR_POLYSIZE_7 (3 << CRC_CR_POLYSIZE_SHIFT)
85/**@}*/
86
87/**@}*/
88
89/** Default polynomial */
90#define CRC_POL_DEFAULT 0x04C11DB7
91
92
94
97
98void crc_set_reverse_input(uint32_t reverse_in);
99void crc_set_polysize(uint32_t polysize);
100
101void crc_set_polynomial(uint32_t polynomial);
102void crc_set_initial(uint32_t initial);
103
105
106/**@}*/
107
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
void crc_reverse_output_enable(void)
void crc_set_polynomial(uint32_t polynomial)
void crc_reverse_output_disable(void)
void crc_set_initial(uint32_t initial)
void crc_set_polysize(uint32_t polysize)
void crc_set_reverse_input(uint32_t reverse_in)