aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorrafael <[email protected]>2024-10-20 23:31:53 +0200
committerrafael <[email protected]>2024-10-20 23:31:53 +0200
commit8baf88f8f4668bdb54c1415bdb8ad62cf2fa5f24 (patch)
treef4425105d4ea307ce29d0ad6fea813512e3bfc35 /examples
parent7fc09f89e8e4b611a868bc986104762b1c5ba81a (diff)
rustfmt
Diffstat (limited to 'examples')
-rw-r--r--examples/rp23/src/bin/pwm_tb6612fng_motor_driver.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/examples/rp23/src/bin/pwm_tb6612fng_motor_driver.rs b/examples/rp23/src/bin/pwm_tb6612fng_motor_driver.rs
index 92c1ff6ba..36b8d9620 100644
--- a/examples/rp23/src/bin/pwm_tb6612fng_motor_driver.rs
+++ b/examples/rp23/src/bin/pwm_tb6612fng_motor_driver.rs
@@ -1,23 +1,23 @@
1//! # PWM TB6612FNG motor driver 1//! # PWM TB6612FNG motor driver
2//! 2//!
3//! This example shows the use of a TB6612FNG motor driver. The driver is built on top of embedded_hal and the example demonstrates how embassy_rp can be used to interact with ist. 3//! This example shows the use of a TB6612FNG motor driver. The driver is built on top of embedded_hal and the example demonstrates how embassy_rp can be used to interact with ist.
4 4
5#![no_std] 5#![no_std]
6#![no_main] 6#![no_main]
7 7
8use assign_resources::assign_resources;
8use defmt::*; 9use defmt::*;
9use embassy_executor::Spawner; 10use embassy_executor::Spawner;
10use embassy_rp::block::ImageDef; 11use embassy_rp::block::ImageDef;
11use embassy_rp::config::Config; 12use embassy_rp::config::Config;
13use embassy_rp::gpio;
12use embassy_rp::gpio::Output; 14use embassy_rp::gpio::Output;
13use embassy_rp::peripherals; 15use embassy_rp::peripherals;
14use embassy_rp::gpio;
15use embassy_rp::pwm; 16use embassy_rp::pwm;
16use embassy_time::Duration; 17use embassy_time::Duration;
17use embassy_time::Timer; 18use embassy_time::Timer;
18use {defmt_rtt as _, panic_probe as _};
19use tb6612fng::{DriveCommand, Motor, Tb6612fng}; 19use tb6612fng::{DriveCommand, Motor, Tb6612fng};
20use assign_resources::assign_resources; 20use {defmt_rtt as _, panic_probe as _};
21 21
22/// Maximum PWM value (fully on) 22/// Maximum PWM value (fully on)
23const PWM_MAX: u16 = 50000; 23const PWM_MAX: u16 = 50000;
@@ -94,21 +94,20 @@ async fn main(_spawner: Spawner) {
94 Timer::after(Duration::from_secs(2)).await; 94 Timer::after(Duration::from_secs(2)).await;
95 95
96 // actively brake 96 // actively brake
97 info!("brake"); 97 info!("brake");
98 control.motor_a.drive(DriveCommand::Brake).unwrap(); 98 control.motor_a.drive(DriveCommand::Brake).unwrap();
99 control.motor_b.drive(DriveCommand::Brake).unwrap(); 99 control.motor_b.drive(DriveCommand::Brake).unwrap();
100 Timer::after(Duration::from_secs(1)).await; 100 Timer::after(Duration::from_secs(1)).await;
101 101
102 // slowly turn for 3s 102 // slowly turn for 3s
103 info!( "turn"); 103 info!("turn");
104 control.motor_a.drive(DriveCommand::Backward(10)).unwrap(); 104 control.motor_a.drive(DriveCommand::Backward(10)).unwrap();
105 control.motor_b.drive(DriveCommand::Forward(10)).unwrap(); 105 control.motor_b.drive(DriveCommand::Forward(10)).unwrap();
106 Timer::after(Duration::from_secs(3)).await; 106 Timer::after(Duration::from_secs(3)).await;
107 107
108 // and put the driver in standby mode and wait for 5s 108 // and put the driver in standby mode and wait for 5s
109 info!( "standby"); 109 info!("standby");
110 control.enable_standby().unwrap(); 110 control.enable_standby().unwrap();
111 Timer::after(Duration::from_secs(5)).await; 111 Timer::after(Duration::from_secs(5)).await;
112 } 112 }
113} 113}
114