TP ENSA Bus CAN
Diff: main.cpp
- Revision:
- 1:db4df4165d4a
- Parent:
- 0:c06e6d1972d6
--- a/main.cpp Tue Jul 03 08:58:18 2012 +0000
+++ b/main.cpp Wed Dec 25 15:12:39 2019 +0000
@@ -1,13 +1,23 @@
#include "mbed.h"
-//#include "MS5607SPI.h"
#include "MS5607I2C.h"
+CAN can1(p9, p10);
+
+DigitalOut led1(LED1);
+CANMessage can_MsgRx;
int main() {
- //MS5607SPI ms5607(p11, p12, p13, p10);
- MS5607I2C ms5607(p9, p10, false);
-
- ms5607.printCoefficients();
- printf("Pressure = %.0f Pa\n", ms5607.getPressure());
- printf("Temperature = %.2f degC\n", ms5607.getTemperature());
- printf("Altitude = %.2f m\n", ms5607.getAltitude());
+
+ can1.frequency(1000000); //bus can 1Mbits/s
+ MS5607I2C ms5607(p28, p27, false); // capteur
+ ms5607.init(15.0,101325.); // initialiser capteur
+ led1=1;
+ // ms5607.printCoefficients();
+ can_MsgRx.id=0x1X0; // X compris entre 0 et 7 voir avec l'enseignant
+ can_MsgRx.len=4; // trame à 4 octets
+ while(1){ // boucle infinie
+ printf("P= %5.0f Pa ", ms5607.getPressure());
+ printf("T= %2.2f ", ms5607.getTemperature());
+ printf("Alt= %.2f m\n", ms5607.getAltitude());
+ wait(1);
+ }
}
\ No newline at end of file