sx1276-LoRaMisc.h 7.5 KB

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