aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorey Schuhen <[email protected]>2024-05-30 22:10:46 +1000
committerCorey Schuhen <[email protected]>2024-05-30 22:10:46 +1000
commitb4a2f7fb70ac3f0b0d9226ab5ff5aab7a5bf8649 (patch)
tree85fa070f35a17d1e8e95bfa2bdebc1a70251fd74
parent7fd79857c339ccc55a4df606e25b432ada8f43a1 (diff)
Use phantom for lifetime holder instead of not used pointer to pointer.
-rw-r--r--embassy-stm32/src/can/bxcan/mod.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/embassy-stm32/src/can/bxcan/mod.rs b/embassy-stm32/src/can/bxcan/mod.rs
index 4f516c917..c242aea2b 100644
--- a/embassy-stm32/src/can/bxcan/mod.rs
+++ b/embassy-stm32/src/can/bxcan/mod.rs
@@ -156,7 +156,6 @@ impl<T: Instance> Drop for CanConfig<'_, T> {
156/// CAN driver 156/// CAN driver
157pub struct Can<'d, T: Instance> { 157pub struct Can<'d, T: Instance> {
158 _peri: PeripheralRef<'d, T>, 158 _peri: PeripheralRef<'d, T>,
159 instance: &'d crate::pac::can::Can,
160 info: &'static Info, 159 info: &'static Info,
161 state: &'static State, 160 state: &'static State,
162} 161}
@@ -228,7 +227,6 @@ impl<'d, T: Instance> Can<'d, T> {
228 227
229 Self { 228 Self {
230 _peri: peri, 229 _peri: peri,
231 instance: &T::info().regs.0,
232 info: T::info(), 230 info: T::info(),
233 state: T::state(), 231 state: T::state(),
234 } 232 }
@@ -346,7 +344,7 @@ impl<'d, T: Instance> Can<'d, T> {
346 /// Waits for a specific transmit mailbox to become empty 344 /// Waits for a specific transmit mailbox to become empty
347 pub async fn flush(&self, mb: Mailbox) { 345 pub async fn flush(&self, mb: Mailbox) {
348 CanTx { 346 CanTx {
349 _instance: &self.instance, 347 _phantom: PhantomData,
350 info: self.info, 348 info: self.info,
351 state: self.state, 349 state: self.state,
352 } 350 }
@@ -362,7 +360,7 @@ impl<'d, T: Instance> Can<'d, T> {
362 /// and a frame with equal priority is already queued for transmission. 360 /// and a frame with equal priority is already queued for transmission.
363 pub async fn flush_any(&self) { 361 pub async fn flush_any(&self) {
364 CanTx { 362 CanTx {
365 _instance: &self.instance, 363 _phantom: PhantomData,
366 info: self.info, 364 info: self.info,
367 state: self.state, 365 state: self.state,
368 } 366 }
@@ -373,7 +371,7 @@ impl<'d, T: Instance> Can<'d, T> {
373 /// Waits until all of the transmit mailboxes become empty 371 /// Waits until all of the transmit mailboxes become empty
374 pub async fn flush_all(&self) { 372 pub async fn flush_all(&self) {
375 CanTx { 373 CanTx {
376 _instance: &self.instance, 374 _phantom: PhantomData,
377 info: self.info, 375 info: self.info,
378 state: self.state, 376 state: self.state,
379 } 377 }
@@ -424,12 +422,12 @@ impl<'d, T: Instance> Can<'d, T> {
424 pub fn split<'c>(&'c mut self) -> (CanTx<'d>, CanRx<'d>) { 422 pub fn split<'c>(&'c mut self) -> (CanTx<'d>, CanRx<'d>) {
425 ( 423 (
426 CanTx { 424 CanTx {
427 _instance: &self.instance, 425 _phantom: PhantomData,
428 info: self.info, 426 info: self.info,
429 state: self.state, 427 state: self.state,
430 }, 428 },
431 CanRx { 429 CanRx {
432 instance: &self.instance, 430 _phantom: PhantomData,
433 info: self.info, 431 info: self.info,
434 state: self.state, 432 state: self.state,
435 }, 433 },
@@ -502,7 +500,7 @@ impl<'d, const TX_BUF_SIZE: usize, const RX_BUF_SIZE: usize> BufferedCan<'d, TX_
502 500
503/// CAN driver, transmit half. 501/// CAN driver, transmit half.
504pub struct CanTx<'d> { 502pub struct CanTx<'d> {
505 _instance: &'d crate::pac::can::Can, 503 _phantom: PhantomData<&'d ()>,
506 info: &'static Info, 504 info: &'static Info,
507 state: &'static State, 505 state: &'static State,
508} 506}
@@ -695,7 +693,7 @@ impl<'d, const TX_BUF_SIZE: usize> Drop for BufferedCanTx<'d, TX_BUF_SIZE> {
695/// CAN driver, receive half. 693/// CAN driver, receive half.
696#[allow(dead_code)] 694#[allow(dead_code)]
697pub struct CanRx<'d> { 695pub struct CanRx<'d> {
698 instance: &'d crate::pac::can::Can, 696 _phantom: PhantomData<&'d ()>,
699 info: &'static Info, 697 info: &'static Info,
700 state: &'static State, 698 state: &'static State,
701} 699}