Skip to content

fix(i2c): prevent unused variable and functions #2253

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
Jan 16, 2024
Merged
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
15 changes: 11 additions & 4 deletions libraries/Wire/src/utility/twi.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ extern "C" {
#if !defined (STM32F1xx) && !defined (STM32F2xx) && !defined (STM32F4xx) &&\
!defined (STM32L1xx)
#define I2C_TIMING
#if !defined(I2C_TIMING_SM) || !defined(I2C_TIMING_FM) || !defined(I2C_TIMING_FMP)
#define I2C_TIMING_COMPUTE
#endif /* !(I2C_TIMING_SM) || !(I2C_TIMING_FM) || !(I2C_TIMING_FMP)*/

#endif

#ifdef I2C_TIMING
#ifdef I2C_TIMING_COMPUTE
#ifndef I2C_VALID_TIMING_NBR
#define I2C_VALID_TIMING_NBR 8U
#endif
Expand Down Expand Up @@ -152,7 +156,7 @@ static const I2C_Charac_t I2C_Charac[] = {
.dnf = I2C_DIGITAL_FILTER_COEF,
}
};
#endif /* I2C_TIMING */
#endif /* I2C_TIMING_COMPUTE */

/* Family specific description for I2C */
typedef enum {
Expand Down Expand Up @@ -180,7 +184,7 @@ typedef enum {
/* Private Variables */
static I2C_HandleTypeDef *i2c_handles[I2C_NUM];

#ifdef I2C_TIMING
#ifdef I2C_TIMING_COMPUTE
/**
* @brief This function return the I2C clock source frequency.
* @param i2c: I2C instance
Expand Down Expand Up @@ -565,7 +569,7 @@ static uint32_t i2c_computeTiming(uint32_t clkSrcFreq, uint32_t i2c_speed)
}
return ret;
}
#endif /* I2C_TIMING */
#endif /* I2C_TIMING_COMPUTE */

/**
* @brief Compute I2C timing according current I2C clock source and
Expand All @@ -587,6 +591,9 @@ static uint32_t i2c_getTiming(i2c_t *obj, uint32_t frequency)
i2c_speed = 1000000;
}
#ifdef I2C_TIMING
#ifndef I2C_TIMING_COMPUTE
UNUSED(obj);
#endif
if (i2c_speed != 0U) {
switch (i2c_speed) {
default:
Expand Down