Capteur_US

Dependencies:   mbed DRV8825

Committer:
Nanaud
Date:
Sun Jul 26 09:24:31 2020 +0000
Revision:
6:ea6b30c4bb01
Parent:
4:ad9b7355332e
Child:
10:0714feaaaee1
Fusion des fichiers codeurs et odo_asserv

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Nanaud 1:2fe8c402ee79 1 // Nom du fichier : main.cpp
Nanaud 0:dc036b67c87c 2 #include "pins.h"
Nanaud 0:dc036b67c87c 3
Nanaud 6:ea6b30c4bb01 4 void btnFct(){
Nanaud 6:ea6b30c4bb01 5 mot_dis();
Nanaud 6:ea6b30c4bb01 6 aff_cd[0] = 0;
Nanaud 6:ea6b30c4bb01 7 aff_cd[1] = 0;
Nanaud 6:ea6b30c4bb01 8
Nanaud 6:ea6b30c4bb01 9 pc.printf("comptG = %d\r\n",comptG);
Nanaud 6:ea6b30c4bb01 10 pc.printf("comptD = %d\r\n",comptD);
Nanaud 6:ea6b30c4bb01 11 bt.printf("comptG = %d\r\n",comptG);
Nanaud 6:ea6b30c4bb01 12 bt.printf("comptD = %d\r\n",comptD);
Nanaud 6:ea6b30c4bb01 13 }
Nanaud 6:ea6b30c4bb01 14
Nanaud 4:ad9b7355332e 15 int main()
Nanaud 4:ad9b7355332e 16 {
Nanaud 0:dc036b67c87c 17 pc.printf("\r\nAresCDFMainCode\r\n");
Nanaud 4:ad9b7355332e 18 bt.printf("\r\nAresCDFMainCode\r\n");
Nanaud 4:ad9b7355332e 19
Nanaud 6:ea6b30c4bb01 20 btn.rise(&btnFct);
Nanaud 6:ea6b30c4bb01 21
Nanaud 1:2fe8c402ee79 22 // debug
Nanaud 1:2fe8c402ee79 23 pc.attach(&serialIT); // Interruption liaison série
Nanaud 4:ad9b7355332e 24 bt.attach(&bluetoothIT); // Interruption bluetooth
Nanaud 6:ea6b30c4bb01 25 pc.baud(9600);
Nanaud 6:ea6b30c4bb01 26 pc.format(8,SerialBase::None,1);
Nanaud 6:ea6b30c4bb01 27 bt.baud(9600);
Nanaud 6:ea6b30c4bb01 28 bt.format(8,SerialBase::None,1);
Nanaud 6:ea6b30c4bb01 29
Nanaud 6:ea6b30c4bb01 30 ticker_US.attach(&captUS_trig,0.2); // On apelle cette fonction toutes 0.2 secondes
Nanaud 6:ea6b30c4bb01 31 ticker_affUS.attach(&affUltrasons,1.0);
Nanaud 6:ea6b30c4bb01 32 ticker_affcd.attach(&affCodeurs,1.0);
Nanaud 4:ad9b7355332e 33
Nanaud 1:2fe8c402ee79 34 // Init capteurs à ultrasons
Nanaud 1:2fe8c402ee79 35 captUS_init();
Nanaud 0:dc036b67c87c 36 echo1.rise(&echoRise1);
Nanaud 0:dc036b67c87c 37 echo1.fall(&echoFall1);
Nanaud 0:dc036b67c87c 38 echo2.rise(&echoRise2);
Nanaud 0:dc036b67c87c 39 echo2.fall(&echoFall2);
Nanaud 0:dc036b67c87c 40 echo3.rise(&echoRise3);
Nanaud 0:dc036b67c87c 41 echo3.fall(&echoFall3);
Nanaud 0:dc036b67c87c 42 echo4.rise(&echoRise4);
Nanaud 0:dc036b67c87c 43 echo4.fall(&echoFall4);
Nanaud 0:dc036b67c87c 44 echo5.rise(&echoRise5);
Nanaud 0:dc036b67c87c 45 echo5.fall(&echoFall5);
Nanaud 0:dc036b67c87c 46 echo6.rise(&echoRise6);
Nanaud 0:dc036b67c87c 47 echo6.fall(&echoFall6);
Nanaud 4:ad9b7355332e 48
Nanaud 1:2fe8c402ee79 49 // Init DRV8825
Nanaud 0:dc036b67c87c 50 drv_init();
Nanaud 4:ad9b7355332e 51
Nanaud 4:ad9b7355332e 52 // Init codeurs
Nanaud 0:dc036b67c87c 53 cdgA.rise(&cdgaRise);
Nanaud 6:ea6b30c4bb01 54 cddA.rise(&cddaRise);
Nanaud 0:dc036b67c87c 55 cdgA.mode(PullUp);
Nanaud 6:ea6b30c4bb01 56 cddA.mode(PullUp);
Nanaud 6:ea6b30c4bb01 57
Nanaud 6:ea6b30c4bb01 58 // Odometrie
Nanaud 4:ad9b7355332e 59
Nanaud 4:ad9b7355332e 60
Nanaud 4:ad9b7355332e 61
Nanaud 1:2fe8c402ee79 62 while(1) {}
Nanaud 0:dc036b67c87c 63 }