Annex swc_radio_hal_t Structure¶
This structure is part of the swc_hal_t
structure. It contains Wireless Core function pointers required to interact with microcontroller peripherals. Every function present in this structure must be implemented except for the transceiver shutdown pin which is optional.
Refer to SR1010 and SR1020 datasheet for physical pin assignments.
typedef struct swc_radio_hal {
void (*set_shutdown_pin)(void); /*!< Set shutdown pin level high */
void (*reset_shutdown_pin)(void); /*!< Set shutdown pin level low */
void (*set_reset_pin)(void); /*!< Set reset pin level high */
void (*reset_reset_pin)(void); /*!< Set reset pin level low */
bool (*read_irq_pin)(void); /*!< Return IRQ pin state */
void (*set_cs)(void); /*!< Set SPI chip select pin level high */
void (*reset_cs)(void); /*!< Set SPI chip select pin level low */
void (*delay_ms)(uint32_t ms); /*!< Block for a specified number of milliseconds */
void (*transfer_full_duplex_blocking)(uint8_t *tx_data, uint8_t *rx_data,
uint16_t size); /*!< SPI Transfer full duplex in blocking mode */
void (*transfer_full_duplex_non_blocking)(uint8_t *tx_data, uint8_t *rx_data,
uint16_t size); /*!< SPI Transfer full duplex in non blocking mode using DMA */
bool (*is_spi_busy)(void); /*!< Check if the SPI controller is busy transferring bytes */
void (*context_switch)(void); /*!< Trigger the radio IRQ */
void (*disable_radio_irq)(void); /*!< Disable radio IRQ interrupt source */
void (*enable_radio_irq)(void); /*!< Enable radio IRQ interrupt source */
void (*disable_radio_dma_irq)(void); /*!< Disable SPI DMA interrupt source */
void (*enable_radio_dma_irq)(void); /*!< EnablesSPI DMA interrupt source */
} swc_radio_hal_t;
Tip
If the user does not intend to provide control over a GPIO for the shutdown pin, the user can simply create a void no_shutdown_pin(void) {}
function and pass it to both set_shutdown_pin
and reset_shutdown_pin
pointers.
set_shutdown_pin¶
This function is used to set a high output level on the GPIO pin connected to the transceiver SHUTDOWN pin. The transceiver will be turned off when this function is called.
In the SDK, this is implemented by this EVK1.4 BSP function:
-
void evk_radio_set_shutdown_pin(void)¶
Set the on-board controller shutdown pin.
reset_shutdown_pin¶
This function is used to set a low output level on the GPIO pin connected to the transceiver SHUTDOWN pin. The transceiver will be turned on when this function is called.
In the SDK, this is implemented by this EVK1.4 BSP function:
-
void evk_radio_reset_shutdown_pin(void)¶
Reset the on-board controller shutdown pin.
set_reset_pin¶
This function is used to set a high output level on the GPIO pin connected to the transceiver RSTN pin. The transceiver will move to active state when this function is called.
In the SDK, this is implemented by this EVK BSP function:
-
void evk_radio_set_reset_pin(void)¶
Set the on-board controller reset pin.
reset_reset_pin¶
This function is used to set a low output level on the GPIO pin connected to the transceiver RSTN pin. The transceiver will enter the reset state when this function is called.
In the SDK, this is implemented by this EVK BSP function:
-
void evk_radio_reset_reset_pin(void)¶
Reset the on-board controller reset pin.
read_irq_pin¶
This function is used to read the state of the GPIO pin connected to the transceiver IRQ pin.
In the SDK, this is implemented by this EVK BSP function:
-
bool evk_radio_read_irq_pin(void)¶
Read the status of the on-board controller IRQ pin.
- Returns True
Pin is high.
- Returns False
Pin is low.
set_cs¶
This function is used to set a high output level on the GPIO pin connected to the transceiver CS pin. Chip select functionality (via CS) needs to be managed by the Wireless Core and not the SPI peripheral.
In the SDK, this is implemented by this EVK BSP function:
-
void evk_radio_spi_set_cs(void)¶
Set the on-board controller chip-select pin.
reset_cs¶
This function is used to set a low output level on the GPIO pin connected to the transceiver CS pin.
Chip select functionality (via CS) needs to be managed by the Wireless Core and not the SPI peripheral.
In the SDK, this is implemented by this EVK BSP function:
-
void evk_radio_spi_reset_cs(void)¶
Reset the on-board controller chip-select pin.
delay_ms¶
Blocking delay function in milliseconds. Delays are usually implemented with a MCU timer peripheral. Blocking means the CPU is held until the delay expires.
In the SDK, this is implemented by this EVK BSP function:
-
void evk_timer_delay_ms(uint32_t ms)¶
Blocking delay with a 1ms resolution.
transfer_full_duplex_blocking¶
This function is used to initiate an SPI transfer in full duplex blocking mode. The CPU is held until the transfer completes.
See the Serial peripheral Interface (SPI) section for more details on how to implement the SPI.
In the SDK, this is implemented by this EVK BSP function:
-
void evk_radio_spi_transfer_full_duplex_blocking(uint8_t *tx_data, uint8_t *rx_data, uint16_t size)¶
Read and Write data full duplex on the radio in blocking mode.
- Parameters
tx_data – Data buffer to write.
rx_data – Data received.
size – Size of the data.
transfer_full_duplex_non_blocking¶
This function is used to initiate an SPI transfer in full duplex non-blocking mode. The non-blocking mode means that the CPU is yielded and is free to execute other tasks while the DMA manages the SPI data transaction. The DMA peripheral needs to provide callback functions for “transmission complete” and “reception complete” status.
See the Serial peripheral Interface (SPI) section for more details on how to implement the SPI.
In the SDK, this is implemented by this EVK BSP function:
-
void evk_radio_spi_transfer_full_duplex_non_blocking(uint8_t *tx_data, uint8_t *rx_data, uint16_t size)¶
Read and Write data full duplex on the radio in non-blocking mode.
- Parameters
tx_data – Data buffer to write.
rx_data – Data received.
size – Size of the data.
is_spi_busy¶
This function is used to return the state of the busy flag in the SPI Status Register.
In the SDK, this is implemented by this EVK BSP function:
-
bool evk_radio_is_spi_busy(void)¶
Read the status of the radio’s SPI.
- Returns true
SPI is busy.
- Returns false
SPI is not busy.
context_switch¶
This functions manually the trigger of the transceiver IRQ pin interrupt.
In the SDK, this is implemented by this EVK BSP functions:
-
void evk_radio_context_switch(void)¶
Software interrupt trigger to force the cpu to get into the interrupt handler.
disable_radio_irq¶
This function is used to disable the external interrupt (transceiver IRQ pin). Some tasks require to momentarily disable external interrupts. For example, this function must be called just prior to the Wireless Core initialization, which must occur without any interruption from the transceiver.
In the SDK, this is implemented by this EVK BSP function:
-
void evk_radio_disable_irq_it(void)¶
Disable the on-board controller IRQ external interrupt.
enable_radio_irq¶
This function is used to enable the external interrupt (transceiver IRQ pin).
For a priority list example, see the Annex EVK1.4 MCU Priority List section.
In the SDK, this is implemented by this EVK BSP function:
-
void evk_radio_enable_irq_it(void)¶
Enable the on-board controller IRQ external interrupt.
disable_radio_dma_irq¶
This function is used to disable the SPI DMA transfer complete interrupt. Some tasks require disabling this interrupt event momentarily.
In the SDK, this is implemented by this EVK BSP function:
-
void evk_radio_disable_dma_irq_it(void)¶
Disable the DMA SPI interrupt of the radio.
enable_radio_dma_irq¶
This function is used to enable the SPI DMA transfer complete interrupt.
For a priority list example, see the Annex EVK1.4 MCU Priority List section.
In the SDK, this is implemented by this EVK BSP function:
-
void evk_radio_enable_dma_irq_it(void)¶
Enable the DMA SPI interrupt of the radio.