Capteur_US

Dependencies:   mbed DRV8825

Committer:
Nanaud
Date:
Wed Jul 08 20:42:19 2020 +0000
Revision:
1:2fe8c402ee79
Parent:
0:dc036b67c87c
Child:
15:43f5bda97488
Amelioration de la lisibilite du code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Nanaud 1:2fe8c402ee79 1 //Nom du fichier : captUS.cpp
Nanaud 0:dc036b67c87c 2 #include "pins.h"
Nanaud 0:dc036b67c87c 3
Nanaud 1:2fe8c402ee79 4 // Variables globales & timers
Nanaud 1:2fe8c402ee79 5 float us_out[6];
Nanaud 1:2fe8c402ee79 6 Timer tps;
Nanaud 1:2fe8c402ee79 7 Ticker ticker_US;
Nanaud 0:dc036b67c87c 8
Nanaud 1:2fe8c402ee79 9 void captUS_init(){
Nanaud 1:2fe8c402ee79 10 tps.start();}
Nanaud 1:2fe8c402ee79 11
Nanaud 1:2fe8c402ee79 12 void captUS_trig(){
Nanaud 0:dc036b67c87c 13 tps.reset();
Nanaud 0:dc036b67c87c 14 trigger=1;
Nanaud 0:dc036b67c87c 15 wait(0.00002);
Nanaud 0:dc036b67c87c 16 trigger=0;
Nanaud 0:dc036b67c87c 17 }
Nanaud 0:dc036b67c87c 18
Nanaud 0:dc036b67c87c 19 void echoRise1(){us_out[0]=tps.read_us();}
Nanaud 0:dc036b67c87c 20 void echoFall1(){us_out[0]=(tps.read_us()-us_out[0])/2;}
Nanaud 0:dc036b67c87c 21
Nanaud 0:dc036b67c87c 22 void echoRise2(){us_out[1]=tps.read_us();}
Nanaud 0:dc036b67c87c 23 void echoFall2(){us_out[1]=(tps.read_us()-us_out[1])/2;}
Nanaud 0:dc036b67c87c 24
Nanaud 0:dc036b67c87c 25 void echoRise3(){us_out[2]=tps.read_us();}
Nanaud 0:dc036b67c87c 26 void echoFall3(){us_out[2]=(tps.read_us()-us_out[2])/2;}
Nanaud 0:dc036b67c87c 27
Nanaud 0:dc036b67c87c 28 void echoRise4(){us_out[3]=tps.read_us();}
Nanaud 0:dc036b67c87c 29 void echoFall4(){us_out[3]=(tps.read_us()-us_out[3])/2;}
Nanaud 0:dc036b67c87c 30
Nanaud 0:dc036b67c87c 31 void echoRise5(){us_out[4]=tps.read_us();}
Nanaud 0:dc036b67c87c 32 void echoFall5(){us_out[4]=(tps.read_us()-us_out[4])/2;}
Nanaud 0:dc036b67c87c 33
Nanaud 0:dc036b67c87c 34 void echoRise6(){us_out[5]=tps.read_us();}
Nanaud 0:dc036b67c87c 35 void echoFall6(){us_out[5]=(tps.read_us()-us_out[5])/2;}