Explorar el Código

Makefile

master
Robin Thoni hace 9 años
padre
commit
f9f41e1163
Se han modificado 3 ficheros con 18 adiciones y 4 borrados
  1. 11
    0
      Makefile
  2. 0
    0
      gpio-raw.cpp
  3. 7
    4
      main.cpp

+ 11
- 0
Makefile Ver fichero

@@ -0,0 +1,11 @@
1
+CXXFLAGS = -O3
2
+EXE = gpio-analyser
3
+SRC = main.cpp gpio-raw.cpp
4
+OBJS = $(SRC:.cpp=.o)
5
+
6
+${EXE}: ${OBJS}
7
+	${LINK.cpp} ${OBJS} ${OUTPUT_OPTION}
8
+
9
+clean:
10
+	rm -rf ${OBJS}
11
+	rm -rf ${EXE}

gpio-raw.c → gpio-raw.cpp Ver fichero


main.c → main.cpp Ver fichero

@@ -29,6 +29,7 @@ int main(int argc, char* argv[])
29 29
   unsigned count = 0;
30 30
   std::cout << "Ready to sniff. Press enter...";
31 31
   getchar();
32
+
32 33
   signal(SIGINT, signal_handler);
33 34
   gettimeofday(&t1, NULL);
34 35
     for (; count < n; ++count)
@@ -38,10 +39,7 @@ int main(int argc, char* argv[])
38 39
     }
39 40
   gettimeofday(&t2, NULL);
40 41
   signal(SIGINT, SIG_DFL);
41
-  std::cout << "Saving file..." << std::endl;
42
-  int fd = open("gpio.out", O_CREAT | O_WRONLY);
43
-  write(fd, (void*)v, count * sizeof(*v));
44
-  close(fd);
42
+
45 43
   unsigned long long ut1 = (__suseconds_t)(1000000L * t1.tv_sec + t1.tv_usec);
46 44
   unsigned long long ut2 = (__suseconds_t)(1000000L * t2.tv_sec + t2.tv_usec);
47 45
   unsigned long long diff = ut2 - ut1;
@@ -49,5 +47,10 @@ int main(int argc, char* argv[])
49 47
   double mhz = (1000000.0 / unit) / 1000000.0;
50 48
   std::cout << "count: " << count << " diff: " << diff << " unit: "
51 49
     << unit << " Mhz: " << mhz << std::endl;
50
+
51
+  std::cout << "Saving file..." << std::endl;
52
+  int fd = open("gpio.out", O_CREAT | O_WRONLY);
53
+  write(fd, (void*)v, count * sizeof(*v));
54
+  close(fd);
52 55
   return 0;
53 56
 }

Loading…
Cancelar
Guardar