Przeglądaj źródła

Добавлена структура для взаимодействия с адресами PCI

Mikhail Zaytsev 1 rok temu
rodzic
commit
57b599a31b
4 zmienionych plików z 30 dodań i 7 usunięć
  1. 3 1
      .vscode/settings.json
  2. 4 5
      Devices/lmk04821.c
  3. 18 0
      Devices/pci.h
  4. 5 1
      main.c

+ 3 - 1
.vscode/settings.json

@@ -1,6 +1,8 @@
 {
     "files.associations": {
         "tmsgheaders.h": "c",
-        "lmx2594regs.h": "c"
+        "lmx2594regs.h": "c",
+        "stdint.h": "c",
+        "lmx2594.h": "c"
     }
 }

+ 4 - 5
Devices/lmk04821.c

@@ -1,4 +1,5 @@
 #include "lmk04821.h"
+#include "pci.h"
 
 const uint32_t lmk04821regs_b[LMK_COUNT] = {
         0x000090,
@@ -272,16 +273,14 @@ const uint32_t lmk04821_rst_b[] = {
         0x000010
 };
 
-void lmk04821_a_init(void *bar1) {
+void lmk04821_a_init(reg_addr_pci* pce_bar_1) {
     //Rst for Lmk_a
     for (int i = 0; i < 2; i++) {
-        uint32_t *ptr = bar1 + LMK_BASE_ADDR;
-        *ptr = lmk04821_rst_a[i];
+        pce_bar_1->lmk_a_addr = lmk04821_rst_a[i];
     }
     //Init for Lmk_a
     for (int j = 0; j < LMK_COUNT; j++) {
-        uint32_t *ptr = bar1 + LMK_BASE_ADDR;
-        *ptr = lmk04821regs_a[j];
+        pce_bar_1->lmk_a_addr = lmk04821regs_a[j];
     }
 }
 

+ 18 - 0
Devices/pci.h

@@ -0,0 +1,18 @@
+#ifndef PCI_H
+#define PCI_H
+
+#include <stdint.h>
+
+typedef struct {
+	uint32_t reserve_1;
+	uint32_t sbtmsg_addr;
+	uint32_t cfg_reg_addr;
+	uint32_t reserve_2;
+	uint32_t lmk_a_addr;
+	uint32_t lmk_b_addr;
+	uint32_t reserve_3;
+	uint32_t att_pe_1_addr;
+	uint32_t att_pe_2_addr;
+} reg_addr_pci;
+
+#endif /* PCI_H */

+ 5 - 1
main.c

@@ -20,6 +20,7 @@
 #include "Devices//potentiometer.h"
 
 #include "command.h"
+#include "Devices//pci.h"
 
 #define REQUESTED_MEMORY_SIZE  0x1000
 #define SERVER_PORT 5025
@@ -30,6 +31,7 @@ volatile int pci_fd = 0;
 int listen_fd = 0;
 
 void *bar1;
+reg_addr_pci* pce_bar_1;
 
 //Обработчик ошибок
 void error(const char *msg)
@@ -106,7 +108,9 @@ int main(int argc, char *argv[])
         return 1;
     }
 
-    lmk04821_a_init(bar1);
+	pce_bar_1 = (reg_addr_pci*)bar1;
+
+    lmk04821_a_init(pce_bar_1);
     usleep(500);
     lmk04821_b_init(bar1);
 	pe43711_att_1_init(bar1);