Преглед на файлове

В функции send_data_qspi добавлены отправки для dac8811 и потенциометра.

Anatoliy Chigirinskiy преди 1 година
родител
ревизия
d8969223be
променени са 5 файла, в които са добавени 36 реда и са изтрити 7 реда
  1. 1 0
      Devices/dac8811.c
  2. 10 0
      Devices/potentiometer.c
  3. 4 1
      Devices/potentiometer.h
  4. 18 6
      command.c
  5. 3 0
      command.h

+ 1 - 0
Devices/dac8811.c

@@ -18,3 +18,4 @@ void dac8811_att_set(void *bar1, uint16_t dac_data) {
     uint32_t *ptr = bar1 + DAC8811_BASE_ADDR;
     *ptr = dac_data;
 }
+

+ 10 - 0
Devices/potentiometer.c

@@ -1,6 +1,7 @@
 #include "potentiometer.h"
 
 
+uint32_t pot_array [2] = {0,0};
 
 void potentiometer_set(void *bar1, uint8_t pot_val_ch_a, uint8_t pot_val_ch_b) {
     usleep(1);
@@ -23,4 +24,13 @@ void potentiometer_set(void *bar1, uint8_t pot_val_ch_a, uint8_t pot_val_ch_b) {
     *spi_mode = cfg_reg;
     set_cfg_reg(cfg_reg);
     usleep(1);
+}
+
+void potentiometer_set_qspi(void *bar1, uint8_t pot_val_ch_a, uint8_t pot_val_ch_b ) {
+
+    uint32_t pot_ch_a      =    (TPL0202_CMD_WR_WIPER_REG_ENUM << TPL0202_CMD_BITP)|(TPL0202_ADR_B_ENUM << TPL0202_ADR_BITP)|(pot_val_ch_a << TPL0202_DATA_BITP);
+    uint32_t pot_ch_b     =    (TPL0202_CMD_WR_WIPER_REG_ENUM << TPL0202_CMD_BITP)|(TPL0202_ADR_A_ENUM << TPL0202_ADR_BITP)|(pot_val_ch_b << TPL0202_DATA_BITP);
+
+    pot_array[0] = pot_ch_a;
+    pot_array[1] = pot_ch_b;
 }

+ 4 - 1
Devices/potentiometer.h

@@ -17,4 +17,7 @@
 #define		TPL0202_DATA_BITM						(0xFF<<TPL0202_DATA_BITP)
 
 
-void potentiometer_set(void *bar1, uint8_t pot_val_ch_a, uint8_t pot_val_ch_b);
+extern uint32_t pot_array [2];
+
+void potentiometer_set(void *bar1, uint8_t pot_val_ch_a, uint8_t pot_val_ch_b);
+void potentiometer_set_qspi(void *bar1, uint8_t pot_val_ch_a, uint8_t pot_val_ch_b );

+ 18 - 6
command.c

@@ -14,9 +14,13 @@
 #include "Devices/lmx2594.h"
 #include "Devices/dac8811.h"
 #include "Devices/ad9912.h"
+#include "Devices/potentiometer.h"
 
 double f_pd = 200e6;
 
+uint16_t armCode[1] = {0};
+uint16_t attCode[1] = {0};
+
 //Массив структур Command, который связывает строки команд с соответствующими функциями.
 Command commands[] = {
 	{"TMSG44:FREQ ", 	handleFreqCmd},
@@ -44,7 +48,6 @@ void handleFreqCmd(const char* recvBuff)
     *spi_mode = cfg_reg;
 
 	set_cfg_reg(cfg_reg);
-
 	lmx_freq = lmx_get_freq(freq[0]);
 	f_pd = ad9912_set(bar1, lmx_freq, f_pd);
 	printf("f_pd frequency is set to %.6f MHz\n", f_pd/1e6);
@@ -67,7 +70,7 @@ void send_data_qspi(void *bar1) {
 	uint32_t gpio_reg = get_tmsg_gpio_reg();
 	uint32_t shift_reg = get_tmsg_shift_reg();
 	// Create a header 4 Mosi mode
-	uint32_t qspi_header = ((ENUM_SPIMODE_4MOSI) |(0x1 << BITP_GPIO_4MOSI_HEADER) |(0x1 << BITP_SHIFT_REG_4MOSI_HEADER )| ((sizeof(ad9912_ftw_regs_qspi) / 4) << BITP_DDS_4MOSI_HEADER) | ((sizeof(lmx_change_freq_regs) / 4) << BITP_LMX2594_4MOSI_HEADER) | TERM_BIT_1);
+	uint32_t qspi_header = ((ENUM_SPIMODE_4MOSI) |(0x1 << BITP_GPIO_4MOSI_HEADER) |(0x1 << BITP_SHIFT_REG_4MOSI_HEADER )| ((sizeof(ad9912_ftw_regs_qspi) / 4) << BITP_DDS_4MOSI_HEADER) | ((sizeof(lmx_change_freq_regs) / 4) << BITP_LMX2594_4MOSI_HEADER) | (0x1 << BITP_DAC_4MOSI_HEADER) | (0x1 << BITP_ATT_4MOSI_HEADER) |(0x2 << BITP_POT_4MOSI_HEADER)| TERM_BIT_1);
 	uint32_t *data = bar1 + LMX_BASE_ADDR;
 	*data = qspi_header;
 	// Initialize the registers
@@ -83,6 +86,15 @@ void send_data_qspi(void *bar1) {
 	}
 	// Send the data for the shift register
 	*data = shift_reg;
+	// Send the data for the potentiometer
+	for (int i = 0; i < sizeof(pot_array) / 4; i++) {
+		*data = pot_array[i];
+	}
+	// Send the data for the DAC
+	*data = armCode[0];
+	// Send the data for the ATT
+	*data = attCode[0];
+
 }
 
 void handleLdCmd(const char* recvBuff)
@@ -130,21 +142,21 @@ void handlePowCmd(const char* recvBuff)
 void handleArmCmd(const char* recvBuff)
 {
 	printf("\nHandle command \"TMSG44:ARM\"\n");
-	uint16_t armCode[1] = {0};
+	armCode[1] = {0};
 
 	splitLexeme(recvBuff, armCode, sizeof(armCode[0]), convertToUInt16);
 	printf("\n%u\n", armCode[0]);
-	dac8811_set(bar1,armCode[0]);
+	// dac8811_set(bar1,armCode[0]);
 }
 
 void handleAttCmd(const char* recvBuff)
 {
 	printf("\nHandle command \"TMSG44:ATT\"\n");
-	uint16_t attCode[1] = {0};
+	attCode[1] = {0};
 
 	splitLexeme(recvBuff, attCode, sizeof(attCode[0]), convertToUInt16);
 	printf("\n%u\n", attCode[0]);
-	dac8811_att_set(bar1,attCode[0]);
+	// dac8811_att_set(bar1,attCode[0]);
 }
 
 void handleIdnCmd(const char* recvBuff)

+ 3 - 0
command.h

@@ -17,6 +17,9 @@ extern volatile int pci_fd;
 
 extern  void *bar1;
 
+extern uint16_t armCode[1];
+extern uint16_t attCode[1];
+
 typedef void (*CommandHandler)(const char*);
 
 // Объявление структур