diff options
| author | Süha Ünüvar <[email protected]> | 2025-08-08 23:14:08 +0800 |
|---|---|---|
| committer | Süha Ünüvar <[email protected]> | 2025-08-08 23:14:08 +0800 |
| commit | d5bf29a30308211bb5d415e59d91507e233b6d4a (patch) | |
| tree | bbeb252ecc4f624b059ae30ca4e17c9652c32eb2 /embassy-stm32/src | |
| parent | 8b65101a7cc685c17acebddce87330581107f1ea (diff) | |
stm32 i2c v2: rename freq to frequency
Diffstat (limited to 'embassy-stm32/src')
| -rw-r--r-- | embassy-stm32/src/i2c/v2.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/embassy-stm32/src/i2c/v2.rs b/embassy-stm32/src/i2c/v2.rs index 76f0d25dc..4d341bab1 100644 --- a/embassy-stm32/src/i2c/v2.rs +++ b/embassy-stm32/src/i2c/v2.rs | |||
| @@ -1320,9 +1320,9 @@ struct Timings { | |||
| 1320 | } | 1320 | } |
| 1321 | 1321 | ||
| 1322 | impl Timings { | 1322 | impl Timings { |
| 1323 | fn new(i2cclk: Hertz, freq: Hertz) -> Self { | 1323 | fn new(i2cclk: Hertz, frequency: Hertz) -> Self { |
| 1324 | let i2cclk = i2cclk.0; | 1324 | let i2cclk = i2cclk.0; |
| 1325 | let freq = freq.0; | 1325 | let frequency = frequency.0; |
| 1326 | // Refer to RM0433 Rev 7 Figure 539 for setup and hold timing: | 1326 | // Refer to RM0433 Rev 7 Figure 539 for setup and hold timing: |
| 1327 | // | 1327 | // |
| 1328 | // t_I2CCLK = 1 / PCLK1 | 1328 | // t_I2CCLK = 1 / PCLK1 |
| @@ -1332,13 +1332,13 @@ impl Timings { | |||
| 1332 | // | 1332 | // |
| 1333 | // t_SYNC1 + t_SYNC2 > 4 * t_I2CCLK | 1333 | // t_SYNC1 + t_SYNC2 > 4 * t_I2CCLK |
| 1334 | // t_SCL ~= t_SYNC1 + t_SYNC2 + t_SCLL + t_SCLH | 1334 | // t_SCL ~= t_SYNC1 + t_SYNC2 + t_SCLL + t_SCLH |
| 1335 | let ratio = i2cclk / freq; | 1335 | let ratio = i2cclk / frequency; |
| 1336 | 1336 | ||
| 1337 | // For the standard-mode configuration method, we must have a ratio of 4 | 1337 | // For the standard-mode configuration method, we must have a ratio of 4 |
| 1338 | // or higher | 1338 | // or higher |
| 1339 | assert!(ratio >= 4, "The I2C PCLK must be at least 4 times the bus frequency!"); | 1339 | assert!(ratio >= 4, "The I2C PCLK must be at least 4 times the bus frequency!"); |
| 1340 | 1340 | ||
| 1341 | let (presc_reg, scll, sclh, sdadel, scldel) = if freq > 100_000 { | 1341 | let (presc_reg, scll, sclh, sdadel, scldel) = if frequency > 100_000 { |
| 1342 | // Fast-mode (Fm) or Fast-mode Plus (Fm+) | 1342 | // Fast-mode (Fm) or Fast-mode Plus (Fm+) |
| 1343 | // here we pick SCLL + 1 = 2 * (SCLH + 1) | 1343 | // here we pick SCLL + 1 = 2 * (SCLH + 1) |
| 1344 | 1344 | ||
| @@ -1352,7 +1352,7 @@ impl Timings { | |||
| 1352 | let sclh = ((ratio / presc) - 3) / 3; | 1352 | let sclh = ((ratio / presc) - 3) / 3; |
| 1353 | let scll = (2 * (sclh + 1)) - 1; | 1353 | let scll = (2 * (sclh + 1)) - 1; |
| 1354 | 1354 | ||
| 1355 | let (sdadel, scldel) = if freq > 400_000 { | 1355 | let (sdadel, scldel) = if frequency > 400_000 { |
| 1356 | // Fast-mode Plus (Fm+) | 1356 | // Fast-mode Plus (Fm+) |
| 1357 | assert!(i2cclk >= 17_000_000); // See table in datsheet | 1357 | assert!(i2cclk >= 17_000_000); // See table in datsheet |
| 1358 | 1358 | ||
