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};
|
2021-11-04 01:37:54 +00:00
|
|
|
use embassy_nrf::pwm::{Prescaler, SequenceConfig, SequenceLoad, SequenceMode, SequencePwm};
|
2021-10-26 07:37:52 +00:00
|
|
|
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-30 23:16:10 +00:00
|
|
|
|
2021-11-04 01:37:54 +00:00
|
|
|
let mut config = SequenceConfig::default();
|
|
|
|
config.top = 15625;
|
|
|
|
config.prescaler = Prescaler::Div128;
|
|
|
|
config.sequence_load = SequenceLoad::Individual;
|
2021-10-26 07:37:52 +00:00
|
|
|
|
2021-11-04 01:25:44 +00:00
|
|
|
let pwm = unwrap!(SequencePwm::new(
|
2021-11-04 01:37:54 +00:00
|
|
|
p.PWM0,
|
|
|
|
p.P0_13,
|
|
|
|
p.P0_15,
|
|
|
|
p.P0_16,
|
|
|
|
p.P0_14,
|
|
|
|
config,
|
|
|
|
&seq_values,
|
2021-11-02 02:11:37 +00:00
|
|
|
));
|
2021-11-02 17:57:01 +00:00
|
|
|
let _ = pwm.start(SequenceMode::Times(5));
|
2021-10-26 07:37:52 +00:00
|
|
|
info!("pwm started!");
|
|
|
|
|
|
|
|
loop {
|
|
|
|
Timer::after(Duration::from_millis(1000)).await;
|
|
|
|
}
|
|
|
|
}
|