aboutsummaryrefslogtreecommitdiff
path: root/examples/rp/src/bin/pwm.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/rp/src/bin/pwm.rs')
-rw-r--r--examples/rp/src/bin/pwm.rs5
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::*;
11use embassy_executor::Spawner; 11use embassy_executor::Spawner;
12use embassy_rp::peripherals::{PIN_25, PIN_4, PWM_SLICE2, PWM_SLICE4}; 12use embassy_rp::peripherals::{PIN_25, PIN_4, PWM_SLICE2, PWM_SLICE4};
13use embassy_rp::pwm::{Config, Pwm, SetDutyCycle}; 13use embassy_rp::pwm::{Config, Pwm, SetDutyCycle};
14use embassy_rp::Peri;
14use embassy_time::Timer; 15use embassy_time::Timer;
15use {defmt_rtt as _, panic_probe as _}; 16use {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]
29async fn pwm_set_config(slice4: PWM_SLICE4, pin25: PIN_25) { 30async 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]
47async fn pwm_set_dutycycle(slice2: PWM_SLICE2, pin4: PIN_4) { 48async 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: