loragw_ad5338r.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. / _____) _ | |
  3. ( (____ _____ ____ _| |_ _____ ____| |__
  4. \____ \| ___ | (_ _) ___ |/ ___) _ \
  5. _____) ) ____| | | || |_| ____( (___| | | |
  6. (______/|_____)_|_|_| \__)_____)\____)_| |_|
  7. (C)2020 Semtech
  8. Description:
  9. Basic driver for Analog AD5338R DAC.
  10. License: Revised BSD License, see LICENSE.TXT file include in the project
  11. */
  12. #ifndef _LORAGW_AD5338R_H
  13. #define _LORAGW_AD5338R_H
  14. #include <stdint.h> /* C99 types */
  15. #include <stdbool.h> /* bool type */
  16. #include "config.h" /* library configuration options (dynamically generated) */
  17. /* -------------------------------------------------------------------------- */
  18. /* --- PRIVATE MACROS ------------------------------------------------------- */
  19. #define VOLTAGE2HEX_H(a) ( (a)*1024/5/4 )
  20. #define VOLTAGE2HEX_L(a) ( (((int)((a)*1024/5)) & 0x3) * 64 )
  21. /* -------------------------------------------------------------------------- */
  22. /* --- PRIVATE CONSTANTS ---------------------------------------------------- */
  23. #define I2C_PORT_DAC_AD5338R 0x0C
  24. #define AD5338R_CMD_SIZE 3
  25. /* -------------------------------------------------------------------------- */
  26. /* --- PUBLIC FUNCTIONS ----------------------------------------------------- */
  27. int ad5338r_configure(int i2c_fd, uint8_t i2c_addr);
  28. int ad5338r_write(int i2c_fd, uint8_t i2c_addr, uint8_t buf[static AD5338R_CMD_SIZE]);
  29. #endif