embassy-stm32

Crates

git

Versions

stm32wle5jc

Flavors

Skip to main content

SubghzControl

Struct SubghzControl 

Source
pub struct SubghzControl<'d> { /* private fields */ }
Expand description

Control of the sub-GHz radio: reset, RFBUSY monitoring, wakeup and interrupts.

This is not a radio driver. It does not know the radio’s command set; send commands through SubghzSpi.

Implementations§

Source§

impl<'d> SubghzControl<'d>

Source

pub fn new(_irq: impl Binding<SUBGHZ_RADIO, RadioInterruptHandler> + 'd) -> Self

Create a new SubghzControl driver instance.

Source

pub fn is_busy(&self) -> bool

Check if the radio is currently asserting the RFBUSY signal.

Source

pub fn is_busy_masked(&self) -> bool

Check if the masked radio busy signal (RFBUSYMS) is currently asserted.

The reference manual describes RFBUSYMS as set when NSS goes low and held for a minimum time after the command, so that it covers the gap before the radio raises RFBUSY. On an STM32WLE5CC it was still set 400 ms after RFBUSY had gone low, following either a command or a plain NSS pulse, so wait_on_busy uses RFBUSY and not this.

Source

pub async fn wait_on_busy(&mut self)

Asynchronously wait for the radio to clear the RFBUSY signal.

Most commands release RFBUSY within a few microseconds and are waited for by polling. A longer wait, such as calibration or waking from sleep (about 1.5 ms), sleeps until the RFBUSY falling edge interrupts through EXTI line 45, so the executor can idle.

This shares the SUBGHZ_RADIO vector with await_irq, so the interrupt must be bound with RadioInterruptHandler.

After a radio interrupt the vector stays off until await_irq switches it on again. In that time this polls instead of sleeping, because it must not switch the vector on itself.

Source

pub async fn wait_on_busy_timeout( &mut self, timeout: Duration, ) -> Result<(), BusyTimeout>

Like wait_on_busy, but gives up after timeout.

A radio that never releases RFBUSY (for example after a bad command sequence) makes wait_on_busy wait forever. Reset the radio with reset on error.

Source

pub fn blocking_wait_on_busy(&mut self)

Block the current thread until the radio clears the RFBUSY signal.

Source

pub async fn wakeup(&mut self)

Wake the radio from sleep.

The radio leaves sleep on a falling edge of NSS. This holds NSS low until the radio releases RFBUSY, so the next SPI command can be sent immediately. It is harmless if the radio is already awake. Releasing NSS is cancel-safe.

Source

pub fn set_wakeup_sources(&mut self, irq: bool, busy: bool)

Choose which radio events wake the CPU from Standby (PWR_CR3.EWRFIRQ and EWRFBUSY).

  • irq: a radio interrupt (IRQ[2:0]) wakes the CPU.
  • busy: an edge on RFBUSY wakes the CPU. The active edge is PWR_CR4.WRFBUSYP and is not changed here; it defaults to the rising edge.

Both are off by default. Waking from Standby restarts the program as after a reset.

This does not affect Run, Sleep or Stop. There the radio interrupt and the RFBUSY edge reach the CPU through EXTI lines 44 and 45 and the SUBGHZ_RADIO vector. Line 45 is armed by wait_on_busy. Waking from Stop on a radio interrupt is not configured by this driver.

Source

pub async fn reset(&mut self)

Asynchronously perform a hardware reset of the sub-GHz radio via RCC_CSR.RFRST.

Source

pub fn blocking_reset(&mut self)

Blockingly perform a hardware reset of the sub-GHz radio via RCC_CSR.RFRST.

Source

pub async fn await_irq(&mut self)

Asynchronously wait for a radio interrupt event (SUBGHZ_RADIO).

The radio keeps the interrupt asserted until it is cleared in the radio, for example with ClrIrqStatus. Clear it before waiting again, or this returns straight away.

Auto Trait Implementations§

§

impl<'d> Forget for SubghzControl<'d>

§

impl<'d> Freeze for SubghzControl<'d>

§

impl<'d> Move for SubghzControl<'d>

§

impl<'d> RefUnwindSafe for SubghzControl<'d>

§

impl<'d> Send for SubghzControl<'d>

§

impl<'d> Sync for SubghzControl<'d>

§

impl<'d> Unpin for SubghzControl<'d>

§

impl<'d> UnsafeUnpin for SubghzControl<'d>

§

impl<'d> UnwindSafe for SubghzControl<'d>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.