porting a OS5
Dependencies: BSP_B-L475E-IOT01
main.cpp
- Committer:
- fabio_gatti
- Date:
- 2018-08-07
- Revision:
- 0:faa406d23ae7
File content as of revision 0:faa406d23ae7:
#include "mbed.h"
// Sensors drivers present in the BSP library
#include "stm32l475e_iot01_tsensor.h"
#include "stm32l475e_iot01_hsensor.h"
#include "stm32l475e_iot01_psensor.h"
#include "stm32l475e_iot01_magneto.h"
#include "stm32l475e_iot01_gyro.h"
#include "stm32l475e_iot01_accelero.h"
// laser driver
//#include "lis3mdl_class.h"
#include "VL53L0X.h"
DigitalOut led(LED1);
Serial pc(USBTX, USBRX); //use these pins for serial coms
#ifdef TARGET_DISCO_L475VG_IOT01A
static DevI2C devI2c(PB_11,PB_10);
static DigitalOut shutdown_pin(PC_6);
static VL53L0X range(&devI2c, &shutdown_pin, PC_7);
#endif
int main()
{
float sensor_value = 0;
int16_t pDataXYZ[3] = {0};
float pGyroDataXYZ[3] = {0};
pc.baud(115200);
range.init_sensor(VL53L0X_DEFAULT_ADDRESS);
BSP_TSENSOR_Init();
BSP_HSENSOR_Init();
BSP_PSENSOR_Init();
BSP_MAGNETO_Init();
BSP_GYRO_Init();
BSP_ACCELERO_Init();
while(1) {
led = 1;
sensor_value = BSP_TSENSOR_ReadTemp();
printf("TEMPERATURE = %.2f degC\n", sensor_value);
sensor_value = BSP_HSENSOR_ReadHumidity();
printf("HUMIDITY = %.2f %%\n", sensor_value);
sensor_value = BSP_PSENSOR_ReadPressure();
printf("PRESSURE is = %.2f mBar\n", sensor_value);
led = 0;
wait(1);
led = 1;
BSP_MAGNETO_GetXYZ(pDataXYZ);
printf("MAGNETO_X = %d\n", pDataXYZ[0]);
printf("MAGNETO_Y = %d\n", pDataXYZ[1]);
printf("MAGNETO_Z = %d\n", pDataXYZ[2]);
BSP_GYRO_GetXYZ(pGyroDataXYZ);
printf("GYRO_X = %.2f\n", pGyroDataXYZ[0]);
printf("GYRO_Y = %.2f\n", pGyroDataXYZ[1]);
printf("GYRO_Z = %.2f\n", pGyroDataXYZ[2]);
BSP_ACCELERO_AccGetXYZ(pDataXYZ);
printf("ACCELERO_X = %d\n", pDataXYZ[0]);
printf("ACCELERO_Y = %d\n", pDataXYZ[1]);
printf("ACCELERO_Z = %d\n", pDataXYZ[2]);
uint32_t distance;
int status = range.get_distance(&distance);
if (status == VL53L0X_ERROR_NONE) {
printf("VL53L0X [mm]: %6ld\r\n", distance);
} else {
printf("VL53L0X [mm]: --\r\n");
}
led = 0;
wait(1);
}
}