2021-10-26 07:37:52 +00:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
#![feature(type_alias_impl_trait)]
|
|
|
|
|
|
|
|
#[path = "../example_common.rs"]
|
|
|
|
mod example_common;
|
|
|
|
use defmt::*;
|
|
|
|
use embassy::executor::Spawner;
|
|
|
|
use embassy::time::{Duration, Timer};
|
|
|
|
use embassy_nrf::pwm::{CounterMode, LoopingConfig, Prescaler, Pwm, SequenceLoad};
|
|
|
|
use embassy_nrf::Peripherals;
|
|
|
|
|
|
|
|
#[embassy::main]
|
|
|
|
async fn main(_spawner: Spawner, p: Peripherals) {
|
2021-10-29 23:39:41 +00:00
|
|
|
let seq_values: [u16; 16] = [
|
|
|
|
0x8000, 0, 0, 0, 0, 0x8000, 0, 0, 0, 0, 0x8000, 0, 0, 0, 0, 0x8000,
|
|
|
|
];
|
2021-10-26 07:37:52 +00:00
|
|
|
let config = LoopingConfig {
|
|
|
|
counter_mode: CounterMode::Up,
|
2021-10-29 23:39:41 +00:00
|
|
|
top: 15625,
|
2021-10-26 07:37:52 +00:00
|
|
|
prescaler: Prescaler::Div128,
|
|
|
|
sequence: &seq_values,
|
2021-10-29 23:39:41 +00:00
|
|
|
sequence_load: SequenceLoad::Individual,
|
|
|
|
repeats: 0,
|
2021-10-26 07:37:52 +00:00
|
|
|
enddelay: 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
let pwm = unwrap!(Pwm::simple_playback(
|
2021-10-29 23:39:41 +00:00
|
|
|
p.PWM0, p.P0_13, p.P0_15, p.P0_16, p.P0_14, config
|
2021-10-26 07:37:52 +00:00
|
|
|
));
|
|
|
|
info!("pwm started!");
|
|
|
|
|
|
|
|
Timer::after(Duration::from_millis(10000)).await;
|
|
|
|
|
|
|
|
pwm.stop();
|
|
|
|
info!("pwm stopped!");
|
|
|
|
|
|
|
|
loop {
|
|
|
|
Timer::after(Duration::from_millis(1000)).await;
|
|
|
|
}
|
|
|
|
}
|