aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2024-04-02 14:37:46 +0000
committerGitHub <[email protected]>2024-04-02 14:37:46 +0000
commite29b5619d1dafb46a25f42a5b3552605bb3c2d86 (patch)
tree1a2df329ec5521f8a390c0f8a1376b50e792727a
parent016d552d1addb175ecba2bd96d794d8135fd51cc (diff)
parentaa9eb2ab01cb21e06bb12efb425088827f6127d9 (diff)
Merge pull request #2762 from UPB-FILS-MA/rp_rename_pwm
rp2040: Rename PWM_CH to PWM_SLICE
-rw-r--r--embassy-rp/src/lib.rs16
-rw-r--r--embassy-rp/src/pwm.rs76
-rw-r--r--examples/rp/src/bin/pio_hd44780.rs2
-rw-r--r--examples/rp/src/bin/pwm.rs2
-rw-r--r--examples/rp/src/bin/pwm_input.rs2
-rw-r--r--tests/rp/src/bin/pwm.rs14
6 files changed, 56 insertions, 56 deletions
diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs
index d91cea410..1c83e306d 100644
--- a/embassy-rp/src/lib.rs
+++ b/embassy-rp/src/lib.rs
@@ -183,14 +183,14 @@ embassy_hal_internal::peripherals! {
183 DMA_CH10, 183 DMA_CH10,
184 DMA_CH11, 184 DMA_CH11,
185 185
186 PWM_CH0, 186 PWM_SLICE0,
187 PWM_CH1, 187 PWM_SLICE1,
188 PWM_CH2, 188 PWM_SLICE2,
189 PWM_CH3, 189 PWM_SLICE3,
190 PWM_CH4, 190 PWM_SLICE4,
191 PWM_CH5, 191 PWM_SLICE5,
192 PWM_CH6, 192 PWM_SLICE6,
193 PWM_CH7, 193 PWM_SLICE7,
194 194
195 USB, 195 USB,
196 196
diff --git a/embassy-rp/src/pwm.rs b/embassy-rp/src/pwm.rs
index e6f3b2aa2..3b980108a 100644
--- a/embassy-rp/src/pwm.rs
+++ b/embassy-rp/src/pwm.rs
@@ -326,14 +326,14 @@ macro_rules! channel {
326 }; 326 };
327} 327}
328 328
329channel!(PWM_CH0, 0); 329channel!(PWM_SLICE0, 0);
330channel!(PWM_CH1, 1); 330channel!(PWM_SLICE1, 1);
331channel!(PWM_CH2, 2); 331channel!(PWM_SLICE2, 2);
332channel!(PWM_CH3, 3); 332channel!(PWM_SLICE3, 3);
333channel!(PWM_CH4, 4); 333channel!(PWM_SLICE4, 4);
334channel!(PWM_CH5, 5); 334channel!(PWM_SLICE5, 5);
335channel!(PWM_CH6, 6); 335channel!(PWM_SLICE6, 6);
336channel!(PWM_CH7, 7); 336channel!(PWM_SLICE7, 7);
337 337
338/// PWM Pin A. 338/// PWM Pin A.
339pub trait PwmPinA<T: Channel>: GpioPin {} 339pub trait PwmPinA<T: Channel>: GpioPin {}
@@ -346,33 +346,33 @@ macro_rules! impl_pin {
346 }; 346 };
347} 347}
348 348
349impl_pin!(PIN_0, PWM_CH0, PwmPinA); 349impl_pin!(PIN_0, PWM_SLICE0, PwmPinA);
350impl_pin!(PIN_1, PWM_CH0, PwmPinB); 350impl_pin!(PIN_1, PWM_SLICE0, PwmPinB);
351impl_pin!(PIN_2, PWM_CH1, PwmPinA); 351impl_pin!(PIN_2, PWM_SLICE1, PwmPinA);
352impl_pin!(PIN_3, PWM_CH1, PwmPinB); 352impl_pin!(PIN_3, PWM_SLICE1, PwmPinB);
353impl_pin!(PIN_4, PWM_CH2, PwmPinA); 353impl_pin!(PIN_4, PWM_SLICE2, PwmPinA);
354impl_pin!(PIN_5, PWM_CH2, PwmPinB); 354impl_pin!(PIN_5, PWM_SLICE2, PwmPinB);
355impl_pin!(PIN_6, PWM_CH3, PwmPinA); 355impl_pin!(PIN_6, PWM_SLICE3, PwmPinA);
356impl_pin!(PIN_7, PWM_CH3, PwmPinB); 356impl_pin!(PIN_7, PWM_SLICE3, PwmPinB);
357impl_pin!(PIN_8, PWM_CH4, PwmPinA); 357impl_pin!(PIN_8, PWM_SLICE4, PwmPinA);
358impl_pin!(PIN_9, PWM_CH4, PwmPinB); 358impl_pin!(PIN_9, PWM_SLICE4, PwmPinB);
359impl_pin!(PIN_10, PWM_CH5, PwmPinA); 359impl_pin!(PIN_10, PWM_SLICE5, PwmPinA);
360impl_pin!(PIN_11, PWM_CH5, PwmPinB); 360impl_pin!(PIN_11, PWM_SLICE5, PwmPinB);
361impl_pin!(PIN_12, PWM_CH6, PwmPinA); 361impl_pin!(PIN_12, PWM_SLICE6, PwmPinA);
362impl_pin!(PIN_13, PWM_CH6, PwmPinB); 362impl_pin!(PIN_13, PWM_SLICE6, PwmPinB);
363impl_pin!(PIN_14, PWM_CH7, PwmPinA); 363impl_pin!(PIN_14, PWM_SLICE7, PwmPinA);
364impl_pin!(PIN_15, PWM_CH7, PwmPinB); 364impl_pin!(PIN_15, PWM_SLICE7, PwmPinB);
365impl_pin!(PIN_16, PWM_CH0, PwmPinA); 365impl_pin!(PIN_16, PWM_SLICE0, PwmPinA);
366impl_pin!(PIN_17, PWM_CH0, PwmPinB); 366impl_pin!(PIN_17, PWM_SLICE0, PwmPinB);
367impl_pin!(PIN_18, PWM_CH1, PwmPinA); 367impl_pin!(PIN_18, PWM_SLICE1, PwmPinA);
368impl_pin!(PIN_19, PWM_CH1, PwmPinB); 368impl_pin!(PIN_19, PWM_SLICE1, PwmPinB);
369impl_pin!(PIN_20, PWM_CH2, PwmPinA); 369impl_pin!(PIN_20, PWM_SLICE2, PwmPinA);
370impl_pin!(PIN_21, PWM_CH2, PwmPinB); 370impl_pin!(PIN_21, PWM_SLICE2, PwmPinB);
371impl_pin!(PIN_22, PWM_CH3, PwmPinA); 371impl_pin!(PIN_22, PWM_SLICE3, PwmPinA);
372impl_pin!(PIN_23, PWM_CH3, PwmPinB); 372impl_pin!(PIN_23, PWM_SLICE3, PwmPinB);
373impl_pin!(PIN_24, PWM_CH4, PwmPinA); 373impl_pin!(PIN_24, PWM_SLICE4, PwmPinA);
374impl_pin!(PIN_25, PWM_CH4, PwmPinB); 374impl_pin!(PIN_25, PWM_SLICE4, PwmPinB);
375impl_pin!(PIN_26, PWM_CH5, PwmPinA); 375impl_pin!(PIN_26, PWM_SLICE5, PwmPinA);
376impl_pin!(PIN_27, PWM_CH5, PwmPinB); 376impl_pin!(PIN_27, PWM_SLICE5, PwmPinB);
377impl_pin!(PIN_28, PWM_CH6, PwmPinA); 377impl_pin!(PIN_28, PWM_SLICE6, PwmPinA);
378impl_pin!(PIN_29, PWM_CH6, PwmPinB); 378impl_pin!(PIN_29, PWM_SLICE6, PwmPinB);
diff --git a/examples/rp/src/bin/pio_hd44780.rs b/examples/rp/src/bin/pio_hd44780.rs
index 3fab7b5f2..6c02630e0 100644
--- a/examples/rp/src/bin/pio_hd44780.rs
+++ b/examples/rp/src/bin/pio_hd44780.rs
@@ -35,7 +35,7 @@ async fn main(_spawner: Spawner) {
35 // allowing direct connection of the display to the RP2040 without level shifters. 35 // allowing direct connection of the display to the RP2040 without level shifters.
36 let p = embassy_rp::init(Default::default()); 36 let p = embassy_rp::init(Default::default());
37 37
38 let _pwm = Pwm::new_output_b(p.PWM_CH7, p.PIN_15, { 38 let _pwm = Pwm::new_output_b(p.PWM_SLICE7, p.PIN_15, {
39 let mut c = pwm::Config::default(); 39 let mut c = pwm::Config::default();
40 c.divider = 125.into(); 40 c.divider = 125.into();
41 c.top = 100; 41 c.top = 100;
diff --git a/examples/rp/src/bin/pwm.rs b/examples/rp/src/bin/pwm.rs
index 4fb62546d..26e233260 100644
--- a/examples/rp/src/bin/pwm.rs
+++ b/examples/rp/src/bin/pwm.rs
@@ -18,7 +18,7 @@ async fn main(_spawner: Spawner) {
18 let mut c: Config = Default::default(); 18 let mut c: Config = Default::default();
19 c.top = 0x8000; 19 c.top = 0x8000;
20 c.compare_b = 8; 20 c.compare_b = 8;
21 let mut pwm = Pwm::new_output_b(p.PWM_CH4, p.PIN_25, c.clone()); 21 let mut pwm = Pwm::new_output_b(p.PWM_SLICE4, p.PIN_25, c.clone());
22 22
23 loop { 23 loop {
24 info!("current LED duty cycle: {}/32768", c.compare_b); 24 info!("current LED duty cycle: {}/32768", c.compare_b);
diff --git a/examples/rp/src/bin/pwm_input.rs b/examples/rp/src/bin/pwm_input.rs
index e7bcbfbd4..0652dc42b 100644
--- a/examples/rp/src/bin/pwm_input.rs
+++ b/examples/rp/src/bin/pwm_input.rs
@@ -14,7 +14,7 @@ async fn main(_spawner: Spawner) {
14 let p = embassy_rp::init(Default::default()); 14 let p = embassy_rp::init(Default::default());
15 15
16 let cfg: Config = Default::default(); 16 let cfg: Config = Default::default();
17 let pwm = Pwm::new_input(p.PWM_CH2, p.PIN_5, InputMode::RisingEdge, cfg); 17 let pwm = Pwm::new_input(p.PWM_SLICE2, p.PIN_5, InputMode::RisingEdge, cfg);
18 18
19 let mut ticker = Ticker::every(Duration::from_secs(1)); 19 let mut ticker = Ticker::every(Duration::from_secs(1));
20 loop { 20 loop {
diff --git a/tests/rp/src/bin/pwm.rs b/tests/rp/src/bin/pwm.rs
index e71d9e610..4b02e5bab 100644
--- a/tests/rp/src/bin/pwm.rs
+++ b/tests/rp/src/bin/pwm.rs
@@ -28,7 +28,7 @@ async fn main(_spawner: Spawner) {
28 28
29 // Test free-running clock 29 // Test free-running clock
30 { 30 {
31 let pwm = Pwm::new_free(&mut p.PWM_CH3, cfg.clone()); 31 let pwm = Pwm::new_free(&mut p.PWM_SLICE3, cfg.clone());
32 cortex_m::asm::delay(125); 32 cortex_m::asm::delay(125);
33 let ctr = pwm.counter(); 33 let ctr = pwm.counter();
34 assert!(ctr > 0); 34 assert!(ctr > 0);
@@ -46,7 +46,7 @@ async fn main(_spawner: Spawner) {
46 // Test output from A 46 // Test output from A
47 { 47 {
48 let pin1 = Input::new(&mut p9, Pull::None); 48 let pin1 = Input::new(&mut p9, Pull::None);
49 let _pwm = Pwm::new_output_a(&mut p.PWM_CH3, &mut p6, cfg.clone()); 49 let _pwm = Pwm::new_output_a(&mut p.PWM_SLICE3, &mut p6, cfg.clone());
50 Timer::after_millis(1).await; 50 Timer::after_millis(1).await;
51 assert_eq!(pin1.is_low(), invert_a); 51 assert_eq!(pin1.is_low(), invert_a);
52 Timer::after_millis(5).await; 52 Timer::after_millis(5).await;
@@ -60,7 +60,7 @@ async fn main(_spawner: Spawner) {
60 // Test output from B 60 // Test output from B
61 { 61 {
62 let pin2 = Input::new(&mut p11, Pull::None); 62 let pin2 = Input::new(&mut p11, Pull::None);
63 let _pwm = Pwm::new_output_b(&mut p.PWM_CH3, &mut p7, cfg.clone()); 63 let _pwm = Pwm::new_output_b(&mut p.PWM_SLICE3, &mut p7, cfg.clone());
64 Timer::after_millis(1).await; 64 Timer::after_millis(1).await;
65 assert_ne!(pin2.is_low(), invert_a); 65 assert_ne!(pin2.is_low(), invert_a);
66 Timer::after_millis(5).await; 66 Timer::after_millis(5).await;
@@ -75,7 +75,7 @@ async fn main(_spawner: Spawner) {
75 { 75 {
76 let pin1 = Input::new(&mut p9, Pull::None); 76 let pin1 = Input::new(&mut p9, Pull::None);
77 let pin2 = Input::new(&mut p11, Pull::None); 77 let pin2 = Input::new(&mut p11, Pull::None);
78 let _pwm = Pwm::new_output_ab(&mut p.PWM_CH3, &mut p6, &mut p7, cfg.clone()); 78 let _pwm = Pwm::new_output_ab(&mut p.PWM_SLICE3, &mut p6, &mut p7, cfg.clone());
79 Timer::after_millis(1).await; 79 Timer::after_millis(1).await;
80 assert_eq!(pin1.is_low(), invert_a); 80 assert_eq!(pin1.is_low(), invert_a);
81 assert_ne!(pin2.is_low(), invert_a); 81 assert_ne!(pin2.is_low(), invert_a);
@@ -94,7 +94,7 @@ async fn main(_spawner: Spawner) {
94 // Test level-gated 94 // Test level-gated
95 { 95 {
96 let mut pin2 = Output::new(&mut p11, Level::Low); 96 let mut pin2 = Output::new(&mut p11, Level::Low);
97 let pwm = Pwm::new_input(&mut p.PWM_CH3, &mut p7, InputMode::Level, cfg.clone()); 97 let pwm = Pwm::new_input(&mut p.PWM_SLICE3, &mut p7, InputMode::Level, cfg.clone());
98 assert_eq!(pwm.counter(), 0); 98 assert_eq!(pwm.counter(), 0);
99 Timer::after_millis(5).await; 99 Timer::after_millis(5).await;
100 assert_eq!(pwm.counter(), 0); 100 assert_eq!(pwm.counter(), 0);
@@ -110,7 +110,7 @@ async fn main(_spawner: Spawner) {
110 // Test rising-gated 110 // Test rising-gated
111 { 111 {
112 let mut pin2 = Output::new(&mut p11, Level::Low); 112 let mut pin2 = Output::new(&mut p11, Level::Low);
113 let pwm = Pwm::new_input(&mut p.PWM_CH3, &mut p7, InputMode::RisingEdge, cfg.clone()); 113 let pwm = Pwm::new_input(&mut p.PWM_SLICE3, &mut p7, InputMode::RisingEdge, cfg.clone());
114 assert_eq!(pwm.counter(), 0); 114 assert_eq!(pwm.counter(), 0);
115 Timer::after_millis(5).await; 115 Timer::after_millis(5).await;
116 assert_eq!(pwm.counter(), 0); 116 assert_eq!(pwm.counter(), 0);
@@ -125,7 +125,7 @@ async fn main(_spawner: Spawner) {
125 // Test falling-gated 125 // Test falling-gated
126 { 126 {
127 let mut pin2 = Output::new(&mut p11, Level::High); 127 let mut pin2 = Output::new(&mut p11, Level::High);
128 let pwm = Pwm::new_input(&mut p.PWM_CH3, &mut p7, InputMode::FallingEdge, cfg.clone()); 128 let pwm = Pwm::new_input(&mut p.PWM_SLICE3, &mut p7, InputMode::FallingEdge, cfg.clone());
129 assert_eq!(pwm.counter(), 0); 129 assert_eq!(pwm.counter(), 0);
130 Timer::after_millis(5).await; 130 Timer::after_millis(5).await;
131 assert_eq!(pwm.counter(), 0); 131 assert_eq!(pwm.counter(), 0);