sx1276-Hal.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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-Hal.h
  13. * \brief SX1276 Hardware Abstraction Layer
  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_HAL_H__
  22. #define __SX1276_HAL_H__
  23. #include <stdint.h>
  24. #include <stdbool.h>
  25. /*!
  26. * DIO state read functions mapping
  27. */
  28. #define DIO0 SX1276ReadDio0( )
  29. #define DIO1 SX1276ReadDio1( )
  30. #define DIO2 SX1276ReadDio2( )
  31. #define DIO3 SX1276ReadDio3( )
  32. #define DIO4 SX1276ReadDio4( )
  33. #define DIO5 SX1276ReadDio5( )
  34. // RXTX pin control see errata note
  35. #define RXTX( txEnable ) SX1276WriteRxTx( txEnable );
  36. #define GET_TICK_COUNT( ) ( TickCounter )
  37. #define TICK_RATE_MS( ms ) ( ms )
  38. typedef enum
  39. {
  40. RADIO_RESET_OFF,
  41. RADIO_RESET_ON,
  42. }tRadioResetState;
  43. /*!
  44. * \brief Initializes the radio interface I/Os
  45. */
  46. void SX1276InitIo( void );
  47. /*!
  48. * \brief Set the radio reset pin state
  49. *
  50. * \param state New reset pin state
  51. */
  52. void SX1276SetReset( uint8_t state );
  53. /*!
  54. * \brief Writes the radio register at the specified address
  55. *
  56. * \param [IN]: addr Register address
  57. * \param [IN]: data New register value
  58. */
  59. void SX1276Write( uint8_t addr, uint8_t data );
  60. /*!
  61. * \brief Reads the radio register at the specified address
  62. *
  63. * \param [IN]: addr Register address
  64. * \param [OUT]: data Register value
  65. */
  66. void SX1276Read( uint8_t addr, uint8_t *data );
  67. /*!
  68. * \brief Writes multiple radio registers starting at address
  69. *
  70. * \param [IN] addr First Radio register address
  71. * \param [IN] buffer Buffer containing the new register's values
  72. * \param [IN] size Number of registers to be written
  73. */
  74. void SX1276WriteBuffer( uint8_t addr, uint8_t *buffer, uint8_t size );
  75. /*!
  76. * \brief Reads multiple radio registers starting at address
  77. *
  78. * \param [IN] addr First Radio register address
  79. * \param [OUT] buffer Buffer where to copy the registers data
  80. * \param [IN] size Number of registers to be read
  81. */
  82. void SX1276ReadBuffer( uint8_t addr, uint8_t *buffer, uint8_t size );
  83. /*!
  84. * \brief Writes the buffer contents to the radio FIFO
  85. *
  86. * \param [IN] buffer Buffer containing data to be put on the FIFO.
  87. * \param [IN] size Number of bytes to be written to the FIFO
  88. */
  89. void SX1276WriteFifo( uint8_t *buffer, uint8_t size );
  90. /*!
  91. * \brief Reads the contents of the radio FIFO
  92. *
  93. * \param [OUT] buffer Buffer where to copy the FIFO read data.
  94. * \param [IN] size Number of bytes to be read from the FIFO
  95. */
  96. void SX1276ReadFifo( uint8_t *buffer, uint8_t size );
  97. /*!
  98. * \brief Gets the SX1276 DIO0 hardware pin status
  99. *
  100. * \retval status Current hardware pin status [1, 0]
  101. */
  102. inline uint8_t SX1276ReadDio0( void );
  103. /*!
  104. * \brief Gets the SX1276 DIO1 hardware pin status
  105. *
  106. * \retval status Current hardware pin status [1, 0]
  107. */
  108. inline uint8_t SX1276ReadDio1( void );
  109. /*!
  110. * \brief Gets the SX1276 DIO2 hardware pin status
  111. *
  112. * \retval status Current hardware pin status [1, 0]
  113. */
  114. inline uint8_t SX1276ReadDio2( void );
  115. /*!
  116. * \brief Gets the SX1276 DIO3 hardware pin status
  117. *
  118. * \retval status Current hardware pin status [1, 0]
  119. */
  120. inline uint8_t SX1276ReadDio3( void );
  121. /*!
  122. * \brief Gets the SX1276 DIO4 hardware pin status
  123. *
  124. * \retval status Current hardware pin status [1, 0]
  125. */
  126. inline uint8_t SX1276ReadDio4( void );
  127. /*!
  128. * \brief Gets the SX1276 DIO5 hardware pin status
  129. *
  130. * \retval status Current hardware pin status [1, 0]
  131. */
  132. inline uint8_t SX1276ReadDio5( void );
  133. /*!
  134. * \brief Writes the external RxTx pin value
  135. *
  136. * \remark see errata note
  137. *
  138. * \param [IN] txEnable [1: Tx, 0: Rx]
  139. */
  140. inline void SX1276WriteRxTx( uint8_t txEnable );
  141. #endif //__SX1276_HAL_H__