tmsgheaders.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #ifndef DMADRIVER_TMSGHEADERS_H
  2. #define DMADRIVER_TMSGHEADERS_H
  3. #include <stdint.h>
  4. #include <unistd.h>
  5. #include <stdio.h>
  6. // Device IDs
  7. #define DeviceIdLmx2594 0x0
  8. #define DeviceIdDDS 0x1
  9. #define DeviceIdPot 0x2
  10. #define DeviceIdDac 0x3
  11. #define DeviceIdAtt 0x4
  12. #define DeviceIdShReg 0x5
  13. #define DeviceIdMax2870 0x6
  14. #define DeviceIdGpio1 0x7
  15. #define DeviceIdTemp 0x8
  16. #define DeviceIdGpio2 0x9
  17. // Init Word Numbers 1 MOSI
  18. #define Gpio1InitWordNum 2
  19. #define Gpio2InitWordNum 1
  20. #define PotWordInitNum 1
  21. #define DacWordInitNum 1
  22. #define AttWordInitNum 1
  23. #define ShRegWordInitNum 1
  24. #define Lmx2594InitWordNum 113
  25. #define DDSInitWordNum 37
  26. #define MaxInitWordNum 6
  27. #define TempSensWordNum 1
  28. // Headers 1-MOSI
  29. #define LMX2594_RST_HEADER ((0 << 23) | (DeviceIdLmx2594 << 18) | (2 << 1) | 1)
  30. #define GPIO_INIT_HEADER ((0 << 23) | (DeviceIdGpio1 << 18) | (Gpio1InitWordNum << 1) | 1)
  31. #define InitGpio2Header ((0 << 23) | (DeviceIdGpio2 << 18) | (Gpio2InitWordNum << 1) | 1)
  32. #define TempSensHeader ((0 << 23) | (DeviceIdTemp << 18) | (TempSensWordNum << 1) | 1)
  33. #define InitLMX2594Header ((0 << 23) | (DeviceIdLmx2594 << 18) | (Lmx2594InitWordNum << 1) | 1)
  34. #define InitDDSHeader ((0 << 23) | (DeviceIdDDS << 18) | (DDSInitWordNum << 1) | 1)
  35. #define InitMAX2870Header ((0 << 23) | (DeviceIdMax2870 << 18) | (MaxInitWordNum << 1) | 1)
  36. #define InitPotHeader ((0 << 23) | (DeviceIdPot << 18) | (PotWordInitNum << 1) | 1)
  37. #define InitDacHeader ((0 << 23) | (DeviceIdDac << 18) | (DacWordInitNum << 1) | 1)
  38. #define InitAttHeader ((0 << 23) | (DeviceIdAtt << 18) | (AttWordInitNum << 1) | 1)
  39. #define InitShRegHeader ((0 << 23) | (DeviceIdShReg << 18) | (ShRegWordInitNum << 1) | 1)
  40. // Word Numbers 4-MOSI
  41. #define LMXWordNum 14
  42. #define DDSWordNum 4
  43. #define POTWordNum 2
  44. #define DACWordNum 1
  45. #define ATTWordNum 1
  46. #define ShRegWordNum 1
  47. #define MaxWordNum 2
  48. #define GPIOWordNum 1
  49. // Define bit values for GPIO Reg
  50. #define RF_SW1 0x0
  51. #define RF_SW2 0x0
  52. #define CTRL_AM_SW3 0x0
  53. #define DDS_SYNC_CTRL_FPGA 0x0
  54. #define DDS_RESET_FPGA 0x0
  55. #define DDS_SYNC_FPGA 0x0
  56. #define SW_CAP4 0x0
  57. #define AM_ALC_SW 0x0
  58. #define SW_CAP3 0x0
  59. #define SW_CAP2 0x0
  60. #define SW_CAP1 0x0
  61. #define AM_ALC_1_FIX 0x0
  62. #define PLL_VTUNE_CTRL 0x1
  63. #define PLL_SYNC_CTRL 0x0
  64. #define PLL_SYNC 0x0
  65. #define PLL_LOOP_CTRL 0x1
  66. #define DDS_X2_FPGA 0x0
  67. #define DDS_SAW2_FPGA 0x0
  68. #define REF_OFFSET_CTRL_FPGA 0x1
  69. #define GPIO_ADRF_V1 0x2
  70. #define GPIO_ADRF_V2 0x0
  71. #define DDS_SAW1_FPGA 0x0
  72. // Define values for Shift Reg
  73. #define SHIFT_REG_RF_SW_RF 0x0
  74. #define SHIFT_REG_RF_SW4 0x0
  75. #define SHIFT_REG_RF_SW0 0x1
  76. #define SHIFT_REG_RF_SW_X2 0x0
  77. #define SHIFT_REG_RF_SWx_BANK 0x1
  78. #define SHIFT_REG_RF_SW_MIXER 0x0
  79. #define SHIFT_REG ((SHIFT_REG_RF_SW_RF << 1) | \
  80. (SHIFT_REG_RF_SW4<<2) | \
  81. (SHIFT_REG_RF_SW0<<3) | \
  82. (SHIFT_REG_RF_SW_X2<<0) | \
  83. (SHIFT_REG_RF_SWx_BANK <<5) | \
  84. (SHIFT_REG_RF_SW_MIXER <<4))
  85. #define GPIO_REG ((DDS_SAW1_FPGA << 21) | \
  86. (GPIO_ADRF_V2 << 20) | \
  87. (GPIO_ADRF_V1 << 19) | \
  88. (REF_OFFSET_CTRL_FPGA << 18) | \
  89. (DDS_SAW2_FPGA << 17) | \
  90. (DDS_X2_FPGA << 16) | \
  91. (PLL_LOOP_CTRL << 15) | \
  92. (PLL_SYNC << 14) | \
  93. (PLL_SYNC_CTRL << 13) | \
  94. (PLL_VTUNE_CTRL << 12) | \
  95. (AM_ALC_1_FIX << 11) | \
  96. (SW_CAP1 << 10) | \
  97. (SW_CAP2 << 9) | \
  98. (SW_CAP3 << 8) | \
  99. (AM_ALC_SW << 7) | \
  100. (SW_CAP4 << 6) | \
  101. (DDS_SYNC_FPGA << 5) | \
  102. (DDS_RESET_FPGA << 4) | \
  103. (DDS_SYNC_CTRL_FPGA << 3) | \
  104. (CTRL_AM_SW3 << 2) | \
  105. (RF_SW2 << 1) | \
  106. (RF_SW1 << 0))
  107. #define RST_ADDR 0x08
  108. #define RST_FOR_FPGA_ON 0x1
  109. #define RST_FOR_FPGA_OFF 0x0
  110. #define LMX_BASE_ADDR 0x04
  111. void rst_for_fpga(void *bar1);
  112. void shift_reg (void *bar1);
  113. #endif //DMADRIVER_TMSGHEADERS_H