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 mbed
main.cpp
00001 #include "mbed.h" 00002 00003 // Sensors drivers present in the BSP library 00004 #include "stm32l475e_iot01_tsensor.h" 00005 #include "stm32l475e_iot01_hsensor.h" 00006 #include "stm32l475e_iot01_psensor.h" 00007 #include "stm32l475e_iot01_magneto.h" 00008 #include "stm32l475e_iot01_gyro.h" 00009 #include "stm32l475e_iot01_accelero.h" 00010 00011 DigitalOut led(LED1); 00012 InterruptIn button(USER_BUTTON); 00013 int options = 0; 00014 bool has_changed = false; 00015 00016 void toggle() { 00017 options = options + 1 % 5; 00018 has_changed = true; 00019 } 00020 00021 int main() 00022 { 00023 float sensor_value = 0; 00024 int16_t pDataXYZ[3] = {0}; 00025 float pGyroDataXYZ[3] = {0}; 00026 00027 BSP_TSENSOR_Init(); 00028 BSP_HSENSOR_Init(); 00029 00030 BSP_PSENSOR_Init(); 00031 00032 BSP_MAGNETO_Init(); 00033 BSP_GYRO_Init(); 00034 BSP_ACCELERO_Init(); 00035 00036 button.rise(&toggle); 00037 00038 while(1) { 00039 00040 led = !led; 00041 00042 switch (options) 00043 { case 0: 00044 break; 00045 case 1: 00046 sensor_value = BSP_TSENSOR_ReadTemp(); 00047 printf("\nTEMPERATURE = %.2f degC\n", sensor_value); 00048 00049 sensor_value = BSP_HSENSOR_ReadHumidity(); 00050 printf("HUMIDITY = %.2f %%\n", sensor_value); 00051 00052 sensor_value = BSP_PSENSOR_ReadPressure(); 00053 printf("PRESSURE is = %.2f mBar\n", sensor_value); 00054 break; 00055 00056 case 2: 00057 BSP_MAGNETO_GetXYZ(pDataXYZ); 00058 printf("\nMAGNETO_X = %d\n", pDataXYZ[0]); 00059 printf("MAGNETO_Y = %d\n", pDataXYZ[1]); 00060 printf("MAGNETO_Z = %d\n", pDataXYZ[2]); 00061 break; 00062 case 3: 00063 BSP_GYRO_GetXYZ(pGyroDataXYZ); 00064 printf("\nGYRO_X = %.2f\n", pGyroDataXYZ[0]); 00065 printf("GYRO_Y = %.2f\n", pGyroDataXYZ[1]); 00066 printf("GYRO_Z = %.2f\n", pGyroDataXYZ[2]); 00067 break; 00068 case 4: 00069 BSP_ACCELERO_AccGetXYZ(pDataXYZ); 00070 printf("\nACCELERO_X = %d\n", pDataXYZ[0]); 00071 printf("ACCELERO_Y = %d\n", pDataXYZ[1]); 00072 printf("ACCELERO_Z = %d\n", pDataXYZ[2]); 00073 break; 00074 default: 00075 break; 00076 } 00077 00078 if(has_changed){ 00079 wait(1); 00080 has_changed = false; 00081 } 00082 led = !led; 00083 00084 } 00085 }
Generated on Thu Aug 4 2022 08:32:34 by
1.7.2