Capteur_US

Dependencies:   mbed DRV8825

Committer:
plmir
Date:
Fri Sep 11 13:47:56 2020 +0000
Revision:
12:2c312916a621
Parent:
10:0714feaaaee1
Child:
13:a72b0752aa6f
Odometrie

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 10:0714feaaaee1 30 //ticker_US.attach(&captUS_trig,0.2); // On apelle cette fonction toutes 0.2 secondes
Nanaud 10:0714feaaaee1 31 //ticker_affUS.attach(&affUltrasons,1.0);
Nanaud 6:ea6b30c4bb01 32 ticker_affcd.attach(&affCodeurs,1.0);
Nanaud 10:0714feaaaee1 33 //tickTest.attach(&test4,0.1);
plmir 12:2c312916a621 34 ticker_odo.attach(&odometrie,0.2);
plmir 12:2c312916a621 35 ticker_affodo.attach(&affOdo,1);
Nanaud 4:ad9b7355332e 36
Nanaud 1:2fe8c402ee79 37 // Init capteurs à ultrasons
Nanaud 1:2fe8c402ee79 38 captUS_init();
Nanaud 0:dc036b67c87c 39 echo1.rise(&echoRise1);
Nanaud 0:dc036b67c87c 40 echo1.fall(&echoFall1);
Nanaud 0:dc036b67c87c 41 echo2.rise(&echoRise2);
Nanaud 0:dc036b67c87c 42 echo2.fall(&echoFall2);
Nanaud 0:dc036b67c87c 43 echo3.rise(&echoRise3);
Nanaud 0:dc036b67c87c 44 echo3.fall(&echoFall3);
Nanaud 0:dc036b67c87c 45 echo4.rise(&echoRise4);
Nanaud 0:dc036b67c87c 46 echo4.fall(&echoFall4);
Nanaud 0:dc036b67c87c 47 echo5.rise(&echoRise5);
Nanaud 0:dc036b67c87c 48 echo5.fall(&echoFall5);
Nanaud 0:dc036b67c87c 49 echo6.rise(&echoRise6);
Nanaud 0:dc036b67c87c 50 echo6.fall(&echoFall6);
Nanaud 4:ad9b7355332e 51
Nanaud 1:2fe8c402ee79 52 // Init DRV8825
Nanaud 0:dc036b67c87c 53 drv_init();
Nanaud 4:ad9b7355332e 54
Nanaud 4:ad9b7355332e 55 // Init codeurs
Nanaud 0:dc036b67c87c 56 cdgA.rise(&cdgaRise);
Nanaud 6:ea6b30c4bb01 57 cddA.rise(&cddaRise);
Nanaud 0:dc036b67c87c 58 cdgA.mode(PullUp);
Nanaud 6:ea6b30c4bb01 59 cddA.mode(PullUp);
Nanaud 6:ea6b30c4bb01 60
Nanaud 6:ea6b30c4bb01 61 // Odometrie
plmir 12:2c312916a621 62
Nanaud 4:ad9b7355332e 63
Nanaud 4:ad9b7355332e 64
Nanaud 1:2fe8c402ee79 65 while(1) {}
Nanaud 0:dc036b67c87c 66 }