aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/rp/src/bin/pio_pwm.rs4
-rw-r--r--examples/rp/src/bin/pio_servo.rs4
2 files changed, 4 insertions, 4 deletions
diff --git a/examples/rp/src/bin/pio_pwm.rs b/examples/rp/src/bin/pio_pwm.rs
index e14f243aa..23d63d435 100644
--- a/examples/rp/src/bin/pio_pwm.rs
+++ b/examples/rp/src/bin/pio_pwm.rs
@@ -28,7 +28,7 @@ pub struct PwmPio<'d, T: Instance, const SM: usize> {
28} 28}
29 29
30impl<'d, T: Instance, const SM: usize> PwmPio<'d, T, SM> { 30impl<'d, T: Instance, const SM: usize> PwmPio<'d, T, SM> {
31 pub fn attach(pio: &mut Common<'d, T>, mut sm: StateMachine<'d, T, SM>, pin: impl PioPin) -> Self { 31 pub fn new(pio: &mut Common<'d, T>, mut sm: StateMachine<'d, T, SM>, pin: impl PioPin) -> Self {
32 let prg = pio_proc::pio_asm!( 32 let prg = pio_proc::pio_asm!(
33 ".side_set 1 opt" 33 ".side_set 1 opt"
34 "pull noblock side 0" 34 "pull noblock side 0"
@@ -105,7 +105,7 @@ async fn main(_spawner: Spawner) {
105 let Pio { mut common, sm0, .. } = Pio::new(p.PIO0, Irqs); 105 let Pio { mut common, sm0, .. } = Pio::new(p.PIO0, Irqs);
106 106
107 // Note that PIN_25 is the led pin on the Pico 107 // Note that PIN_25 is the led pin on the Pico
108 let mut pwm_pio = PwmPio::attach(&mut common, sm0, p.PIN_25); 108 let mut pwm_pio = PwmPio::new(&mut common, sm0, p.PIN_25);
109 pwm_pio.set_period(Duration::from_micros(REFRESH_INTERVAL)); 109 pwm_pio.set_period(Duration::from_micros(REFRESH_INTERVAL));
110 pwm_pio.start(); 110 pwm_pio.start();
111 111
diff --git a/examples/rp/src/bin/pio_servo.rs b/examples/rp/src/bin/pio_servo.rs
index 47c3121fc..a79540479 100644
--- a/examples/rp/src/bin/pio_servo.rs
+++ b/examples/rp/src/bin/pio_servo.rs
@@ -31,7 +31,7 @@ pub struct PwmPio<'d, T: Instance, const SM: usize> {
31} 31}
32 32
33impl<'d, T: Instance, const SM: usize> PwmPio<'d, T, SM> { 33impl<'d, T: Instance, const SM: usize> PwmPio<'d, T, SM> {
34 pub fn attach(pio: &mut Common<'d, T>, mut sm: StateMachine<'d, T, SM>, pin: impl PioPin) -> Self { 34 pub fn new(pio: &mut Common<'d, T>, mut sm: StateMachine<'d, T, SM>, pin: impl PioPin) -> Self {
35 let prg = pio_proc::pio_asm!( 35 let prg = pio_proc::pio_asm!(
36 ".side_set 1 opt" 36 ".side_set 1 opt"
37 "pull noblock side 0" 37 "pull noblock side 0"
@@ -190,7 +190,7 @@ async fn main(_spawner: Spawner) {
190 let p = embassy_rp::init(Default::default()); 190 let p = embassy_rp::init(Default::default());
191 let Pio { mut common, sm0, .. } = Pio::new(p.PIO0, Irqs); 191 let Pio { mut common, sm0, .. } = Pio::new(p.PIO0, Irqs);
192 192
193 let pwm_pio = PwmPio::attach(&mut common, sm0, p.PIN_1); 193 let pwm_pio = PwmPio::new(&mut common, sm0, p.PIN_1);
194 let mut servo = ServoBuilder::new(pwm_pio) 194 let mut servo = ServoBuilder::new(pwm_pio)
195 .set_max_degree_rotation(120) // Example of adjusting values for MG996R servo 195 .set_max_degree_rotation(120) // Example of adjusting values for MG996R servo
196 .set_min_pulse_width(Duration::from_micros(350)) // This value was detemined by a rough experiment. 196 .set_min_pulse_width(Duration::from_micros(350)) // This value was detemined by a rough experiment.