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-02 02:11:37 +00:00
|
|
|
use embassy_nrf::pwm::{
|
2021-11-04 01:25:44 +00:00
|
|
|
CounterMode, Prescaler, SequenceConfig, SequenceLoad, SequenceMode, SequencePwm,
|
2021-11-02 02:11:37 +00:00
|
|
|
};
|
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-01 15:54:07 +00:00
|
|
|
let config = SequenceConfig {
|
2021-10-26 07:37:52 +00:00
|
|
|
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,
|
2021-10-30 23:16:10 +00:00
|
|
|
refresh: 0,
|
2021-11-01 08:20:01 +00:00
|
|
|
end_delay: 0,
|
2021-10-26 07:37:52 +00:00
|
|
|
};
|
|
|
|
|
2021-11-04 01:25:44 +00:00
|
|
|
let pwm = unwrap!(SequencePwm::new(
|
2021-11-02 02:11:37 +00:00
|
|
|
p.PWM0, p.P0_13, p.P0_15, p.P0_16, p.P0_14, config
|
|
|
|
));
|
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;
|
|
|
|
}
|
|
|
|
}
|