sx1276-LoRaMisc.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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-LoRaMisc.h
  13. * \brief SX1276 RF chip high level functions driver
  14. *
  15. * \remark Optional support functions.
  16. * These functions are defined only to easy the change of the
  17. * parameters.
  18. * For a final firmware the radio parameters will be known so
  19. * there is no need to support all possible parameters.
  20. * Removing these functions will greatly reduce the final firmware
  21. * size.
  22. *
  23. * \version 2.0.B2
  24. * \date May 6 2013
  25. * \author Gregory Cristian
  26. *
  27. * Last modified by Miguel Luis on Jun 19 2013
  28. */
  29. #ifndef __SX1276_LORA_MISC_H__
  30. #define __SX1276_LORA_MISC_H__
  31. /*!
  32. * \brief Writes the new RF frequency value
  33. *
  34. * \param [IN] freq New RF frequency value in [Hz]
  35. */
  36. void SX1276LoRaSetRFFrequency( uint32_t freq );
  37. /*!
  38. * \brief Reads the current RF frequency value
  39. *
  40. * \retval freq Current RF frequency value in [Hz]
  41. */
  42. uint32_t SX1276LoRaGetRFFrequency( void );
  43. /*!
  44. * \brief Writes the new RF output power value
  45. *
  46. * \param [IN] power New output power value in [dBm]
  47. */
  48. void SX1276LoRaSetRFPower( int8_t power );
  49. /*!
  50. * \brief Reads the current RF output power value
  51. *
  52. * \retval power Current output power value in [dBm]
  53. */
  54. int8_t SX1276LoRaGetRFPower( void );
  55. /*!
  56. * \brief Writes the new Signal Bandwidth value
  57. *
  58. * \remark This function sets the IF frequency according to the datasheet
  59. *
  60. * \param [IN] factor New Signal Bandwidth value [0: 125 kHz, 1: 250 kHz, 2: 500 kHz]
  61. */
  62. void SX1276LoRaSetSignalBandwidth( uint8_t bw );
  63. /*!
  64. * \brief Reads the current Signal Bandwidth value
  65. *
  66. * \retval factor Current Signal Bandwidth value [0: 125 kHz, 1: 250 kHz, 2: 500 kHz]
  67. */
  68. uint8_t SX1276LoRaGetSignalBandwidth( void );
  69. /*!
  70. * \brief Writes the new Spreading Factor value
  71. *
  72. * \param [IN] factor New Spreading Factor value [7, 8, 9, 10, 11, 12]
  73. */
  74. void SX1276LoRaSetSpreadingFactor( uint8_t factor );
  75. /*!
  76. * \brief Reads the current Spreading Factor value
  77. *
  78. * \retval factor Current Spreading Factor value [7, 8, 9, 10, 11, 12]
  79. */
  80. uint8_t SX1276LoRaGetSpreadingFactor( void );
  81. /*!
  82. * \brief Writes the new Error Coding value
  83. *
  84. * \param [IN] value New Error Coding value [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
  85. */
  86. void SX1276LoRaSetErrorCoding( uint8_t value );
  87. /*!
  88. * \brief Reads the current Error Coding value
  89. *
  90. * \retval value Current Error Coding value [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
  91. */
  92. uint8_t SX1276LoRaGetErrorCoding( void );
  93. /*!
  94. * \brief Enables/Disables the packet CRC generation
  95. *
  96. * \param [IN] enaable [true, false]
  97. */
  98. void SX1276LoRaSetPacketCrcOn( bool enable );
  99. /*!
  100. * \brief Reads the current packet CRC generation status
  101. *
  102. * \retval enable [true, false]
  103. */
  104. bool SX1276LoRaGetPacketCrcOn( void );
  105. /*!
  106. * \brief Enables/Disables the Implicit Header mode in LoRa
  107. *
  108. * \param [IN] enable [true, false]
  109. */
  110. void SX1276LoRaSetImplicitHeaderOn( bool enable );
  111. /*!
  112. * \brief Check if implicit header mode in LoRa in enabled or disabled
  113. *
  114. * \retval enable [true, false]
  115. */
  116. bool SX1276LoRaGetImplicitHeaderOn( void );
  117. /*!
  118. * \brief Enables/Disables Rx single instead of Rx continuous
  119. *
  120. * \param [IN] enable [true, false]
  121. */
  122. void SX1276LoRaSetRxSingleOn( bool enable );
  123. /*!
  124. * \brief Check if LoRa is in Rx Single mode
  125. *
  126. * \retval enable [true, false]
  127. */
  128. bool SX1276LoRaGetRxSingleOn( void );
  129. /*!
  130. * \brief Enables/Disables the frequency hopping
  131. *
  132. * \param [IN] enable [true, false]
  133. */
  134. void SX1276LoRaSetFreqHopOn( bool enable );
  135. /*!
  136. * \brief Get the frequency hopping status
  137. *
  138. * \param [IN] enable [true, false]
  139. */
  140. bool SX1276LoRaGetFreqHopOn( void );
  141. /*!
  142. * \brief Set symbol period between frequency hops
  143. *
  144. * \param [IN] value
  145. */
  146. void SX1276LoRaSetHopPeriod( uint8_t value );
  147. /*!
  148. * \brief Get symbol period between frequency hops
  149. *
  150. * \retval value symbol period between frequency hops
  151. */
  152. uint8_t SX1276LoRaGetHopPeriod( void );
  153. /*!
  154. * \brief Set timeout Tx packet (based on MCU timer, timeout between Tx Mode entry Tx Done IRQ)
  155. *
  156. * \param [IN] value timeout (ms)
  157. */
  158. void SX1276LoRaSetTxPacketTimeout( uint32_t value );
  159. /*!
  160. * \brief Get timeout between Tx packet (based on MCU timer, timeout between Tx Mode entry Tx Done IRQ)
  161. *
  162. * \retval value timeout (ms)
  163. */
  164. uint32_t SX1276LoRaGetTxPacketTimeout( void );
  165. /*!
  166. * \brief Set timeout Rx packet (based on MCU timer, timeout between Rx Mode entry and Rx Done IRQ)
  167. *
  168. * \param [IN] value timeout (ms)
  169. */
  170. void SX1276LoRaSetRxPacketTimeout( uint32_t value );
  171. /*!
  172. * \brief Get timeout Rx packet (based on MCU timer, timeout between Rx Mode entry and Rx Done IRQ)
  173. *
  174. * \retval value timeout (ms)
  175. */
  176. uint32_t SX1276LoRaGetRxPacketTimeout( void );
  177. /*!
  178. * \brief Set payload length
  179. *
  180. * \param [IN] value payload length
  181. */
  182. void SX1276LoRaSetPayloadLength( uint8_t value );
  183. /*!
  184. * \brief Get payload length
  185. *
  186. * \retval value payload length
  187. */
  188. uint8_t SX1276LoRaGetPayloadLength( void );
  189. /*!
  190. * \brief Enables/Disables the 20 dBm PA
  191. *
  192. * \param [IN] enable [true, false]
  193. */
  194. void SX1276LoRaSetPa20dBm( bool enale );
  195. /*!
  196. * \brief Gets the current 20 dBm PA status
  197. *
  198. * \retval enable [true, false]
  199. */
  200. bool SX1276LoRaGetPa20dBm( void );
  201. /*!
  202. * \brief Set the RF Output pin
  203. *
  204. * \param [IN] RF_PACONFIG_PASELECT_PABOOST or RF_PACONFIG_PASELECT_RFO
  205. */
  206. void SX1276LoRaSetPAOutput( uint8_t outputPin );
  207. /*!
  208. * \brief Gets the used RF Ouptut pin
  209. *
  210. * \retval RF_PACONFIG_PASELECT_PABOOST or RF_PACONFIG_PASELECT_RFO
  211. */
  212. uint8_t SX1276LoRaGetPAOutput( void );
  213. /*!
  214. * \brief Writes the new PA rise/fall time of ramp up/down value
  215. *
  216. * \param [IN] value New PaRamp value
  217. */
  218. void SX1276LoRaSetPaRamp( uint8_t value );
  219. /*!
  220. * \brief Reads the current PA rise/fall time of ramp up/down value
  221. *
  222. * \retval freq Current PaRamp value
  223. */
  224. uint8_t SX1276LoRaGetPaRamp( void );
  225. /*!
  226. * \brief Set Symbol Timeout based on symbol length
  227. *
  228. * \param [IN] value number of symbol
  229. */
  230. void SX1276LoRaSetSymbTimeout( uint16_t value );
  231. /*!
  232. * \brief Get Symbol Timeout based on symbol length
  233. *
  234. * \retval value number of symbol
  235. */
  236. uint16_t SX1276LoRaGetSymbTimeout( void );
  237. /*!
  238. * \brief Configure the device to optimize low datarate transfers
  239. *
  240. * \param [IN] enable Enables/Disables the low datarate optimization
  241. */
  242. void SX1276LoRaSetLowDatarateOptimize( bool enable );
  243. /*!
  244. * \brief Get the status of optimize low datarate transfers
  245. *
  246. * \retval LowDatarateOptimize enable or disable
  247. */
  248. bool SX1276LoRaGetLowDatarateOptimize( void );
  249. /*!
  250. * \brief Get the preamble length
  251. *
  252. * \retval value preamble length
  253. */
  254. uint16_t SX1276LoRaGetPreambleLength( void );
  255. /*!
  256. * \brief Set the preamble length
  257. *
  258. * \param [IN] value preamble length
  259. */
  260. void SX1276LoRaSetPreambleLength( uint16_t value );
  261. /*!
  262. * \brief Set the number or rolling preamble symbol needed for detection
  263. *
  264. * \param [IN] value number of preamble symbol
  265. */
  266. void SX1276LoRaSetNbTrigPeaks( uint8_t value );
  267. /*!
  268. * \brief Get the number or rolling preamble symbol needed for detection
  269. *
  270. * \retval value number of preamble symbol
  271. */
  272. uint8_t SX1276LoRaGetNbTrigPeaks( void );
  273. #endif //__SX1276_LORA_MISC_H__