Skip to content

Commit

Permalink
Add support to CRC peripheral by default
Browse files Browse the repository at this point in the history
  • Loading branch information
cparata committed May 12, 2022
1 parent 437cbed commit 529a505
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cores/arduino/stm32/stm32yyxx_hal_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
#undef HAL_SAI_MODULE_ENABLED
#endif


#if !defined(HAL_SPI_MODULE_DISABLED)
#define HAL_SPI_MODULE_ENABLED
#else
Expand All @@ -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
*/
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions libraries/SrcWrapper/src/stm32/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions libraries/SrcWrapper/src/stm32/hw_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 529a505

Please sign in to comment.