diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-02-01 00:48:33 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-02-01 01:17:41 +0100 |
| commit | b5cf332cc076a0de11ce6a0563a2235c9e57eb5c (patch) | |
| tree | ce14e014dfbe8c3764040d7f9f1ffee84ab5747b /examples | |
| parent | ca10fe7135d10084e38038f3cd433da39e505bea (diff) | |
nrf: docs.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/nrf52840/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/nrf52840/src/bin/i2s_effect.rs | 6 | ||||
| -rw-r--r-- | examples/nrf52840/src/bin/i2s_monitor.rs | 6 | ||||
| -rw-r--r-- | examples/nrf52840/src/bin/i2s_waveform.rs | 6 | ||||
| -rw-r--r-- | examples/nrf52840/src/bin/saadc_continuous.rs | 4 | ||||
| -rw-r--r-- | examples/nrf52840/src/bin/usb_ethernet.rs | 6 | ||||
| -rw-r--r-- | examples/nrf52840/src/bin/usb_hid_keyboard.rs | 4 | ||||
| -rw-r--r-- | examples/nrf52840/src/bin/usb_hid_mouse.rs | 4 | ||||
| -rw-r--r-- | examples/nrf52840/src/bin/usb_serial.rs | 6 | ||||
| -rw-r--r-- | examples/nrf52840/src/bin/usb_serial_multitask.rs | 6 |
10 files changed, 25 insertions, 25 deletions
diff --git a/examples/nrf52840/Cargo.toml b/examples/nrf52840/Cargo.toml index bbd8a5d2f..95d939873 100644 --- a/examples/nrf52840/Cargo.toml +++ b/examples/nrf52840/Cargo.toml | |||
| @@ -14,7 +14,7 @@ embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | |||
| 14 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } | 14 | embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] } |
| 15 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } | 15 | embassy-executor = { version = "0.1.0", path = "../../embassy-executor", features = ["defmt", "integrated-timers"] } |
| 16 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | 16 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } |
| 17 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } | 17 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac", "time"] } |
| 18 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"], optional = true } | 18 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet"], optional = true } |
| 19 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"], optional = true } | 19 | embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"], optional = true } |
| 20 | embedded-io = "0.4.0" | 20 | embedded-io = "0.4.0" |
diff --git a/examples/nrf52840/src/bin/i2s_effect.rs b/examples/nrf52840/src/bin/i2s_effect.rs index 3cca005b1..52d46e4f9 100644 --- a/examples/nrf52840/src/bin/i2s_effect.rs +++ b/examples/nrf52840/src/bin/i2s_effect.rs | |||
| @@ -24,9 +24,9 @@ async fn main(_spawner: Spawner) { | |||
| 24 | let sample_rate = master_clock.sample_rate(); | 24 | let sample_rate = master_clock.sample_rate(); |
| 25 | info!("Sample rate: {}", sample_rate); | 25 | info!("Sample rate: {}", sample_rate); |
| 26 | 26 | ||
| 27 | let config = Config::default() | 27 | let mut config = Config::default(); |
| 28 | .sample_width(SampleWidth::_16bit) | 28 | config.sample_width = SampleWidth::_16bit; |
| 29 | .channels(Channels::MonoLeft); | 29 | config.channels = Channels::MonoLeft; |
| 30 | 30 | ||
| 31 | let irq = interrupt::take!(I2S); | 31 | let irq = interrupt::take!(I2S); |
| 32 | let buffers_out = MultiBuffering::<Sample, NUM_BUFFERS, NUM_SAMPLES>::new(); | 32 | let buffers_out = MultiBuffering::<Sample, NUM_BUFFERS, NUM_SAMPLES>::new(); |
diff --git a/examples/nrf52840/src/bin/i2s_monitor.rs b/examples/nrf52840/src/bin/i2s_monitor.rs index 48eb7d581..5ebfd9542 100644 --- a/examples/nrf52840/src/bin/i2s_monitor.rs +++ b/examples/nrf52840/src/bin/i2s_monitor.rs | |||
| @@ -22,9 +22,9 @@ async fn main(_spawner: Spawner) { | |||
| 22 | let sample_rate = master_clock.sample_rate(); | 22 | let sample_rate = master_clock.sample_rate(); |
| 23 | info!("Sample rate: {}", sample_rate); | 23 | info!("Sample rate: {}", sample_rate); |
| 24 | 24 | ||
| 25 | let config = Config::default() | 25 | let mut config = Config::default(); |
| 26 | .sample_width(SampleWidth::_16bit) | 26 | config.sample_width = SampleWidth::_16bit; |
| 27 | .channels(Channels::MonoLeft); | 27 | config.channels = Channels::MonoLeft; |
| 28 | 28 | ||
| 29 | let irq = interrupt::take!(I2S); | 29 | let irq = interrupt::take!(I2S); |
| 30 | let buffers = DoubleBuffering::<Sample, NUM_SAMPLES>::new(); | 30 | let buffers = DoubleBuffering::<Sample, NUM_SAMPLES>::new(); |
diff --git a/examples/nrf52840/src/bin/i2s_waveform.rs b/examples/nrf52840/src/bin/i2s_waveform.rs index 1b0e8ebc8..eda930677 100644 --- a/examples/nrf52840/src/bin/i2s_waveform.rs +++ b/examples/nrf52840/src/bin/i2s_waveform.rs | |||
| @@ -23,9 +23,9 @@ async fn main(_spawner: Spawner) { | |||
| 23 | let sample_rate = master_clock.sample_rate(); | 23 | let sample_rate = master_clock.sample_rate(); |
| 24 | info!("Sample rate: {}", sample_rate); | 24 | info!("Sample rate: {}", sample_rate); |
| 25 | 25 | ||
| 26 | let config = Config::default() | 26 | let mut config = Config::default(); |
| 27 | .sample_width(SampleWidth::_16bit) | 27 | config.sample_width = SampleWidth::_16bit; |
| 28 | .channels(Channels::MonoLeft); | 28 | config.channels = Channels::MonoLeft; |
| 29 | 29 | ||
| 30 | let irq = interrupt::take!(I2S); | 30 | let irq = interrupt::take!(I2S); |
| 31 | let buffers = DoubleBuffering::<Sample, NUM_SAMPLES>::new(); | 31 | let buffers = DoubleBuffering::<Sample, NUM_SAMPLES>::new(); |
diff --git a/examples/nrf52840/src/bin/saadc_continuous.rs b/examples/nrf52840/src/bin/saadc_continuous.rs index bb50ac65e..2551d15fd 100644 --- a/examples/nrf52840/src/bin/saadc_continuous.rs +++ b/examples/nrf52840/src/bin/saadc_continuous.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::info; | 5 | use defmt::info; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::interrupt; | 7 | use embassy_nrf::interrupt; |
| 8 | use embassy_nrf::saadc::{ChannelConfig, Config, Saadc, SamplerState}; | 8 | use embassy_nrf::saadc::{CallbackResult, ChannelConfig, Config, Saadc}; |
| 9 | use embassy_nrf::timer::Frequency; | 9 | use embassy_nrf::timer::Frequency; |
| 10 | use embassy_time::Duration; | 10 | use embassy_time::Duration; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -61,7 +61,7 @@ async fn main(_p: Spawner) { | |||
| 61 | c = 0; | 61 | c = 0; |
| 62 | a = 0; | 62 | a = 0; |
| 63 | } | 63 | } |
| 64 | SamplerState::Sampled | 64 | CallbackResult::Continue |
| 65 | }, | 65 | }, |
| 66 | ) | 66 | ) |
| 67 | .await; | 67 | .await; |
diff --git a/examples/nrf52840/src/bin/usb_ethernet.rs b/examples/nrf52840/src/bin/usb_ethernet.rs index a8d53e460..699666cee 100644 --- a/examples/nrf52840/src/bin/usb_ethernet.rs +++ b/examples/nrf52840/src/bin/usb_ethernet.rs | |||
| @@ -9,7 +9,7 @@ use embassy_executor::Spawner; | |||
| 9 | use embassy_net::tcp::TcpSocket; | 9 | use embassy_net::tcp::TcpSocket; |
| 10 | use embassy_net::{Stack, StackResources}; | 10 | use embassy_net::{Stack, StackResources}; |
| 11 | use embassy_nrf::rng::Rng; | 11 | use embassy_nrf::rng::Rng; |
| 12 | use embassy_nrf::usb::{Driver, PowerUsb}; | 12 | use embassy_nrf::usb::{Driver, HardwareVbusDetect}; |
| 13 | use embassy_nrf::{interrupt, pac, peripherals}; | 13 | use embassy_nrf::{interrupt, pac, peripherals}; |
| 14 | use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState}; | 14 | use embassy_usb::class::cdc_ncm::embassy_net::{Device, Runner, State as NetState}; |
| 15 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; | 15 | use embassy_usb::class::cdc_ncm::{CdcNcmClass, State}; |
| @@ -18,7 +18,7 @@ use embedded_io::asynch::Write; | |||
| 18 | use static_cell::StaticCell; | 18 | use static_cell::StaticCell; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 20 | ||
| 21 | type MyDriver = Driver<'static, peripherals::USBD, PowerUsb>; | 21 | type MyDriver = Driver<'static, peripherals::USBD, HardwareVbusDetect>; |
| 22 | 22 | ||
| 23 | macro_rules! singleton { | 23 | macro_rules! singleton { |
| 24 | ($val:expr) => {{ | 24 | ($val:expr) => {{ |
| @@ -58,7 +58,7 @@ async fn main(spawner: Spawner) { | |||
| 58 | // Create the driver, from the HAL. | 58 | // Create the driver, from the HAL. |
| 59 | let irq = interrupt::take!(USBD); | 59 | let irq = interrupt::take!(USBD); |
| 60 | let power_irq = interrupt::take!(POWER_CLOCK); | 60 | let power_irq = interrupt::take!(POWER_CLOCK); |
| 61 | let driver = Driver::new(p.USBD, irq, PowerUsb::new(power_irq)); | 61 | let driver = Driver::new(p.USBD, irq, HardwareVbusDetect::new(power_irq)); |
| 62 | 62 | ||
| 63 | // Create embassy-usb Config | 63 | // Create embassy-usb Config |
| 64 | let mut config = Config::new(0xc0de, 0xcafe); | 64 | let mut config = Config::new(0xc0de, 0xcafe); |
diff --git a/examples/nrf52840/src/bin/usb_hid_keyboard.rs b/examples/nrf52840/src/bin/usb_hid_keyboard.rs index 76e198719..017cac197 100644 --- a/examples/nrf52840/src/bin/usb_hid_keyboard.rs +++ b/examples/nrf52840/src/bin/usb_hid_keyboard.rs | |||
| @@ -10,7 +10,7 @@ use embassy_executor::Spawner; | |||
| 10 | use embassy_futures::join::join; | 10 | use embassy_futures::join::join; |
| 11 | use embassy_futures::select::{select, Either}; | 11 | use embassy_futures::select::{select, Either}; |
| 12 | use embassy_nrf::gpio::{Input, Pin, Pull}; | 12 | use embassy_nrf::gpio::{Input, Pin, Pull}; |
| 13 | use embassy_nrf::usb::{Driver, PowerUsb}; | 13 | use embassy_nrf::usb::{Driver, HardwareVbusDetect}; |
| 14 | use embassy_nrf::{interrupt, pac}; | 14 | use embassy_nrf::{interrupt, pac}; |
| 15 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 15 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 16 | use embassy_sync::signal::Signal; | 16 | use embassy_sync::signal::Signal; |
| @@ -34,7 +34,7 @@ async fn main(_spawner: Spawner) { | |||
| 34 | // Create the driver, from the HAL. | 34 | // Create the driver, from the HAL. |
| 35 | let irq = interrupt::take!(USBD); | 35 | let irq = interrupt::take!(USBD); |
| 36 | let power_irq = interrupt::take!(POWER_CLOCK); | 36 | let power_irq = interrupt::take!(POWER_CLOCK); |
| 37 | let driver = Driver::new(p.USBD, irq, PowerUsb::new(power_irq)); | 37 | let driver = Driver::new(p.USBD, irq, HardwareVbusDetect::new(power_irq)); |
| 38 | 38 | ||
| 39 | // Create embassy-usb Config | 39 | // Create embassy-usb Config |
| 40 | let mut config = Config::new(0xc0de, 0xcafe); | 40 | let mut config = Config::new(0xc0de, 0xcafe); |
diff --git a/examples/nrf52840/src/bin/usb_hid_mouse.rs b/examples/nrf52840/src/bin/usb_hid_mouse.rs index 4916a38d4..a5849129a 100644 --- a/examples/nrf52840/src/bin/usb_hid_mouse.rs +++ b/examples/nrf52840/src/bin/usb_hid_mouse.rs | |||
| @@ -7,7 +7,7 @@ use core::mem; | |||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_futures::join::join; | 9 | use embassy_futures::join::join; |
| 10 | use embassy_nrf::usb::{Driver, PowerUsb}; | 10 | use embassy_nrf::usb::{Driver, HardwareVbusDetect}; |
| 11 | use embassy_nrf::{interrupt, pac}; | 11 | use embassy_nrf::{interrupt, pac}; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::{Duration, Timer}; |
| 13 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; | 13 | use embassy_usb::class::hid::{HidWriter, ReportId, RequestHandler, State}; |
| @@ -28,7 +28,7 @@ async fn main(_spawner: Spawner) { | |||
| 28 | // Create the driver, from the HAL. | 28 | // Create the driver, from the HAL. |
| 29 | let irq = interrupt::take!(USBD); | 29 | let irq = interrupt::take!(USBD); |
| 30 | let power_irq = interrupt::take!(POWER_CLOCK); | 30 | let power_irq = interrupt::take!(POWER_CLOCK); |
| 31 | let driver = Driver::new(p.USBD, irq, PowerUsb::new(power_irq)); | 31 | let driver = Driver::new(p.USBD, irq, HardwareVbusDetect::new(power_irq)); |
| 32 | 32 | ||
| 33 | // Create embassy-usb Config | 33 | // Create embassy-usb Config |
| 34 | let mut config = Config::new(0xc0de, 0xcafe); | 34 | let mut config = Config::new(0xc0de, 0xcafe); |
diff --git a/examples/nrf52840/src/bin/usb_serial.rs b/examples/nrf52840/src/bin/usb_serial.rs index 7c9c4184b..18b6f25b9 100644 --- a/examples/nrf52840/src/bin/usb_serial.rs +++ b/examples/nrf52840/src/bin/usb_serial.rs | |||
| @@ -7,7 +7,7 @@ use core::mem; | |||
| 7 | use defmt::{info, panic}; | 7 | use defmt::{info, panic}; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_futures::join::join; | 9 | use embassy_futures::join::join; |
| 10 | use embassy_nrf::usb::{Driver, Instance, PowerUsb, UsbSupply}; | 10 | use embassy_nrf::usb::{Driver, HardwareVbusDetect, Instance, VbusDetect}; |
| 11 | use embassy_nrf::{interrupt, pac}; | 11 | use embassy_nrf::{interrupt, pac}; |
| 12 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 12 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 13 | use embassy_usb::driver::EndpointError; | 13 | use embassy_usb::driver::EndpointError; |
| @@ -26,7 +26,7 @@ async fn main(_spawner: Spawner) { | |||
| 26 | // Create the driver, from the HAL. | 26 | // Create the driver, from the HAL. |
| 27 | let irq = interrupt::take!(USBD); | 27 | let irq = interrupt::take!(USBD); |
| 28 | let power_irq = interrupt::take!(POWER_CLOCK); | 28 | let power_irq = interrupt::take!(POWER_CLOCK); |
| 29 | let driver = Driver::new(p.USBD, irq, PowerUsb::new(power_irq)); | 29 | let driver = Driver::new(p.USBD, irq, HardwareVbusDetect::new(power_irq)); |
| 30 | 30 | ||
| 31 | // Create embassy-usb Config | 31 | // Create embassy-usb Config |
| 32 | let mut config = Config::new(0xc0de, 0xcafe); | 32 | let mut config = Config::new(0xc0de, 0xcafe); |
| @@ -97,7 +97,7 @@ impl From<EndpointError> for Disconnected { | |||
| 97 | } | 97 | } |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | async fn echo<'d, T: Instance + 'd, P: UsbSupply + 'd>( | 100 | async fn echo<'d, T: Instance + 'd, P: VbusDetect + 'd>( |
| 101 | class: &mut CdcAcmClass<'d, Driver<'d, T, P>>, | 101 | class: &mut CdcAcmClass<'d, Driver<'d, T, P>>, |
| 102 | ) -> Result<(), Disconnected> { | 102 | ) -> Result<(), Disconnected> { |
| 103 | let mut buf = [0; 64]; | 103 | let mut buf = [0; 64]; |
diff --git a/examples/nrf52840/src/bin/usb_serial_multitask.rs b/examples/nrf52840/src/bin/usb_serial_multitask.rs index 93efc2fe6..3532d3f82 100644 --- a/examples/nrf52840/src/bin/usb_serial_multitask.rs +++ b/examples/nrf52840/src/bin/usb_serial_multitask.rs | |||
| @@ -6,7 +6,7 @@ use core::mem; | |||
| 6 | 6 | ||
| 7 | use defmt::{info, panic, unwrap}; | 7 | use defmt::{info, panic, unwrap}; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_nrf::usb::{Driver, PowerUsb}; | 9 | use embassy_nrf::usb::{Driver, HardwareVbusDetect}; |
| 10 | use embassy_nrf::{interrupt, pac, peripherals}; | 10 | use embassy_nrf::{interrupt, pac, peripherals}; |
| 11 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; | 11 | use embassy_usb::class::cdc_acm::{CdcAcmClass, State}; |
| 12 | use embassy_usb::driver::EndpointError; | 12 | use embassy_usb::driver::EndpointError; |
| @@ -14,7 +14,7 @@ use embassy_usb::{Builder, Config, UsbDevice}; | |||
| 14 | use static_cell::StaticCell; | 14 | use static_cell::StaticCell; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
| 17 | type MyDriver = Driver<'static, peripherals::USBD, PowerUsb>; | 17 | type MyDriver = Driver<'static, peripherals::USBD, HardwareVbusDetect>; |
| 18 | 18 | ||
| 19 | #[embassy_executor::task] | 19 | #[embassy_executor::task] |
| 20 | async fn usb_task(mut device: UsbDevice<'static, MyDriver>) { | 20 | async fn usb_task(mut device: UsbDevice<'static, MyDriver>) { |
| @@ -42,7 +42,7 @@ async fn main(spawner: Spawner) { | |||
| 42 | // Create the driver, from the HAL. | 42 | // Create the driver, from the HAL. |
| 43 | let irq = interrupt::take!(USBD); | 43 | let irq = interrupt::take!(USBD); |
| 44 | let power_irq = interrupt::take!(POWER_CLOCK); | 44 | let power_irq = interrupt::take!(POWER_CLOCK); |
| 45 | let driver = Driver::new(p.USBD, irq, PowerUsb::new(power_irq)); | 45 | let driver = Driver::new(p.USBD, irq, HardwareVbusDetect::new(power_irq)); |
| 46 | 46 | ||
| 47 | // Create embassy-usb Config | 47 | // Create embassy-usb Config |
| 48 | let mut config = Config::new(0xc0de, 0xcafe); | 48 | let mut config = Config::new(0xc0de, 0xcafe); |
