000

Dependencies:   BSP_B-L475E-IOT01

Committer:
18124178734
Date:
Thu Oct 27 18:40:05 2022 +0800
Revision:
3:e3446fb7ca12
Parent:
2:0e0dbbf22676
Child:
4:28533c0e8527
ff ???

Who changed what in which revision?

UserRevisionLine numberNew contents of line
18124178734 0:079949a2c813 1 #include "mbed.h"
18124178734 0:079949a2c813 2 // Sensors drivers present in the BSP library
18124178734 0:079949a2c813 3 #include "stm32l475e_iot01_tsensor.h"
18124178734 0:079949a2c813 4 #include "stm32l475e_iot01_hsensor.h"
18124178734 0:079949a2c813 5 #include "stm32l475e_iot01_psensor.h"
18124178734 0:079949a2c813 6 #include "stm32l475e_iot01_magneto.h"
18124178734 0:079949a2c813 7 #include "stm32l475e_iot01_gyro.h"
18124178734 0:079949a2c813 8 #include "stm32l475e_iot01_accelero.h"
18124178734 0:079949a2c813 9
18124178734 0:079949a2c813 10 DigitalOut led(LED1);
18124178734 3:e3446fb7ca12 11
18124178734 0:079949a2c813 12 int main()
18124178734 0:079949a2c813 13 {
18124178734 0:079949a2c813 14 float sensor_value = 0;
18124178734 0:079949a2c813 15 int16_t pDataXYZ[3] = {0};
18124178734 0:079949a2c813 16 float pGyroDataXYZ[3] = {0};
18124178734 0:079949a2c813 17
18124178734 0:079949a2c813 18 printf("Start sensor init\n");
18124178734 0:079949a2c813 19
18124178734 0:079949a2c813 20 BSP_TSENSOR_Init();
18124178734 0:079949a2c813 21 BSP_HSENSOR_Init();
18124178734 0:079949a2c813 22 BSP_PSENSOR_Init();
18124178734 0:079949a2c813 23
18124178734 0:079949a2c813 24 BSP_MAGNETO_Init();
18124178734 0:079949a2c813 25 BSP_GYRO_Init();
18124178734 0:079949a2c813 26 BSP_ACCELERO_Init();
18124178734 0:079949a2c813 27
18124178734 0:079949a2c813 28 while(1) {
18124178734 0:079949a2c813 29 printf("\nNew loop, LED1 should blink during sensor read\n");
18124178734 2:0e0dbbf22676 30
18124178734 0:079949a2c813 31
18124178734 0:079949a2c813 32 led = 1;
18124178734 0:079949a2c813 33
18124178734 0:079949a2c813 34 sensor_value = BSP_TSENSOR_ReadTemp();
18124178734 1:78c7a2c90fcd 35 printf("\n温度 = %.2f degC\n", sensor_value);
18124178734 0:079949a2c813 36
18124178734 0:079949a2c813 37 sensor_value = BSP_HSENSOR_ReadHumidity();
18124178734 1:78c7a2c90fcd 38 printf("湿度 = %.2f %%\n", sensor_value);
18124178734 0:079949a2c813 39
18124178734 0:079949a2c813 40 sensor_value = BSP_PSENSOR_ReadPressure();
18124178734 1:78c7a2c90fcd 41 printf("压力 is = %.2f mBar\n", sensor_value);
18124178734 0:079949a2c813 42
18124178734 0:079949a2c813 43 led = 0;
18124178734 0:079949a2c813 44
18124178734 0:079949a2c813 45 ThisThread::sleep_for(1000);
18124178734 0:079949a2c813 46
18124178734 0:079949a2c813 47 led = 1;
18124178734 0:079949a2c813 48
18124178734 0:079949a2c813 49 BSP_MAGNETO_GetXYZ(pDataXYZ);
18124178734 0:079949a2c813 50 printf("\nMAGNETO_X = %d\n", pDataXYZ[0]);
18124178734 0:079949a2c813 51 printf("MAGNETO_Y = %d\n", pDataXYZ[1]);
18124178734 0:079949a2c813 52 printf("MAGNETO_Z = %d\n", pDataXYZ[2]);
18124178734 0:079949a2c813 53
18124178734 0:079949a2c813 54 BSP_GYRO_GetXYZ(pGyroDataXYZ);
18124178734 0:079949a2c813 55 printf("\nGYRO_X = %.2f\n", pGyroDataXYZ[0]);
18124178734 0:079949a2c813 56 printf("GYRO_Y = %.2f\n", pGyroDataXYZ[1]);
18124178734 0:079949a2c813 57 printf("GYRO_Z = %.2f\n", pGyroDataXYZ[2]);
18124178734 0:079949a2c813 58
18124178734 0:079949a2c813 59 BSP_ACCELERO_AccGetXYZ(pDataXYZ);
18124178734 0:079949a2c813 60 printf("\nACCELERO_X = %d\n", pDataXYZ[0]);
18124178734 0:079949a2c813 61 printf("ACCELERO_Y = %d\n", pDataXYZ[1]);
18124178734 0:079949a2c813 62 printf("ACCELERO_Z = %d\n", pDataXYZ[2]);
18124178734 0:079949a2c813 63
18124178734 0:079949a2c813 64 led = 0;
18124178734 0:079949a2c813 65
18124178734 0:079949a2c813 66 ThisThread::sleep_for(1000);
18124178734 0:079949a2c813 67
18124178734 0:079949a2c813 68 }
18124178734 0:079949a2c813 69 }