1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use embedded_hal::can::Frame;

mod receiver;
pub use receiver::{DualReceiver, Receiver};

pub trait Receive {
    type Frame: Frame;
    type Error;

    fn receive(&mut self) -> nb::Result<Self::Frame, Self::Error>;
}

#[cfg(feature = "bxcan")]
impl<I: bxcan::Instance> Receive for bxcan::Rx0<I> {
    type Frame = bxcan::Frame;
    type Error = bxcan::OverrunError;

    fn receive(&mut self) -> nb::Result<Self::Frame, Self::Error> {
        self.receive()
    }
}

#[cfg(feature = "bxcan")]
impl<I: bxcan::Instance> Receive for bxcan::Rx1<I> {
    type Frame = bxcan::Frame;
    type Error = bxcan::OverrunError;

    fn receive(&mut self) -> nb::Result<Self::Frame, Self::Error> {
        self.receive()
    }
}