pub struct RcDevice<Bus, Cs, Delay> { /* private fields */ }std or alloc only.Expand description
Implementation of SpiDevice around a bus shared with Rc<RefCell<T>>.
This is the reference-counting equivalent of RefCellDevice, requiring allocation.
A single SpiBus is shared via RefCell, and its ownership is handled by Rc.
Both of these mechanisms only allow sharing within a single thread (or interrupt priority level).
For this reason, this does not implement Send.
When this structure is dropped, the reference count of the Bus instance will be decremented,
and it will be cleaned up once the reference count reaches zero.
Implementations§
Source§impl<Bus, Cs, Delay> RcDevice<Bus, Cs, Delay>
impl<Bus, Cs, Delay> RcDevice<Bus, Cs, Delay>
Sourcepub fn new(
bus: Rc<RefCell<Bus>>,
cs: Cs,
delay: Delay,
) -> Result<Self, Cs::Error>where
Cs: OutputPin,
Available on crate feature alloc only.
pub fn new(
bus: Rc<RefCell<Bus>>,
cs: Cs,
delay: Delay,
) -> Result<Self, Cs::Error>where
Cs: OutputPin,
alloc only.Creates a new RcDevice.
This sets the cs pin high, and returns an error if that fails.
It is recommended to have already set that pin high the moment it has been configured as an output, to avoid glitches.
This function does not increment the reference count:
you will need to call Rc::clone(&bus) if you only have a &Rc<RefCell<Bus>>.
Source§impl<Bus, Cs> RcDevice<Bus, Cs, NoDelay>
impl<Bus, Cs> RcDevice<Bus, Cs, NoDelay>
Sourcepub fn new_no_delay(bus: Rc<RefCell<Bus>>, cs: Cs) -> Result<Self, Cs::Error>where
Cs: OutputPin,
Available on crate feature alloc only.
pub fn new_no_delay(bus: Rc<RefCell<Bus>>, cs: Cs) -> Result<Self, Cs::Error>where
Cs: OutputPin,
alloc only.Creates a new RcDevice without support for in-transaction delays.
Warning: It’s advised to prefer RcDevice::new,
as the contract of SpiDevice requests support for in-transaction delays.
Refer to RefCellDevice::new_no_delay for more information.
Trait Implementations§
Source§impl<Bus, Cs, Delay> ErrorType for RcDevice<Bus, Cs, Delay>
Available on crate feature alloc only.
impl<Bus, Cs, Delay> ErrorType for RcDevice<Bus, Cs, Delay>
alloc only.Source§impl<Word, Bus, Cs, Delay> SpiDevice<Word> for RcDevice<Bus, Cs, Delay>
Available on crate feature alloc only.
impl<Word, Bus, Cs, Delay> SpiDevice<Word> for RcDevice<Bus, Cs, Delay>
alloc only.