Uttam Bhat / SX1280Lib

Fork of SX1280Lib by Semtech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sx1280-hal.h Source File

sx1280-hal.h

00001 /*
00002   ______                              _
00003  / _____)             _              | |
00004 ( (____  _____ ____ _| |_ _____  ____| |__
00005  \____ \| ___ |    (_   _) ___ |/ ___)  _ \
00006  _____) ) ____| | | || |_| ____( (___| | | |
00007 (______/|_____)_|_|_| \__)_____)\____)_| |_|
00008     (C)2015 Semtech
00009 
00010 Description: Handling of the node configuration protocol
00011 
00012 License: Revised BSD License, see LICENSE.TXT file include in the project
00013 
00014 Maintainer: Miguel Luis and Gregory Cristian
00015 */
00016 #ifndef __SX1280_HAL_H__
00017 #define __SX1280_HAL_H__
00018 
00019 #include "sx1280.h"
00020 
00021 /*!
00022  * \brief Actual implementation of a SX1280 radio
00023  */
00024 class SX1280Hal : public SX1280
00025 {
00026 public:
00027     /*!
00028      * \brief Constructor for SX1280Hal with SPI support
00029      *
00030      * Represents the physical connectivity with the radio and set callback functions on radio interrupts
00031      */
00032     SX1280Hal( PinName mosi, PinName miso, PinName sclk, PinName nss,
00033                PinName busy, PinName dio1, PinName dio2, PinName dio3, PinName rst,
00034                RadioCallbacks_t *callbacks );
00035 
00036     /*!
00037      * \brief Constructor for SX1280Hal with UART support
00038      *
00039      * Represents the physical connectivity with the radio and set callback functions on radio interrupts
00040      */
00041     SX1280Hal( PinName tx, PinName rx, PinName ctsn,
00042                PinName busy, PinName dio1, PinName dio2, PinName dio3, PinName rst,
00043                RadioCallbacks_t *callbacks );
00044 
00045     /*!
00046      * \brief Destructor for SX1280Hal with UART support
00047      *
00048      * Take care of the correct destruction of the communication objects
00049      */
00050     virtual ~SX1280Hal( void );
00051 
00052     /*!
00053      * \brief Soft resets the radio
00054      */
00055     virtual void Reset( void );
00056 
00057     /*!
00058      * \brief Wakes up the radio
00059      */
00060     virtual void Wakeup( void );
00061 
00062     /*!
00063      * \brief Send a command that write data to the radio
00064      *
00065      * \param [in]  opcode        Opcode of the command
00066      * \param [in]  buffer        Buffer to be send to the radio
00067      * \param [in]  size          Size of the buffer to send
00068      */
00069     virtual void WriteCommand( RadioCommands_t opcode, uint8_t *buffer, uint16_t size );
00070 
00071     /*!
00072      * \brief Send a command that read data from the radio
00073      *
00074      * \param [in]  opcode        Opcode of the command
00075      * \param [out] buffer        Buffer holding data from the radio
00076      * \param [in]  size          Size of the buffer
00077      */
00078     virtual void ReadCommand( RadioCommands_t opcode, uint8_t *buffer, uint16_t size );
00079 
00080     /*!
00081      * \brief Write data to the radio memory
00082      *
00083      * \param [in]  address       The address of the first byte to write in the radio
00084      * \param [in]  buffer        The data to be written in radio's memory
00085      * \param [in]  size          The number of bytes to write in radio's memory
00086      */
00087     virtual void WriteRegister( uint16_t address, uint8_t *buffer, uint16_t size );
00088 
00089     /*!
00090      * \brief Write a single byte of data to the radio memory
00091      *
00092      * \param [in]  address       The address of the first byte to write in the radio
00093      * \param [in]  value         The data to be written in radio's memory
00094      */
00095     virtual void WriteRegister( uint16_t address, uint8_t value );
00096 
00097     /*!
00098      * \brief Read data from the radio memory
00099      *
00100      * \param [in]  address       The address of the first byte to read from the radio
00101      * \param [out] buffer        The buffer that holds data read from radio
00102      * \param [in]  size          The number of bytes to read from radio's memory
00103      */
00104     virtual void ReadRegister( uint16_t address, uint8_t *buffer, uint16_t size );
00105 
00106     /*!
00107      * \brief Read a single byte of data from the radio memory
00108      *
00109      * \param [in]  address       The address of the first byte to write in the
00110      *                            radio
00111      *
00112      * \retval      value         The value of the byte at the given address in
00113      *                            radio's memory
00114      */
00115     virtual uint8_t ReadRegister( uint16_t address );
00116 
00117     /*!
00118      * \brief Write data to the buffer holding the payload in the radio
00119      *
00120      * \param [in]  offset        The offset to start writing the payload
00121      * \param [in]  buffer        The data to be written (the payload)
00122      * \param [in]  size          The number of byte to be written
00123      */
00124     virtual void WriteBuffer( uint8_t offset, uint8_t *buffer, uint8_t size );
00125 
00126     /*!
00127      * \brief Read data from the buffer holding the payload in the radio
00128      *
00129      * \param [in]  offset        The offset to start reading the payload
00130      * \param [out] buffer        A pointer to a buffer holding the data from the radio
00131      * \param [in]  size          The number of byte to be read
00132      */
00133     virtual void ReadBuffer( uint8_t offset, uint8_t *buffer, uint8_t size );
00134 
00135     /*!
00136      * \brief Returns the status of DIOs pins
00137      *
00138      * \retval      dioStatus     A byte where each bit represents a DIO state:
00139      *                            [ DIO3 | DIO2 | DIO1 | BUSY ]
00140      */
00141     virtual uint8_t GetDioStatus( void );
00142 
00143 protected:
00144 
00145     SPI *RadioSpi;                                  //!< The SPI object used to communicate with the radio
00146     Serial *RadioUart;                              //!< The UART object used to communicate with the radio
00147     DigitalOut RadioNss;                            //!< The pin connected to Radio chip select (active low)
00148     DigitalInOut RadioReset;                        //!< The reset pin connected to the radio
00149     DigitalOut RadioCtsn;                           //!< The Clear To Send radio pin (active low)
00150 
00151     DigitalIn    BUSY;                              //!< The pin connected to BUSY
00152     InterruptIn *DIO1;                              //!< The pin connected to DIO1
00153     InterruptIn *DIO2;                              //!< The pin connected to DIO2
00154     InterruptIn *DIO3;                              //!< The pin connected to DIO3
00155 
00156     /*!
00157      * \brief Initializes SPI object used to communicate with the radio
00158      */
00159     virtual void SpiInit( void );
00160 
00161     /*!
00162      * \brief Initializes UART object used to communicate with the radio
00163      */
00164     virtual void UartInit( void );
00165 
00166     /*!
00167      * \brief Sets the callback functions to be run on DIO1..3 interrupt
00168      *
00169      * \param [in]  irqHandler    A function pointer of the function to be run on every DIO interrupt
00170      */
00171     virtual void IoIrqInit( DioIrqHandler irqHandler );
00172 };
00173 
00174 #endif // __SX1280_HAL_H__