sx1276-board.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. / _____) _ | |
  3. ( (____ _____ ____ _| |_ _____ ____| |__
  4. \____ \| ___ | (_ _) ___ |/ ___) _ \
  5. _____) ) ____| | | || |_| ____( (___| | | |
  6. (______/|_____)_|_|_| \__)_____)\____)_| |_|
  7. (C)2013 Semtech
  8. Description: SX1276 driver specific target board functions implementation
  9. License: Revised BSD License, see LICENSE.TXT file include in the project
  10. Maintainer: Miguel Luis and Gregory Cristian
  11. */
  12. #ifndef __SX1276_ARCH_H__
  13. #define __SX1276_ARCH_H__
  14. #include "stdbool.h"
  15. #include "stdint.h"
  16. #include "sx1276.h"
  17. /*!
  18. * \brief Radio hardware registers initialization definition
  19. *
  20. * \remark Can be automatically generated by the SX1276 GUI (not yet implemented)
  21. */
  22. #define RADIO_INIT_REGISTERS_VALUE \
  23. { \
  24. { MODEM_FSK , REG_LNA , 0x23 },\
  25. { MODEM_FSK , REG_RXCONFIG , 0x1E },\
  26. { MODEM_FSK , REG_RSSICONFIG , 0xD2 },\
  27. { MODEM_FSK , REG_AFCFEI , 0x01 },\
  28. { MODEM_FSK , REG_PREAMBLEDETECT , 0xAA },\
  29. { MODEM_FSK , REG_OSC , 0x07 },\
  30. { MODEM_FSK , REG_SYNCCONFIG , 0x12 },\
  31. { MODEM_FSK , REG_SYNCVALUE1 , 0xC1 },\
  32. { MODEM_FSK , REG_SYNCVALUE2 , 0x94 },\
  33. { MODEM_FSK , REG_SYNCVALUE3 , 0xC1 },\
  34. { MODEM_FSK , REG_PACKETCONFIG1 , 0xD8 },\
  35. { MODEM_FSK , REG_FIFOTHRESH , 0x8F },\
  36. { MODEM_FSK , REG_IMAGECAL , 0x02 },\
  37. { MODEM_FSK , REG_DIOMAPPING1 , 0x00 },\
  38. { MODEM_FSK , REG_DIOMAPPING2 , 0x30 },\
  39. { MODEM_LORA, REG_LR_PAYLOADMAXLENGTH, 0x40 },\
  40. } \
  41. #define RF_MID_BAND_THRESH 525000000
  42. /*!
  43. * \brief Initializes the radio I/Os pins interface
  44. */
  45. void SX1276IoInit( void );
  46. /*!
  47. * \brief Initializes DIO IRQ handlers
  48. *
  49. * \param [IN] irqHandlers Array containing the IRQ callback functions
  50. */
  51. void SX1276IoIrqInit( DioIrqHandler **irqHandlers );
  52. /*!
  53. * \brief De-initializes the radio I/Os pins interface.
  54. *
  55. * \remark Useful when going in MCU lowpower modes
  56. */
  57. void SX1276IoDeInit( void );
  58. /*!
  59. * \brief Gets the board PA selection configuration
  60. *
  61. * \param [IN] channel Channel frequency in Hz
  62. * \retval PaSelect RegPaConfig PaSelect value
  63. */
  64. uint8_t SX1276GetPaSelect( uint32_t channel );
  65. /*!
  66. * \brief Initializes the RF Switch I/Os pins interface
  67. */
  68. void SX1276AntSwInit( void );
  69. /*!
  70. * \brief De-initializes the RF Switch I/Os pins interface
  71. *
  72. * \remark Needed to decrease the power consumption in MCU lowpower modes
  73. */
  74. void SX1276AntSwDeInit( void );
  75. /*!
  76. * \brief Controls the antena switch if necessary.
  77. *
  78. * \remark see errata note
  79. *
  80. * \param [IN] rxTx [1: Tx, 0: Rx]
  81. */
  82. void SX1276SetAntSw( uint8_t rxTx );
  83. /*!
  84. * \brief Checks if the given RF frequency is supported by the hardware
  85. *
  86. * \param [IN] frequency RF frequency to be checked
  87. * \retval isSupported [true: supported, false: unsupported]
  88. */
  89. bool SX1276CheckRfFrequency( uint32_t frequency );
  90. void Sx1276SetNSS(bool enable );
  91. uint8_t Sx1276SpiInOut(uint16_t data );
  92. void SX1276TimerInit(void);
  93. void SX1276TxTimeoutTimerStart( uint32_t timeoutMs );
  94. void SX1276TxTimeoutTimerStop(void);
  95. void SX1276RxTimeoutTimerStart( uint32_t timeoutMs );
  96. void SX1276RxTimeoutTimerStop(void);
  97. void SX1276SyncWordTimeoutTimerStart( uint32_t timeoutMs );
  98. void SX1276SyncWordTimeoutTimerStop(void);
  99. void SX1276Reset( void );
  100. void SX1276DelayMs(uint32_t delayMs);
  101. /*!
  102. * Radio hardware and global parameters
  103. */
  104. extern SX1276_t SX1276;
  105. #endif // __SX1276_ARCH_H__