diff options
| author | xoviat <[email protected]> | 2023-10-01 09:37:42 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2023-10-01 09:37:42 -0500 |
| commit | d2a2734752ed276123a15b58fd8f50c3b531f62d (patch) | |
| tree | be04ec9df0a7c0c96dc12b73e1c683d6344a1c9a | |
| parent | 5ad34404af9b7cfecfed5075d987c4c03ff2ca27 (diff) | |
nrf, rp: update set_config
| -rw-r--r-- | embassy-nrf/src/spim.rs | 7 | ||||
| -rw-r--r-- | embassy-nrf/src/spis.rs | 7 | ||||
| -rw-r--r-- | embassy-nrf/src/twim.rs | 7 | ||||
| -rw-r--r-- | embassy-rp/src/spi.rs | 5 |
4 files changed, 19 insertions, 7 deletions
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index 4828af43e..caf681d99 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs | |||
| @@ -176,7 +176,7 @@ impl<'d, T: Instance> Spim<'d, T> { | |||
| 176 | let mut spim = Self { _p: spim }; | 176 | let mut spim = Self { _p: spim }; |
| 177 | 177 | ||
| 178 | // Apply runtime peripheral configuration | 178 | // Apply runtime peripheral configuration |
| 179 | Self::set_config(&mut spim, &config); | 179 | Self::set_config(&mut spim, &config).unwrap(); |
| 180 | 180 | ||
| 181 | // Disable all events interrupts | 181 | // Disable all events interrupts |
| 182 | r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) }); | 182 | r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) }); |
| @@ -566,7 +566,8 @@ mod eha { | |||
| 566 | 566 | ||
| 567 | impl<'d, T: Instance> SetConfig for Spim<'d, T> { | 567 | impl<'d, T: Instance> SetConfig for Spim<'d, T> { |
| 568 | type Config = Config; | 568 | type Config = Config; |
| 569 | fn set_config(&mut self, config: &Self::Config) { | 569 | type ConfigError = (); |
| 570 | fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError> { | ||
| 570 | let r = T::regs(); | 571 | let r = T::regs(); |
| 571 | // Configure mode. | 572 | // Configure mode. |
| 572 | let mode = config.mode; | 573 | let mode = config.mode; |
| @@ -604,5 +605,7 @@ impl<'d, T: Instance> SetConfig for Spim<'d, T> { | |||
| 604 | // Set over-read character | 605 | // Set over-read character |
| 605 | let orc = config.orc; | 606 | let orc = config.orc; |
| 606 | r.orc.write(|w| unsafe { w.orc().bits(orc) }); | 607 | r.orc.write(|w| unsafe { w.orc().bits(orc) }); |
| 608 | |||
| 609 | Ok(()) | ||
| 607 | } | 610 | } |
| 608 | } | 611 | } |
diff --git a/embassy-nrf/src/spis.rs b/embassy-nrf/src/spis.rs index e695ba6b7..e202c6c27 100644 --- a/embassy-nrf/src/spis.rs +++ b/embassy-nrf/src/spis.rs | |||
| @@ -172,7 +172,7 @@ impl<'d, T: Instance> Spis<'d, T> { | |||
| 172 | let mut spis = Self { _p: spis }; | 172 | let mut spis = Self { _p: spis }; |
| 173 | 173 | ||
| 174 | // Apply runtime peripheral configuration | 174 | // Apply runtime peripheral configuration |
| 175 | Self::set_config(&mut spis, &config); | 175 | Self::set_config(&mut spis, &config).unwrap(); |
| 176 | 176 | ||
| 177 | // Disable all events interrupts. | 177 | // Disable all events interrupts. |
| 178 | r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) }); | 178 | r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) }); |
| @@ -467,7 +467,8 @@ macro_rules! impl_spis { | |||
| 467 | 467 | ||
| 468 | impl<'d, T: Instance> SetConfig for Spis<'d, T> { | 468 | impl<'d, T: Instance> SetConfig for Spis<'d, T> { |
| 469 | type Config = Config; | 469 | type Config = Config; |
| 470 | fn set_config(&mut self, config: &Self::Config) { | 470 | type ConfigError = (); |
| 471 | fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError> { | ||
| 471 | let r = T::regs(); | 472 | let r = T::regs(); |
| 472 | // Configure mode. | 473 | // Configure mode. |
| 473 | let mode = config.mode; | 474 | let mode = config.mode; |
| @@ -509,5 +510,7 @@ impl<'d, T: Instance> SetConfig for Spis<'d, T> { | |||
| 509 | // Configure auto-acquire on 'transfer end' event. | 510 | // Configure auto-acquire on 'transfer end' event. |
| 510 | let auto_acquire = config.auto_acquire; | 511 | let auto_acquire = config.auto_acquire; |
| 511 | r.shorts.write(|w| w.end_acquire().bit(auto_acquire)); | 512 | r.shorts.write(|w| w.end_acquire().bit(auto_acquire)); |
| 513 | |||
| 514 | Ok(()) | ||
| 512 | } | 515 | } |
| 513 | } | 516 | } |
diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs index fe38fb102..919bb4ab2 100644 --- a/embassy-nrf/src/twim.rs +++ b/embassy-nrf/src/twim.rs | |||
| @@ -170,7 +170,7 @@ impl<'d, T: Instance> Twim<'d, T> { | |||
| 170 | let mut twim = Self { _p: twim }; | 170 | let mut twim = Self { _p: twim }; |
| 171 | 171 | ||
| 172 | // Apply runtime peripheral configuration | 172 | // Apply runtime peripheral configuration |
| 173 | Self::set_config(&mut twim, &config); | 173 | Self::set_config(&mut twim, &config).unwrap(); |
| 174 | 174 | ||
| 175 | // Disable all events interrupts | 175 | // Disable all events interrupts |
| 176 | r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) }); | 176 | r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) }); |
| @@ -890,9 +890,12 @@ mod eha { | |||
| 890 | 890 | ||
| 891 | impl<'d, T: Instance> SetConfig for Twim<'d, T> { | 891 | impl<'d, T: Instance> SetConfig for Twim<'d, T> { |
| 892 | type Config = Config; | 892 | type Config = Config; |
| 893 | fn set_config(&mut self, config: &Self::Config) { | 893 | type ConfigError = (); |
| 894 | fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError> { | ||
| 894 | let r = T::regs(); | 895 | let r = T::regs(); |
| 895 | r.frequency | 896 | r.frequency |
| 896 | .write(|w| unsafe { w.frequency().bits(config.frequency as u32) }); | 897 | .write(|w| unsafe { w.frequency().bits(config.frequency as u32) }); |
| 898 | |||
| 899 | Ok(()) | ||
| 897 | } | 900 | } |
| 898 | } | 901 | } |
diff --git a/embassy-rp/src/spi.rs b/embassy-rp/src/spi.rs index 46c440b84..a59ce8419 100644 --- a/embassy-rp/src/spi.rs +++ b/embassy-rp/src/spi.rs | |||
| @@ -597,7 +597,8 @@ mod eha { | |||
| 597 | 597 | ||
| 598 | impl<'d, T: Instance, M: Mode> SetConfig for Spi<'d, T, M> { | 598 | impl<'d, T: Instance, M: Mode> SetConfig for Spi<'d, T, M> { |
| 599 | type Config = Config; | 599 | type Config = Config; |
| 600 | fn set_config(&mut self, config: &Self::Config) { | 600 | type ConfigError = (); |
| 601 | fn set_config(&mut self, config: &Self::Config) -> Result<(), ()> { | ||
| 601 | let p = self.inner.regs(); | 602 | let p = self.inner.regs(); |
| 602 | let (presc, postdiv) = calc_prescs(config.frequency); | 603 | let (presc, postdiv) = calc_prescs(config.frequency); |
| 603 | p.cpsr().write(|w| w.set_cpsdvsr(presc)); | 604 | p.cpsr().write(|w| w.set_cpsdvsr(presc)); |
| @@ -607,5 +608,7 @@ impl<'d, T: Instance, M: Mode> SetConfig for Spi<'d, T, M> { | |||
| 607 | w.set_sph(config.phase == Phase::CaptureOnSecondTransition); | 608 | w.set_sph(config.phase == Phase::CaptureOnSecondTransition); |
| 608 | w.set_scr(postdiv); | 609 | w.set_scr(postdiv); |
| 609 | }); | 610 | }); |
| 611 | |||
| 612 | Ok(()) | ||
| 610 | } | 613 | } |
| 611 | } | 614 | } |
