@@ -10,22 +10,29 @@ static uint32_t final_xor;
10
10
static uint32_t crc_mask ;
11
11
12
12
/* STM32 CRC preipheral features
13
- +-------------------------+-----------------------+---------------- ---------------+
14
- | Feature | F1/L1/F2/F4 series | F0/ L0/F3/L4/F7/H7 or newer |
15
- +-========================+=======================+================ ===============+
13
+ +-------------------------+-----------------------+---------------+ ---------------+
14
+ | Feature | F1/L1/F2/F4 series | F0 series (#1)| L0/F3/L4/F7 |
15
+ +-========================+=======================+===============+ ===============+
16
16
| Reversibility option | NO | YES |
17
17
| on I/O data | | |
18
- +-------------------------+-----------------------+-------------------------------+
19
- | CRC initial Value | Fixed to 0xFFFFFFFF | Programmable on 8, 16, 32 |
20
- | | | bits |
21
- +-------------------------+-----------------------+-------------------------------+
22
- | Handled data size in bit| 32 | 8, 16, 32 |
23
- +-------------------------+-----------------------+-------------------------------+
24
- | Polynomial size in bit | 32 | 7, 8, 16, 32 |
25
- +-------------------------+-----------------------+-------------------------------+
26
- | Polynomial coefficients | Fixed to 0x4C11DB7 | Programmable |
27
- +-------------------------+-----------------------+-------------------------------+
28
- */
18
+ +-------------------------+-----------------------+---------------+---------------+
19
+ | CRC initial Value | Fixed to 0xFFFFFFFF | Programmable | Programmable |
20
+ | | | on 32 bits | on 8,16,32 |
21
+ +-------------------------+-----------------------+---------------+---------------+
22
+ | Handled data size in bit| 32 | 8,16,32 |
23
+ +-------------------------+---------------------------------------+---------------+
24
+ | Polynomial size in bit | 32 | 7,8,16,32 |
25
+ +-------------------------+---------------------------------------+---------------+
26
+ | Polynomial coefficients | Fixed to 0x4C11DB7 | Programmable |
27
+ +-------------------------+---------------------------------------+---------------+
28
+
29
+ #1 The STM32F0 series which supported polynomial in 7, 8, 16, 32 bits as below list:
30
+ STM32F071xB
31
+ STM32F072xB
32
+ STM32F078xx
33
+ STM32F091xC
34
+ STM32F098xx
35
+ */
29
36
bool hal_crc_is_supported (const crc_mbed_config_t * config )
30
37
{
31
38
if (config == NULL ) {
@@ -36,6 +43,10 @@ bool hal_crc_is_supported(const crc_mbed_config_t *config)
36
43
/* Currently, mbed supported input data format fix on bytes,
37
44
so those devices are not supported at default. */
38
45
return false;
46
+ #elif !defined(CRC_POLYLENGTH_7B )
47
+ /* Some targets are not support polynomial in 7, 8, 16 bits, ex. STMF070RB,
48
+ so those devices are not supported at default. */
49
+ return false;
39
50
#else
40
51
if (config -> width != 32 && config -> width != 16 && config -> width != 8 && config -> width != 7 ) {
41
52
return false;
@@ -59,10 +70,10 @@ void hal_crc_compute_partial_start(const crc_mbed_config_t *config)
59
70
crc_mask = get_crc_mask (config -> width );
60
71
61
72
current_state .Instance = CRC ;
62
- #if !defined(TARGET_STM32F1 ) && !defined(TARGET_STM32F2 ) && !defined(TARGET_STM32F4 ) && !defined(TARGET_STM32L1 )
73
+ #if !defined(TARGET_STM32F1 ) && !defined(TARGET_STM32F2 ) && !defined(TARGET_STM32F4 ) && !defined(TARGET_STM32L1 ) && defined( CRC_POLYLENGTH_7B )
63
74
current_state .InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES ;
64
- current_state .Init .DefaultPolynomialUse = DEFAULT_POLYNOMIAL_DISABLE ;
65
75
current_state .Init .DefaultInitValueUse = DEFAULT_INIT_VALUE_DISABLE ;
76
+ current_state .Init .DefaultPolynomialUse = DEFAULT_POLYNOMIAL_DISABLE ;
66
77
current_state .Init .InitValue = config -> initial_xor ;
67
78
current_state .Init .GeneratingPolynomial = config -> polynomial ;
68
79
@@ -109,7 +120,7 @@ uint32_t hal_crc_get_result(void)
109
120
{
110
121
uint32_t result = current_state .Instance -> DR ;
111
122
112
- #if !defined(TARGET_STM32F1 ) && !defined(TARGET_STM32F2 ) && !defined(TARGET_STM32F4 ) && !defined(TARGET_STM32L1 )
123
+ #if !defined(TARGET_STM32F1 ) && !defined(TARGET_STM32F2 ) && !defined(TARGET_STM32F4 ) && !defined(TARGET_STM32L1 ) && defined( CRC_POLYLENGTH_7B )
113
124
/* The CRC-7 SD needs to shift left by 1 bit after obtaining the result, but the output
114
125
* inversion of CRC peripheral will convert the result before shift left by 1 bit, so
115
126
* the result seems to have shifted after the conversion.
0 commit comments