diff options
Diffstat (limited to 'examples/mspm0l1306/src')
| -rw-r--r-- | examples/mspm0l1306/src/bin/i2c.rs | 3 | ||||
| -rw-r--r-- | examples/mspm0l1306/src/bin/i2c_async.rs | 8 |
2 files changed, 6 insertions, 5 deletions
diff --git a/examples/mspm0l1306/src/bin/i2c.rs b/examples/mspm0l1306/src/bin/i2c.rs index cf65206b2..51327dff5 100644 --- a/examples/mspm0l1306/src/bin/i2c.rs +++ b/examples/mspm0l1306/src/bin/i2c.rs | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | //! Example of using blocking I2C | 1 | //! This example uses FIFO with polling, and the maximum FIFO size is 8. |
| 2 | //! Refer to async example to handle larger packets. | ||
| 2 | //! | 3 | //! |
| 3 | //! This uses the virtual COM port provided on the LP-MSPM0L1306 board. | 4 | //! This uses the virtual COM port provided on the LP-MSPM0L1306 board. |
| 4 | 5 | ||
diff --git a/examples/mspm0l1306/src/bin/i2c_async.rs b/examples/mspm0l1306/src/bin/i2c_async.rs index a54beebe5..74826bcc4 100644 --- a/examples/mspm0l1306/src/bin/i2c_async.rs +++ b/examples/mspm0l1306/src/bin/i2c_async.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | //! Example of using async I2C | 1 | //! The example uses FIFO and interrupts, wrapped in async API. |
| 2 | //! | 2 | //! |
| 3 | //! This uses the virtual COM port provided on the LP-MSPM0L1306 board. | 3 | //! This uses the virtual COM port provided on the LP-MSPM0L1306 board. |
| 4 | 4 | ||
| @@ -28,10 +28,10 @@ async fn main(_spawner: Spawner) -> ! { | |||
| 28 | 28 | ||
| 29 | let mut i2c = unwrap!(I2c::new_async(instance, scl, sda, Irqs, Config::default())); | 29 | let mut i2c = unwrap!(I2c::new_async(instance, scl, sda, Irqs, Config::default())); |
| 30 | 30 | ||
| 31 | let mut to_read = [0u8; 1]; | 31 | let mut to_read = [1u8; 17]; |
| 32 | let to_write: u8 = 0x0F; | 32 | let to_write = [0u8; 17]; |
| 33 | 33 | ||
| 34 | match i2c.async_write_read(ADDRESS, &[to_write], &mut to_read).await { | 34 | match i2c.async_write_read(ADDRESS, &to_write, &mut to_read).await { |
| 35 | Ok(()) => info!("Register {}: {}", to_write, to_read[0]), | 35 | Ok(()) => info!("Register {}: {}", to_write, to_read[0]), |
| 36 | Err(e) => error!("I2c Error: {:?}", e), | 36 | Err(e) => error!("I2c Error: {:?}", e), |
| 37 | } | 37 | } |
