aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxoviat <[email protected]>2023-06-20 17:39:00 -0500
committerxoviat <[email protected]>2023-06-20 17:39:00 -0500
commit0a551eb7c6646af1b5c7e79849594fafe877e99a (patch)
tree11fcea42885bc9d3bbbe922c615fc5a30e9505fe
parent5a075acc6a91f9eb05d065ee31551a4695cc4cdf (diff)
stm32/can: fix time
-rw-r--r--embassy-stm32/src/can/bxcan.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/embassy-stm32/src/can/bxcan.rs b/embassy-stm32/src/can/bxcan.rs
index e23ce6863..224c39ea3 100644
--- a/embassy-stm32/src/can/bxcan.rs
+++ b/embassy-stm32/src/can/bxcan.rs
@@ -158,10 +158,11 @@ impl<'d, T: Instance> Can<'d, T> {
158 /// Queues the message to be sent but exerts backpressure 158 /// Queues the message to be sent but exerts backpressure
159 pub async fn write(&mut self, frame: &Frame) -> bxcan::TransmitStatus { 159 pub async fn write(&mut self, frame: &Frame) -> bxcan::TransmitStatus {
160 poll_fn(|cx| { 160 poll_fn(|cx| {
161 T::state().tx_waker.register(cx.waker());
161 if let Ok(status) = self.can.transmit(frame) { 162 if let Ok(status) = self.can.transmit(frame) {
162 return Poll::Ready(status); 163 return Poll::Ready(status);
163 } 164 }
164 T::state().tx_waker.register(cx.waker()); 165
165 Poll::Pending 166 Poll::Pending
166 }) 167 })
167 .await 168 .await
@@ -169,10 +170,11 @@ impl<'d, T: Instance> Can<'d, T> {
169 170
170 pub async fn flush(&self, mb: bxcan::Mailbox) { 171 pub async fn flush(&self, mb: bxcan::Mailbox) {
171 poll_fn(|cx| { 172 poll_fn(|cx| {
173 T::state().tx_waker.register(cx.waker());
172 if T::regs().tsr().read().tme(mb.index()) { 174 if T::regs().tsr().read().tme(mb.index()) {
173 return Poll::Ready(()); 175 return Poll::Ready(());
174 } 176 }
175 T::state().tx_waker.register(cx.waker()); 177
176 Poll::Pending 178 Poll::Pending
177 }) 179 })
178 .await; 180 .await;
@@ -181,12 +183,13 @@ impl<'d, T: Instance> Can<'d, T> {
181 /// Returns a tuple of the time the message was received and the message frame 183 /// Returns a tuple of the time the message was received and the message frame
182 pub async fn read(&mut self) -> Result<(u16, bxcan::Frame), BusError> { 184 pub async fn read(&mut self) -> Result<(u16, bxcan::Frame), BusError> {
183 poll_fn(|cx| { 185 poll_fn(|cx| {
186 T::state().err_waker.register(cx.waker());
184 if let Poll::Ready((time, frame)) = T::state().rx_queue.recv().poll_unpin(cx) { 187 if let Poll::Ready((time, frame)) = T::state().rx_queue.recv().poll_unpin(cx) {
185 return Poll::Ready(Ok((time, frame))); 188 return Poll::Ready(Ok((time, frame)));
186 } else if let Some(err) = self.curr_error() { 189 } else if let Some(err) = self.curr_error() {
187 return Poll::Ready(Err(err)); 190 return Poll::Ready(Err(err));
188 } 191 }
189 T::state().err_waker.register(cx.waker()); 192
190 Poll::Pending 193 Poll::Pending
191 }) 194 })
192 .await 195 .await