This is the Radio Driver HAL source file which contains LoRa-specific Radio Driver Hardware Abstract Layer.
Copyright (c) 2019 Microchip Technology Inc. and its subsidiaries.
#include "asf.h"
#include "radio_driver_hal.h"
#include "board.h"
#include "spi.h"
#include "sys.h"
#include "pmm.h"
Macros | |
#define | ENABLE_DIO0 |
#define | ENABLE_DIO1 |
#define | ENABLE_DIO2 |
#define | RADIO_CLK_SRC XTAL |
#define | RADIO_CLK_STABILITATION_DELAY 0 |
#define | SX_RF_SPI_BAUDRATE 2000000 |
Functions | |
uint8_t | HAL_DIO0PinValue (void) |
This function is used to read the status of DIO0 pin. More... | |
uint8_t | HAL_DIO1PinValue (void) |
This function is used to read the status of DIO1 pin. More... | |
uint8_t | HAL_DIO2PinValue (void) |
This function is used to read the status of DIO2 pin. More... | |
void | HAL_DisableRFCtrl (RFCtrl1_t RFCtrl1, RFCtrl2_t RFCtrl2) |
This function Disables RF Control pins. More... | |
void | HAL_DisbleDIO0Interrupt (void) |
This function is used to disable DIO0 interrupt. More... | |
void | HAL_DisbleDIO1Interrupt (void) |
This function is used to disable DIO2 interrupt. More... | |
void | HAL_DisbleDIO2Interrupt (void) |
This function is used to disable DIO2 interrupt. More... | |
void | HAL_EnableDIO0Interrupt (void) |
This function is used to enable DIO0 interrupt. More... | |
void | HAL_EnableDIO1Interrupt (void) |
This function is used to enable DIO1 interrupt. More... | |
void | HAL_EnableDIO2Interrupt (void) |
This function is used to enable DIO2 interrupt. More... | |
void | HAL_EnableRFCtrl (RFCtrl1_t RFCtrl1, RFCtrl2_t RFCtrl2) |
This function Enables RF Control pins. More... | |
RadioClockSources_t | HAL_GetRadioClkSrc (void) |
This function gets the clock source of Radio defined by user. More... | |
uint8_t | HAL_GetRadioClkStabilizationDelay (void) |
This function gets the time taken for the radio clock to stabilize. More... | |
void | HAL_Radio_resources_init (void) |
This function is used to initialize the SPI Interface after PMM wakeup. More... | |
void | HAL_RadioDeInit (void) |
This function is used to deinitialize the SPI Interface. More... | |
static void | HAL_RadioDIO0Callback (void) |
static void | HAL_RadioDIO1Callback (void) |
static void | HAL_RadioDIO2Callback (void) |
void | HAL_RadioInit (void) |
This function is used to initialize the Radio Hardware The SPI interface,DIO and reset pins are initialized by this api. More... | |
static void | HAL_RadioIOInit (void) |
static void | HAL_RadioSpiInit (void) |
void | HAL_RegisterDioInterruptHandler (uint8_t dioPin, DioInterruptHandler_t handler) |
This function sets the interrupt handler for given DIO interrupt. More... | |
static void | HAL_ResetPinMakeInput (void) |
static void | HAL_ResetPinMakeOutput (void) |
static void | HAL_ResetPinOutputValue (uint8_t value) |
static void | HAL_SPICSAssert (void) |
static void | HAL_SPICSDeassert (void) |
static uint8_t | HAL_SPISend (uint8_t data) |
void | HAL_TCXOPowerOff (void) |
This function Powering off the TCXO oscillator. More... | |
void | HAL_TCXOPowerOn (void) |
This function Powering up the TCXO oscillator. More... | |
uint8_t | INTERRUPT_GetDioStatus (void) |
This function is used to get the interrupt status The interrupt status is cleared after calling this function. More... | |
uint8_t | INTERRUPT_PeekDioStatus (void) |
This function is used to get the interrupt status The interrupt status is not cleared after calling this function. More... | |
void | RADIO_FrameRead (uint8_t offset, uint8_t *buffer, uint8_t bufferLen) |
This function is used to read a stream of data from the Radio Frame buffer. More... | |
void | RADIO_FrameWrite (uint8_t offset, uint8_t *buffer, uint8_t bufferLen) |
This function is used to write a stream of data into the Radio Frame buffer. More... | |
uint8_t | RADIO_RegisterRead (uint8_t reg) |
This function is used to read a byte of data from the radio register. More... | |
void | RADIO_RegisterWrite (uint8_t reg, uint8_t value) |
This function is used to write a byte of data to the radio register. More... | |
void | RADIO_Reset (void) |
This function resets the Radio hardware by pulling the reset pin low. More... | |
Variables | |
static uint8_t | dioStatus |
static DioInterruptHandler_t | interruptHandlerDio0 = NULL |
static DioInterruptHandler_t | interruptHandlerDio1 = NULL |
static DioInterruptHandler_t | interruptHandlerDio2 = NULL |
static struct spi_module | master |
struct spi_slave_inst | slave |
#define ENABLE_DIO0 |
#define ENABLE_DIO1 |
#define ENABLE_DIO2 |
#define RADIO_CLK_SRC XTAL |
Referenced by HAL_GetRadioClkSrc().
#define RADIO_CLK_STABILITATION_DELAY 0 |
Referenced by HAL_GetRadioClkStabilizationDelay(), and HAL_TCXOPowerOn().
#define SX_RF_SPI_BAUDRATE 2000000 |
Referenced by HAL_RadioSpiInit().
uint8_t HAL_DIO0PinValue | ( | void | ) |
This function is used to read the status of DIO0 pin.
References port_pin_get_input_level().
uint8_t HAL_DIO1PinValue | ( | void | ) |
This function is used to read the status of DIO1 pin.
References port_pin_get_input_level().
uint8_t HAL_DIO2PinValue | ( | void | ) |
This function is used to read the status of DIO2 pin.
References port_pin_get_input_level().
This function Disables RF Control pins.
[in] | RFCtrl1 | RFO_LF = 0 RFO_HF = 1 PA_BOOST = 2 |
[in] | RFCtrl2 | RX = 0 TX = 1 |
[out] | None |
References port_pin_set_output_level(), RFO_HF, and RX.
void HAL_DisbleDIO0Interrupt | ( | void | ) |
This function is used to disable DIO0 interrupt.
References EXTINT_CALLBACK_TYPE_DETECT, and extint_chan_disable_callback().
void HAL_DisbleDIO1Interrupt | ( | void | ) |
This function is used to disable DIO2 interrupt.
This function is used to disable DIO1 interrupt.
References EXTINT_CALLBACK_TYPE_DETECT, and extint_chan_disable_callback().
void HAL_DisbleDIO2Interrupt | ( | void | ) |
This function is used to disable DIO2 interrupt.
References EXTINT_CALLBACK_TYPE_DETECT, and extint_chan_disable_callback().
void HAL_EnableDIO0Interrupt | ( | void | ) |
This function is used to enable DIO0 interrupt.
References EXTINT_CALLBACK_TYPE_DETECT, and extint_chan_enable_callback().
void HAL_EnableDIO1Interrupt | ( | void | ) |
This function is used to enable DIO1 interrupt.
References EXTINT_CALLBACK_TYPE_DETECT, and extint_chan_enable_callback().
void HAL_EnableDIO2Interrupt | ( | void | ) |
This function is used to enable DIO2 interrupt.
References EXTINT_CALLBACK_TYPE_DETECT, and extint_chan_enable_callback().
This function Enables RF Control pins.
[in] | RFCtrl1 | RFO_LF = 0 RFO_HF = 1 PA_BOOST = 2 |
[in] | RFCtrl2 | RX = 0 TX = 1 |
[out] | None |
References PA_BOOST, port_pin_set_output_level(), RFO_HF, RX, and TX.
RadioClockSources_t HAL_GetRadioClkSrc | ( | void | ) |
This function gets the clock source of Radio defined by user.
[in] | None | |
[out] | Type | of clock source TCXO or XTAL |
References RADIO_CLK_SRC.
uint8_t HAL_GetRadioClkStabilizationDelay | ( | void | ) |
This function gets the time taken for the radio clock to stabilize.
[in] | None | |
[out] | Time | value in ms |
References RADIO_CLK_STABILITATION_DELAY.
void HAL_Radio_resources_init | ( | void | ) |
This function is used to initialize the SPI Interface after PMM wakeup.
This function is used to initialize the Radio SPI after PMM wakeup.
References master, spi_enable(), and spi_is_syncing().
Referenced by appWakeup(), and processJoinAndSend().
void HAL_RadioDeInit | ( | void | ) |
This function is used to deinitialize the SPI Interface.
This function is used to deinitialize the Radio SPI.
References master, and spi_disable().
Referenced by app_resources_uninit().
|
static |
References interruptHandlerDio0, and PMM_Wakeup().
Referenced by HAL_RadioIOInit().
|
static |
References interruptHandlerDio1, and PMM_Wakeup().
Referenced by HAL_RadioIOInit().
|
static |
References interruptHandlerDio2, and PMM_Wakeup().
Referenced by HAL_RadioIOInit().
void HAL_RadioInit | ( | void | ) |
This function is used to initialize the Radio Hardware The SPI interface,DIO and reset pins are initialized by this api.
References HAL_RadioIOInit(), and HAL_RadioSpiInit().
|
static |
References extint_chan_conf::detection_criteria, port_config::direction, EXTINT_CALLBACK_TYPE_DETECT, extint_chan_enable_callback(), extint_chan_get_config_defaults(), extint_chan_set_config(), EXTINT_DETECT_RISING, EXTINT_PULL_NONE, extint_register_callback(), extint_chan_conf::gpio_pin, extint_chan_conf::gpio_pin_mux, extint_chan_conf::gpio_pin_pull, HAL_RadioDIO0Callback(), HAL_RadioDIO1Callback(), HAL_RadioDIO2Callback(), port_get_config_defaults(), PORT_PIN_DIR_INPUT, PORT_PIN_DIR_OUTPUT, port_pin_set_config(), and port_pin_set_output_level().
Referenced by HAL_RadioInit().
|
static |
References spi_master_config::baudrate, master, spi_config::master, spi_config::mode_specific, spi_config::mux_setting, spi_config::pinmux_pad0, spi_config::pinmux_pad1, spi_config::pinmux_pad2, spi_config::pinmux_pad3, PINMUX_UNUSED, slave, spi_attach_slave(), spi_enable(), spi_get_config_defaults(), spi_init(), spi_slave_inst_get_config_defaults(), spi_slave_inst_config::ss_pin, and SX_RF_SPI_BAUDRATE.
Referenced by HAL_RadioInit().
void HAL_RegisterDioInterruptHandler | ( | uint8_t | dioPin, |
DioInterruptHandler_t | handler | ||
) |
This function sets the interrupt handler for given DIO interrupt.
[in] | dioPin | - DIO pin |
[in] | handler | - function to be called upon given DIO interrupt |
References DIO0, DIO1, DIO2, DIO3, DIO4, DIO5, interruptHandlerDio0, interruptHandlerDio1, and interruptHandlerDio2.
|
static |
References port_config::direction, port_get_config_defaults(), PORT_PIN_DIR_INPUT, and port_pin_set_config().
Referenced by RADIO_Reset().
|
static |
References port_config::direction, port_get_config_defaults(), PORT_PIN_DIR_OUTPUT, and port_pin_set_config().
Referenced by RADIO_Reset().
|
static |
References port_pin_set_output_level().
Referenced by RADIO_Reset().
|
static |
References master, slave, and spi_select_slave().
Referenced by RADIO_FrameRead(), RADIO_FrameWrite(), RADIO_RegisterRead(), and RADIO_RegisterWrite().
|
static |
References master, slave, and spi_select_slave().
Referenced by RADIO_FrameRead(), RADIO_FrameWrite(), RADIO_RegisterRead(), and RADIO_RegisterWrite().
|
static |
References master, spi_is_ready_to_read(), spi_is_ready_to_write(), spi_is_write_complete(), spi_read(), and spi_write().
Referenced by RADIO_FrameRead(), RADIO_FrameWrite(), RADIO_RegisterRead(), and RADIO_RegisterWrite().
void HAL_TCXOPowerOff | ( | void | ) |
This function Powering off the TCXO oscillator.
[in] | None | |
[out] | None |
References port_pin_set_output_level().
void HAL_TCXOPowerOn | ( | void | ) |
This function Powering up the TCXO oscillator.
[in] | None | |
[out] | None |
References delay_ms, port_pin_set_output_level(), and RADIO_CLK_STABILITATION_DELAY.
uint8_t INTERRUPT_GetDioStatus | ( | void | ) |
This function is used to get the interrupt status The interrupt status is cleared after calling this function.
Returns | the mask of received interrupts |
References dioStatus, INTERRUPT_GlobalInterruptDisable, and INTERRUPT_GlobalInterruptEnable.
uint8_t INTERRUPT_PeekDioStatus | ( | void | ) |
This function is used to get the interrupt status The interrupt status is not cleared after calling this function.
Returns | the mask of received interrupts |
References dioStatus.
void RADIO_FrameRead | ( | uint8_t | offset, |
uint8_t * | buffer, | ||
uint8_t | bufferLen | ||
) |
This function is used to read a stream of data from the Radio Frame buffer.
[in] | FIFO | offset to be read from |
[in] | buffer | Pointer to the data where the data is read and stored |
[in] | bufferLen | Length of the data to be read from the frame buffer |
References HAL_SPICSAssert(), HAL_SPICSDeassert(), HAL_SPISend(), and i.
void RADIO_FrameWrite | ( | uint8_t | offset, |
uint8_t * | buffer, | ||
uint8_t | bufferLen | ||
) |
This function is used to write a stream of data into the Radio Frame buffer.
[in] | FIFO | offset to be written to |
[in] | buffer | Pointer to the data to be written into the frame buffer |
[in] | bufferLen | Length of the data to be written |
References HAL_SPICSAssert(), HAL_SPICSDeassert(), HAL_SPISend(), i, and REG_WRITE_CMD.
uint8_t RADIO_RegisterRead | ( | uint8_t | reg | ) |
This function is used to read a byte of data from the radio register.
[in] | reg | Radio register to be read |
Value | read from the radio register |
References HAL_SPICSAssert(), HAL_SPICSDeassert(), and HAL_SPISend().
Referenced by RADIO_FHSSChangeChannel(), Radio_ReadFSKRssi(), Radio_ReadLoraRssi(), RADIO_ReadRandom(), and Radio_WriteMode().
void RADIO_RegisterWrite | ( | uint8_t | reg, |
uint8_t | value | ||
) |
This function is used to write a byte of data to the radio register.
[in] | reg | Radio register to be written |
[in] | value | Value to be written into the radio register |
References HAL_SPICSAssert(), HAL_SPICSDeassert(), HAL_SPISend(), and REG_WRITE_CMD.
Referenced by RADIO_FHSSChangeChannel(), RADIO_ReadRandom(), and Radio_WriteMode().
void RADIO_Reset | ( | void | ) |
This function resets the Radio hardware by pulling the reset pin low.
References HAL_ResetPinMakeInput(), HAL_ResetPinMakeOutput(), HAL_ResetPinOutputValue(), and SystemBlockingWaitMs().
|
static |
Referenced by INTERRUPT_GetDioStatus(), and INTERRUPT_PeekDioStatus().
|
static |
Referenced by HAL_RadioDIO0Callback(), and HAL_RegisterDioInterruptHandler().
|
static |
Referenced by HAL_RadioDIO1Callback(), and HAL_RegisterDioInterruptHandler().
|
static |
Referenced by HAL_RadioDIO2Callback(), and HAL_RegisterDioInterruptHandler().
|
static |
struct spi_slave_inst slave |