sx1261_defs.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. / _____) _ | |
  3. ( (____ _____ ____ _| |_ _____ ____| |__
  4. \____ \| ___ | (_ _) ___ |/ ___) _ \
  5. _____) ) ____| | | || |_| ____( (___| | | |
  6. (______/|_____)_|_|_| \__)_____)\____)_| |_|
  7. (C)2019 Semtech
  8. Description:
  9. Functions used to handle LoRa concentrator SX1261 radio.
  10. License: Revised BSD License, see LICENSE.TXT file include in the project
  11. */
  12. #ifndef _SX1261_DEFS_H
  13. #define _SX1261_DEFS_H
  14. /* -------------------------------------------------------------------------- */
  15. /* --- DEPENDANCIES --------------------------------------------------------- */
  16. #include <stdint.h> /* C99 types*/
  17. #include "config.h" /* library configuration options (dynamically generated) */
  18. /* -------------------------------------------------------------------------- */
  19. /* --- PUBLIC MACROS -------------------------------------------------------- */
  20. #define SX1261_FREQ_TO_REG(f) (uint32_t)((uint64_t)f * (1 << 25) / 32000000U)
  21. /* -------------------------------------------------------------------------- */
  22. /* --- PUBLIC CONSTANTS ----------------------------------------------------- */
  23. /* -------------------------------------------------------------------------- */
  24. /* --- PUBLIC TYPES --------------------------------------------------------- */
  25. typedef enum {
  26. SX1261_CALIBRATE_IMAGE = 0x98,
  27. SX1261_CLR_IRQ_STATUS = 0x02,
  28. SX1261_STOP_TIMER_ON_PREAMBLE = 0x9F,
  29. SX1261_SET_RFSWITCHMODE = 0x9D,
  30. SX1261_GET_IRQ_STATUS = 0x12,
  31. SX1261_GET_RX_BUFFER_STATUS = 0x13,
  32. SX1261_GET_PACKET_STATUS = 0x14,
  33. SX1261_GET_RSSI_INST = 0x15,
  34. SX1261_READ_BUFFER = 0x1E,
  35. SX1261_READ_REGISTER = 0x1D,
  36. SX1261_SET_DIO_IRQ_PARAMS = 0x08,
  37. SX1261_SET_MODULATION_PARAMS = 0x8B,
  38. SX1261_SET_PA_CONFIG = 0x95,
  39. SX1261_SET_PACKET_PARAMS = 0x8C,
  40. SX1261_SET_PACKET_TYPE = 0x8A,
  41. SX1261_SET_RF_FREQUENCY = 0x86,
  42. SX1261_SET_BUFFER_BASE_ADDRESS = 0x8F,
  43. SX1261_SET_SLEEP = 0x84,
  44. SX1261_SET_STANDBY = 0x80,
  45. SX1261_SET_RX = 0x82,
  46. SX1261_SET_TX = 0x83,
  47. SX1261_SET_TX_PARAMS = 0x8E,
  48. SX1261_WRITE_BUFFER = 0x0E,
  49. SX1261_WRITE_REGISTER = 0x0D,
  50. SX1261_SET_TXCONTINUOUSWAVE = 0xD1,
  51. SX1261_SET_TXCONTINUOUSPREAMBLE = 0xD2,
  52. SX1261_GET_STATUS = 0xC0,
  53. SX1261_SET_REGULATORMODE = 0x96,
  54. SX1261_SET_FS = 0xC1,
  55. SX1261_GET_DEVICE_ERRORS = 0x17
  56. } sx1261_op_code_t;
  57. typedef enum {
  58. SX1261_STDBY_RC = 0x00,
  59. SX1261_STDBY_XOSC = 0x01
  60. } sx1261_standby_modes_t;
  61. typedef enum {
  62. SX1261_PACKET_TYPE_GFSK = 0x00,
  63. SX1261_PACKET_TYPE_LORA = 0x01
  64. } sx1261_packet_type_t;
  65. typedef enum {
  66. SX1261_SET_RAMP_10U = 0x00,
  67. SX1261_SET_RAMP_20U = 0x01,
  68. SX1261_SET_RAMP_40U = 0x02,
  69. SX1261_SET_RAMP_80U = 0x03,
  70. SX1261_SET_RAMP_200U = 0x04,
  71. SX1261_SET_RAMP_800U = 0x05,
  72. SX1261_SET_RAMP_1700U = 0x06,
  73. SX1261_SET_RAMP_3400U = 0x07
  74. } sx1261_ramp_time_t;
  75. typedef enum {
  76. SX1261_STATUS_MODE_STBY_RC = 0x20, /* 0x02 - bits 6:4 */
  77. SX1261_STATUS_MODE_STBY_XOSC = 0x30, /* 0x03 - bits 6:4 */
  78. SX1261_STATUS_MODE_FS = 0x40, /* 0x04 - bits 6:4 */
  79. SX1261_STATUS_MODE_RX = 0x50, /* 0x05 - bits 6:4 */
  80. SX1261_STATUS_MODE_TX = 0x60 /* 0x06 - bits 6:4 */
  81. } sx1261_status_mode_t;
  82. typedef enum {
  83. SX1261_STATUS_READY = 0x02, /* 0x02 - bits 3:1 */
  84. SX1261_STATUS_TIMEOUT = 0x03, /* 0x03 - bits 3:1 */
  85. SX1261_STATUS_PROCESSING_ERROR = 0x04, /* 0x04 - bits 3:1 */
  86. SX1261_STATUS_EXECUTION_FAILED = 0x05, /* 0x05 - bits 3:1 */
  87. SX1261_STATUS_TX_DONE = 0x06 /* 0x06 - bits 3:1 */
  88. } sx1261_status_command_status_t;
  89. #endif
  90. /* --- EOF ------------------------------------------------------------------ */