Skip to content

Commit 8d58f8b

Browse files
kevinong0108Cruz Monrreal II
authored andcommitted
stm32: fix some F0 target compile error
1 parent 995594b commit 8d58f8b

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

targets/TARGET_STM/mbed_crc_api.c

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,29 @@ static uint32_t final_xor;
1010
static uint32_t crc_mask;
1111

1212
/* 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+
+-========================+=======================+===============+===============+
1616
| Reversibility option | NO | YES |
1717
| 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+
*/
2936
bool hal_crc_is_supported(const crc_mbed_config_t *config)
3037
{
3138
if (config == NULL) {
@@ -36,6 +43,10 @@ bool hal_crc_is_supported(const crc_mbed_config_t *config)
3643
/* Currently, mbed supported input data format fix on bytes,
3744
so those devices are not supported at default. */
3845
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;
3950
#else
4051
if (config->width != 32 && config->width != 16 && config->width != 8 && config->width != 7) {
4152
return false;
@@ -59,10 +70,10 @@ void hal_crc_compute_partial_start(const crc_mbed_config_t *config)
5970
crc_mask = get_crc_mask(config->width);
6071

6172
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)
6374
current_state.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES;
64-
current_state.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_DISABLE;
6575
current_state.Init.DefaultInitValueUse = DEFAULT_INIT_VALUE_DISABLE;
76+
current_state.Init.DefaultPolynomialUse = DEFAULT_POLYNOMIAL_DISABLE;
6677
current_state.Init.InitValue = config->initial_xor;
6778
current_state.Init.GeneratingPolynomial = config->polynomial;
6879

@@ -109,7 +120,7 @@ uint32_t hal_crc_get_result(void)
109120
{
110121
uint32_t result = current_state.Instance->DR;
111122

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)
113124
/* The CRC-7 SD needs to shift left by 1 bit after obtaining the result, but the output
114125
* inversion of CRC peripheral will convert the result before shift left by 1 bit, so
115126
* the result seems to have shifted after the conversion.

0 commit comments

Comments
 (0)