diff options
| author | Dion Dokter <[email protected]> | 2025-09-18 11:04:13 +0200 |
|---|---|---|
| committer | Dion Dokter <[email protected]> | 2025-09-18 11:04:13 +0200 |
| commit | 6c801a0dba93680c8e41e611eada0576eab0f861 (patch) | |
| tree | ddeea826c566b63d2451403f9290d8b80e1c7574 | |
| parent | 93b5f1ebe312bbfa0fc93deb2d6d00062cbddc95 (diff) | |
Add clone impl on shared i2c
| -rw-r--r-- | embassy-embedded-hal/src/shared_bus/asynch/i2c.rs | 18 | ||||
| -rw-r--r-- | embassy-embedded-hal/src/shared_bus/blocking/i2c.rs | 18 |
2 files changed, 36 insertions, 0 deletions
diff --git a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs index 6de685ee1..48246270e 100644 --- a/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs +++ b/embassy-embedded-hal/src/shared_bus/asynch/i2c.rs | |||
| @@ -41,6 +41,12 @@ impl<'a, M: RawMutex, BUS> I2cDevice<'a, M, BUS> { | |||
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | impl<'a, M: RawMutex, BUS> Clone for I2cDevice<'a, M, BUS> { | ||
| 45 | fn clone(&self) -> Self { | ||
| 46 | Self { bus: self.bus } | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 44 | impl<'a, M: RawMutex, BUS> i2c::ErrorType for I2cDevice<'a, M, BUS> | 50 | impl<'a, M: RawMutex, BUS> i2c::ErrorType for I2cDevice<'a, M, BUS> |
| 45 | where | 51 | where |
| 46 | BUS: i2c::ErrorType, | 52 | BUS: i2c::ErrorType, |
| @@ -113,6 +119,18 @@ impl<'a, M: RawMutex, BUS: SetConfig> I2cDeviceWithConfig<'a, M, BUS> { | |||
| 113 | } | 119 | } |
| 114 | } | 120 | } |
| 115 | 121 | ||
| 122 | impl<'a, M: RawMutex, BUS: SetConfig> Clone for I2cDeviceWithConfig<'a, M, BUS> | ||
| 123 | where | ||
| 124 | BUS::Config: Clone, | ||
| 125 | { | ||
| 126 | fn clone(&self) -> Self { | ||
| 127 | Self { | ||
| 128 | bus: self.bus, | ||
| 129 | config: self.config.clone(), | ||
| 130 | } | ||
| 131 | } | ||
| 132 | } | ||
| 133 | |||
| 116 | impl<'a, M, BUS> i2c::ErrorType for I2cDeviceWithConfig<'a, M, BUS> | 134 | impl<'a, M, BUS> i2c::ErrorType for I2cDeviceWithConfig<'a, M, BUS> |
| 117 | where | 135 | where |
| 118 | BUS: i2c::ErrorType, | 136 | BUS: i2c::ErrorType, |
diff --git a/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs b/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs index 627767c8a..fa34cd416 100644 --- a/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs +++ b/embassy-embedded-hal/src/shared_bus/blocking/i2c.rs | |||
| @@ -36,6 +36,12 @@ impl<'a, M: RawMutex, BUS> I2cDevice<'a, M, BUS> { | |||
| 36 | } | 36 | } |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | impl<'a, M: RawMutex, BUS> Clone for I2cDevice<'a, M, BUS> { | ||
| 40 | fn clone(&self) -> Self { | ||
| 41 | Self { bus: self.bus } | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 39 | impl<'a, M: RawMutex, BUS> ErrorType for I2cDevice<'a, M, BUS> | 45 | impl<'a, M: RawMutex, BUS> ErrorType for I2cDevice<'a, M, BUS> |
| 40 | where | 46 | where |
| 41 | BUS: ErrorType, | 47 | BUS: ErrorType, |
| @@ -139,6 +145,18 @@ impl<'a, M: RawMutex, BUS: SetConfig> I2cDeviceWithConfig<'a, M, BUS> { | |||
| 139 | } | 145 | } |
| 140 | } | 146 | } |
| 141 | 147 | ||
| 148 | impl<'a, M: RawMutex, BUS: SetConfig> Clone for I2cDeviceWithConfig<'a, M, BUS> | ||
| 149 | where | ||
| 150 | BUS::Config: Clone, | ||
| 151 | { | ||
| 152 | fn clone(&self) -> Self { | ||
| 153 | Self { | ||
| 154 | bus: self.bus, | ||
| 155 | config: self.config.clone(), | ||
| 156 | } | ||
| 157 | } | ||
| 158 | } | ||
| 159 | |||
| 142 | impl<'a, M, BUS> ErrorType for I2cDeviceWithConfig<'a, M, BUS> | 160 | impl<'a, M, BUS> ErrorType for I2cDeviceWithConfig<'a, M, BUS> |
| 143 | where | 161 | where |
| 144 | M: RawMutex, | 162 | M: RawMutex, |
