diff --git a/cores/arduino/stm32/stm32yyxx_hal_conf.h b/cores/arduino/stm32/stm32yyxx_hal_conf.h index b469baa643..b3473bdefa 100644 --- a/cores/arduino/stm32/stm32yyxx_hal_conf.h +++ b/cores/arduino/stm32/stm32yyxx_hal_conf.h @@ -52,7 +52,6 @@ #undef HAL_SAI_MODULE_ENABLED #endif - #if !defined(HAL_SPI_MODULE_DISABLED) #define HAL_SPI_MODULE_ENABLED #else @@ -71,6 +70,12 @@ #undef HAL_ICACHE_MODULE_ENABLED #endif +#if !defined(HAL_CRC_MODULE_ENABLED) + #define HAL_CRC_MODULE_ENABLED +#else + #undef HAL_CRC_MODULE_ENABLED +#endif + /* * Not defined by default */ @@ -127,7 +132,6 @@ HAL_CEC_MODULE_ENABLED HAL_COMP_MODULE_ENABLED HAL_CORDIC_MODULE_ENABLED - HAL_CRC_MODULE_ENABLED HAL_CRYP_MODULE_ENABLED HAL_DCMI_MODULE_ENABLED HAL_DFSDM_MODULE_ENABLED diff --git a/libraries/SrcWrapper/src/stm32/clock.c b/libraries/SrcWrapper/src/stm32/clock.c index 8e3029f761..500cad05a6 100644 --- a/libraries/SrcWrapper/src/stm32/clock.c +++ b/libraries/SrcWrapper/src/stm32/clock.c @@ -173,6 +173,13 @@ void configIPClock(void) /* Enable SYSCFG clock, needed for example: Pin remap or Analog switch ... */ __HAL_RCC_SYSCFG_CLK_ENABLE(); #endif + + /* Enable CRC clock, needed for example: MotionFX Library ... */ +#if defined(__HAL_RCC_CRC2_CLK_ENABLE) + __HAL_RCC_CRC2_CLK_ENABLE(); +#elif defined(__HAL_RCC_CRC_CLK_ENABLE) + __HAL_RCC_CRC_CLK_ENABLE(); +#endif } #ifdef __cplusplus diff --git a/libraries/SrcWrapper/src/stm32/hw_config.c b/libraries/SrcWrapper/src/stm32/hw_config.c index 2f630839f4..889d124719 100644 --- a/libraries/SrcWrapper/src/stm32/hw_config.c +++ b/libraries/SrcWrapper/src/stm32/hw_config.c @@ -19,6 +19,15 @@ extern "C" { #endif +#ifdef CRC2_BASE +#define CRC_INSTANCE CRC2 +#elif defined(CRC_BASE) +#define CRC_INSTANCE CRC +#else +#error "No CRC instance available" +#endif +CRC_HandleTypeDef hcrc = {.Instance = CRC_INSTANCE}; + /** * @brief This function performs the global init of the system (HAL, IOs...) * @param None @@ -53,6 +62,11 @@ void hw_config_init(void) /* Configure the system clock */ SystemClock_Config(); + /* Initialize the CRC */ +#if defined(CRC_INSTANCE) + HAL_CRC_Init(&hcrc); +#endif + #if defined (USBCON) && defined(USBD_USE_CDC) USBD_CDC_init(); #endif