Add clone impl on shared i2c

This commit is contained in:
Dion Dokter 2025-09-18 11:04:13 +02:00
parent 93b5f1ebe3
commit 6c801a0dba
2 changed files with 36 additions and 0 deletions

View File

@ -41,6 +41,12 @@ impl<'a, M: RawMutex, BUS> I2cDevice<'a, M, BUS> {
}
}
impl<'a, M: RawMutex, BUS> Clone for I2cDevice<'a, M, BUS> {
fn clone(&self) -> Self {
Self { bus: self.bus }
}
}
impl<'a, M: RawMutex, BUS> i2c::ErrorType for I2cDevice<'a, M, BUS>
where
BUS: i2c::ErrorType,
@ -113,6 +119,18 @@ impl<'a, M: RawMutex, BUS: SetConfig> I2cDeviceWithConfig<'a, M, BUS> {
}
}
impl<'a, M: RawMutex, BUS: SetConfig> Clone for I2cDeviceWithConfig<'a, M, BUS>
where
BUS::Config: Clone,
{
fn clone(&self) -> Self {
Self {
bus: self.bus,
config: self.config.clone(),
}
}
}
impl<'a, M, BUS> i2c::ErrorType for I2cDeviceWithConfig<'a, M, BUS>
where
BUS: i2c::ErrorType,

View File

@ -36,6 +36,12 @@ impl<'a, M: RawMutex, BUS> I2cDevice<'a, M, BUS> {
}
}
impl<'a, M: RawMutex, BUS> Clone for I2cDevice<'a, M, BUS> {
fn clone(&self) -> Self {
Self { bus: self.bus }
}
}
impl<'a, M: RawMutex, BUS> ErrorType for I2cDevice<'a, M, BUS>
where
BUS: ErrorType,
@ -139,6 +145,18 @@ impl<'a, M: RawMutex, BUS: SetConfig> I2cDeviceWithConfig<'a, M, BUS> {
}
}
impl<'a, M: RawMutex, BUS: SetConfig> Clone for I2cDeviceWithConfig<'a, M, BUS>
where
BUS::Config: Clone,
{
fn clone(&self) -> Self {
Self {
bus: self.bus,
config: self.config.clone(),
}
}
}
impl<'a, M, BUS> ErrorType for I2cDeviceWithConfig<'a, M, BUS>
where
M: RawMutex,