diff options
| author | chemicstry <[email protected]> | 2022-10-24 22:48:40 +0300 |
|---|---|---|
| committer | chemicstry <[email protected]> | 2022-10-24 22:48:40 +0300 |
| commit | 52c03cf0a4ae5a7a6374e6acac123670b83860fe (patch) | |
| tree | b76df86eda0fb573fe9ff4743af2c69fdc86e2c6 /examples | |
| parent | ac61e0ee9fcec2792c73806afe4c998019b0db75 (diff) | |
Add more docs
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32f4/src/bin/i2c.rs | 3 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/i2c.rs | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/examples/stm32f4/src/bin/i2c.rs b/examples/stm32f4/src/bin/i2c.rs index 12965d2b8..6e51c211d 100644 --- a/examples/stm32f4/src/bin/i2c.rs +++ b/examples/stm32f4/src/bin/i2c.rs | |||
| @@ -30,6 +30,9 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 30 | Hertz(100_000), | 30 | Hertz(100_000), |
| 31 | Default::default(), | 31 | Default::default(), |
| 32 | ); | 32 | ); |
| 33 | |||
| 34 | // I2C bus can freeze if SCL line is shorted or due to a broken device that clock stretches for too long. | ||
| 35 | // TimeoutI2c allows recovering from such errors by throwing `Error::Timeout` after a given delay. | ||
| 33 | let mut timeout_i2c = TimeoutI2c::new(&mut i2c, Duration::from_millis(1000)); | 36 | let mut timeout_i2c = TimeoutI2c::new(&mut i2c, Duration::from_millis(1000)); |
| 34 | 37 | ||
| 35 | let mut data = [0u8; 1]; | 38 | let mut data = [0u8; 1]; |
diff --git a/examples/stm32h7/src/bin/i2c.rs b/examples/stm32h7/src/bin/i2c.rs index 7a314b996..d44319ae6 100644 --- a/examples/stm32h7/src/bin/i2c.rs +++ b/examples/stm32h7/src/bin/i2c.rs | |||
| @@ -29,6 +29,9 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 29 | Hertz(100_000), | 29 | Hertz(100_000), |
| 30 | Default::default(), | 30 | Default::default(), |
| 31 | ); | 31 | ); |
| 32 | |||
| 33 | // I2C bus can freeze if SCL line is shorted or due to a broken device that clock stretches for too long. | ||
| 34 | // TimeoutI2c allows recovering from such errors by throwing `Error::Timeout` after a given delay. | ||
| 32 | let mut timeout_i2c = TimeoutI2c::new(&mut i2c, Duration::from_millis(1000)); | 35 | let mut timeout_i2c = TimeoutI2c::new(&mut i2c, Duration::from_millis(1000)); |
| 33 | 36 | ||
| 34 | let mut data = [0u8; 1]; | 37 | let mut data = [0u8; 1]; |
