sx1276-Hal.h 4.3 KB

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