diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-03-26 16:01:37 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-03-27 15:18:06 +0100 |
| commit | d41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch) | |
| tree | 678b6fc732216e529dc38e6f65b72a309917ac32 /examples/rp/src/bin/pwm.rs | |
| parent | 9edf5b7f049f95742b60b041e4443967d8a6b708 (diff) | |
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'examples/rp/src/bin/pwm.rs')
| -rw-r--r-- | examples/rp/src/bin/pwm.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/examples/rp/src/bin/pwm.rs b/examples/rp/src/bin/pwm.rs index 2f5f94870..04374323d 100644 --- a/examples/rp/src/bin/pwm.rs +++ b/examples/rp/src/bin/pwm.rs | |||
| @@ -11,6 +11,7 @@ use defmt::*; | |||
| 11 | use embassy_executor::Spawner; | 11 | use embassy_executor::Spawner; |
| 12 | use embassy_rp::peripherals::{PIN_25, PIN_4, PWM_SLICE2, PWM_SLICE4}; | 12 | use embassy_rp::peripherals::{PIN_25, PIN_4, PWM_SLICE2, PWM_SLICE4}; |
| 13 | use embassy_rp::pwm::{Config, Pwm, SetDutyCycle}; | 13 | use embassy_rp::pwm::{Config, Pwm, SetDutyCycle}; |
| 14 | use embassy_rp::Peri; | ||
| 14 | use embassy_time::Timer; | 15 | use embassy_time::Timer; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 16 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 17 | ||
| @@ -26,7 +27,7 @@ async fn main(spawner: Spawner) { | |||
| 26 | /// Using the onboard led, if You are using a different Board than plain Pico2 (i.e. W variant) | 27 | /// Using the onboard led, if You are using a different Board than plain Pico2 (i.e. W variant) |
| 27 | /// you must use another slice & pin and an appropriate resistor. | 28 | /// you must use another slice & pin and an appropriate resistor. |
| 28 | #[embassy_executor::task] | 29 | #[embassy_executor::task] |
| 29 | async fn pwm_set_config(slice4: PWM_SLICE4, pin25: PIN_25) { | 30 | async fn pwm_set_config(slice4: Peri<'static, PWM_SLICE4>, pin25: Peri<'static, PIN_25>) { |
| 30 | let mut c = Config::default(); | 31 | let mut c = Config::default(); |
| 31 | c.top = 32_768; | 32 | c.top = 32_768; |
| 32 | c.compare_b = 8; | 33 | c.compare_b = 8; |
| @@ -44,7 +45,7 @@ async fn pwm_set_config(slice4: PWM_SLICE4, pin25: PIN_25) { | |||
| 44 | /// | 45 | /// |
| 45 | /// Using GP4 in Slice2, make sure to use an appropriate resistor. | 46 | /// Using GP4 in Slice2, make sure to use an appropriate resistor. |
| 46 | #[embassy_executor::task] | 47 | #[embassy_executor::task] |
| 47 | async fn pwm_set_dutycycle(slice2: PWM_SLICE2, pin4: PIN_4) { | 48 | async fn pwm_set_dutycycle(slice2: Peri<'static, PWM_SLICE2>, pin4: Peri<'static, PIN_4>) { |
| 48 | // If we aim for a specific frequency, here is how we can calculate the top value. | 49 | // If we aim for a specific frequency, here is how we can calculate the top value. |
| 49 | // The top value sets the period of the PWM cycle, so a counter goes from 0 to top and then wraps around to 0. | 50 | // The top value sets the period of the PWM cycle, so a counter goes from 0 to top and then wraps around to 0. |
| 50 | // Every such wraparound is one PWM cycle. So here is how we get 25KHz: | 51 | // Every such wraparound is one PWM cycle. So here is how we get 25KHz: |
