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>
impl<'d> SubghzControl<'d>
Sourcepub fn new(_irq: impl Binding<SUBGHZ_RADIO, RadioInterruptHandler> + 'd) -> Self
pub fn new(_irq: impl Binding<SUBGHZ_RADIO, RadioInterruptHandler> + 'd) -> Self
Create a new SubghzControl driver instance.
Sourcepub fn is_busy_masked(&self) -> bool
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.
Sourcepub async fn wait_on_busy(&mut self)
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.
Sourcepub async fn wait_on_busy_timeout(
&mut self,
timeout: Duration,
) -> Result<(), BusyTimeout>
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.
Sourcepub fn blocking_wait_on_busy(&mut self)
pub fn blocking_wait_on_busy(&mut self)
Block the current thread until the radio clears the RFBUSY signal.
Sourcepub async fn wakeup(&mut self)
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.
Sourcepub fn set_wakeup_sources(&mut self, irq: bool, busy: bool)
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 onRFBUSYwakes the CPU. The active edge isPWR_CR4.WRFBUSYPand 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.
Sourcepub async fn reset(&mut self)
pub async fn reset(&mut self)
Asynchronously perform a hardware reset of the sub-GHz radio via RCC_CSR.RFRST.
Sourcepub fn blocking_reset(&mut self)
pub fn blocking_reset(&mut self)
Blockingly perform a hardware reset of the sub-GHz radio via RCC_CSR.RFRST.