Remove default, reorder generic params
This commit is contained in:
parent
8536666148
commit
c5ce02b30e
@ -3,7 +3,7 @@ use core::cell::Cell;
|
||||
use core::future::{poll_fn, Future};
|
||||
use core::task::{Context, Poll, Waker};
|
||||
|
||||
use crate::blocking_mutex::raw::{CriticalSectionRawMutex, RawMutex};
|
||||
use crate::blocking_mutex::raw::RawMutex;
|
||||
use crate::blocking_mutex::Mutex;
|
||||
|
||||
/// Single-slot signaling primitive.
|
||||
@ -22,19 +22,20 @@ use crate::blocking_mutex::Mutex;
|
||||
///
|
||||
/// ```
|
||||
/// use embassy_sync::signal::Signal;
|
||||
/// use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||
///
|
||||
/// enum SomeCommand {
|
||||
/// On,
|
||||
/// Off,
|
||||
/// }
|
||||
///
|
||||
/// static SOME_SIGNAL: Signal<SomeCommand> = Signal::new();
|
||||
/// static SOME_SIGNAL: Signal<CriticalSectionRawMutex, SomeCommand> = Signal::new();
|
||||
/// ```
|
||||
pub struct Signal<T, R = CriticalSectionRawMutex>
|
||||
pub struct Signal<M, T>
|
||||
where
|
||||
R: RawMutex,
|
||||
M: RawMutex,
|
||||
{
|
||||
state: Mutex<R, Cell<State<T>>>,
|
||||
state: Mutex<M, Cell<State<T>>>,
|
||||
}
|
||||
|
||||
enum State<T> {
|
||||
@ -43,9 +44,9 @@ enum State<T> {
|
||||
Signaled(T),
|
||||
}
|
||||
|
||||
impl<T, R> Signal<T, R>
|
||||
impl<M, T> Signal<M, T>
|
||||
where
|
||||
R: RawMutex,
|
||||
M: RawMutex,
|
||||
{
|
||||
/// Create a new `Signal`.
|
||||
pub const fn new() -> Self {
|
||||
@ -55,9 +56,9 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<R, T: Send> Signal<T, R>
|
||||
impl<M, T: Send> Signal<M, T>
|
||||
where
|
||||
R: RawMutex,
|
||||
M: RawMutex,
|
||||
{
|
||||
/// Mark this Signal as signaled.
|
||||
pub fn signal(&self, val: T) {
|
||||
|
@ -12,6 +12,7 @@ use embassy_futures::select::{select, Either};
|
||||
use embassy_nrf::gpio::{Input, Pin, Pull};
|
||||
use embassy_nrf::usb::{Driver, PowerUsb};
|
||||
use embassy_nrf::{interrupt, pac};
|
||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||
use embassy_sync::signal::Signal;
|
||||
use embassy_usb::control::OutResponse;
|
||||
use embassy_usb::{Builder, Config, DeviceStateHandler};
|
||||
@ -77,7 +78,7 @@ async fn main(_spawner: Spawner) {
|
||||
// Build the builder.
|
||||
let mut usb = builder.build();
|
||||
|
||||
let remote_wakeup: Signal<_> = Signal::new();
|
||||
let remote_wakeup: Signal<CriticalSectionRawMutex, _> = Signal::new();
|
||||
|
||||
// Run the USB device.
|
||||
let usb_fut = async {
|
||||
|
@ -4,11 +4,12 @@
|
||||
|
||||
use defmt::{info, unwrap};
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||
use embassy_sync::signal::Signal;
|
||||
use embassy_time::{Duration, Timer};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
static SIGNAL: Signal<u32> = Signal::new();
|
||||
static SIGNAL: Signal<CriticalSectionRawMutex, u32> = Signal::new();
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn my_sending_task() {
|
||||
|
@ -12,6 +12,7 @@ use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
use embassy_stm32::interrupt;
|
||||
use embassy_stm32::interrupt::{Interrupt, InterruptExt};
|
||||
use embassy_stm32::subghz::*;
|
||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||
use embassy_sync::signal::Signal;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
@ -64,7 +65,7 @@ async fn main(_spawner: Spawner) {
|
||||
let button = Input::new(p.PA0, Pull::Up);
|
||||
let mut pin = ExtiInput::new(button, p.EXTI0);
|
||||
|
||||
static IRQ_SIGNAL: Signal<()> = Signal::new();
|
||||
static IRQ_SIGNAL: Signal<CriticalSectionRawMutex, ()> = Signal::new();
|
||||
let radio_irq = interrupt::take!(SUBGHZ_RADIO);
|
||||
radio_irq.set_handler(|_| {
|
||||
IRQ_SIGNAL.signal(());
|
||||
|
Loading…
Reference in New Issue
Block a user