000
Dependencies: BSP_B-L475E-IOT01
main.cpp@0:079949a2c813, 2022-10-26 (annotated)
- Committer:
- 18124178734
- Date:
- Wed Oct 26 02:24:18 2022 +0000
- Revision:
- 0:079949a2c813
- Child:
- 1:78c7a2c90fcd
000
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
18124178734 | 0:079949a2c813 | 1 | #include "mbed.h" |
18124178734 | 0:079949a2c813 | 2 | |
18124178734 | 0:079949a2c813 | 3 | // Sensors drivers present in the BSP library |
18124178734 | 0:079949a2c813 | 4 | #include "stm32l475e_iot01_tsensor.h" |
18124178734 | 0:079949a2c813 | 5 | #include "stm32l475e_iot01_hsensor.h" |
18124178734 | 0:079949a2c813 | 6 | #include "stm32l475e_iot01_psensor.h" |
18124178734 | 0:079949a2c813 | 7 | #include "stm32l475e_iot01_magneto.h" |
18124178734 | 0:079949a2c813 | 8 | #include "stm32l475e_iot01_gyro.h" |
18124178734 | 0:079949a2c813 | 9 | #include "stm32l475e_iot01_accelero.h" |
18124178734 | 0:079949a2c813 | 10 | |
18124178734 | 0:079949a2c813 | 11 | DigitalOut led(LED1); |
18124178734 | 0:079949a2c813 | 12 | |
18124178734 | 0:079949a2c813 | 13 | int main() |
18124178734 | 0:079949a2c813 | 14 | { |
18124178734 | 0:079949a2c813 | 15 | float sensor_value = 0; |
18124178734 | 0:079949a2c813 | 16 | int16_t pDataXYZ[3] = {0}; |
18124178734 | 0:079949a2c813 | 17 | float pGyroDataXYZ[3] = {0}; |
18124178734 | 0:079949a2c813 | 18 | |
18124178734 | 0:079949a2c813 | 19 | printf("Start sensor init\n"); |
18124178734 | 0:079949a2c813 | 20 | |
18124178734 | 0:079949a2c813 | 21 | BSP_TSENSOR_Init(); |
18124178734 | 0:079949a2c813 | 22 | BSP_HSENSOR_Init(); |
18124178734 | 0:079949a2c813 | 23 | BSP_PSENSOR_Init(); |
18124178734 | 0:079949a2c813 | 24 | |
18124178734 | 0:079949a2c813 | 25 | BSP_MAGNETO_Init(); |
18124178734 | 0:079949a2c813 | 26 | BSP_GYRO_Init(); |
18124178734 | 0:079949a2c813 | 27 | BSP_ACCELERO_Init(); |
18124178734 | 0:079949a2c813 | 28 | |
18124178734 | 0:079949a2c813 | 29 | while(1) { |
18124178734 | 0:079949a2c813 | 30 | printf("\nNew loop, LED1 should blink during sensor read\n"); |
18124178734 | 0:079949a2c813 | 31 | |
18124178734 | 0:079949a2c813 | 32 | led = 1; |
18124178734 | 0:079949a2c813 | 33 | |
18124178734 | 0:079949a2c813 | 34 | sensor_value = BSP_TSENSOR_ReadTemp(); |
18124178734 | 0:079949a2c813 | 35 | printf("\nTEMPERATURE = %.2f degC\n", sensor_value); |
18124178734 | 0:079949a2c813 | 36 | |
18124178734 | 0:079949a2c813 | 37 | sensor_value = BSP_HSENSOR_ReadHumidity(); |
18124178734 | 0:079949a2c813 | 38 | printf("HUMIDITY = %.2f %%\n", sensor_value); |
18124178734 | 0:079949a2c813 | 39 | |
18124178734 | 0:079949a2c813 | 40 | sensor_value = BSP_PSENSOR_ReadPressure(); |
18124178734 | 0:079949a2c813 | 41 | printf("PRESSURE 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 | } |