2019-2020 LIS2DW12 Accelerometer Project

Dependencies:   X_NUCLEO_IKS01A3

Revision:
13:f4ad8550374a
Parent:
12:2c129618b350
Child:
14:8b7ce0fc3971
--- a/main.cpp	Tue Sep 17 12:33:08 2019 +0000
+++ b/main.cpp	Tue Sep 17 14:01:00 2019 +0000
@@ -38,7 +38,7 @@
 
 /*
     LELEC2811 Multisensor IKS01A3 Project
-    M. Lefebvre - 2019
+    M. Lefebvre - 2019-2020
 */
 
 /* Includes */
@@ -65,6 +65,7 @@
 #define LPS22HH_ODR             50.0    // Output data rate (one-shot, 1, 10, 25, 50, 75, 100, 200 Hz)
 #define LPS22HH_LOW_NOISE_EN    1       // Low-noise (0 disabled, 1 enabled)
 #define LPS22HH_LPF_CFG         3       // Device bandwidth (0 for ODR/2, 2 for ODR/9, 3 for ODR/20)
+#define LPS22HH_DATA_SIZE       8       // Number of bytes for LPS22HH pressure sensor data
 
 // LIS2DW12 Accelerometer
 #define LIS2DW12_ODR            4       // Output data rate (0 power down, 1 HP 12.5Hz/LP 1.6Hz, 2 for 12.5Hz, 3 for 25Hz, 4 for 50Hz, 5 for 100Hz, 6 for 200Hz, 7 for HP 400Hz/LP 200Hz, 8 for HP 800Hz/LP 200Hz, 9 for HP 1600Hz/LP 200Hz)
@@ -108,6 +109,8 @@
 void button1_onpressed_cb(void);
 static char *print_double(char *str, double v);
 float pressure_to_altitude(double pressure);
+uint32_t FloatToUint(float n);
+float UintToFloat(uint32_t n);
 
 /* Serial link */
 Serial pc(SERIAL_TX, SERIAL_RX);
@@ -580,3 +583,13 @@
 {
     return 44330.77 * (1-pow(pressure/P0, 0.1902632));
 }
+
+uint32_t FloatToUint(float n)
+{
+   return (uint32_t)(*(uint32_t*)&n);
+}
+ 
+float UintToFloat(uint32_t n)
+{
+   return (float)(*(float*)&n);
+}
\ No newline at end of file