aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-rp/src/pio.rs9
-rw-r--r--embassy-rp/src/pwm.rs12
-rw-r--r--examples/rp/src/bin/pio_async.rs1
-rw-r--r--examples/rp/src/bin/pio_dma.rs1
-rw-r--r--examples/rp/src/bin/pio_hd44780.rs1
-rw-r--r--examples/rp/src/bin/pwm.rs1
-rw-r--r--examples/rp/src/bin/ws2812-pio.rs1
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
7use atomic_polyfill::{AtomicU32, AtomicU8}; 7use atomic_polyfill::{AtomicU32, AtomicU8};
8use embassy_cortex_m::interrupt::{Interrupt, InterruptExt}; 8use embassy_cortex_m::interrupt::{Interrupt, InterruptExt};
9use embassy_embedded_hal::SetConfig;
10use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; 9use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
11use embassy_sync::waitqueue::AtomicWaker; 10use embassy_sync::waitqueue::AtomicWaker;
12use fixed::types::extra::U8; 11use fixed::types::extra::U8;
@@ -637,10 +636,8 @@ impl<'d, PIO: Instance> Config<'d, PIO> {
637 } 636 }
638} 637}
639 638
640impl<'d, PIO: Instance, const SM: usize> SetConfig for StateMachine<'d, PIO, SM> { 639impl<'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
696impl<'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
3use embassy_embedded_hal::SetConfig;
4use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; 3use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
5use fixed::traits::ToFixed; 4use fixed::traits::ToFixed;
6use fixed::FixedU16; 5use 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);
329impl_pin!(PIN_27, PWM_CH5, PwmPinB); 332impl_pin!(PIN_27, PWM_CH5, PwmPinB);
330impl_pin!(PIN_28, PWM_CH6, PwmPinA); 333impl_pin!(PIN_28, PWM_CH6, PwmPinA);
331impl_pin!(PIN_29, PWM_CH6, PwmPinB); 334impl_pin!(PIN_29, PWM_CH6, PwmPinB);
332
333impl<'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)]
4use defmt::info; 4use defmt::info;
5use embassy_embedded_hal::SetConfig;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
7use embassy_rp::peripherals::PIO0; 6use embassy_rp::peripherals::PIO0;
8use embassy_rp::pio::{Common, Config, Irq, Pio, PioPin, ShiftDirection, StateMachine}; 7use 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)]
4use defmt::info; 4use defmt::info;
5use embassy_embedded_hal::SetConfig;
6use embassy_executor::Spawner; 5use embassy_executor::Spawner;
7use embassy_futures::join::join; 6use embassy_futures::join::join;
8use embassy_rp::pio::{Config, Pio, ShiftConfig, ShiftDirection}; 7use 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
5use core::fmt::Write; 5use core::fmt::Write;
6 6
7use embassy_embedded_hal::SetConfig;
8use embassy_executor::Spawner; 7use embassy_executor::Spawner;
9use embassy_rp::dma::{AnyChannel, Channel}; 8use embassy_rp::dma::{AnyChannel, Channel};
10use embassy_rp::peripherals::PIO0; 9use 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
5use defmt::*; 5use defmt::*;
6use embassy_embedded_hal::SetConfig;
7use embassy_executor::Spawner; 6use embassy_executor::Spawner;
8use embassy_rp::pwm::{Config, Pwm}; 7use embassy_rp::pwm::{Config, Pwm};
9use embassy_time::{Duration, Timer}; 8use 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
5use defmt::*; 5use defmt::*;
6use embassy_embedded_hal::SetConfig;
7use embassy_executor::Spawner; 6use embassy_executor::Spawner;
8use embassy_rp::pio::{Common, Config, FifoJoin, Instance, Pio, PioPin, ShiftConfig, ShiftDirection, StateMachine}; 7use embassy_rp::pio::{Common, Config, FifoJoin, Instance, Pio, PioPin, ShiftConfig, ShiftDirection, StateMachine};
9use embassy_rp::relocate::RelocatedProgram; 8use embassy_rp::relocate::RelocatedProgram;