diff options
Diffstat (limited to 'examples/nrf')
| -rw-r--r-- | examples/nrf/src/bin/pwm.rs | 2 | ||||
| -rw-r--r-- | examples/nrf/src/bin/pwm_double_sequence.rs | 5 | ||||
| -rw-r--r-- | examples/nrf/src/bin/pwm_sequence.rs | 5 | ||||
| -rw-r--r-- | examples/nrf/src/bin/pwm_sequence_ppi.rs | 6 | ||||
| -rw-r--r-- | examples/nrf/src/bin/pwm_sequence_ws2812b.rs | 5 | ||||
| -rw-r--r-- | examples/nrf/src/bin/pwm_servo.rs | 3 | ||||
| -rw-r--r-- | examples/nrf/src/bin/uart.rs | 3 | ||||
| -rw-r--r-- | examples/nrf/src/bin/uart_idle.rs | 3 | ||||
| -rw-r--r-- | examples/nrf/src/bin/uart_split.rs | 3 |
9 files changed, 10 insertions, 25 deletions
diff --git a/examples/nrf/src/bin/pwm.rs b/examples/nrf/src/bin/pwm.rs index 8679eddd8..68402ce22 100644 --- a/examples/nrf/src/bin/pwm.rs +++ b/examples/nrf/src/bin/pwm.rs | |||
| @@ -85,7 +85,7 @@ static DUTY: [u16; 1024] = [ | |||
| 85 | 85 | ||
| 86 | #[embassy::main] | 86 | #[embassy::main] |
| 87 | async fn main(_spawner: Spawner, p: Peripherals) { | 87 | async fn main(_spawner: Spawner, p: Peripherals) { |
| 88 | let mut pwm = SimplePwm::new(p.PWM0, p.P0_13, p.P0_14, p.P0_16, p.P0_15); | 88 | let mut pwm = SimplePwm::new_4ch(p.PWM0, p.P0_13, p.P0_14, p.P0_16, p.P0_15); |
| 89 | pwm.set_prescaler(Prescaler::Div1); | 89 | pwm.set_prescaler(Prescaler::Div1); |
| 90 | pwm.set_max_duty(32767); | 90 | pwm.set_max_duty(32767); |
| 91 | info!("pwm initialized!"); | 91 | info!("pwm initialized!"); |
diff --git a/examples/nrf/src/bin/pwm_double_sequence.rs b/examples/nrf/src/bin/pwm_double_sequence.rs index 269015f4a..85938f32c 100644 --- a/examples/nrf/src/bin/pwm_double_sequence.rs +++ b/examples/nrf/src/bin/pwm_double_sequence.rs | |||
| @@ -7,7 +7,6 @@ mod example_common; | |||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| 9 | use embassy::time::{Duration, Timer}; | 9 | use embassy::time::{Duration, Timer}; |
| 10 | use embassy_nrf::gpio::NoPin; | ||
| 11 | use embassy_nrf::pwm::{ | 10 | use embassy_nrf::pwm::{ |
| 12 | Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, | 11 | Config, Prescaler, Sequence, SequenceConfig, SequenceMode, SequencePwm, Sequencer, |
| 13 | StartSequence, | 12 | StartSequence, |
| @@ -29,9 +28,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 29 | seq_config.refresh = 624; | 28 | seq_config.refresh = 624; |
| 30 | // thus our sequence takes 5 * 5000ms or 25 seconds | 29 | // thus our sequence takes 5 * 5000ms or 25 seconds |
| 31 | 30 | ||
| 32 | let mut pwm = unwrap!(SequencePwm::new( | 31 | let mut pwm = unwrap!(SequencePwm::new_1ch(p.PWM0, p.P0_13, config)); |
| 33 | p.PWM0, p.P0_13, NoPin, NoPin, NoPin, config, | ||
| 34 | )); | ||
| 35 | 32 | ||
| 36 | let sequence_0 = Sequence::new(&seq_words_0, seq_config.clone()); | 33 | let sequence_0 = Sequence::new(&seq_words_0, seq_config.clone()); |
| 37 | let sequence_1 = Sequence::new(&seq_words_1, seq_config); | 34 | let sequence_1 = Sequence::new(&seq_words_1, seq_config); |
diff --git a/examples/nrf/src/bin/pwm_sequence.rs b/examples/nrf/src/bin/pwm_sequence.rs index f06ea0b19..f42958145 100644 --- a/examples/nrf/src/bin/pwm_sequence.rs +++ b/examples/nrf/src/bin/pwm_sequence.rs | |||
| @@ -7,7 +7,6 @@ mod example_common; | |||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| 9 | use embassy::time::{Duration, Timer}; | 9 | use embassy::time::{Duration, Timer}; |
| 10 | use embassy_nrf::gpio::NoPin; | ||
| 11 | use embassy_nrf::pwm::{ | 10 | use embassy_nrf::pwm::{ |
| 12 | Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer, | 11 | Config, Prescaler, SequenceConfig, SequencePwm, SingleSequenceMode, SingleSequencer, |
| 13 | }; | 12 | }; |
| @@ -27,9 +26,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 27 | seq_config.refresh = 624; | 26 | seq_config.refresh = 624; |
| 28 | // thus our sequence takes 5 * 5000ms or 25 seconds | 27 | // thus our sequence takes 5 * 5000ms or 25 seconds |
| 29 | 28 | ||
| 30 | let mut pwm = unwrap!(SequencePwm::new( | 29 | let mut pwm = unwrap!(SequencePwm::new_1ch(p.PWM0, p.P0_13, config,)); |
| 31 | p.PWM0, p.P0_13, NoPin, NoPin, NoPin, config, | ||
| 32 | )); | ||
| 33 | 30 | ||
| 34 | let sequencer = SingleSequencer::new(&mut pwm, &seq_words, seq_config); | 31 | let sequencer = SingleSequencer::new(&mut pwm, &seq_words, seq_config); |
| 35 | unwrap!(sequencer.start(SingleSequenceMode::Times(1))); | 32 | unwrap!(sequencer.start(SingleSequenceMode::Times(1))); |
diff --git a/examples/nrf/src/bin/pwm_sequence_ppi.rs b/examples/nrf/src/bin/pwm_sequence_ppi.rs index c25c5e10d..66717c592 100644 --- a/examples/nrf/src/bin/pwm_sequence_ppi.rs +++ b/examples/nrf/src/bin/pwm_sequence_ppi.rs | |||
| @@ -8,7 +8,7 @@ mod example_common; | |||
| 8 | use core::future::pending; | 8 | use core::future::pending; |
| 9 | use defmt::*; | 9 | use defmt::*; |
| 10 | use embassy::executor::Spawner; | 10 | use embassy::executor::Spawner; |
| 11 | use embassy_nrf::gpio::{Input, NoPin, Pull}; | 11 | use embassy_nrf::gpio::{Input, Pull}; |
| 12 | use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; | 12 | use embassy_nrf::gpiote::{InputChannel, InputChannelPolarity}; |
| 13 | use embassy_nrf::ppi::Ppi; | 13 | use embassy_nrf::ppi::Ppi; |
| 14 | use embassy_nrf::pwm::{ | 14 | use embassy_nrf::pwm::{ |
| @@ -29,9 +29,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 29 | let mut seq_config = SequenceConfig::default(); | 29 | let mut seq_config = SequenceConfig::default(); |
| 30 | seq_config.refresh = 30; | 30 | seq_config.refresh = 30; |
| 31 | 31 | ||
| 32 | let mut pwm = unwrap!(SequencePwm::new( | 32 | let mut pwm = unwrap!(SequencePwm::new_1ch(p.PWM0, p.P0_13, config)); |
| 33 | p.PWM0, p.P0_13, NoPin, NoPin, NoPin, config, | ||
| 34 | )); | ||
| 35 | 33 | ||
| 36 | // pwm.stop() deconfigures pins, and then the task_start_seq0 task cant work | 34 | // pwm.stop() deconfigures pins, and then the task_start_seq0 task cant work |
| 37 | // so its going to have to start running in order load the configuration | 35 | // so its going to have to start running in order load the configuration |
diff --git a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs index d1a027a7e..e5af7b462 100644 --- a/examples/nrf/src/bin/pwm_sequence_ws2812b.rs +++ b/examples/nrf/src/bin/pwm_sequence_ws2812b.rs | |||
| @@ -7,7 +7,6 @@ mod example_common; | |||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| 9 | use embassy::time::{Duration, Timer}; | 9 | use embassy::time::{Duration, Timer}; |
| 10 | use embassy_nrf::gpio::NoPin; | ||
| 11 | use embassy_nrf::pwm::{ | 10 | use embassy_nrf::pwm::{ |
| 12 | Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, | 11 | Config, Prescaler, SequenceConfig, SequenceLoad, SequencePwm, SingleSequenceMode, |
| 13 | SingleSequencer, | 12 | SingleSequencer, |
| @@ -35,9 +34,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 35 | config.sequence_load = SequenceLoad::Common; | 34 | config.sequence_load = SequenceLoad::Common; |
| 36 | config.prescaler = Prescaler::Div1; | 35 | config.prescaler = Prescaler::Div1; |
| 37 | config.max_duty = 20; // 1.25us (1s / 16Mhz * 20) | 36 | config.max_duty = 20; // 1.25us (1s / 16Mhz * 20) |
| 38 | let mut pwm = unwrap!(SequencePwm::new( | 37 | let mut pwm = unwrap!(SequencePwm::new_1ch(p.PWM0, p.P1_05, config)); |
| 39 | p.PWM0, p.P1_05, NoPin, NoPin, NoPin, config, | ||
| 40 | )); | ||
| 41 | 38 | ||
| 42 | // Declare the bits of 24 bits in a buffer we'll be | 39 | // Declare the bits of 24 bits in a buffer we'll be |
| 43 | // mutating later. | 40 | // mutating later. |
diff --git a/examples/nrf/src/bin/pwm_servo.rs b/examples/nrf/src/bin/pwm_servo.rs index 7859a858e..c2ab0e7d1 100644 --- a/examples/nrf/src/bin/pwm_servo.rs +++ b/examples/nrf/src/bin/pwm_servo.rs | |||
| @@ -7,13 +7,12 @@ mod example_common; | |||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| 9 | use embassy::time::{Duration, Timer}; | 9 | use embassy::time::{Duration, Timer}; |
| 10 | use embassy_nrf::gpio::NoPin; | ||
| 11 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; | 10 | use embassy_nrf::pwm::{Prescaler, SimplePwm}; |
| 12 | use embassy_nrf::Peripherals; | 11 | use embassy_nrf::Peripherals; |
| 13 | 12 | ||
| 14 | #[embassy::main] | 13 | #[embassy::main] |
| 15 | async fn main(_spawner: Spawner, p: Peripherals) { | 14 | async fn main(_spawner: Spawner, p: Peripherals) { |
| 16 | let mut pwm = SimplePwm::new(p.PWM0, p.P0_05, NoPin, NoPin, NoPin); | 15 | let mut pwm = SimplePwm::new_1ch(p.PWM0, p.P0_05); |
| 17 | // sg90 microervo requires 50hz or 20ms period | 16 | // sg90 microervo requires 50hz or 20ms period |
| 18 | // set_period can only set down to 125khz so we cant use it directly | 17 | // set_period can only set down to 125khz so we cant use it directly |
| 19 | // Div128 is 125khz or 0.000008s or 0.008ms, 20/0.008 is 2500 is top | 18 | // Div128 is 125khz or 0.000008s or 0.008ms, 20/0.008 is 2500 is top |
diff --git a/examples/nrf/src/bin/uart.rs b/examples/nrf/src/bin/uart.rs index 68ee3978a..5dc89df66 100644 --- a/examples/nrf/src/bin/uart.rs +++ b/examples/nrf/src/bin/uart.rs | |||
| @@ -7,7 +7,6 @@ mod example_common; | |||
| 7 | use example_common::*; | 7 | use example_common::*; |
| 8 | 8 | ||
| 9 | use embassy::executor::Spawner; | 9 | use embassy::executor::Spawner; |
| 10 | use embassy_nrf::gpio::NoPin; | ||
| 11 | use embassy_nrf::{interrupt, uarte, Peripherals}; | 10 | use embassy_nrf::{interrupt, uarte, Peripherals}; |
| 12 | 11 | ||
| 13 | #[embassy::main] | 12 | #[embassy::main] |
| @@ -17,7 +16,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 17 | config.baudrate = uarte::Baudrate::BAUD115200; | 16 | config.baudrate = uarte::Baudrate::BAUD115200; |
| 18 | 17 | ||
| 19 | let irq = interrupt::take!(UARTE0_UART0); | 18 | let irq = interrupt::take!(UARTE0_UART0); |
| 20 | let mut uart = uarte::Uarte::new(p.UARTE0, irq, p.P0_08, p.P0_06, NoPin, NoPin, config); | 19 | let mut uart = uarte::Uarte::new(p.UARTE0, irq, p.P0_08, p.P0_06, config); |
| 21 | 20 | ||
| 22 | info!("uarte initialized!"); | 21 | info!("uarte initialized!"); |
| 23 | 22 | ||
diff --git a/examples/nrf/src/bin/uart_idle.rs b/examples/nrf/src/bin/uart_idle.rs index 76449c0e3..88dc185af 100644 --- a/examples/nrf/src/bin/uart_idle.rs +++ b/examples/nrf/src/bin/uart_idle.rs | |||
| @@ -7,7 +7,6 @@ mod example_common; | |||
| 7 | use example_common::*; | 7 | use example_common::*; |
| 8 | 8 | ||
| 9 | use embassy::executor::Spawner; | 9 | use embassy::executor::Spawner; |
| 10 | use embassy_nrf::gpio::NoPin; | ||
| 11 | use embassy_nrf::{interrupt, uarte, Peripherals}; | 10 | use embassy_nrf::{interrupt, uarte, Peripherals}; |
| 12 | 11 | ||
| 13 | #[embassy::main] | 12 | #[embassy::main] |
| @@ -18,7 +17,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { | |||
| 18 | 17 | ||
| 19 | let irq = interrupt::take!(UARTE0_UART0); | 18 | let irq = interrupt::take!(UARTE0_UART0); |
| 20 | let mut uart = uarte::UarteWithIdle::new( | 19 | let mut uart = uarte::UarteWithIdle::new( |
| 21 | p.UARTE0, p.TIMER0, p.PPI_CH0, p.PPI_CH1, irq, p.P0_08, p.P0_06, NoPin, NoPin, config, | 20 | p.UARTE0, p.TIMER0, p.PPI_CH0, p.PPI_CH1, irq, p.P0_08, p.P0_06, config, |
| 22 | ); | 21 | ); |
| 23 | 22 | ||
| 24 | info!("uarte initialized!"); | 23 | info!("uarte initialized!"); |
diff --git a/examples/nrf/src/bin/uart_split.rs b/examples/nrf/src/bin/uart_split.rs index a9c02e796..750798378 100644 --- a/examples/nrf/src/bin/uart_split.rs +++ b/examples/nrf/src/bin/uart_split.rs | |||
| @@ -10,7 +10,6 @@ use embassy::blocking_mutex::kind::Noop; | |||
| 10 | use embassy::channel::mpsc::{self, Channel, Sender}; | 10 | use embassy::channel::mpsc::{self, Channel, Sender}; |
| 11 | use embassy::executor::Spawner; | 11 | use embassy::executor::Spawner; |
| 12 | use embassy::util::Forever; | 12 | use embassy::util::Forever; |
| 13 | use embassy_nrf::gpio::NoPin; | ||
| 14 | use embassy_nrf::peripherals::UARTE0; | 13 | use embassy_nrf::peripherals::UARTE0; |
| 15 | use embassy_nrf::uarte::UarteRx; | 14 | use embassy_nrf::uarte::UarteRx; |
| 16 | use embassy_nrf::{interrupt, uarte, Peripherals}; | 15 | use embassy_nrf::{interrupt, uarte, Peripherals}; |
| @@ -24,7 +23,7 @@ async fn main(spawner: Spawner, p: Peripherals) { | |||
| 24 | config.baudrate = uarte::Baudrate::BAUD115200; | 23 | config.baudrate = uarte::Baudrate::BAUD115200; |
| 25 | 24 | ||
| 26 | let irq = interrupt::take!(UARTE0_UART0); | 25 | let irq = interrupt::take!(UARTE0_UART0); |
| 27 | let uart = uarte::Uarte::new(p.UARTE0, irq, p.P0_08, p.P0_06, NoPin, NoPin, config); | 26 | let uart = uarte::Uarte::new(p.UARTE0, irq, p.P0_08, p.P0_06, config); |
| 28 | let (mut tx, rx) = uart.split(); | 27 | let (mut tx, rx) = uart.split(); |
| 29 | 28 | ||
| 30 | let c = CHANNEL.put(Channel::new()); | 29 | let c = CHANNEL.put(Channel::new()); |
