Skip to content

Commit 0e00a8d

Browse files
committed
fix: allow to disable HAL CRC module
Thanks to @patricklaf comment. Signed-off-by: Frederic Pillon <[email protected]>
1 parent f44e2aa commit 0e00a8d

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

Diff for: cores/arduino/stm32/stm32yyxx_hal_conf.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
#undef HAL_ADC_MODULE_ENABLED
2929
#endif
3030

31+
#if !defined(HAL_CRC_MODULE_DISABLED)
32+
#define HAL_CRC_MODULE_ENABLED
33+
#else
34+
#undef HAL_CRC_MODULE_ENABLED
35+
#endif
36+
3137
#if !defined(HAL_I2C_MODULE_DISABLED)
3238
#define HAL_I2C_MODULE_ENABLED
3339
#else
@@ -70,12 +76,6 @@
7076
#undef HAL_ICACHE_MODULE_ENABLED
7177
#endif
7278

73-
#if !defined(HAL_CRC_MODULE_ENABLED)
74-
#define HAL_CRC_MODULE_ENABLED
75-
#else
76-
#undef HAL_CRC_MODULE_ENABLED
77-
#endif
78-
7979
/*
8080
* Not defined by default
8181
*/

Diff for: libraries/SrcWrapper/src/stm32/clock.c

+2
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,14 @@ void configIPClock(void)
174174
__HAL_RCC_SYSCFG_CLK_ENABLE();
175175
#endif
176176

177+
#if defined(HAL_CRC_MODULE_ENABLED)
177178
/* Enable CRC clock, needed for example: MotionFX Library ... */
178179
#if defined(__HAL_RCC_CRC2_CLK_ENABLE)
179180
__HAL_RCC_CRC2_CLK_ENABLE();
180181
#elif defined(__HAL_RCC_CRC_CLK_ENABLE)
181182
__HAL_RCC_CRC_CLK_ENABLE();
182183
#endif
184+
#endif
183185
}
184186

185187
#ifdef __cplusplus

Diff for: libraries/SrcWrapper/src/stm32/hw_config.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@
1919
extern "C" {
2020
#endif
2121

22-
#ifdef CRC2_BASE
23-
#define CRC_INSTANCE CRC2
22+
#if defined(HAL_CRC_MODULE_ENABLED)
23+
CRC_HandleTypeDef hcrc = {.Instance =
24+
#if defined(CRC2_BASE)
25+
CRC2
2426
#elif defined(CRC_BASE)
25-
#define CRC_INSTANCE CRC
27+
CRC
2628
#else
27-
#error "No CRC instance available"
29+
#error "No CRC instance available!"
30+
#endif
31+
};
2832
#endif
29-
CRC_HandleTypeDef hcrc = {.Instance = CRC_INSTANCE};
3033

3134
/**
3235
* @brief This function performs the global init of the system (HAL, IOs...)
@@ -63,7 +66,7 @@ void hw_config_init(void)
6366
SystemClock_Config();
6467

6568
/* Initialize the CRC */
66-
#if defined(CRC_INSTANCE)
69+
#if defined(HAL_CRC_MODULE_ENABLED)
6770
HAL_CRC_Init(&hcrc);
6871
#endif
6972

0 commit comments

Comments
 (0)