Procházet zdrojové kódy

Добавлено управление для dac8811

Anatoliy Chigirinskiy před 1 rokem
rodič
revize
efb11540f5
5 změnil soubory, kde provedl 83 přidání a 22 odebrání
  1. 20 0
      Devices/dac8811.c
  2. 11 0
      Devices/dac8811.h
  3. 2 0
      Devices/lmx2594.c
  4. 47 22
      Devices/tmsgheaders.h
  5. 3 0
      command.c

+ 20 - 0
Devices/dac8811.c

@@ -0,0 +1,20 @@
+#include <dac8811.h>
+
+
+void dac8811_set(void *bar1, uint16_t dac_data) {
+    //Header for DAC8811
+    uint32_t *ptr_header = bar1 + DAC8811_BASE_ADDR;
+    *ptr_header = DAC8811_HEADER;
+    //Data for DAC8811
+    uint32_t *ptr = bar1 + DAC8811_BASE_ADDR;
+    *ptr = dac_data;
+}
+
+void dac8811_att_set(void *bar1, uint16_t dac_data) {
+    //Header for DAC8811
+    uint32_t *ptr_header = bar1 + DAC8811_BASE_ADDR;
+    *ptr_header = DAC8811_ATT_HEADER;
+    //Data for DAC8811
+    uint32_t *ptr = bar1 + DAC8811_BASE_ADDR;
+    *ptr = dac_data;
+}

+ 11 - 0
Devices/dac8811.h

@@ -0,0 +1,11 @@
+#include <tmsgheaders.h>
+
+
+#define     DAC8811_BASE_ADDR       0x04
+
+#define     DAC8811_HEADER          ((0 << 23) | (DeviceIdDac << 18) | (DACWordNum << 1) | 1)
+#define     DAC8811_ATT_HEADER      ((0 << 23) | (DeviceIdAtt << 18) | (ATTWordNum << 1) | 1)
+
+
+void dac8811_set(void *bar1, uint16_t dac_data);
+void dac8811_att_set(void *bar1, uint16_t dac_data);

+ 2 - 0
Devices/lmx2594.c

@@ -385,6 +385,8 @@ int lmx_freq_set_out_of_band(void *bar1, double freq, double f_pd) {
         frac_n = 0;
         frac_d = 524287;
     }
+    // Partial assist for the calibration
+
     lmx2594regs[112 - MASH_ORDER] = lmx2594regs[112 - MASH_ORDER] & (~BITM_LMX2594_R44_MASH_ORDER);
     // Set the MASH_ORDER to 3
     lmx2594regs[112 - MASH_ORDER] = lmx2594regs[112 - MASH_ORDER] | ENUM_LMX2594_R44_MASH_ORDER_3;

+ 47 - 22
Devices/tmsgheaders.h

@@ -4,28 +4,53 @@
 #include <unistd.h>
 #include <stdio.h>
 // Device IDs
-#define DeviceIdLmx2594    0x0
-#define DeviceIdDDS        0x1
-#define DeviceIdPot        0x2
-#define DeviceIdDac        0x3
-#define DeviceIdAtt        0x4
-#define DeviceIdShReg      0x5
-#define DeviceIdMax2870    0x6
-#define DeviceIdGpio1      0x7
-#define DeviceIdTemp       0x8
-#define DeviceIdGpio2      0x9
+#define DeviceIdLmx2594                 0x0
+#define DeviceIdDDS                     0x1
+#define DeviceIdPot                     0x2
+#define DeviceIdDac                     0x3
+#define DeviceIdAtt                     0x4
+#define DeviceIdShReg                   0x5
+#define DeviceIdMax2870                 0x6
+#define DeviceIdGpio1                   0x7
+#define DeviceIdTemp                    0x8
+#define DeviceIdGpio2                   0x9
 
 // Init Word Numbers 1 MOSI
-#define Gpio1InitWordNum   2
-#define Gpio2InitWordNum   1
-#define PotWordInitNum     1
-#define DacWordInitNum     1
-#define AttWordInitNum     1
-#define ShRegWordInitNum   1
-#define Lmx2594InitWordNum 113
-#define DDSInitWordNum     37
-#define MaxInitWordNum     6
-#define TempSensWordNum    1
+#define Gpio1InitWordNum                2
+#define Gpio2InitWordNum                1
+#define PotWordInitNum                  1
+#define DacWordInitNum                  1
+#define AttWordInitNum                  1
+#define ShRegWordInitNum                1
+#define Lmx2594InitWordNum              113
+#define DDSInitWordNum                  37
+#define MaxInitWordNum                  6
+#define TempSensWordNum                 1
+
+// Bit Positions
+#define RF_SW1_BITP                     0
+#define RF_SW2_BITP                     1
+#define CTRL_AM_SW3_BITP                2
+#define DDS_SYNC_CTRL_FPGA_BITP         3
+#define DDS_RESET_FPGA_BITP             4
+#define DDS_SYNC_FPGA_BITP              5
+#define SW_CAP4_BITP                    6
+#define AM_ALC_SW_BITP                  7
+#define SW_CAP3_BITP                    8
+#define SW_CAP2_BITP                    9
+#define SW_CAP1_BITP                    10
+#define AM_ALC_1_FIX_BITP               11
+#define PLL_VTUNE_CTRL_BITP             12
+#define PLL_SYNC_CTRL_BITP              13
+#define PLL_SYNC_BITP                   14
+#define PLL_LOOP_CTRL_BITP              15
+#define DDS_X2_FPGA_BITP                16
+#define DDS_SAW2_FPGA_BITP              17
+#define REF_OFFSET_CTRL_FPGA_BITP       18
+#define GPIO_ADRF_V1_BITP               19
+#define GPIO_ADRF_V2_BITP               20
+#define DDS_SAW1_FPGA_BITP              21
+
 
 // Headers 1-MOSI
 #define LMX2594_RST_HEADER  ((0 << 23) | (DeviceIdLmx2594 << 18) | (2 << 1) | 1)
@@ -59,11 +84,11 @@
 #define DDS_RESET_FPGA          0x0
 #define DDS_SYNC_FPGA           0x0
 #define SW_CAP4                 0x0
-#define AM_ALC_SW               0x0
+#define AM_ALC_SW               0x1
 #define SW_CAP3                 0x0
 #define SW_CAP2                 0x0
 #define SW_CAP1                 0x0
-#define AM_ALC_1_FIX            0x0
+#define AM_ALC_1_FIX            0x1
 #define PLL_VTUNE_CTRL          0x1
 #define PLL_SYNC_CTRL           0x0
 #define PLL_SYNC                0x0

+ 3 - 0
command.c

@@ -11,6 +11,7 @@
 #include <time.h>
 
 #include "Devices/lmx2594.h"
+#include "Devices/dac8811.h"
 
 //Массив структур Command, который связывает строки команд с соответствующими функциями.
 Command commands[] = {
@@ -86,6 +87,7 @@ void handleArmCmd(const char* recvBuff)
 
 	splitLexeme(recvBuff, armCode, sizeof(armCode[0]), convertToUInt16);
 	printf("\n%u\n", armCode[0]);
+	dac8811_set(bar1,armCode[0]);
 }
 
 void handleAttCmd(const char* recvBuff)
@@ -95,6 +97,7 @@ void handleAttCmd(const char* recvBuff)
 
 	splitLexeme(recvBuff, attCode, sizeof(attCode[0]), convertToUInt16);
 	printf("\n%u\n", attCode[0]);
+	dac8811_set_att(bar1,attCode[0]);
 }
 
 void handleIdnCmd(const char* recvBuff)