Microchip® Advanced Software Framework

radio_driver_hal.h File Reference

This is the Radio Driver HAL source file which contains LoRa-specific Radio Driver Hardware Abstract Layer.

Copyright (c) 2018 Microchip Technology Inc. and its subsidiaries.

#include <stdint.h>

Macros

#define DIO0   0x01
 
#define DIO1   0x02
 
#define DIO2   0x04
 
#define DIO3   0x08
 
#define DIO4   0x10
 
#define DIO5   0x20
 
#define REG_FIFO_ADDRESS   0
 
#define REG_WRITE_CMD   0x80
 

Typedefs

typedef void(* DioInterruptHandler_t )(void)
 
typedef enum _RadioClockSources_t RadioClockSources_t
 Possible Radio Clock sources supported. More...
 
typedef enum _RFCtrl1 RFCtrl1_t
 
typedef enum _RFCtrl2 RFCtrl2_t
 

Enumerations

enum  _RadioClockSources_t {
  TCXO = 0,
  XTAL
}
 Possible Radio Clock sources supported. More...
 
enum  _RFCtrl1 {
  RFO_LF = 0,
  RFO_HF = 1,
  PA_BOOST = 2
}
 
enum  _RFCtrl2 {
  RX = 0,
  TX = 1
}
 

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...
 
uint8_t HAL_DIO3PinValue (void)
 This function is used to read the status of DIO2 pin. More...
 
uint8_t HAL_DIO4PinValue (void)
 This function is used to read the status of DIO4 pin. More...
 
uint8_t HAL_DIO5PinValue (void)
 This function is used to read the status of DIO5 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 DIO1 interrupt. More...
 
void HAL_DisbleDIO2Interrupt (void)
 This function is used to disable DIO2 interrupt. More...
 
void HAL_DisbleDIO3Interrupt (void)
 This function is used to disable DIO3 interrupt. More...
 
void HAL_DisbleDIO4Interrupt (void)
 This function is used to disable DIO4 interrupt. More...
 
void HAL_DisbleDIO5Interrupt (void)
 This function is used to disable DIO5 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_EnableDIO3Interrupt (void)
 This function is used to enable DIO3 interrupt. More...
 
void HAL_EnableDIO4Interrupt (void)
 This function is used to enable DIO4 interrupt. More...
 
void HAL_EnableDIO5Interrupt (void)
 This function is used to enable DIO5 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 Radio SPI after PMM wakeup. More...
 
void HAL_RadioDeInit (void)
 This function is used to deinitialize the Radio SPI. More...
 
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...
 
void HAL_RegisterDioInterruptHandler (uint8_t dioPin, DioInterruptHandler_t handler)
 This function sets the interrupt handler for given DIO interrupt. More...
 
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...
 

#define DIO0   0x01
#define DIO1   0x02
#define DIO2   0x04
#define DIO3   0x08
#define DIO4   0x10
#define DIO5   0x20
#define REG_FIFO_ADDRESS   0
#define REG_WRITE_CMD   0x80

typedef void(* DioInterruptHandler_t)(void)

Possible Radio Clock sources supported.

typedef enum _RFCtrl1 RFCtrl1_t
typedef enum _RFCtrl2 RFCtrl2_t

Possible Radio Clock sources supported.

Enumerator
TCXO 
XTAL 
enum _RFCtrl1
Enumerator
RFO_LF 
RFO_HF 
PA_BOOST 
enum _RFCtrl2
Enumerator
RX 
TX 

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().

uint8_t HAL_DIO3PinValue ( void  )

This function is used to read the status of DIO2 pin.

uint8_t HAL_DIO4PinValue ( void  )

This function is used to read the status of DIO4 pin.

uint8_t HAL_DIO5PinValue ( void  )

This function is used to read the status of DIO5 pin.

void HAL_DisableRFCtrl ( RFCtrl1_t  RFCtrl1,
RFCtrl2_t  RFCtrl2 
)

This function Disables RF Control pins.

Parameters
[in]RFCtrl1RFO_LF = 0 RFO_HF = 1 PA_BOOST = 2
[in]RFCtrl2RX = 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 DIO1 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_DisbleDIO3Interrupt ( void  )

This function is used to disable DIO3 interrupt.

void HAL_DisbleDIO4Interrupt ( void  )

This function is used to disable DIO4 interrupt.

void HAL_DisbleDIO5Interrupt ( void  )

This function is used to disable DIO5 interrupt.

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().

void HAL_EnableDIO3Interrupt ( void  )

This function is used to enable DIO3 interrupt.

void HAL_EnableDIO4Interrupt ( void  )

This function is used to enable DIO4 interrupt.

void HAL_EnableDIO5Interrupt ( void  )

This function is used to enable DIO5 interrupt.

void HAL_EnableRFCtrl ( RFCtrl1_t  RFCtrl1,
RFCtrl2_t  RFCtrl2 
)

This function Enables RF Control pins.

Parameters
[in]RFCtrl1RFO_LF = 0 RFO_HF = 1 PA_BOOST = 2
[in]RFCtrl2RX = 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.

Parameters
[in]None
[out]Typeof 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.

Parameters
[in]None
[out]Timevalue in ms

References RADIO_CLK_STABILITATION_DELAY.

void HAL_Radio_resources_init ( void  )

This function is used to initialize the Radio SPI 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 Radio SPI.

This function is used to deinitialize the Radio SPI.

References master, and spi_disable().

Referenced by app_resources_uninit().

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().

void HAL_RegisterDioInterruptHandler ( uint8_t  dioPin,
DioInterruptHandler_t  handler 
)

This function sets the interrupt handler for given DIO interrupt.

Parameters
[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.

void HAL_TCXOPowerOff ( void  )

This function Powering off the TCXO oscillator.

Parameters
[in]None
[out]None

References port_pin_set_output_level().

void HAL_TCXOPowerOn ( void  )

This function Powering up the TCXO oscillator.

Parameters
[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.

Return values
Returnsthe 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.

Return values
Returnsthe 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.

Parameters
[in]FIFOoffset to be read from
[in]bufferPointer to the data where the data is read and stored
[in]bufferLenLength 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.

Parameters
[in]FIFOoffset to be written to
[in]bufferPointer to the data to be written into the frame buffer
[in]bufferLenLength 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.

Parameters
[in]regRadio register to be read
Return values
Valueread 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.

Parameters
[in]regRadio register to be written
[in]valueValue 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().