Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

184 lines
4.5 KiB

  1. /*!
  2. * \file sx1276-board.h
  3. *
  4. * \brief Target board SX1276 driver implementation
  5. *
  6. * \copyright Revised BSD License, see section \ref LICENSE.
  7. *
  8. * \code
  9. * ______ _
  10. * / _____) _ | |
  11. * ( (____ _____ ____ _| |_ _____ ____| |__
  12. * \____ \| ___ | (_ _) ___ |/ ___) _ \
  13. * _____) ) ____| | | || |_| ____( (___| | | |
  14. * (______/|_____)_|_|_| \__)_____)\____)_| |_|
  15. * (C)2013-2017 Semtech
  16. *
  17. * \endcode
  18. *
  19. * \author Miguel Luis ( Semtech )
  20. *
  21. * \author Gregory Cristian ( Semtech )
  22. */
  23. #ifndef __SX1276_BOARD_H__
  24. #define __SX1276_BOARD_H__
  25. #ifdef __cplusplus
  26. extern "C"
  27. {
  28. #endif
  29. #include <stdint.h>
  30. #include <stdbool.h>
  31. #include "sx1276/sx1276.h"
  32. /*!
  33. * \brief Radio hardware registers initialization definition
  34. *
  35. * \remark Can be automatically generated by the SX1276 GUI (not yet implemented)
  36. */
  37. #define RADIO_INIT_REGISTERS_VALUE \
  38. { \
  39. { MODEM_FSK , REG_LNA , 0x23 },\
  40. { MODEM_FSK , REG_RXCONFIG , 0x1E },\
  41. { MODEM_FSK , REG_RSSICONFIG , 0xD2 },\
  42. { MODEM_FSK , REG_AFCFEI , 0x01 },\
  43. { MODEM_FSK , REG_PREAMBLEDETECT , 0xAA },\
  44. { MODEM_FSK , REG_OSC , 0x07 },\
  45. { MODEM_FSK , REG_SYNCCONFIG , 0x12 },\
  46. { MODEM_FSK , REG_SYNCVALUE1 , 0xC1 },\
  47. { MODEM_FSK , REG_SYNCVALUE2 , 0x94 },\
  48. { MODEM_FSK , REG_SYNCVALUE3 , 0xC1 },\
  49. { MODEM_FSK , REG_PACKETCONFIG1 , 0xD8 },\
  50. { MODEM_FSK , REG_FIFOTHRESH , 0xBF },\
  51. { MODEM_FSK , REG_IMAGECAL , 0x02 },\
  52. { MODEM_FSK , REG_DIOMAPPING1 , 0x00 },\
  53. { MODEM_FSK , REG_DIOMAPPING2 , 0x30 },\
  54. { MODEM_LORA, REG_LR_PAYLOADMAXLENGTH, 0x40 },\
  55. } \
  56. #define RF_MID_BAND_THRESH 525000000
  57. /*!
  58. * \brief Initializes the radio I/Os pins interface
  59. */
  60. void SX1276IoInit( void );
  61. /*!
  62. * \brief Initializes DIO IRQ handlers
  63. *
  64. * \param [IN] irqHandlers Array containing the IRQ callback functions
  65. */
  66. void SX1276IoIrqInit( DioIrqHandler **irqHandlers );
  67. /*!
  68. * \brief De-initializes the radio I/Os pins interface.
  69. *
  70. * \remark Useful when going in MCU low power modes
  71. */
  72. void SX1276IoDeInit( void );
  73. /*!
  74. * \brief Initializes the TCXO power pin.
  75. */
  76. void SX1276IoTcxoInit( void );
  77. /*!
  78. * \brief Initializes the radio debug pins.
  79. */
  80. void SX1276IoDbgInit( void );
  81. /*!
  82. * \brief Resets the radio
  83. */
  84. void SX1276Reset( void );
  85. /*!
  86. * \brief Sets the radio output power.
  87. *
  88. * \param [IN] power Sets the RF output power
  89. */
  90. void SX1276SetRfTxPower( int8_t power );
  91. /*!
  92. * \brief Set the RF Switch I/Os pins in low power mode
  93. *
  94. * \param [IN] status enable or disable
  95. */
  96. void SX1276SetAntSwLowPower( bool status );
  97. /*!
  98. * \brief Initializes the RF Switch I/Os pins interface
  99. */
  100. void SX1276AntSwInit( void );
  101. /*!
  102. * \brief De-initializes the RF Switch I/Os pins interface
  103. *
  104. * \remark Needed to decrease the power consumption in MCU low power modes
  105. */
  106. void SX1276AntSwDeInit( void );
  107. /*!
  108. * \brief Controls the antenna switch if necessary.
  109. *
  110. * \remark see errata note
  111. *
  112. * \param [IN] opMode Current radio operating mode
  113. */
  114. void SX1276SetAntSw( uint8_t opMode );
  115. /*!
  116. * \brief Checks if the given RF frequency is supported by the hardware
  117. *
  118. * \param [IN] frequency RF frequency to be checked
  119. * \retval isSupported [true: supported, false: unsupported]
  120. */
  121. bool SX1276CheckRfFrequency( uint32_t frequency );
  122. /*!
  123. * \brief Enables/disables the TCXO if available on board design.
  124. *
  125. * \param [IN] state TCXO enabled when true and disabled when false.
  126. */
  127. void SX1276SetBoardTcxo( uint8_t state );
  128. /*!
  129. * \brief Gets the Defines the time required for the TCXO to wakeup [ms].
  130. *
  131. * \retval time Board TCXO wakeup time in ms.
  132. */
  133. uint32_t SX1276GetBoardTcxoWakeupTime( void );
  134. /*!
  135. * \brief Gets current state of DIO1 pin state (FifoLevel).
  136. *
  137. * \retval state DIO1 pin current state.
  138. */
  139. uint32_t SX1276GetDio1PinState( void );
  140. /*!
  141. * \brief Writes new Tx debug pin state
  142. *
  143. * \param [IN] state Debug pin state
  144. */
  145. void SX1276DbgPinTxWrite( uint8_t state );
  146. /*!
  147. * \brief Writes new Rx debug pin state
  148. *
  149. * \param [IN] state Debug pin state
  150. */
  151. void SX1276DbgPinRxWrite( uint8_t state );
  152. /*!
  153. * Radio hardware and global parameters
  154. */
  155. extern SX1276_t SX1276;
  156. #ifdef __cplusplus
  157. }
  158. #endif
  159. #endif // __SX1276_BOARD_H__