Browse Source

Добавлена обработка команд потенциометра

Anatoliy Chigirinskiy 1 year ago
parent
commit
a73fc74a01
4 changed files with 9 additions and 8 deletions
  1. 3 3
      Devices/potentiometer.c
  2. 1 1
      Devices/potentiometer.h
  3. 3 2
      command.c
  4. 2 2
      command.h

+ 3 - 3
Devices/potentiometer.c

@@ -26,10 +26,10 @@ void potentiometer_set(void *bar1, uint8_t pot_val_ch_a, uint8_t pot_val_ch_b) {
     usleep(1);
 }
 
-void potentiometer_set_qspi(uint8_t pot_val_ch_a, uint8_t pot_val_ch_b ) {
+void potentiometer_set_qspi(uint8_t pot_offset, uint8_t pot_slope ) {
 
-    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);
+    uint32_t pot_ch_a      =    (TPL0202_CMD_WR_WIPER_REG_ENUM << TPL0202_CMD_BITP)|(TPL0202_ADR_B_ENUM << TPL0202_ADR_BITP)|(pot_offset << 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_slope << TPL0202_DATA_BITP);
 
     pot_array[0] = pot_ch_a;
     pot_array[1] = pot_ch_b;

+ 1 - 1
Devices/potentiometer.h

@@ -20,4 +20,4 @@
 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(uint8_t pot_val_ch_a, uint8_t pot_val_ch_b );
+void potentiometer_set_qspi(uint8_t pot_offset, uint8_t pot_slope );

+ 3 - 2
command.c

@@ -20,6 +20,8 @@ double f_pd = 200e6;
 
 uint16_t armCode[1] = {0};
 uint16_t attCode[1] = {0};
+uint16_t offsetCode[1] = {0};
+uint16_t slopeCode[1] = {0};
 
 //Массив структур Command, который связывает строки команд с соответствующими функциями.
 Command commands[] = {
@@ -50,6 +52,7 @@ void handleFreqCmd(const char* recvBuff)
     *spi_mode = cfg_reg;
 
 	set_cfg_reg(cfg_reg);
+	potentiometer_set_qspi((uint8_t) offsetCode[0], (uint8_t) slopeCode[0]);
 	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);
@@ -170,7 +173,6 @@ void handleIdnCmd(const char* recvBuff)
 void handleOffsetCmd(const char* recvBuff)
 {
 	printf("\nHandle command \"TMSG44:OFFSET\"\n");
-	uint16_t offsetCode[1] = {0};
 
 	splitLexeme(recvBuff, offsetCode, sizeof(offsetCode[0]), convertToUInt16);
 	printf("\n%u\n", offsetCode[0]);
@@ -179,7 +181,6 @@ void handleOffsetCmd(const char* recvBuff)
 void handleSlopeCmd(const char* recvBuff)
 {
 	printf("\nHandle command \"TMSG44:SLOPE\"\n");
-	uint16_t slopeCode[1] = {0};
 
 	splitLexeme(recvBuff, slopeCode, sizeof(slopeCode[0]), convertToUInt16);
 	printf("\n%u\n", slopeCode[0]);

+ 2 - 2
command.h

@@ -17,8 +17,8 @@ extern volatile int pci_fd;
 
 extern  void *bar1;
 
-extern uint16_t armCode[1];
-extern uint16_t attCode[1];
+// extern uint16_t armCode[1];
+// extern uint16_t attCode[1];
 
 typedef void (*CommandHandler)(const char*);