sx1276-LoRaMisc.h 7.5 KB

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