AD5933_ATY.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /**
  2. * @file AD5933_ATY.h
  3. *
  4. * @param Project DEVICE_GENERAL_ATY_LIB
  5. *
  6. * @author ATY
  7. *
  8. * @copyright
  9. * - Copyright 2017 - 2025 MZ-ATY
  10. * - This code follows:
  11. * - MZ-ATY Various Contents Joint Statement -
  12. * <a href="https://mengze.top/MZ-ATY_VCJS">
  13. * https://mengze.top/MZ-ATY_VCJS</a>
  14. * - CC 4.0 BY-NC-SA -
  15. * <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
  16. * https://creativecommons.org/licenses/by-nc-sa/4.0/</a>
  17. * - Your use will be deemed to have accepted the terms of this statement.
  18. *
  19. * @brief Familiar functions of AD5933 for all embedded device
  20. *
  21. * @version
  22. * - 1_01_24015 > ATY
  23. * -# Preliminary version, first Release
  24. ********************************************************************************
  25. */
  26. #ifndef __AD5933_ATY_H
  27. #define __AD5933_ATY_H
  28. #include "INCLUDE_ATY.h"
  29. /******************************* For user *************************************/
  30. // 0 0 0 1 1 0 1 R/W
  31. #define AD5933_ADDRESS (0x0D)
  32. /******************************************************************************/
  33. struct AD5933_ATY_Dev
  34. {
  35. uint8_t addr;
  36. uint8_t(*i2cProcess)(uint8_t addr, uint8_t* data_t, uint8_t len, uint8_t rw);
  37. uint8_t lock;
  38. uint8_t debugEnable;
  39. int (*LOG)();
  40. };
  41. void AD5933_Init(struct AD5933_ATY_Dev* dev);
  42. void AD5933_Measure(struct AD5933_ATY_Dev* dev);
  43. // Device address and address pointer
  44. #define AD5933_ADDR (0x0D)
  45. #define ADDR_PTR (0xB0)
  46. // Control Register
  47. #define CTRL_REG1 (0x80)
  48. #define CTRL_REG2 (0x81)
  49. // Start Frequency Register
  50. #define START_FREQ_1 (0x82)
  51. #define START_FREQ_2 (0x83)
  52. #define START_FREQ_3 (0x84)
  53. // Frequency increment register
  54. #define INC_FREQ_1 (0x85)
  55. #define INC_FREQ_2 (0x86)
  56. #define INC_FREQ_3 (0x87)
  57. // Number of increments register
  58. #define NUM_INC_1 (0x88)
  59. #define NUM_INC_2 (0x89)
  60. // Number of settling time cycles register
  61. #define NUM_SCYCLES_1 (0x8A)
  62. #define NUM_SCYCLES_2 (0x8B)
  63. // Status register
  64. #define STATUS_REG (0x8F)
  65. // Temperature data register
  66. #define TEMP_DATA_1 (0x92)
  67. #define TEMP_DATA_2 (0x93)
  68. // Real data register
  69. #define REAL_DATA_1 (0x94)
  70. #define REAL_DATA_2 (0x95)
  71. // Imaginary data register
  72. #define IMAG_DATA_1 (0x96)
  73. #define IMAG_DATA_2 (0x97)
  74. /**
  75. * Constants
  76. * Constants for use with the AD5933 library class.
  77. */
  78. // Temperature measuring
  79. #define TEMP_MEASURE (CTRL_TEMP_MEASURE)
  80. #define TEMP_NO_MEASURE (CTRL_NO_OPERATION)
  81. // Clock sources
  82. #define CLOCK_INTERNAL (CTRL_CLOCK_INTERNAL)
  83. #define CLOCK_EXTERNAL (CTRL_CLOCK_EXTERNAL)
  84. // PGA gain options
  85. #define PGA_GAIN_X1 (CTRL_PGA_GAIN_X1)
  86. #define PGA_GAIN_X5 (CTRL_PGA_GAIN_X5)
  87. // Power modes
  88. #define POWER_STANDBY (CTRL_STANDBY_MODE)
  89. #define POWER_DOWN (CTRL_POWER_DOWN_MODE)
  90. #define POWER_ON (CTRL_NO_OPERATION)
  91. // I2C result success/fail
  92. #define I2C_RESULT_SUCCESS (0)
  93. #define I2C_RESULT_DATA_TOO_LONG (1)
  94. #define I2C_RESULT_ADDR_NAK (2)
  95. #define I2C_RESULT_DATA_NAK (3)
  96. #define I2C_RESULT_OTHER_FAIL (4)
  97. // Control output voltage range options
  98. #define CTRL_OUTPUT_RANGE_1 (0b00000000)
  99. #define CTRL_OUTPUT_RANGE_2 (0b00000110)
  100. #define CTRL_OUTPUT_RANGE_3 (0b00000100)
  101. #define CTRL_OUTPUT_RANGE_4 (0b00000010)
  102. // Control register options
  103. #define CTRL_NO_OPERATION (0b00000000)
  104. #define CTRL_INIT_START_FREQ (0b00010000)
  105. #define CTRL_START_FREQ_SWEEP (0b00100000)
  106. #define CTRL_INCREMENT_FREQ (0b00110000)
  107. #define CTRL_REPEAT_FREQ (0b01000000)
  108. #define CTRL_TEMP_MEASURE (0b10010000)
  109. #define CTRL_POWER_DOWN_MODE (0b10100000)
  110. #define CTRL_STANDBY_MODE (0b10110000)
  111. #define CTRL_RESET (0b00010000)
  112. #define CTRL_CLOCK_EXTERNAL (0b00001000)
  113. #define CTRL_CLOCK_INTERNAL (0b00000000)
  114. #define CTRL_PGA_GAIN_X1 (0b00000001)
  115. #define CTRL_PGA_GAIN_X5 (0b00000000)
  116. // Status register options
  117. #define STATUS_TEMP_VALID (0x01)
  118. #define STATUS_DATA_VALID (0x02)
  119. #define STATUS_SWEEP_DONE (0x04)
  120. #define STATUS_ERROR (0xFF)
  121. // Frequency sweep parameters
  122. #define SWEEP_DELAY (1)
  123. #endif /* __AD5933_ATY_H */
  124. /******************************** End Of File *********************************/