sx1276-Hal.h 4.5 KB

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