Add Device::deactivate and InactiveDevice::activate

This commit is contained in:
Michael Watzko 2021-03-23 23:31:51 +01:00
commit 10bbe99582
2 changed files with 41 additions and 17 deletions

View file

@ -75,4 +75,29 @@ impl<SpiBus: Bus, HostImpl: Host> Device<SpiBus, HostImpl> {
pub fn release(self) -> (SpiBus, HostImpl) {
(self.bus, self.host)
}
pub fn deactivate(self) -> (SpiBus, InactiveDevice<HostImpl>) {
(
self.bus,
InactiveDevice {
host: self.host,
sockets: self.sockets,
},
)
}
}
pub struct InactiveDevice<HostImpl: Host> {
host: HostImpl,
sockets: [u8; 1],
}
impl<HostImpl: Host> InactiveDevice<HostImpl> {
pub fn activate<SpiBus: Bus>(self, bus: SpiBus) -> Device<SpiBus, HostImpl> {
Device {
bus,
host: self.host,
sockets: self.sockets,
}
}
}