Dependents:   SX1280PingPong RangignMaster RangingSlave MSNV2-Terminal_V1-6 ... more

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 Set the SPI Speed
00064      *
00065      * \param [in]  spiSpeed      Speed of the SPI in Hz
00066      */
00067     void SetSpiSpeed( uint32_t spiSpeed );
00068 
00069     /*!
00070      * \brief Send a command that write data to the radio
00071      *
00072      * \param [in]  opcode        Opcode of the command
00073      * \param [in]  buffer        Buffer to be send to the radio
00074      * \param [in]  size          Size of the buffer to send
00075      */
00076     virtual void WriteCommand( RadioCommands_t opcode, uint8_t *buffer, uint16_t size );
00077 
00078     /*!
00079      * \brief Send a command that read data from the radio
00080      *
00081      * \param [in]  opcode        Opcode of the command
00082      * \param [out] buffer        Buffer holding data from the radio
00083      * \param [in]  size          Size of the buffer
00084      */
00085     virtual void ReadCommand( RadioCommands_t opcode, uint8_t *buffer, uint16_t size );
00086 
00087     /*!
00088      * \brief Write data to the radio memory
00089      *
00090      * \param [in]  address       The address of the first byte to write in the radio
00091      * \param [in]  buffer        The data to be written in radio's memory
00092      * \param [in]  size          The number of bytes to write in radio's memory
00093      */
00094     virtual void WriteRegister( uint16_t address, uint8_t *buffer, uint16_t size );
00095 
00096     /*!
00097      * \brief Write a single byte of data to the radio memory
00098      *
00099      * \param [in]  address       The address of the first byte to write in the radio
00100      * \param [in]  value         The data to be written in radio's memory
00101      */
00102     virtual void WriteRegister( uint16_t address, uint8_t value );
00103 
00104     /*!
00105      * \brief Read data from the radio memory
00106      *
00107      * \param [in]  address       The address of the first byte to read from the radio
00108      * \param [out] buffer        The buffer that holds data read from radio
00109      * \param [in]  size          The number of bytes to read from radio's memory
00110      */
00111     virtual void ReadRegister( uint16_t address, uint8_t *buffer, uint16_t size );
00112 
00113     /*!
00114      * \brief Read a single byte of data from the radio memory
00115      *
00116      * \param [in]  address       The address of the first byte to write in the
00117      *                            radio
00118      *
00119      * \retval      value         The value of the byte at the given address in
00120      *                            radio's memory
00121      */
00122     virtual uint8_t ReadRegister( uint16_t address );
00123 
00124     /*!
00125      * \brief Write data to the buffer holding the payload in the radio
00126      *
00127      * \param [in]  offset        The offset to start writing the payload
00128      * \param [in]  buffer        The data to be written (the payload)
00129      * \param [in]  size          The number of byte to be written
00130      */
00131     virtual void WriteBuffer( uint8_t offset, uint8_t *buffer, uint8_t size );
00132 
00133     /*!
00134      * \brief Read data from the buffer holding the payload in the radio
00135      *
00136      * \param [in]  offset        The offset to start reading the payload
00137      * \param [out] buffer        A pointer to a buffer holding the data from the radio
00138      * \param [in]  size          The number of byte to be read
00139      */
00140     virtual void ReadBuffer( uint8_t offset, uint8_t *buffer, uint8_t size );
00141 
00142     /*!
00143      * \brief Returns the status of DIOs pins
00144      *
00145      * \retval      dioStatus     A byte where each bit represents a DIO state:
00146      *                            [ DIO3 | DIO2 | DIO1 | BUSY ]
00147      */
00148     virtual uint8_t GetDioStatus( void );
00149 
00150 protected:
00151 
00152     SPI *RadioSpi;                                  //!< The SPI object used to communicate with the radio
00153     Serial *RadioUart;                              //!< The UART object used to communicate with the radio
00154     DigitalOut RadioNss;                            //!< The pin connected to Radio chip select (active low)
00155     DigitalInOut RadioReset;                        //!< The reset pin connected to the radio
00156     DigitalOut RadioCtsn;                           //!< The Clear To Send radio pin (active low)
00157 
00158     DigitalIn    BUSY;                              //!< The pin connected to BUSY
00159     InterruptIn *DIO1;                              //!< The pin connected to DIO1
00160     InterruptIn *DIO2;                              //!< The pin connected to DIO2
00161     InterruptIn *DIO3;                              //!< The pin connected to DIO3
00162 
00163     /*!
00164      * \brief Initializes SPI object used to communicate with the radio
00165      */
00166     virtual void SpiInit( void );
00167 
00168     /*!
00169      * \brief Initializes UART object used to communicate with the radio
00170      */
00171     virtual void UartInit( void );
00172 
00173     /*!
00174      * \brief Sets the callback functions to be run on DIO1..3 interrupt
00175      *
00176      * \param [in]  irqHandler    A function pointer of the function to be run on every DIO interrupt
00177      */
00178     virtual void IoIrqInit( DioIrqHandler irqHandler );
00179 };
00180 
00181 #endif // __SX1280_HAL_H__