loragw_com.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. / _____) _ | |
  3. ( (____ _____ ____ _| |_ _____ ____| |__
  4. \____ \| ___ | (_ _) ___ |/ ___) _ \
  5. _____) ) ____| | | || |_| ____( (___| | | |
  6. (______/|_____)_|_|_| \__)_____)\____)_| |_|
  7. (C)2020 Semtech
  8. Description:
  9. Functions to abstract the communication interface used to communicate with
  10. the concentrator.
  11. Single-byte read/write and burst read/write.
  12. License: Revised BSD License, see LICENSE.TXT file include in the project
  13. */
  14. #ifndef _LORAGW_COM_H
  15. #define _LORAGW_COM_H
  16. /* -------------------------------------------------------------------------- */
  17. /* --- DEPENDANCIES --------------------------------------------------------- */
  18. #include <stdint.h> /* C99 types*/
  19. #include "config.h" /* library configuration options (dynamically generated) */
  20. /* -------------------------------------------------------------------------- */
  21. /* --- PUBLIC CONSTANTS ----------------------------------------------------- */
  22. #define LGW_COM_SUCCESS 0
  23. #define LGW_COM_ERROR -1
  24. #define LGW_SPI_MUX_TARGET_SX1302 0x00
  25. #define LGW_SPI_MUX_TARGET_RADIOA 0x01
  26. #define LGW_SPI_MUX_TARGET_RADIOB 0x02
  27. /* -------------------------------------------------------------------------- */
  28. /* --- PUBLIC TYPES --------------------------------------------------------- */
  29. typedef enum com_type_e {
  30. LGW_COM_SPI,
  31. LGW_COM_USB,
  32. LGW_COM_UNKNOWN
  33. } lgw_com_type_t;
  34. typedef enum com_write_mode_e {
  35. LGW_COM_WRITE_MODE_SINGLE,
  36. LGW_COM_WRITE_MODE_BULK,
  37. LGW_COM_WRITE_MODE_UNKNOWN
  38. } lgw_com_write_mode_t;
  39. /* -------------------------------------------------------------------------- */
  40. /* --- PUBLIC FUNCTIONS PROTOTYPES ------------------------------------------ */
  41. /**
  42. *
  43. */
  44. int lgw_com_open(lgw_com_type_t com_type, const char *com_path);
  45. /**
  46. *
  47. */
  48. int lgw_com_close(void);
  49. /**
  50. *
  51. */
  52. int lgw_com_w(uint8_t spi_mux_target, uint16_t address, uint8_t data);
  53. /**
  54. *
  55. */
  56. int lgw_com_r(uint8_t spi_mux_target, uint16_t address, uint8_t *data);
  57. /**
  58. *
  59. */
  60. int lgw_com_rmw(uint8_t spi_mux_target, uint16_t address, uint8_t offs, uint8_t leng, uint8_t data);
  61. /**
  62. *
  63. */
  64. int lgw_com_wb(uint8_t spi_mux_target, uint16_t address, const uint8_t *data, uint16_t size);
  65. /**
  66. *
  67. */
  68. int lgw_com_rb(uint8_t spi_mux_target, uint16_t address, uint8_t *data, uint16_t size);
  69. /**
  70. *
  71. */
  72. int lgw_com_set_write_mode(lgw_com_write_mode_t write_mode);
  73. /**
  74. *
  75. */
  76. int lgw_com_flush(void);
  77. /**
  78. *
  79. */
  80. uint16_t lgw_com_chunk_size(void);
  81. /**
  82. *
  83. **/
  84. int lgw_com_get_temperature(float * temperature);
  85. /**
  86. *
  87. **/
  88. void* lgw_com_target(void);
  89. /**
  90. *
  91. **/
  92. lgw_com_type_t lgw_com_type(void);
  93. #endif
  94. /* --- EOF ------------------------------------------------------------------ */