Merge remote-tracking branch 'origin/master' into nrf-pdm
This commit is contained in:
@ -5,9 +5,9 @@
|
||||
use defmt::unwrap;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_nrf::gpio::{Level, Output, OutputDrive};
|
||||
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
|
||||
use embassy_sync::channel::Channel;
|
||||
use embassy_time::{Duration, Timer};
|
||||
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
|
||||
use embassy_util::channel::mpmc::Channel;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
enum LedState {
|
||||
|
@ -5,10 +5,10 @@
|
||||
use defmt::unwrap;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_nrf::gpio::{AnyPin, Level, Output, OutputDrive, Pin};
|
||||
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
|
||||
use embassy_sync::channel::{Channel, Receiver, Sender};
|
||||
use embassy_time::{Duration, Timer};
|
||||
use embassy_util::blocking_mutex::raw::NoopRawMutex;
|
||||
use embassy_util::channel::mpmc::{Channel, Receiver, Sender};
|
||||
use embassy_util::Forever;
|
||||
use static_cell::StaticCell;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
enum LedState {
|
||||
@ -16,7 +16,7 @@ enum LedState {
|
||||
Off,
|
||||
}
|
||||
|
||||
static CHANNEL: Forever<Channel<NoopRawMutex, LedState, 1>> = Forever::new();
|
||||
static CHANNEL: StaticCell<Channel<NoopRawMutex, LedState, 1>> = StaticCell::new();
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn send_task(sender: Sender<'static, NoopRawMutex, LedState, 1>) {
|
||||
@ -43,7 +43,7 @@ async fn recv_task(led: AnyPin, receiver: Receiver<'static, NoopRawMutex, LedSta
|
||||
#[embassy_executor::main]
|
||||
async fn main(spawner: Spawner) {
|
||||
let p = embassy_nrf::init(Default::default());
|
||||
let channel = CHANNEL.put(Channel::new());
|
||||
let channel = CHANNEL.init(Channel::new());
|
||||
|
||||
unwrap!(spawner.spawn(send_task(channel.sender())));
|
||||
unwrap!(spawner.spawn(recv_task(p.P0_13.degrade(), channel.receiver())));
|
||||
|
@ -63,7 +63,7 @@ use embassy_nrf::executor::{Executor, InterruptExecutor};
|
||||
use embassy_nrf::interrupt;
|
||||
use embassy_nrf::interrupt::InterruptExt;
|
||||
use embassy_time::{Duration, Instant, Timer};
|
||||
use embassy_util::Forever;
|
||||
use static_cell::StaticCell;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::task]
|
||||
@ -108,9 +108,9 @@ async fn run_low() {
|
||||
}
|
||||
}
|
||||
|
||||
static EXECUTOR_HIGH: Forever<InterruptExecutor<interrupt::SWI1_EGU1>> = Forever::new();
|
||||
static EXECUTOR_MED: Forever<InterruptExecutor<interrupt::SWI0_EGU0>> = Forever::new();
|
||||
static EXECUTOR_LOW: Forever<Executor> = Forever::new();
|
||||
static EXECUTOR_HIGH: StaticCell<InterruptExecutor<interrupt::SWI1_EGU1>> = StaticCell::new();
|
||||
static EXECUTOR_MED: StaticCell<InterruptExecutor<interrupt::SWI0_EGU0>> = StaticCell::new();
|
||||
static EXECUTOR_LOW: StaticCell<Executor> = StaticCell::new();
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
@ -121,19 +121,19 @@ fn main() -> ! {
|
||||
// High-priority executor: SWI1_EGU1, priority level 6
|
||||
let irq = interrupt::take!(SWI1_EGU1);
|
||||
irq.set_priority(interrupt::Priority::P6);
|
||||
let executor = EXECUTOR_HIGH.put(InterruptExecutor::new(irq));
|
||||
let executor = EXECUTOR_HIGH.init(InterruptExecutor::new(irq));
|
||||
let spawner = executor.start();
|
||||
unwrap!(spawner.spawn(run_high()));
|
||||
|
||||
// Medium-priority executor: SWI0_EGU0, priority level 7
|
||||
let irq = interrupt::take!(SWI0_EGU0);
|
||||
irq.set_priority(interrupt::Priority::P7);
|
||||
let executor = EXECUTOR_MED.put(InterruptExecutor::new(irq));
|
||||
let executor = EXECUTOR_MED.init(InterruptExecutor::new(irq));
|
||||
let spawner = executor.start();
|
||||
unwrap!(spawner.spawn(run_med()));
|
||||
|
||||
// Low priority executor: runs in thread mode, using WFE/SEV
|
||||
let executor = EXECUTOR_LOW.put(Executor::new());
|
||||
let executor = EXECUTOR_LOW.init(Executor::new());
|
||||
executor.run(|spawner| {
|
||||
unwrap!(spawner.spawn(run_low()));
|
||||
});
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
use defmt::{info, unwrap};
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
|
||||
use embassy_sync::mutex::Mutex;
|
||||
use embassy_time::{Duration, Timer};
|
||||
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
|
||||
use embassy_util::mutex::Mutex;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
static MUTEX: Mutex<ThreadModeRawMutex, u32> = Mutex::new(0);
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
use defmt::unwrap;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
|
||||
use embassy_sync::pubsub::{DynSubscriber, PubSubChannel, Subscriber};
|
||||
use embassy_time::{Duration, Timer};
|
||||
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
|
||||
use embassy_util::channel::pubsub::{DynSubscriber, PubSubChannel, Subscriber};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
/// Create the message bus. It has a queue of 4, supports 3 subscribers and 1 publisher
|
||||
|
@ -8,7 +8,7 @@ use defmt::{info, unwrap};
|
||||
use embassy_executor::raw::TaskStorage;
|
||||
use embassy_executor::Executor;
|
||||
use embassy_time::{Duration, Timer};
|
||||
use embassy_util::Forever;
|
||||
use static_cell::StaticCell;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
async fn run1() {
|
||||
@ -25,14 +25,14 @@ async fn run2() {
|
||||
}
|
||||
}
|
||||
|
||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
||||
static EXECUTOR: StaticCell<Executor> = StaticCell::new();
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
info!("Hello World!");
|
||||
|
||||
let _p = embassy_nrf::init(Default::default());
|
||||
let executor = EXECUTOR.put(Executor::new());
|
||||
let executor = EXECUTOR.init(Executor::new());
|
||||
|
||||
let run1_task = TaskStorage::new();
|
||||
let run2_task = TaskStorage::new();
|
||||
|
@ -7,8 +7,8 @@ use embassy_executor::Spawner;
|
||||
use embassy_nrf::peripherals::UARTE0;
|
||||
use embassy_nrf::uarte::UarteRx;
|
||||
use embassy_nrf::{interrupt, uarte};
|
||||
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
|
||||
use embassy_util::channel::mpmc::Channel;
|
||||
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
|
||||
use embassy_sync::channel::Channel;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
static CHANNEL: Channel<ThreadModeRawMutex, [u8; 8], 1> = Channel::new();
|
||||
|
@ -14,21 +14,21 @@ use embassy_net::{PacketBox, PacketBoxExt, PacketBuf, Stack, StackResources};
|
||||
use embassy_nrf::rng::Rng;
|
||||
use embassy_nrf::usb::{Driver, PowerUsb};
|
||||
use embassy_nrf::{interrupt, pac, peripherals};
|
||||
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
|
||||
use embassy_sync::channel::Channel;
|
||||
use embassy_usb::{Builder, Config, UsbDevice};
|
||||
use embassy_usb_ncm::{CdcNcmClass, Receiver, Sender, State};
|
||||
use embassy_util::blocking_mutex::raw::ThreadModeRawMutex;
|
||||
use embassy_util::channel::mpmc::Channel;
|
||||
use embassy_util::Forever;
|
||||
use embedded_io::asynch::{Read, Write};
|
||||
use static_cell::StaticCell;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
type MyDriver = Driver<'static, peripherals::USBD, PowerUsb>;
|
||||
|
||||
macro_rules! forever {
|
||||
macro_rules! singleton {
|
||||
($val:expr) => {{
|
||||
type T = impl Sized;
|
||||
static FOREVER: Forever<T> = Forever::new();
|
||||
FOREVER.put_with(move || $val)
|
||||
static STATIC_CELL: StaticCell<T> = StaticCell::new();
|
||||
STATIC_CELL.init_with(move || $val)
|
||||
}};
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ async fn main(spawner: Spawner) {
|
||||
control_buf: [u8; 128],
|
||||
serial_state: State<'static>,
|
||||
}
|
||||
let res: &mut Resources = forever!(Resources {
|
||||
let res: &mut Resources = singleton!(Resources {
|
||||
device_descriptor: [0; 256],
|
||||
config_descriptor: [0; 256],
|
||||
bos_descriptor: [0; 256],
|
||||
@ -174,10 +174,10 @@ async fn main(spawner: Spawner) {
|
||||
|
||||
// Init network stack
|
||||
let device = Device { mac_addr: our_mac_addr };
|
||||
let stack = &*forever!(Stack::new(
|
||||
let stack = &*singleton!(Stack::new(
|
||||
device,
|
||||
config,
|
||||
forever!(StackResources::<1, 2, 8>::new()),
|
||||
singleton!(StackResources::<1, 2, 8>::new()),
|
||||
seed
|
||||
));
|
||||
|
||||
|
@ -8,14 +8,14 @@ use core::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_futures::{select, Either};
|
||||
use embassy_nrf::gpio::{Input, Pin, Pull};
|
||||
use embassy_nrf::usb::{Driver, PowerUsb};
|
||||
use embassy_nrf::{interrupt, pac};
|
||||
use embassy_sync::signal::Signal;
|
||||
use embassy_usb::control::OutResponse;
|
||||
use embassy_usb::{Builder, Config, DeviceStateHandler};
|
||||
use embassy_usb_hid::{HidReaderWriter, ReportId, RequestHandler, State};
|
||||
use embassy_util::channel::signal::Signal;
|
||||
use embassy_util::{select, Either};
|
||||
use futures::future::join;
|
||||
use usbd_hid::descriptor::{KeyboardReport, SerializedDescriptor};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
@ -12,7 +12,7 @@ use embassy_nrf::{interrupt, pac, peripherals};
|
||||
use embassy_usb::driver::EndpointError;
|
||||
use embassy_usb::{Builder, Config, UsbDevice};
|
||||
use embassy_usb_serial::{CdcAcmClass, State};
|
||||
use embassy_util::Forever;
|
||||
use static_cell::StaticCell;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
type MyDriver = Driver<'static, peripherals::USBD, PowerUsb>;
|
||||
@ -67,8 +67,8 @@ async fn main(spawner: Spawner) {
|
||||
control_buf: [u8; 64],
|
||||
serial_state: State<'static>,
|
||||
}
|
||||
static RESOURCES: Forever<Resources> = Forever::new();
|
||||
let res = RESOURCES.put(Resources {
|
||||
static RESOURCES: StaticCell<Resources> = StaticCell::new();
|
||||
let res = RESOURCES.init(Resources {
|
||||
device_descriptor: [0; 256],
|
||||
config_descriptor: [0; 256],
|
||||
bos_descriptor: [0; 256],
|
||||
|
Reference in New Issue
Block a user