Commit b24d29803d55ee112aa239b5d51aac3bad675dcf

Authored by achemin1
1 parent 3d1c6506

Nettoyage du code, structure

Makefile
... ... @@ -24,13 +24,12 @@ all : main demostep
24 24  
25 25  
26 26  
27   -main :
28   - echo "Here compile the main program"
  27 +main : libusb_wrapper ${SRC}/main.c
  28 + gcc -o ${OBJ}/$@.o -c ${SRC}/$@.c -I ${INCLUDE} ${CLIBS} ${CFLAGS}
  29 + gcc -o ${BIN}/$@.out ${OBJ}/main.o ${OBJ}/libusb_wrapper.o ${CFLAGS} ${CLIBS}
29 30  
30 31 demostep : STEP4.1
31 32  
32   -
33   -
34 33 STEP4.1 : ${SRC}/GetUsbInfos.c bin
35 34 gcc -o ${BIN}/STEP4.1.out ${SRC}/GetUsbInfos.c ${CLIBS} ${CFLAGS}
36 35  
... ... @@ -40,6 +39,14 @@ STEP4.2 : ${SRC}/FourPointTwo.c bin
40 39 STEP4.3 : ${SRC}/FourPointThree.c bin
41 40 gcc -o ${BIN}/STEP4.3.out ${SRC}/FourPointThree.c ${CLIBS} ${CFLAGS}
42 41  
  42 +
  43 +libs: libusb_wrapper
  44 +
  45 +libusb_wrapper: obj ${SRC}/libusb_wrapper.c ${INCLUDE}/libusb_wrapper.h
  46 + gcc -o ${OBJ}/$@.o -c ${SRC}/$@.c -I ${INCLUDE} ${CLIBS} ${CFLAGS}
  47 +
  48 +
  49 +
43 50 obj :
44 51 @-mkdir ${OBJ}
45 52  
... ...
include/libusb_wrapper.h 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +#include <libusb-1.0/libusb.h>
  2 +
  3 +void usbinit();
  4 +
  5 +void usbclose();
  6 +
  7 +void displayDevices();
  8 +
  9 +void displayDeviceEndpoints();
... ...
src/GetUsbInfos.c renamed to src/libusb_wrapper.c
... ... @@ -2,7 +2,24 @@
2 2 #include <stdio.h>
3 3 #include <stdlib.h>
4 4  
5   -int main() {
  5 +
  6 +void usbinit(){
  7 + printf("Hello usbinit\n");
  8 +}
  9 +
  10 +void usbclose(){
  11 + printf("Hello usbclose\n");
  12 +}
  13 +
  14 +void displayDevices(){
  15 + printf("Hello list of device");
  16 +}
  17 +
  18 +void displayDeviceEndpoints(){
  19 + printf("Hello endpoint\n");
  20 +}
  21 +
  22 +/*int main() {
6 23  
7 24 // initiate the usb thing
8 25  
... ... @@ -12,7 +29,7 @@ int main() {
12 29 perror("libusb_init");
13 30 exit(-1);
14 31 }
15   - /* ... some code ... */
  32 + /* ... some code ...*//*
16 33  
17 34 // actually enumerates all the usb and gives some infos abot the usb things
18 35  
... ... @@ -62,7 +79,7 @@ int main() {
62 79 if (statusConfig != 0) {
63 80 perror("libusb_set_configuration"); /*exit(-1);*/
64 81 /* }
65   - */
  82 + *//*
66 83 int MAXLEN_DESCRIPTOR_STRING = 200;
67 84 uint8_t desc_idx = 2;
68 85 uint16_t langid = 16;
... ... @@ -115,11 +132,11 @@ int main() {
115 132 */
116 133  
117 134 /* ... some ... code */
118   - libusb_close(handle);
119   - }
  135 + /*libusb_close(handle);
  136 + }*/
120 137  
121   - libusb_free_device_list(list, 1);
  138 +/* libusb_free_device_list(list, 1);
122 139  
123 140 libusb_exit(context);
124 141 return 0;
125   -}
  142 +}*/
... ...
src/main.c 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +#include <stdio.h>
  2 +#include "libusb_wrapper.h"
  3 +
  4 +int main(){
  5 + printf("Hello World :)\n");
  6 +
  7 + usbinit();
  8 +
  9 + //if 4.1
  10 + displayDevices();
  11 +
  12 + //if 4.2
  13 + displayDeviceEndpoints();
  14 +
  15 + usbclose();
  16 +
  17 + return 0;
  18 +}
... ...