aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-rp/src/i2c.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/embassy-rp/src/i2c.rs b/embassy-rp/src/i2c.rs
index 68cfc653e..b9e4382c7 100644
--- a/embassy-rp/src/i2c.rs
+++ b/embassy-rp/src/i2c.rs
@@ -70,7 +70,7 @@ impl<'d, T: Instance> I2c<'d, T, Blocking> {
70 } 70 }
71} 71}
72 72
73static I2C_WAKER: AtomicWaker = AtomicWaker::new(); 73static I2C_WAKER: [AtomicWaker; 2] = [AtomicWaker::new(), AtomicWaker::new()];
74 74
75impl<'d, T: Instance> I2c<'d, T, Async> { 75impl<'d, T: Instance> I2c<'d, T, Async> {
76 pub fn new_async( 76 pub fn new_async(
@@ -109,7 +109,7 @@ impl<'d, T: Instance> I2c<'d, T, Async> {
109 let r = f(self); 109 let r = f(self);
110 110
111 if r.is_pending() { 111 if r.is_pending() {
112 I2C_WAKER.register(cx.waker()); 112 I2C_WAKER[T::IDX].register(cx.waker());
113 g(self); 113 g(self);
114 } 114 }
115 r 115 r
@@ -122,7 +122,7 @@ impl<'d, T: Instance> I2c<'d, T, Async> {
122 let i2c = T::regs(); 122 let i2c = T::regs();
123 i2c.ic_intr_mask().write_value(pac::i2c::regs::IcIntrMask::default()); 123 i2c.ic_intr_mask().write_value(pac::i2c::regs::IcIntrMask::default());
124 124
125 I2C_WAKER.wake(); 125 I2C_WAKER[T::IDX].wake();
126 } 126 }
127 127
128 async fn read_async_internal(&mut self, buffer: &mut [u8], restart: bool, send_stop: bool) -> Result<(), Error> { 128 async fn read_async_internal(&mut self, buffer: &mut [u8], restart: bool, send_stop: bool) -> Result<(), Error> {
@@ -813,6 +813,7 @@ mod sealed {
813 pub trait Instance { 813 pub trait Instance {
814 const TX_DREQ: u8; 814 const TX_DREQ: u8;
815 const RX_DREQ: u8; 815 const RX_DREQ: u8;
816 const IDX: usize;
816 817
817 type Interrupt: Interrupt; 818 type Interrupt: Interrupt;
818 819
@@ -844,10 +845,11 @@ impl_mode!(Async);
844pub trait Instance: sealed::Instance {} 845pub trait Instance: sealed::Instance {}
845 846
846macro_rules! impl_instance { 847macro_rules! impl_instance {
847 ($type:ident, $irq:ident, $reset:ident, $tx_dreq:expr, $rx_dreq:expr) => { 848 ($type:ident, $idx:expr, $irq:ident, $reset:ident, $tx_dreq:expr, $rx_dreq:expr) => {
848 impl sealed::Instance for peripherals::$type { 849 impl sealed::Instance for peripherals::$type {
849 const TX_DREQ: u8 = $tx_dreq; 850 const TX_DREQ: u8 = $tx_dreq;
850 const RX_DREQ: u8 = $rx_dreq; 851 const RX_DREQ: u8 = $rx_dreq;
852 const IDX: usize = $idx;
851 853
852 type Interrupt = crate::interrupt::$irq; 854 type Interrupt = crate::interrupt::$irq;
853 855
@@ -867,8 +869,8 @@ macro_rules! impl_instance {
867 }; 869 };
868} 870}
869 871
870impl_instance!(I2C0, I2C0_IRQ, set_i2c0, 32, 33); 872impl_instance!(I2C0, 0, I2C0_IRQ, set_i2c0, 32, 33);
871impl_instance!(I2C1, I2C1_IRQ, set_i2c1, 34, 35); 873impl_instance!(I2C1, 1, I2C1_IRQ, set_i2c1, 34, 35);
872 874
873pub trait SdaPin<T: Instance>: sealed::SdaPin<T> + crate::gpio::Pin {} 875pub trait SdaPin<T: Instance>: sealed::SdaPin<T> + crate::gpio::Pin {}
874pub trait SclPin<T: Instance>: sealed::SclPin<T> + crate::gpio::Pin {} 876pub trait SclPin<T: Instance>: sealed::SclPin<T> + crate::gpio::Pin {}