Allow changing Spi/I2cDeviceWithConfig's config at runtime
This commit is contained in:
parent
1171e11655
commit
8f1bed3d95
4 changed files with 20 additions and 0 deletions
|
@ -106,6 +106,11 @@ impl<'a, M: RawMutex, BUS: SetConfig> I2cDeviceWithConfig<'a, M, BUS> {
|
|||
pub fn new(bus: &'a Mutex<M, BUS>, config: BUS::Config) -> Self {
|
||||
Self { bus, config }
|
||||
}
|
||||
|
||||
/// Change the device's config at runtime
|
||||
pub fn set_config(&mut self, config: BUS::Config) {
|
||||
self.config = config;
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, M, BUS> i2c::ErrorType for I2cDeviceWithConfig<'a, M, BUS>
|
||||
|
|
|
@ -122,6 +122,11 @@ impl<'a, M: RawMutex, BUS: SetConfig, CS> SpiDeviceWithConfig<'a, M, BUS, CS> {
|
|||
pub fn new(bus: &'a Mutex<M, BUS>, cs: CS, config: BUS::Config) -> Self {
|
||||
Self { bus, cs, config }
|
||||
}
|
||||
|
||||
/// Change the device's config at runtime
|
||||
pub fn set_config(&mut self, config: BUS::Config) {
|
||||
self.config = config;
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, M, BUS, CS> spi::ErrorType for SpiDeviceWithConfig<'a, M, BUS, CS>
|
||||
|
|
|
@ -132,6 +132,11 @@ impl<'a, M: RawMutex, BUS: SetConfig> I2cDeviceWithConfig<'a, M, BUS> {
|
|||
pub fn new(bus: &'a Mutex<M, RefCell<BUS>>, config: BUS::Config) -> Self {
|
||||
Self { bus, config }
|
||||
}
|
||||
|
||||
/// Change the device's config at runtime
|
||||
pub fn set_config(&mut self, config: BUS::Config) {
|
||||
self.config = config;
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, M, BUS> ErrorType for I2cDeviceWithConfig<'a, M, BUS>
|
||||
|
|
|
@ -147,6 +147,11 @@ impl<'a, M: RawMutex, BUS: SetConfig, CS> SpiDeviceWithConfig<'a, M, BUS, CS> {
|
|||
pub fn new(bus: &'a Mutex<M, RefCell<BUS>>, cs: CS, config: BUS::Config) -> Self {
|
||||
Self { bus, cs, config }
|
||||
}
|
||||
|
||||
/// Change the device's config at runtime
|
||||
pub fn set_config(&mut self, config: BUS::Config) {
|
||||
self.config = config;
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, M, BUS, CS> spi::ErrorType for SpiDeviceWithConfig<'a, M, BUS, CS>
|
||||
|
|
Loading…
Reference in a new issue