aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-07-02 22:07:20 +0200
committerDario Nieuwenhuis <[email protected]>2023-07-02 22:16:01 +0200
commitc9b9be5b819911aaf809df9b55be7e7efa3a1fba (patch)
treebc19248a36ab6e9439e22db6fcdc835b60e61202
parentba4344429264fa7beb99ab19c09059c2d531716d (diff)
hal-common: require DerefMut for peripherals, not just Deref.
Otherwise you can create multiple drivers on the same singleton like this: ```rust let mut input = Input::new(&pin, Pull::None); let mut output = Output::new(&pin, Level::Low, Speed::Low); input.is_high(); output.set_high(); input.is_high(); output.set_high(); ``` Thanks @pennae for reporting.
-rw-r--r--embassy-hal-common/src/peripheral.rs2
-rw-r--r--embassy-stm32/src/dac/mod.rs4
2 files changed, 3 insertions, 3 deletions
diff --git a/embassy-hal-common/src/peripheral.rs b/embassy-hal-common/src/peripheral.rs
index c7133bac6..38b4c452e 100644
--- a/embassy-hal-common/src/peripheral.rs
+++ b/embassy-hal-common/src/peripheral.rs
@@ -161,7 +161,7 @@ pub trait Peripheral: Sized {
161 } 161 }
162} 162}
163 163
164impl<'b, T: Deref> Peripheral for T 164impl<'b, T: DerefMut> Peripheral for T
165where 165where
166 T::Target: Peripheral, 166 T::Target: Peripheral,
167{ 167{
diff --git a/embassy-stm32/src/dac/mod.rs b/embassy-stm32/src/dac/mod.rs
index 1dc13949d..31a2d8863 100644
--- a/embassy-stm32/src/dac/mod.rs
+++ b/embassy-stm32/src/dac/mod.rs
@@ -264,7 +264,7 @@ impl<'d, T: Instance, Tx> DacCh1<'d, T, Tx> {
264 }); 264 });
265 265
266 let tx_request = self.dma.request(); 266 let tx_request = self.dma.request();
267 let dma_channel = &self.dma; 267 let dma_channel = &mut self.dma;
268 268
269 let tx_options = crate::dma::TransferOptions { 269 let tx_options = crate::dma::TransferOptions {
270 circular, 270 circular,
@@ -376,7 +376,7 @@ impl<'d, T: Instance, Tx> DacCh2<'d, T, Tx> {
376 }); 376 });
377 377
378 let tx_request = self.dma.request(); 378 let tx_request = self.dma.request();
379 let dma_channel = &self.dma; 379 let dma_channel = &mut self.dma;
380 380
381 let tx_options = crate::dma::TransferOptions { 381 let tx_options = crate::dma::TransferOptions {
382 circular, 382 circular,