Skip to content

Commit 1863c25

Browse files
committed
fix(i2c): prevent unused variable and functions
when all I2C timings are defined Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 8f3eac4 commit 1863c25

File tree

1 file changed

+11
-4
lines changed
  • libraries/Wire/src/utility

1 file changed

+11
-4
lines changed

libraries/Wire/src/utility/twi.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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 */
158162
typedef enum {
@@ -180,7 +184,7 @@ typedef enum {
180184
/* Private Variables */
181185
static 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

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy