Skip to content

Commit d9f14e9

Browse files
committed
Add more documentation
1 parent 23946d5 commit d9f14e9

File tree

2 files changed

+251
-55
lines changed

2 files changed

+251
-55
lines changed

examples/mcpwm-simple.rs

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,57 @@
1+
/// # x = 10
2+
///
3+
/// . .
4+
/// . .
5+
/// .------. .------.
6+
/// | | | |
7+
/// pin4 | | | |
8+
/// | | | |
9+
/// ----- -------------------------- --------------------------
10+
/// . .
11+
/// . .
12+
/// .------------------------. .------------------------.
13+
/// | | | |
14+
/// pin5 | | | |
15+
/// | | | |
16+
/// ----- -------- --------
17+
/// . .
18+
///
19+
///
20+
/// # x = 50
21+
/// . .
22+
/// . .
23+
/// .---------------. .---------------.
24+
/// | | | |
25+
/// pin4 | | | |
26+
/// | | | |
27+
/// ----- ----------------- -----------------
28+
/// . .
29+
/// . .
30+
/// .---------------. .---------------.
31+
/// | | | |
32+
/// pin5 | | | |
33+
/// | | | |
34+
/// ----- ----------------- -----------------
35+
/// . .
36+
///
37+
///
38+
/// # x = 90
39+
/// . .
40+
/// . .
41+
/// .------------------------. .------------------------.
42+
/// | | | |
43+
/// pin4 | | | |
44+
/// | | | |
45+
/// ----- -------- --------
46+
/// . .
47+
/// . .
48+
/// .------. .------.
49+
/// | | | |
50+
/// pin5 | | | |
51+
/// | | | |
52+
/// ----- -------------------------- --------------------------
53+
/// . .
54+
155
#[cfg(any(esp32, esp32s3))]
256
fn main() -> anyhow::Result<()> {
357
use embedded_hal::delay::blocking::DelayUs;
@@ -12,7 +66,7 @@ fn main() -> anyhow::Result<()> {
1266
println!("Configuring MCPWM");
1367

1468
let peripherals = Peripherals::take().unwrap();
15-
let config = OperatorConfig::default().frequency(25.kHz().into());
69+
let config = OperatorConfig::default().frequency(25.kHz());
1670
let mcpwm = Mcpwm::new(peripherals.mcpwm0.mcpwm)?;
1771
let mut operator = Operator::new(
1872
peripherals.mcpwm0.operator0,
@@ -24,10 +78,10 @@ fn main() -> anyhow::Result<()> {
2478

2579
println!("Starting duty-cycle loop");
2680

27-
for &duty in [0.0, 20.0, 40.0, 60.0, 80.0, 100.0].iter().cycle() {
28-
println!("Duty {}%", duty);
29-
operator.set_duty_a(duty)?;
30-
operator.set_duty_b(100.0 - duty)?;
81+
for &x in [0.0, 20.0, 40.0, 60.0, 80.0, 100.0].iter().cycle() {
82+
println!("Duty {}%", x);
83+
operator.set_duty_a(x)?;
84+
operator.set_duty_b(100.0 - x)?;
3185
FreeRtos.delay_ms(2000)?;
3286
}
3387

0 commit comments

Comments
 (0)