aboutsummaryrefslogtreecommitdiff
path: root/examples/rp/src/bin/i2c_async.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2023-05-15 15:59:30 +0000
committerGitHub <[email protected]>2023-05-15 15:59:30 +0000
commit1a87f7477abdb033d960a6af63c95a9e0575e670 (patch)
tree0523c59fe3ef2bd406d44ab414f2903c68a918b9 /examples/rp/src/bin/i2c_async.rs
parent2bf2e54db925e1d8845deb5eaea737b6add95402 (diff)
parent14a5d03af2a74eccaa9930bdf81eef43791a4b33 (diff)
Merge #1458
1458: rp: remove take!, add bind_interrupts! r=Dirbaio a=pennae both of the uart interrupts now check a flag that only the dma rx path ever sets (and now unsets again on drop) to return early if it's not as they expect. this is ... not our preferred solution, but if bind_interrupts *must* allow mutiple handlers to be specified then this is the only way we can think of that doesn't break uarts. Co-authored-by: pennae <[email protected]>
Diffstat (limited to 'examples/rp/src/bin/i2c_async.rs')
-rw-r--r--examples/rp/src/bin/i2c_async.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/rp/src/bin/i2c_async.rs b/examples/rp/src/bin/i2c_async.rs
index d1a2e3cd7..cf3cf742c 100644
--- a/examples/rp/src/bin/i2c_async.rs
+++ b/examples/rp/src/bin/i2c_async.rs
@@ -4,12 +4,17 @@
4 4
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_rp::i2c::{self, Config}; 7use embassy_rp::bind_interrupts;
8use embassy_rp::interrupt; 8use embassy_rp::i2c::{self, Config, InterruptHandler};
9use embassy_rp::peripherals::I2C1;
9use embassy_time::{Duration, Timer}; 10use embassy_time::{Duration, Timer};
10use embedded_hal_async::i2c::I2c; 11use embedded_hal_async::i2c::I2c;
11use {defmt_rtt as _, panic_probe as _}; 12use {defmt_rtt as _, panic_probe as _};
12 13
14bind_interrupts!(struct Irqs {
15 I2C1_IRQ => InterruptHandler<I2C1>;
16});
17
13#[allow(dead_code)] 18#[allow(dead_code)]
14mod mcp23017 { 19mod mcp23017 {
15 pub const ADDR: u8 = 0x20; // default addr 20 pub const ADDR: u8 = 0x20; // default addr
@@ -64,10 +69,9 @@ async fn main(_spawner: Spawner) {
64 69
65 let sda = p.PIN_14; 70 let sda = p.PIN_14;
66 let scl = p.PIN_15; 71 let scl = p.PIN_15;
67 let irq = interrupt::take!(I2C1_IRQ);
68 72
69 info!("set up i2c "); 73 info!("set up i2c ");
70 let mut i2c = i2c::I2c::new_async(p.I2C1, scl, sda, irq, Config::default()); 74 let mut i2c = i2c::I2c::new_async(p.I2C1, scl, sda, Irqs, Config::default());
71 75
72 use mcp23017::*; 76 use mcp23017::*;
73 77