diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-05-13 00:14:50 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-13 00:14:50 +0000 |
| commit | 82f7e104d90a6628d1873017ea5ef6a7afb3b3f7 (patch) | |
| tree | fc13e33e7d855e005798d2ed589ca99cdd5473bc | |
| parent | dec75474d5fd82dd6abe25647f0e221c2266dda2 (diff) | |
| parent | 2fcdfc48762849d4de4686f9a4098db49c4031e6 (diff) | |
Merge #1448
1448: rp: don't use SetConfig trait in PWM and PIO. r=Dirbaio a=Dirbaio
It was intended to allow changing baudrate on shared spi/i2c. There's no advantage in using it for PWM or PIO, and makes it less usable because you have to have `embassy-embedded-hal` as a dep to use it.
bors r+
Co-authored-by: Dario Nieuwenhuis <[email protected]>
| -rw-r--r-- | embassy-rp/src/pio.rs | 9 | ||||
| -rw-r--r-- | embassy-rp/src/pwm.rs | 12 | ||||
| -rw-r--r-- | examples/rp/src/bin/pio_async.rs | 1 | ||||
| -rw-r--r-- | examples/rp/src/bin/pio_dma.rs | 1 | ||||
| -rw-r--r-- | examples/rp/src/bin/pio_hd44780.rs | 1 | ||||
| -rw-r--r-- | examples/rp/src/bin/pwm.rs | 1 | ||||
| -rw-r--r-- | examples/rp/src/bin/ws2812-pio.rs | 1 |
7 files changed, 6 insertions, 20 deletions
diff --git a/embassy-rp/src/pio.rs b/embassy-rp/src/pio.rs index 1e41bed30..cbe45334a 100644 --- a/embassy-rp/src/pio.rs +++ b/embassy-rp/src/pio.rs | |||
| @@ -6,7 +6,6 @@ use core::task::{Context, Poll}; | |||
| 6 | 6 | ||
| 7 | use atomic_polyfill::{AtomicU32, AtomicU8}; | 7 | use atomic_polyfill::{AtomicU32, AtomicU8}; |
| 8 | use embassy_cortex_m::interrupt::{Interrupt, InterruptExt}; | 8 | use embassy_cortex_m::interrupt::{Interrupt, InterruptExt}; |
| 9 | use embassy_embedded_hal::SetConfig; | ||
| 10 | use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | 9 | use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; |
| 11 | use embassy_sync::waitqueue::AtomicWaker; | 10 | use embassy_sync::waitqueue::AtomicWaker; |
| 12 | use fixed::types::extra::U8; | 11 | use fixed::types::extra::U8; |
| @@ -637,10 +636,8 @@ impl<'d, PIO: Instance> Config<'d, PIO> { | |||
| 637 | } | 636 | } |
| 638 | } | 637 | } |
| 639 | 638 | ||
| 640 | impl<'d, PIO: Instance, const SM: usize> SetConfig for StateMachine<'d, PIO, SM> { | 639 | impl<'d, PIO: Instance + 'd, const SM: usize> StateMachine<'d, PIO, SM> { |
| 641 | type Config = Config<'d, PIO>; | 640 | pub fn set_config(&mut self, config: &Config<'d, PIO>) { |
| 642 | |||
| 643 | fn set_config(&mut self, config: &Self::Config) { | ||
| 644 | // sm expects 0 for 65536, truncation makes that happen | 641 | // sm expects 0 for 65536, truncation makes that happen |
| 645 | assert!(config.clock_divider <= 65536, "clkdiv must be <= 65536"); | 642 | assert!(config.clock_divider <= 65536, "clkdiv must be <= 65536"); |
| 646 | assert!(config.clock_divider >= 1, "clkdiv must be >= 1"); | 643 | assert!(config.clock_divider >= 1, "clkdiv must be >= 1"); |
| @@ -691,9 +688,7 @@ impl<'d, PIO: Instance, const SM: usize> SetConfig for StateMachine<'d, PIO, SM> | |||
| 691 | } | 688 | } |
| 692 | } | 689 | } |
| 693 | } | 690 | } |
| 694 | } | ||
| 695 | 691 | ||
| 696 | impl<'d, PIO: Instance + 'd, const SM: usize> StateMachine<'d, PIO, SM> { | ||
| 697 | #[inline(always)] | 692 | #[inline(always)] |
| 698 | fn this_sm() -> crate::pac::pio::StateMachine { | 693 | fn this_sm() -> crate::pac::pio::StateMachine { |
| 699 | PIO::PIO.sm(SM) | 694 | PIO::PIO.sm(SM) |
diff --git a/embassy-rp/src/pwm.rs b/embassy-rp/src/pwm.rs index d2bf79584..0f9dcf479 100644 --- a/embassy-rp/src/pwm.rs +++ b/embassy-rp/src/pwm.rs | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | //! Pulse Width Modulation (PWM) | 1 | //! Pulse Width Modulation (PWM) |
| 2 | 2 | ||
| 3 | use embassy_embedded_hal::SetConfig; | ||
| 4 | use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | 3 | use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; |
| 5 | use fixed::traits::ToFixed; | 4 | use fixed::traits::ToFixed; |
| 6 | use fixed::FixedU16; | 5 | use fixed::FixedU16; |
| @@ -153,6 +152,10 @@ impl<'d, T: Channel> Pwm<'d, T> { | |||
| 153 | Self::new_inner(inner, Some(a.map_into()), Some(b.map_into()), config, mode.into()) | 152 | Self::new_inner(inner, Some(a.map_into()), Some(b.map_into()), config, mode.into()) |
| 154 | } | 153 | } |
| 155 | 154 | ||
| 155 | pub fn set_config(&mut self, config: &Config) { | ||
| 156 | Self::configure(self.inner.regs(), config); | ||
| 157 | } | ||
| 158 | |||
| 156 | fn configure(p: pac::pwm::Channel, config: &Config) { | 159 | fn configure(p: pac::pwm::Channel, config: &Config) { |
| 157 | if config.divider > FixedU16::<fixed::types::extra::U4>::from_bits(0xFF_F) { | 160 | if config.divider > FixedU16::<fixed::types::extra::U4>::from_bits(0xFF_F) { |
| 158 | panic!("Requested divider is too large"); | 161 | panic!("Requested divider is too large"); |
| @@ -329,10 +332,3 @@ impl_pin!(PIN_26, PWM_CH5, PwmPinA); | |||
| 329 | impl_pin!(PIN_27, PWM_CH5, PwmPinB); | 332 | impl_pin!(PIN_27, PWM_CH5, PwmPinB); |
| 330 | impl_pin!(PIN_28, PWM_CH6, PwmPinA); | 333 | impl_pin!(PIN_28, PWM_CH6, PwmPinA); |
| 331 | impl_pin!(PIN_29, PWM_CH6, PwmPinB); | 334 | impl_pin!(PIN_29, PWM_CH6, PwmPinB); |
| 332 | |||
| 333 | impl<'d, T: Channel> SetConfig for Pwm<'d, T> { | ||
| 334 | type Config = Config; | ||
| 335 | fn set_config(&mut self, config: &Self::Config) { | ||
| 336 | Self::configure(self.inner.regs(), config); | ||
| 337 | } | ||
| 338 | } | ||
diff --git a/examples/rp/src/bin/pio_async.rs b/examples/rp/src/bin/pio_async.rs index 12484e882..79eda1a09 100644 --- a/examples/rp/src/bin/pio_async.rs +++ b/examples/rp/src/bin/pio_async.rs | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | use defmt::info; | 4 | use defmt::info; |
| 5 | use embassy_embedded_hal::SetConfig; | ||
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 7 | use embassy_rp::peripherals::PIO0; | 6 | use embassy_rp::peripherals::PIO0; |
| 8 | use embassy_rp::pio::{Common, Config, Irq, Pio, PioPin, ShiftDirection, StateMachine}; | 7 | use embassy_rp::pio::{Common, Config, Irq, Pio, PioPin, ShiftDirection, StateMachine}; |
diff --git a/examples/rp/src/bin/pio_dma.rs b/examples/rp/src/bin/pio_dma.rs index 7f85288bf..05c0ebb16 100644 --- a/examples/rp/src/bin/pio_dma.rs +++ b/examples/rp/src/bin/pio_dma.rs | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | use defmt::info; | 4 | use defmt::info; |
| 5 | use embassy_embedded_hal::SetConfig; | ||
| 6 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 7 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 8 | use embassy_rp::pio::{Config, Pio, ShiftConfig, ShiftDirection}; | 7 | use embassy_rp::pio::{Config, Pio, ShiftConfig, ShiftDirection}; |
diff --git a/examples/rp/src/bin/pio_hd44780.rs b/examples/rp/src/bin/pio_hd44780.rs index 088fd5649..bfc6c9908 100644 --- a/examples/rp/src/bin/pio_hd44780.rs +++ b/examples/rp/src/bin/pio_hd44780.rs | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | use core::fmt::Write; | 5 | use core::fmt::Write; |
| 6 | 6 | ||
| 7 | use embassy_embedded_hal::SetConfig; | ||
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 9 | use embassy_rp::dma::{AnyChannel, Channel}; | 8 | use embassy_rp::dma::{AnyChannel, Channel}; |
| 10 | use embassy_rp::peripherals::PIO0; | 9 | use embassy_rp::peripherals::PIO0; |
diff --git a/examples/rp/src/bin/pwm.rs b/examples/rp/src/bin/pwm.rs index 69d315553..2b3d5d97a 100644 --- a/examples/rp/src/bin/pwm.rs +++ b/examples/rp/src/bin/pwm.rs | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_embedded_hal::SetConfig; | ||
| 7 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 8 | use embassy_rp::pwm::{Config, Pwm}; | 7 | use embassy_rp::pwm::{Config, Pwm}; |
| 9 | use embassy_time::{Duration, Timer}; | 8 | use embassy_time::{Duration, Timer}; |
diff --git a/examples/rp/src/bin/ws2812-pio.rs b/examples/rp/src/bin/ws2812-pio.rs index d7c4742d8..f4c2d6313 100644 --- a/examples/rp/src/bin/ws2812-pio.rs +++ b/examples/rp/src/bin/ws2812-pio.rs | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_embedded_hal::SetConfig; | ||
| 7 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 8 | use embassy_rp::pio::{Common, Config, FifoJoin, Instance, Pio, PioPin, ShiftConfig, ShiftDirection, StateMachine}; | 7 | use embassy_rp::pio::{Common, Config, FifoJoin, Instance, Pio, PioPin, ShiftConfig, ShiftDirection, StateMachine}; |
| 9 | use embassy_rp::relocate::RelocatedProgram; | 8 | use embassy_rp::relocate::RelocatedProgram; |
