Projet_APP5
/
MS5607modele
TP ENSA Bus CAN
main.cpp@1:db4df4165d4a, 2019-12-25 (annotated)
- Committer:
- bouaziz
- Date:
- Wed Dec 25 15:12:39 2019 +0000
- Revision:
- 1:db4df4165d4a
- Parent:
- 0:c06e6d1972d6
Version ENSA
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yamaguch | 0:c06e6d1972d6 | 1 | #include "mbed.h" |
yamaguch | 0:c06e6d1972d6 | 2 | #include "MS5607I2C.h" |
bouaziz | 1:db4df4165d4a | 3 | CAN can1(p9, p10); |
bouaziz | 1:db4df4165d4a | 4 | |
bouaziz | 1:db4df4165d4a | 5 | DigitalOut led1(LED1); |
bouaziz | 1:db4df4165d4a | 6 | CANMessage can_MsgRx; |
yamaguch | 0:c06e6d1972d6 | 7 | |
yamaguch | 0:c06e6d1972d6 | 8 | int main() { |
bouaziz | 1:db4df4165d4a | 9 | |
bouaziz | 1:db4df4165d4a | 10 | can1.frequency(1000000); //bus can 1Mbits/s |
bouaziz | 1:db4df4165d4a | 11 | MS5607I2C ms5607(p28, p27, false); // capteur |
bouaziz | 1:db4df4165d4a | 12 | ms5607.init(15.0,101325.); // initialiser capteur |
bouaziz | 1:db4df4165d4a | 13 | led1=1; |
bouaziz | 1:db4df4165d4a | 14 | // ms5607.printCoefficients(); |
bouaziz | 1:db4df4165d4a | 15 | can_MsgRx.id=0x1X0; // X compris entre 0 et 7 voir avec l'enseignant |
bouaziz | 1:db4df4165d4a | 16 | can_MsgRx.len=4; // trame à 4 octets |
bouaziz | 1:db4df4165d4a | 17 | while(1){ // boucle infinie |
bouaziz | 1:db4df4165d4a | 18 | printf("P= %5.0f Pa ", ms5607.getPressure()); |
bouaziz | 1:db4df4165d4a | 19 | printf("T= %2.2f ", ms5607.getTemperature()); |
bouaziz | 1:db4df4165d4a | 20 | printf("Alt= %.2f m\n", ms5607.getAltitude()); |
bouaziz | 1:db4df4165d4a | 21 | wait(1); |
bouaziz | 1:db4df4165d4a | 22 | } |
yamaguch | 0:c06e6d1972d6 | 23 | } |