Skip to content

fix: allow to disable HAL CRC module #1716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cores/arduino/stm32/stm32yyxx_hal_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
#undef HAL_ADC_MODULE_ENABLED
#endif

#if !defined(HAL_CRC_MODULE_DISABLED)
#define HAL_CRC_MODULE_ENABLED
#else
#undef HAL_CRC_MODULE_ENABLED
#endif

#if !defined(HAL_I2C_MODULE_DISABLED)
#define HAL_I2C_MODULE_ENABLED
#else
Expand Down Expand Up @@ -70,12 +76,6 @@
#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
*/
Expand Down
2 changes: 2 additions & 0 deletions libraries/SrcWrapper/src/stm32/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,14 @@ void configIPClock(void)
__HAL_RCC_SYSCFG_CLK_ENABLE();
#endif

#if defined(HAL_CRC_MODULE_ENABLED)
/* 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
#endif
}

#ifdef __cplusplus
Expand Down
15 changes: 9 additions & 6 deletions libraries/SrcWrapper/src/stm32/hw_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@
extern "C" {
#endif

#ifdef CRC2_BASE
#define CRC_INSTANCE CRC2
#if defined(HAL_CRC_MODULE_ENABLED)
CRC_HandleTypeDef hcrc = {.Instance =
#if defined(CRC2_BASE)
CRC2
#elif defined(CRC_BASE)
#define CRC_INSTANCE CRC
CRC
#else
#error "No CRC instance available"
#error "No CRC instance available!"
#endif
};
#endif
CRC_HandleTypeDef hcrc = {.Instance = CRC_INSTANCE};

/**
* @brief This function performs the global init of the system (HAL, IOs...)
Expand Down Expand Up @@ -63,7 +66,7 @@ void hw_config_init(void)
SystemClock_Config();

/* Initialize the CRC */
#if defined(CRC_INSTANCE)
#if defined(HAL_CRC_MODULE_ENABLED)
HAL_CRC_Init(&hcrc);
#endif

Expand Down