@@ -57,9 +57,13 @@ extern "C" {
5757#if !defined (STM32F1xx ) && !defined (STM32F2xx ) && !defined (STM32F4xx ) && \
5858 !defined (STM32L1xx )
5959#define I2C_TIMING
60+ #if !defined(I2C_TIMING_SM ) || !defined(I2C_TIMING_FM ) || !defined(I2C_TIMING_FMP )
61+ #define I2C_TIMING_COMPUTE
62+ #endif /* !(I2C_TIMING_SM) || !(I2C_TIMING_FM) || !(I2C_TIMING_FMP)*/
63+
6064#endif
6165
62- #ifdef I2C_TIMING
66+ #ifdef I2C_TIMING_COMPUTE
6367#ifndef I2C_VALID_TIMING_NBR
6468#define I2C_VALID_TIMING_NBR 8U
6569#endif
@@ -152,7 +156,7 @@ static const I2C_Charac_t I2C_Charac[] = {
152156 .dnf = I2C_DIGITAL_FILTER_COEF ,
153157 }
154158};
155- #endif /* I2C_TIMING */
159+ #endif /* I2C_TIMING_COMPUTE */
156160
157161/* Family specific description for I2C */
158162typedef enum {
@@ -180,7 +184,7 @@ typedef enum {
180184/* Private Variables */
181185static I2C_HandleTypeDef * i2c_handles [I2C_NUM ];
182186
183- #ifdef I2C_TIMING
187+ #ifdef I2C_TIMING_COMPUTE
184188/**
185189 * @brief This function return the I2C clock source frequency.
186190 * @param i2c: I2C instance
@@ -565,7 +569,7 @@ static uint32_t i2c_computeTiming(uint32_t clkSrcFreq, uint32_t i2c_speed)
565569 }
566570 return ret ;
567571}
568- #endif /* I2C_TIMING */
572+ #endif /* I2C_TIMING_COMPUTE */
569573
570574/**
571575* @brief Compute I2C timing according current I2C clock source and
@@ -587,6 +591,9 @@ static uint32_t i2c_getTiming(i2c_t *obj, uint32_t frequency)
587591 i2c_speed = 1000000 ;
588592 }
589593#ifdef I2C_TIMING
594+ #ifndef I2C_TIMING_COMPUTE
595+ UNUSED (obj );
596+ #endif
590597 if (i2c_speed != 0U ) {
591598 switch (i2c_speed ) {
592599 default :
0 commit comments