diff options
| author | Sebastian Goll <[email protected]> | 2024-04-02 18:10:25 +0200 |
|---|---|---|
| committer | Sebastian Goll <[email protected]> | 2024-04-02 18:10:25 +0200 |
| commit | 7506519a13434736eac6c2b82cf95a405c69d74b (patch) | |
| tree | d5367f40bd046d09534bfadb88b5074a911b128e | |
| parent | 804b19b116ab4a4e883eb709dac3fddd982dc59e (diff) | |
| parent | e29b5619d1dafb46a25f42a5b3552605bb3c2d86 (diff) | |
Merge remote-tracking branch 'upstream/main' into i2c-async-transaction
| -rw-r--r-- | embassy-rp/src/lib.rs | 16 | ||||
| -rw-r--r-- | embassy-rp/src/pwm.rs | 76 | ||||
| -rw-r--r-- | examples/rp/src/bin/pio_hd44780.rs | 2 | ||||
| -rw-r--r-- | examples/rp/src/bin/pwm.rs | 2 | ||||
| -rw-r--r-- | examples/rp/src/bin/pwm_input.rs | 2 | ||||
| -rw-r--r-- | tests/rp/src/bin/pwm.rs | 14 |
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 | ||
| 329 | channel!(PWM_CH0, 0); | 329 | channel!(PWM_SLICE0, 0); |
| 330 | channel!(PWM_CH1, 1); | 330 | channel!(PWM_SLICE1, 1); |
| 331 | channel!(PWM_CH2, 2); | 331 | channel!(PWM_SLICE2, 2); |
| 332 | channel!(PWM_CH3, 3); | 332 | channel!(PWM_SLICE3, 3); |
| 333 | channel!(PWM_CH4, 4); | 333 | channel!(PWM_SLICE4, 4); |
| 334 | channel!(PWM_CH5, 5); | 334 | channel!(PWM_SLICE5, 5); |
| 335 | channel!(PWM_CH6, 6); | 335 | channel!(PWM_SLICE6, 6); |
| 336 | channel!(PWM_CH7, 7); | 336 | channel!(PWM_SLICE7, 7); |
| 337 | 337 | ||
| 338 | /// PWM Pin A. | 338 | /// PWM Pin A. |
| 339 | pub trait PwmPinA<T: Channel>: GpioPin {} | 339 | pub trait PwmPinA<T: Channel>: GpioPin {} |
| @@ -346,33 +346,33 @@ macro_rules! impl_pin { | |||
| 346 | }; | 346 | }; |
| 347 | } | 347 | } |
| 348 | 348 | ||
| 349 | impl_pin!(PIN_0, PWM_CH0, PwmPinA); | 349 | impl_pin!(PIN_0, PWM_SLICE0, PwmPinA); |
| 350 | impl_pin!(PIN_1, PWM_CH0, PwmPinB); | 350 | impl_pin!(PIN_1, PWM_SLICE0, PwmPinB); |
| 351 | impl_pin!(PIN_2, PWM_CH1, PwmPinA); | 351 | impl_pin!(PIN_2, PWM_SLICE1, PwmPinA); |
| 352 | impl_pin!(PIN_3, PWM_CH1, PwmPinB); | 352 | impl_pin!(PIN_3, PWM_SLICE1, PwmPinB); |
| 353 | impl_pin!(PIN_4, PWM_CH2, PwmPinA); | 353 | impl_pin!(PIN_4, PWM_SLICE2, PwmPinA); |
| 354 | impl_pin!(PIN_5, PWM_CH2, PwmPinB); | 354 | impl_pin!(PIN_5, PWM_SLICE2, PwmPinB); |
| 355 | impl_pin!(PIN_6, PWM_CH3, PwmPinA); | 355 | impl_pin!(PIN_6, PWM_SLICE3, PwmPinA); |
| 356 | impl_pin!(PIN_7, PWM_CH3, PwmPinB); | 356 | impl_pin!(PIN_7, PWM_SLICE3, PwmPinB); |
| 357 | impl_pin!(PIN_8, PWM_CH4, PwmPinA); | 357 | impl_pin!(PIN_8, PWM_SLICE4, PwmPinA); |
| 358 | impl_pin!(PIN_9, PWM_CH4, PwmPinB); | 358 | impl_pin!(PIN_9, PWM_SLICE4, PwmPinB); |
| 359 | impl_pin!(PIN_10, PWM_CH5, PwmPinA); | 359 | impl_pin!(PIN_10, PWM_SLICE5, PwmPinA); |
| 360 | impl_pin!(PIN_11, PWM_CH5, PwmPinB); | 360 | impl_pin!(PIN_11, PWM_SLICE5, PwmPinB); |
| 361 | impl_pin!(PIN_12, PWM_CH6, PwmPinA); | 361 | impl_pin!(PIN_12, PWM_SLICE6, PwmPinA); |
| 362 | impl_pin!(PIN_13, PWM_CH6, PwmPinB); | 362 | impl_pin!(PIN_13, PWM_SLICE6, PwmPinB); |
| 363 | impl_pin!(PIN_14, PWM_CH7, PwmPinA); | 363 | impl_pin!(PIN_14, PWM_SLICE7, PwmPinA); |
| 364 | impl_pin!(PIN_15, PWM_CH7, PwmPinB); | 364 | impl_pin!(PIN_15, PWM_SLICE7, PwmPinB); |
| 365 | impl_pin!(PIN_16, PWM_CH0, PwmPinA); | 365 | impl_pin!(PIN_16, PWM_SLICE0, PwmPinA); |
| 366 | impl_pin!(PIN_17, PWM_CH0, PwmPinB); | 366 | impl_pin!(PIN_17, PWM_SLICE0, PwmPinB); |
| 367 | impl_pin!(PIN_18, PWM_CH1, PwmPinA); | 367 | impl_pin!(PIN_18, PWM_SLICE1, PwmPinA); |
| 368 | impl_pin!(PIN_19, PWM_CH1, PwmPinB); | 368 | impl_pin!(PIN_19, PWM_SLICE1, PwmPinB); |
| 369 | impl_pin!(PIN_20, PWM_CH2, PwmPinA); | 369 | impl_pin!(PIN_20, PWM_SLICE2, PwmPinA); |
| 370 | impl_pin!(PIN_21, PWM_CH2, PwmPinB); | 370 | impl_pin!(PIN_21, PWM_SLICE2, PwmPinB); |
| 371 | impl_pin!(PIN_22, PWM_CH3, PwmPinA); | 371 | impl_pin!(PIN_22, PWM_SLICE3, PwmPinA); |
| 372 | impl_pin!(PIN_23, PWM_CH3, PwmPinB); | 372 | impl_pin!(PIN_23, PWM_SLICE3, PwmPinB); |
| 373 | impl_pin!(PIN_24, PWM_CH4, PwmPinA); | 373 | impl_pin!(PIN_24, PWM_SLICE4, PwmPinA); |
| 374 | impl_pin!(PIN_25, PWM_CH4, PwmPinB); | 374 | impl_pin!(PIN_25, PWM_SLICE4, PwmPinB); |
| 375 | impl_pin!(PIN_26, PWM_CH5, PwmPinA); | 375 | impl_pin!(PIN_26, PWM_SLICE5, PwmPinA); |
| 376 | impl_pin!(PIN_27, PWM_CH5, PwmPinB); | 376 | impl_pin!(PIN_27, PWM_SLICE5, PwmPinB); |
| 377 | impl_pin!(PIN_28, PWM_CH6, PwmPinA); | 377 | impl_pin!(PIN_28, PWM_SLICE6, PwmPinA); |
| 378 | impl_pin!(PIN_29, PWM_CH6, PwmPinB); | 378 | impl_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); |
