Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BSP_B-L475E-IOT01
main.cpp
00001 #include "mbed.h" 00002 // Sensors drivers present in the BSP library 00003 #include "stm32l475e_iot01_tsensor.h" 00004 #include "stm32l475e_iot01_hsensor.h" 00005 #include "stm32l475e_iot01_psensor.h" 00006 #include "stm32l475e_iot01_magneto.h" 00007 #include "stm32l475e_iot01_gyro.h" 00008 #include "stm32l475e_iot01_accelero.h" 00009 00010 DigitalOut led(LED1); 00011 00012 int main() 00013 { 00014 float sensor_value = 0; 00015 int16_t pDataXYZ[3] = {0}; 00016 float pGyroDataXYZ[3] = {0}; 00017 00018 printf("Start sensor init\n"); 00019 00020 BSP_TSENSOR_Init(); 00021 BSP_HSENSOR_Init(); 00022 00023 00024 BSP_PSENSOR_Init(); 00025 00026 BSP_MAGNETO_Init(); 00027 BSP_GYRO_Init(); 00028 BSP_ACCELERO_Init(); 00029 00030 while(1) { 00031 printf("\nNew loop, LED1 should blink during sensor read\n"); 00032 00033 00034 led = 1; 00035 00036 sensor_value = BSP_TSENSOR_ReadTemp(); 00037 printf("\n温度 = %.2f degC\n", sensor_value); 00038 00039 sensor_value = BSP_HSENSOR_ReadHumidity(); 00040 printf("湿度 = %.2f %%\n", sensor_value); 00041 00042 sensor_value = BSP_PSENSOR_ReadPressure(); 00043 printf("压力 is = %.2f mBar\n", sensor_value); 00044 00045 led = 0; 00046 00047 ThisThread::sleep_for(1000); 00048 00049 led = 1; 00050 00051 BSP_MAGNETO_GetXYZ(pDataXYZ); 00052 printf("\nMAGNETO_X = %d\n", pDataXYZ[0]); 00053 printf("MAGNETO_Y = %d\n", pDataXYZ[1]); 00054 printf("MAGNETO_Z = %d\n", pDataXYZ[2]); 00055 00056 BSP_GYRO_GetXYZ(pGyroDataXYZ); 00057 printf("\nGYRO_X = %.2f\n", pGyroDataXYZ[0]); 00058 printf("GYRO_Y = %.2f\n", pGyroDataXYZ[1]); 00059 printf("GYRO_Z = %.2f\n", pGyroDataXYZ[2]); 00060 00061 BSP_ACCELERO_AccGetXYZ(pDataXYZ); 00062 printf("\nACCELERO_X = %d\n", pDataXYZ[0]); 00063 printf("ACCELERO_Y = %d\n", pDataXYZ[1]); 00064 printf("ACCELERO_Z = %d\n", pDataXYZ[2]); 00065 00066 led = 0; 00067 00068 ThisThread::sleep_for(1000); 00069 00070 } 00071 }
Generated on Thu Oct 27 2022 10:59:44 by
1.7.2