Reviving InactiveDevice
This commit is contained in:
parent
509ee24309
commit
1c07b969a1
2 changed files with 16 additions and 1 deletions
|
|
@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- [breaking] The driver now uses the v1.0 of the `embedded-hal` traits.
|
- [breaking] The driver now uses the v1.0 of the `embedded-hal` traits.
|
||||||
- [breaking] The `FourWireRef` bus, `InactiveDevice`, and `DeviceRefMut` have been removed in favor of using
|
- [breaking] The `FourWireRef` bus and `DeviceRefMut` have been removed in favor of using
|
||||||
`embedded-hal-bus` to facilitate SPI bus sharing.
|
`embedded-hal-bus` to facilitate SPI bus sharing.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
||||||
|
|
@ -229,4 +229,19 @@ impl<SpiBus: Bus, HostImpl: Host> Device<SpiBus, HostImpl> {
|
||||||
|
|
||||||
Ok(retry_count_register[0])
|
Ok(retry_count_register[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn deactivate(self) -> (SpiBus, InactiveDevice<HostImpl>) {
|
||||||
|
(self.bus, InactiveDevice(self.state))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
|
pub struct InactiveDevice<HostImpl: Host>(DeviceState<HostImpl>);
|
||||||
|
|
||||||
|
impl<HostImpl: Host> InactiveDevice<HostImpl> {
|
||||||
|
/// Activates the device by taking ownership
|
||||||
|
pub fn activate<SpiBus: Bus>(self, bus: SpiBus) -> Device<SpiBus, HostImpl> {
|
||||||
|
Device { bus, state: self.0 }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue