STM32 core 3.0.1-dev
Arduino core for STM32 based boards: API reference
← STM32duino documentation
Loading...
Searching...
No Matches
SubGhzClass Class Reference

Singleton class to manage the SubGHZ ISR and internal signals. More...

#include <SubGhz.h>

Public Types

using callback_function_t = std::function< void(void)>
 Type of the callback called from ISR context when the radio IRQ triggers.
 

Public Member Functions

void attachInterrupt (callback_function_t callback)
 Attach the handler called from ISR context when the radio IRQ triggers, then clear any pending IRQs and enable the IRQ.
 
void detachInterrupt ()
 Detach the interrupt handler, disabling the IRQ too.
 
bool hasInterrupt ()
 Check whether an interrupt callback is attached, regardless of whether it is enabled.
 
void enableInterrupt ()
 Enable the interrupt again if it was previously disabled using disableInterrupt().
 
void disableInterrupt ()
 Temporarily disable interrupt processing by disabling the IRQ in the NVIC.
 
void clearPendingInterrupt ()
 Clear the interrupt pending flag, suppressing IRQs that happened while the interrupt was disabled.
 
bool isInterruptPending ()
 Check whether the interrupt is pending.
 
void setNssActive (bool value)
 Update the NSS signal internally connected to the radio SPI block.
 
bool isNssActive ()
 Read back the value written to NSS with setNssActive().
 
void setResetActive (bool value)
 Update the RESET signal internally connected to the radio.
 
bool isResetActive ()
 Read back the value written to RESET with setResetActive().
 
bool isBusy ()
 Get the busy signal exported by the radio module.
 

Public Attributes

SUBGHZSPIClass SPI
 SPI object used to talk to the radio.
 

Static Public Attributes

static constexpr SPISettings spi_settings = {16000000, MSBFIRST, SPI_MODE0}
 SPI settings to use for the radio, at the maximum speed supported by the radio.
 

Protected Member Functions

void handleIrq ()
 Call the attached callback.
 

Friends

void SUBGHZ_Radio_IRQHandler ()
 ISR entry point for the SubGHz radio IRQ.
 

Detailed Description

Singleton class to manage the SubGHZ ISR and internal signals.

Member Function Documentation

◆ attachInterrupt()

void SubGhzClass::attachInterrupt ( callback_function_t  callback)

Attach the handler called from ISR context when the radio IRQ triggers, then clear any pending IRQs and enable the IRQ.

The radio IRQ is level triggered, so the callback must either process the IRQ and clear the IRQ flags in the radio (so the radio clears its DIO lines before the ISR returns), or disable the IRQ to prevent it from being triggered over and over again.

Parameters
callbackFunction called from ISR context when the radio IRQ triggers.

◆ enableInterrupt()

void SubGhzClass::enableInterrupt ( )

Enable the interrupt again if it was previously disabled using disableInterrupt().

This does not clear pending interrupts: if the IRQ triggered while it was disabled, the callback registered with attachInterrupt() fires directly.

◆ handleIrq()

void SubGhzClass::handleIrq ( )
protected

Call the attached callback.

Invoked from the ISR, not meant to be called directly.

◆ hasInterrupt()

bool SubGhzClass::hasInterrupt ( )

Check whether an interrupt callback is attached, regardless of whether it is enabled.

Returns
true if a callback is attached, false otherwise.

◆ isBusy()

bool SubGhzClass::isBusy ( )

Get the busy signal exported by the radio module.

Uses the RFBUSYS flag, which returns the radio busy signal directly, not the RFBUSYMS flag that also returns an extra busy period after every SPI transaction.

Returns
true if the radio is busy, false otherwise.

◆ isInterruptPending()

bool SubGhzClass::isInterruptPending ( )

Check whether the interrupt is pending.

Only really useful when the interrupt is disabled, or while a higher priority interrupt is running.

Returns
true if the interrupt is pending, false otherwise.

◆ isNssActive()

bool SubGhzClass::isNssActive ( )

Read back the value written to NSS with setNssActive().

Returns
true if the NSS signal is active, false otherwise.

◆ isResetActive()

bool SubGhzClass::isResetActive ( )

Read back the value written to RESET with setResetActive().

Returns
true if the module is in reset, false otherwise.

◆ setNssActive()

void SubGhzClass::setNssActive ( bool  value)

Update the NSS signal internally connected to the radio SPI block.

The NSS signal is active-low: passing true activates the block (NSS driven LOW), passing false deactivates it (NSS HIGH).

Parameters
valuetrue to activate the NSS signal, false to deactivate it.

◆ setResetActive()

void SubGhzClass::setResetActive ( bool  value)

Update the RESET signal internally connected to the radio.

Parameters
valuetrue to put the module in reset, false to enable the module.

Friends And Related Symbol Documentation

◆ SUBGHZ_Radio_IRQHandler

void SUBGHZ_Radio_IRQHandler ( )
friend

ISR entry point for the SubGHz radio IRQ.

Forwards the event to the attached callback.

Member Data Documentation

◆ SPI

SUBGHZSPIClass SubGhzClass::SPI

SPI object used to talk to the radio.

Works like a regular SPI object, except that setNssActive() must be used to control the (internal) NSS signal.

◆ spi_settings

constexpr SPISettings SubGhzClass::spi_settings = {16000000, MSBFIRST, SPI_MODE0}
staticconstexpr

SPI settings to use for the radio, at the maximum speed supported by the radio.

Pass this value to SubGhz.SPI.beginTransaction().


The documentation for this class was generated from the following files: