It is not necessary to enable interrupts before registering waker
This commit is contained in:
parent
2e2986c67b
commit
b299266cd2
1 changed files with 7 additions and 21 deletions
|
@ -489,7 +489,6 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
||||||
|
|
||||||
if frame.send_start() {
|
if frame.send_start() {
|
||||||
// Send a START condition
|
// Send a START condition
|
||||||
Self::enable_interrupts();
|
|
||||||
T::regs().cr1().modify(|reg| {
|
T::regs().cr1().modify(|reg| {
|
||||||
reg.set_start(true);
|
reg.set_start(true);
|
||||||
});
|
});
|
||||||
|
@ -504,8 +503,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
||||||
if sr1.start() {
|
if sr1.start() {
|
||||||
Poll::Ready(Ok(()))
|
Poll::Ready(Ok(()))
|
||||||
} else {
|
} else {
|
||||||
// If we need to go around, then re-enable the interrupts, otherwise nothing
|
// When pending, (re-)enable interrupts to wake us up.
|
||||||
// can wake us up and we'll hang.
|
|
||||||
Self::enable_interrupts();
|
Self::enable_interrupts();
|
||||||
Poll::Pending
|
Poll::Pending
|
||||||
}
|
}
|
||||||
|
@ -520,7 +518,6 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up current address, we're trying to talk to
|
// Set up current address, we're trying to talk to
|
||||||
Self::enable_interrupts();
|
|
||||||
T::regs().dr().write(|reg| reg.set_dr(address << 1));
|
T::regs().dr().write(|reg| reg.set_dr(address << 1));
|
||||||
|
|
||||||
// Wait for the address to be acknowledged
|
// Wait for the address to be acknowledged
|
||||||
|
@ -533,8 +530,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
||||||
if sr1.addr() {
|
if sr1.addr() {
|
||||||
Poll::Ready(Ok(()))
|
Poll::Ready(Ok(()))
|
||||||
} else {
|
} else {
|
||||||
// If we need to go around, then re-enable the interrupts, otherwise nothing
|
// When pending, (re-)enable interrupts to wake us up.
|
||||||
// can wake us up and we'll hang.
|
|
||||||
Self::enable_interrupts();
|
Self::enable_interrupts();
|
||||||
Poll::Pending
|
Poll::Pending
|
||||||
}
|
}
|
||||||
|
@ -548,7 +544,6 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for bytes to be sent, or an error to occur.
|
// Wait for bytes to be sent, or an error to occur.
|
||||||
Self::enable_interrupts();
|
|
||||||
let poll_error = poll_fn(|cx| {
|
let poll_error = poll_fn(|cx| {
|
||||||
state.waker.register(cx.waker());
|
state.waker.register(cx.waker());
|
||||||
|
|
||||||
|
@ -557,8 +552,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
||||||
// identical poll_fn check_and_clear matches.
|
// identical poll_fn check_and_clear matches.
|
||||||
Err(e) => Poll::Ready(Err::<T, Error>(e)),
|
Err(e) => Poll::Ready(Err::<T, Error>(e)),
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
// If we need to go around, then re-enable the interrupts, otherwise nothing
|
// When pending, (re-)enable interrupts to wake us up.
|
||||||
// can wake us up and we'll hang.
|
|
||||||
Self::enable_interrupts();
|
Self::enable_interrupts();
|
||||||
Poll::Pending
|
Poll::Pending
|
||||||
}
|
}
|
||||||
|
@ -580,7 +574,6 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
||||||
|
|
||||||
// 18.3.8 “Master transmitter: In the interrupt routine after the EOT interrupt, disable DMA
|
// 18.3.8 “Master transmitter: In the interrupt routine after the EOT interrupt, disable DMA
|
||||||
// requests then wait for a BTF event before programming the Stop condition.”
|
// requests then wait for a BTF event before programming the Stop condition.”
|
||||||
Self::enable_interrupts();
|
|
||||||
poll_fn(|cx| {
|
poll_fn(|cx| {
|
||||||
state.waker.register(cx.waker());
|
state.waker.register(cx.waker());
|
||||||
|
|
||||||
|
@ -590,8 +583,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
||||||
if sr1.btf() {
|
if sr1.btf() {
|
||||||
Poll::Ready(Ok(()))
|
Poll::Ready(Ok(()))
|
||||||
} else {
|
} else {
|
||||||
// If we need to go around, then re-enable the interrupts, otherwise nothing
|
// When pending, (re-)enable interrupts to wake us up.
|
||||||
// can wake us up and we'll hang.
|
|
||||||
Self::enable_interrupts();
|
Self::enable_interrupts();
|
||||||
Poll::Pending
|
Poll::Pending
|
||||||
}
|
}
|
||||||
|
@ -672,7 +664,6 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
||||||
|
|
||||||
if frame.send_start() {
|
if frame.send_start() {
|
||||||
// Send a START condition and set ACK bit
|
// Send a START condition and set ACK bit
|
||||||
Self::enable_interrupts();
|
|
||||||
T::regs().cr1().modify(|reg| {
|
T::regs().cr1().modify(|reg| {
|
||||||
reg.set_start(true);
|
reg.set_start(true);
|
||||||
reg.set_ack(true);
|
reg.set_ack(true);
|
||||||
|
@ -688,8 +679,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
||||||
if sr1.start() {
|
if sr1.start() {
|
||||||
Poll::Ready(Ok(()))
|
Poll::Ready(Ok(()))
|
||||||
} else {
|
} else {
|
||||||
// If we need to go around, then re-enable the interrupts, otherwise nothing
|
// When pending, (re-)enable interrupts to wake us up.
|
||||||
// can wake us up and we'll hang.
|
|
||||||
Self::enable_interrupts();
|
Self::enable_interrupts();
|
||||||
Poll::Pending
|
Poll::Pending
|
||||||
}
|
}
|
||||||
|
@ -704,7 +694,6 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up current address, we're trying to talk to
|
// Set up current address, we're trying to talk to
|
||||||
Self::enable_interrupts();
|
|
||||||
T::regs().dr().write(|reg| reg.set_dr((address << 1) + 1));
|
T::regs().dr().write(|reg| reg.set_dr((address << 1) + 1));
|
||||||
|
|
||||||
// Wait for the address to be acknowledged
|
// Wait for the address to be acknowledged
|
||||||
|
@ -717,8 +706,7 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
||||||
if sr1.addr() {
|
if sr1.addr() {
|
||||||
Poll::Ready(Ok(()))
|
Poll::Ready(Ok(()))
|
||||||
} else {
|
} else {
|
||||||
// If we need to go around, then re-enable the interrupts, otherwise nothing
|
// When pending, (re-)enable interrupts to wake us up.
|
||||||
// can wake us up and we'll hang.
|
|
||||||
Self::enable_interrupts();
|
Self::enable_interrupts();
|
||||||
Poll::Pending
|
Poll::Pending
|
||||||
}
|
}
|
||||||
|
@ -753,15 +741,13 @@ impl<'d, T: Instance, TXDMA, RXDMA> I2c<'d, T, TXDMA, RXDMA> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for bytes to be received, or an error to occur.
|
// Wait for bytes to be received, or an error to occur.
|
||||||
Self::enable_interrupts();
|
|
||||||
let poll_error = poll_fn(|cx| {
|
let poll_error = poll_fn(|cx| {
|
||||||
state.waker.register(cx.waker());
|
state.waker.register(cx.waker());
|
||||||
|
|
||||||
match Self::check_and_clear_error_flags() {
|
match Self::check_and_clear_error_flags() {
|
||||||
Err(e) => Poll::Ready(Err::<T, Error>(e)),
|
Err(e) => Poll::Ready(Err::<T, Error>(e)),
|
||||||
_ => {
|
_ => {
|
||||||
// If we need to go around, then re-enable the interrupts, otherwise nothing
|
// When pending, (re-)enable interrupts to wake us up.
|
||||||
// can wake us up and we'll hang.
|
|
||||||
Self::enable_interrupts();
|
Self::enable_interrupts();
|
||||||
Poll::Pending
|
Poll::Pending
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue