diff --git a/.gitignore b/.gitignore index 64f4b1bfbc87d72fd1cc75854abf2d0d98276b1d..0d411b1d1ce8f5b83656fc7c673eb898dc4f0e26 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ WiringPi/ +MyInclude/ *.out -*.o \ No newline at end of file +*.o diff --git a/Makefile b/Makefile index 5a6ad5ae021bac990dca77d0255a9962af395294..21d3c02bb1b92146a5e2b0181a6f9863e8bd10c3 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,6 @@ compile_switch : compile_motor : gcc -o motor motor.c -lwiringPi -.PHONY + clean : rm *.o \ No newline at end of file diff --git a/encoder.c b/encoder.c index 211d3117621eab958b5f844d61a17cfbb8eb2dd5..89ddfe35280a43bf521cd26993b01b2145175367 100644 --- a/encoder.c +++ b/encoder.c @@ -3,16 +3,31 @@ #include <wiringPi.h> -const int MOSI_PIN = 12; -const int MISO_PIN = 13; -const int MOSI_PIN_FPGA = 14; -const int MISO_PIN_FPGA = 16; -const int ENC_PIN_1A = 38; -const int ENC_PIN_1B = 36; -const int ENC_PIN_2A = 35; -const int ENC_PIN_2B = 34; +const int MOSI_PIN = 12; //from RASPI to FPGA +const int MISO_PIN = 13; //from RASPI to FPGA +const int MOSI_PIN_FPGA = 14; //from RASPI to FPGA +const int MISO_PIN_FPGA = 16; //from RASPI to FPGA +const int VDD_PIN_FPGA = 29; //from FPGA to ENCODER -> ouput data from encoder +const int ENC_PIN_1A = 38; //from FPGA to ENCODER -> ouput data from encoder +const int ENC_PIN_1B = 36; //from FPGA to ENCODER -> ouput data from encoder +const int ENC_PIN_2A = 35; //from FPGA to ENCODER -> ouput data from encoder +const int ENC_PIN_2B = 34; //from FPGA to ENCODER -> ouput data from encoder +const int SCK_PIN = 14; //from RASPI to FPGA -> clock signal +const int SCK_PIN_FPGA = 13; //from FPGA to ENCODER -> clock signal +const int SS_BAR_1 = 2; //from RASPI to FPGA -> enable encoder +const int SS_BAR_2 = 3; //from RASPI to FPGA -> enable encoder int main(int argc, char const *argv[]) { + if (wiringPiSetup() == -1) { + printf("WiringPiSetup failed\n"); + exit(EXIT_FAILURE); + } + + pinMode(ENC_PIN_1A, INPUT); + pinMode(ENC_PIN_1B, INPUT); + pinMode(ENC_PIN_2A, INPUT); + pinMode(ENC_PIN_2B, INPUT); + return 0; } \ No newline at end of file diff --git a/motor.c b/motor.c index 9d39b0b0bbba0ddfe6b97d2ae37564904e11dd6b..3e8fcaf8bb48589e3fd563c84c1a0275a002040c 100644 --- a/motor.c +++ b/motor.c @@ -13,7 +13,8 @@ int wheelSpeed = 600; int main(int argc, char const *argv[]) { if (wiringPiSetup() == -1) { - exit(1); + printf("WiringPiSetup failed\n"); + exit(EXIT_FAILURE); } pinMode(PWM_PIN_RIGHT, PWM_OUTPUT); pinMode(PWM_PIN_LEFT, PWM_OUTPUT); diff --git a/switch.c b/switch.c index cc2b1716fab802ae93756c222540bad62c09d333..77a3f504287caeebda298fd83cc36831140d1315 100644 --- a/switch.c +++ b/switch.c @@ -9,8 +9,10 @@ const int PIN_SWITCH_LEFT = 29; int main(int argc, char const *argv[]) { - if (wiringPiSetup() == -1) exit(1); - + if (wiringPiSetup() == -1) { + printf("WiringPiSetup failed\n"); + exit(EXIT_FAILURE); + } pinMode(PIN_SWITCH_RIGHT, INPUT); pinMode(PIN_SWITCH_LEFT, INPUT); @@ -23,6 +25,10 @@ int main(int argc, char const *argv[]) printf("Vous avez poussé sur le uswitch gauche\n"); delay(300); } + + if (kbhit()) { + exit(EXIT_SUCCESS); + } } return 0;