sx1276.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * THE FOLLOWING FIRMWARE IS PROVIDED: (1) "AS IS" WITH NO WARRANTY; AND
  3. * (2)TO ENABLE ACCESS TO CODING INFORMATION TO GUIDE AND FACILITATE CUSTOMER.
  4. * CONSEQUENTLY, SEMTECH SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT OR
  5. * CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
  6. * OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
  7. * CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  8. *
  9. * Copyright (C) SEMTECH S.A.
  10. */
  11. /*!
  12. * \file sx1276.h
  13. * \brief SX1276 RF chip driver
  14. *
  15. * \version 2.0.B2
  16. * \date May 6 2013
  17. * \author Gregory Cristian
  18. *
  19. * Last modified by Miguel Luis on Jun 19 2013
  20. */
  21. #ifndef __SX1276_H__
  22. #define __SX1276_H__
  23. #include "stdbool.h"
  24. #include "stdint.h"
  25. /*!
  26. * \brief SX1276 registers array
  27. */
  28. extern uint8_t SX1276Regs[0x70];
  29. /*!
  30. * \brief Enables LoRa modem or FSK modem
  31. *
  32. * \param [IN] opMode New operating mode
  33. */
  34. void SX1276SetLoRaOn( bool enable );
  35. /*!
  36. * \brief Gets the LoRa modem state
  37. *
  38. * \retval LoraOn Current LoRa modem mode
  39. */
  40. bool SX1276GetLoRaOn( void );
  41. /*!
  42. * \brief Initializes the SX1276
  43. */
  44. void SX1276Init( void );
  45. /*!
  46. * \brief Resets the SX1276
  47. */
  48. void SX1276Reset( void );
  49. /*!
  50. * \brief Sets the SX1276 operating mode
  51. *
  52. * \param [IN] opMode New operating mode
  53. */
  54. void SX1276SetOpMode( uint8_t opMode );
  55. /*!
  56. * \brief Gets the SX1276 operating mode
  57. *
  58. * \retval opMode Current operating mode
  59. */
  60. uint8_t SX1276GetOpMode( void );
  61. /*!
  62. * \brief Reads the current Rx gain setting
  63. *
  64. * \retval rxGain Current gain setting
  65. */
  66. uint8_t SX1276ReadRxGain( void );
  67. /*!
  68. * \brief Trigs and reads the current RSSI value
  69. *
  70. * \retval rssiValue Current RSSI value in [dBm]
  71. */
  72. double SX1276ReadRssi( void );
  73. /*!
  74. * \brief Gets the Rx gain value measured while receiving the packet
  75. *
  76. * \retval rxGainValue Current Rx gain value
  77. */
  78. uint8_t SX1276GetPacketRxGain( void );
  79. /*!
  80. * \brief Gets the SNR value measured while receiving the packet
  81. *
  82. * \retval snrValue Current SNR value in [dB]
  83. */
  84. int8_t SX1276GetPacketSnr( void );
  85. /*!
  86. * \brief Gets the RSSI value measured while receiving the packet
  87. *
  88. * \retval rssiValue Current RSSI value in [dBm]
  89. */
  90. double SX1276GetPacketRssi( void );
  91. /*!
  92. * \brief Gets the AFC value measured while receiving the packet
  93. *
  94. * \retval afcValue Current AFC value in [Hz]
  95. */
  96. uint32_t SX1276GetPacketAfc( void );
  97. /*!
  98. * \brief Sets the radio in Rx mode. Waiting for a packet
  99. */
  100. void SX1276StartRx( void );
  101. /*!
  102. * \brief Gets a copy of the current received buffer
  103. *
  104. * \param [IN]: buffer Buffer pointer
  105. * \param [IN]: size Buffer size
  106. */
  107. void SX1276GetRxPacket( void *buffer, uint16_t *size );
  108. /*!
  109. * \brief Sets a copy of the buffer to be transmitted and starts the
  110. * transmission
  111. *
  112. * \param [IN]: buffer Buffer pointer
  113. * \param [IN]: size Buffer size
  114. */
  115. void SX1276SetTxPacket( const void *buffer, uint16_t size );
  116. /*!
  117. * \brief Gets the current RFState
  118. *
  119. * \retval rfState Current RF state [RF_IDLE, RF_BUSY,
  120. * RF_RX_DONE, RF_RX_TIMEOUT,
  121. * RF_TX_DONE, RF_TX_TIMEOUT]
  122. */
  123. uint8_t SX1276GetRFState( void );
  124. /*!
  125. * \brief Sets the new state of the RF state machine
  126. *
  127. * \param [IN]: state New RF state machine state
  128. */
  129. void SX1276SetRFState( uint8_t state );
  130. /*!
  131. * \brief Process the Rx and Tx state machines depending on the
  132. * SX1276 operating mode.
  133. *
  134. * \retval rfState Current RF state [RF_IDLE, RF_BUSY,
  135. * RF_RX_DONE, RF_RX_TIMEOUT,
  136. * RF_TX_DONE, RF_TX_TIMEOUT]
  137. */
  138. uint32_t SX1276Process( void );
  139. void SX1276Init( void );
  140. #endif //__SX1276_H__