blob: c1a97da8426b2c3791c5cde881e9df554963a641 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef _CRC_HW_H
#define _CRC_HW_H
/* CRC-32 hardware implementation with USB constants */
#include "registers.h"
static inline void crc32_init(void)
{
/* switch on CRC controller */
STM32_RCC_AHBENR |= 1 << 6; /* switch on CRC controller */
/* reset CRC state */
STM32_CRC_CR = STM32_CRC_CR_RESET | STM32_CRC_CR_REV_OUT
| STM32_CRC_CR_REV_IN_WORD;
while (STM32_CRC_CR & 1)
;
}
static inline void crc32_hash32(uint32_t val)
{
STM32_CRC_DR = val;
}
static inline void crc32_hash16(uint16_t val)
{
STM32_CRC_DR16 = val;
}
static inline uint32_t crc32_result(void)
{
return STM32_CRC_DR ^ 0xFFFFFFFF;
}
#endif /* _CRC_HW_H */
|