RoboNucleo / Mbed 2 deprecated F411RE_I2C_IMU10D0F

Dependencies:   bmp280prova mbed

Fork of F411RE_I2C_IMU10D0F by Rudy Vicario

Revision:
4:5007cf114255
Parent:
3:03eaa31f1ff8
Child:
5:51d94a515a46
diff -r 03eaa31f1ff8 -r 5007cf114255 main.cpp
--- a/main.cpp	Tue Apr 11 09:55:45 2017 +0000
+++ b/main.cpp	Wed Apr 12 10:48:11 2017 +0000
@@ -1,133 +1,17 @@
-#include "mbed.h"
-#include "bmp280.c"
 #include <stdio.h>
-
-Serial pc(SERIAL_TX,SERIAL_RX);
+#include "bmp280_support.h"
 
 #define ADDRESS_BMP280 0x77
 
 I2C dispositivo(I2C_SDA,I2C_SCL);
 
-int main() {
-    struct bmp280_t bmp280;
-
-    //s32 res = bmp280_init(&obj);
-    
-    s32 pres, temp;
-    /* The variable used to assign the standby time*/
-    u8 v_standby_time_u8 = BMP280_INIT_VALUE;
-
-    /* The variables used in individual data read APIs*/
-    /* The variable used to read uncompensated temperature*/
-    s32 v_data_uncomp_tem_s32 = BMP280_INIT_VALUE;
-    /* The variable used to read uncompensated pressure*/
-    s32 v_data_uncomp_pres_s32 = BMP280_INIT_VALUE;
-    /* The variable used to read real temperature*/
-    s32 v_actual_temp_s32 = BMP280_INIT_VALUE;
-    /* The variable used to read real pressure*/
-    u32 v_actual_press_u32 = BMP280_INIT_VALUE;
-
-    /* The variables used in combined data read APIs*/
-    /* The variable used to read uncompensated temperature*/
-    s32 v_data_uncomp_tem_combined_s32 = BMP280_INIT_VALUE;
-    /* The variable used to read uncompensated pressure*/
-    s32 v_data_uncomp_pres_combined_s32 = BMP280_INIT_VALUE;
-    /* The variable used to read real temperature*/
-    s32 v_actual_temp_combined_s32 = BMP280_INIT_VALUE;
-    /* The variable used to read real pressure*/
-    u32 v_actual_press_combined_u32 = BMP280_INIT_VALUE;
-
-    /* result of communication results*/
-    s32 com_rslt = ERROR;
-/*********************** START INITIALIZATION ************************/
- 
-  bmp280.dev_addr = BMP280_I2C_ADDRESS2;
+s32 com_rslt = ERROR;
 
-/*--------------------------------------------------------------------------*
- *  This function used to assign the value/reference of
- *  the following parameters
- *  I2C address
- *  Bus Write
- *  Bus read
- *  Chip id
-*-------------------------------------------------------------------------*/
-    pc.printf("before - ");
-    com_rslt = bmp280_init(&bmp280);
-    pc.printf("after\n");
-    /*  For initialization it is required to set the mode of
-     *  the sensor as "NORMAL"
-     *  data acquisition/read/write is possible in this mode
-     *  by using the below API able to set the power mode as NORMAL*/
-    /* Set the power mode as NORMAL*/
-    com_rslt += bmp280_set_power_mode(BMP280_NORMAL_MODE);
-    /*  For reading the pressure and temperature data it is required to
-     *  set the work mode
-     *  The measurement period in the Normal mode is depends on the setting of
-     *  over sampling setting of pressure, temperature and standby time
-     *
-     *  OSS             pressure OSS    temperature OSS
-     *  ultra low power         x1          x1
-     *  low power           x2          x1
-     *  standard resolution     x4          x1
-     *  high resolution         x8          x2
-     *  ultra high resolution       x16         x2
-     */
-    /* The oversampling settings are set by using the following API*/
-    com_rslt += bmp280_set_work_mode(BMP280_ULTRA_LOW_POWER_MODE);
-/*------------------------------------------------------------------------*
-************************* START GET and SET FUNCTIONS DATA ****************
-*---------------------------------------------------------------------------*/
-    /* This API used to Write the standby time of the sensor input
-     *  value have to be given*/
-     /* Normal mode comprises an automated perpetual cycling between an (active)
-     *  Measurement period and an (inactive) standby period.
-     *  The standby time is determined by the contents of the register t_sb.
-     *  Standby time can be set using BMP280_STANDBYTIME_125_MS.
-     *  Usage Hint : BMP280_set_standbydur(BMP280_STANDBYTIME_125_MS)*/
-
-    com_rslt += bmp280_set_standby_durn(BMP280_STANDBY_TIME_1_MS);
-
-    /* This API used to read back the written value of standby time*/
-    com_rslt += bmp280_get_standby_durn(&v_standby_time_u8);
-/*-----------------------------------------------------------------*
-************************* END GET and SET FUNCTIONS ****************
-*------------------------------------------------------------------*/
-
-/************************* END INITIALIZATION *************************/
-
-/*------------------------------------------------------------------*
-****** INDIVIDUAL APIs TO READ UNCOMPENSATED PRESSURE AND TEMPERATURE*******
-*---------------------------------------------------------------------*/
-    /* API is used to read the uncompensated temperature*/
-    com_rslt += bmp280_read_uncomp_temperature(&v_data_uncomp_tem_s32);
-
-    /* API is used to read the uncompensated pressure*/
-    com_rslt += bmp280_read_uncomp_pressure(&v_data_uncomp_pres_s32);
-
-    /* API is used to read the true temperature*/
-    /* Input value as uncompensated temperature*/
-    v_actual_temp_s32 = bmp280_compensate_temperature_int32(v_data_uncomp_tem_s32);
-
-    /* API is used to read the true pressure*/
-    /* Input value as uncompensated pressure*/
-    v_actual_press_u32 = bmp280_compensate_pressure_int32(v_data_uncomp_pres_s32);
-
-/*------------------------------------------------------------------*
-******* STAND-ALONE APIs TO READ COMBINED TRUE PRESSURE AND TEMPERATURE********
-*---------------------------------------------------------------------*/
-
-
-    /* API is used to read the uncompensated temperature and pressure*/
-    com_rslt += bmp280_read_uncomp_pressure_temperature(&v_data_uncomp_pres_combined_s32,
-    &v_data_uncomp_tem_combined_s32);
+int main() {
+    //struct bmp280_t bmp280;
     
-    pc.printf("pres %d - temp %d",v_data_uncomp_pres_combined_s32,v_data_uncomp_tem_combined_s32);
-
-    /* API is used to read the true temperature and pressure*/
-    com_rslt += bmp280_read_pressure_temperature(&v_actual_press_combined_u32,
-    &v_actual_temp_combined_s32);
-
-    com_rslt += bmp280_set_power_mode(BMP280_SLEEP_MODE);
+    //com_rslt = bmp280_init(&bmp280);
+    bmp280_data_readout_template();
     
     /*
     while(1) {