BlinkPosition
Dependencies: BSP_B-L475E-IOT01 mbed
main.cpp@1:dce931d77528, 2018-11-09 (annotated)
- Committer:
- lmottola
- Date:
- Fri Nov 09 15:39:17 2018 +0000
- Revision:
- 1:dce931d77528
- Parent:
- 0:0cc3bd737dcb
- Child:
- 2:d51d7f26a4e1
Initial version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lmottola | 0:0cc3bd737dcb | 1 | #include "mbed.h" |
lmottola | 0:0cc3bd737dcb | 2 | |
lmottola | 0:0cc3bd737dcb | 3 | // Sensors drivers present in the BSP library |
lmottola | 0:0cc3bd737dcb | 4 | #include "stm32l475e_iot01_tsensor.h" |
lmottola | 0:0cc3bd737dcb | 5 | #include "stm32l475e_iot01_hsensor.h" |
lmottola | 0:0cc3bd737dcb | 6 | #include "stm32l475e_iot01_psensor.h" |
lmottola | 0:0cc3bd737dcb | 7 | #include "stm32l475e_iot01_magneto.h" |
lmottola | 0:0cc3bd737dcb | 8 | #include "stm32l475e_iot01_gyro.h" |
lmottola | 0:0cc3bd737dcb | 9 | #include "stm32l475e_iot01_accelero.h" |
lmottola | 0:0cc3bd737dcb | 10 | |
lmottola | 0:0cc3bd737dcb | 11 | DigitalOut led(LED1); |
lmottola | 0:0cc3bd737dcb | 12 | |
lmottola | 0:0cc3bd737dcb | 13 | int main() |
lmottola | 0:0cc3bd737dcb | 14 | { |
lmottola | 0:0cc3bd737dcb | 15 | float sensor_value = 0; |
lmottola | 0:0cc3bd737dcb | 16 | int16_t pDataXYZ[3] = {0}; |
lmottola | 0:0cc3bd737dcb | 17 | float pGyroDataXYZ[3] = {0}; |
lmottola | 0:0cc3bd737dcb | 18 | |
lmottola | 0:0cc3bd737dcb | 19 | BSP_TSENSOR_Init(); |
lmottola | 0:0cc3bd737dcb | 20 | BSP_HSENSOR_Init(); |
lmottola | 1:dce931d77528 | 21 | |
lmottola | 0:0cc3bd737dcb | 22 | BSP_PSENSOR_Init(); |
lmottola | 0:0cc3bd737dcb | 23 | |
lmottola | 0:0cc3bd737dcb | 24 | BSP_MAGNETO_Init(); |
lmottola | 0:0cc3bd737dcb | 25 | BSP_GYRO_Init(); |
lmottola | 0:0cc3bd737dcb | 26 | BSP_ACCELERO_Init(); |
lmottola | 0:0cc3bd737dcb | 27 | |
lmottola | 0:0cc3bd737dcb | 28 | while(1) { |
lmottola | 0:0cc3bd737dcb | 29 | |
lmottola | 0:0cc3bd737dcb | 30 | led = 1; |
lmottola | 0:0cc3bd737dcb | 31 | |
lmottola | 0:0cc3bd737dcb | 32 | sensor_value = BSP_TSENSOR_ReadTemp(); |
lmottola | 0:0cc3bd737dcb | 33 | printf("\nTEMPERATURE = %.2f degC\n", sensor_value); |
lmottola | 0:0cc3bd737dcb | 34 | |
lmottola | 0:0cc3bd737dcb | 35 | sensor_value = BSP_HSENSOR_ReadHumidity(); |
lmottola | 0:0cc3bd737dcb | 36 | printf("HUMIDITY = %.2f %%\n", sensor_value); |
lmottola | 0:0cc3bd737dcb | 37 | |
lmottola | 0:0cc3bd737dcb | 38 | sensor_value = BSP_PSENSOR_ReadPressure(); |
lmottola | 0:0cc3bd737dcb | 39 | printf("PRESSURE is = %.2f mBar\n", sensor_value); |
lmottola | 0:0cc3bd737dcb | 40 | |
lmottola | 0:0cc3bd737dcb | 41 | led = 0; |
lmottola | 0:0cc3bd737dcb | 42 | |
lmottola | 0:0cc3bd737dcb | 43 | wait(1); |
lmottola | 0:0cc3bd737dcb | 44 | |
lmottola | 0:0cc3bd737dcb | 45 | led = 1; |
lmottola | 0:0cc3bd737dcb | 46 | |
lmottola | 0:0cc3bd737dcb | 47 | BSP_MAGNETO_GetXYZ(pDataXYZ); |
lmottola | 0:0cc3bd737dcb | 48 | printf("\nMAGNETO_X = %d\n", pDataXYZ[0]); |
lmottola | 0:0cc3bd737dcb | 49 | printf("MAGNETO_Y = %d\n", pDataXYZ[1]); |
lmottola | 0:0cc3bd737dcb | 50 | printf("MAGNETO_Z = %d\n", pDataXYZ[2]); |
lmottola | 0:0cc3bd737dcb | 51 | |
lmottola | 0:0cc3bd737dcb | 52 | BSP_GYRO_GetXYZ(pGyroDataXYZ); |
lmottola | 0:0cc3bd737dcb | 53 | printf("\nGYRO_X = %.2f\n", pGyroDataXYZ[0]); |
lmottola | 0:0cc3bd737dcb | 54 | printf("GYRO_Y = %.2f\n", pGyroDataXYZ[1]); |
lmottola | 0:0cc3bd737dcb | 55 | printf("GYRO_Z = %.2f\n", pGyroDataXYZ[2]); |
lmottola | 0:0cc3bd737dcb | 56 | |
lmottola | 0:0cc3bd737dcb | 57 | BSP_ACCELERO_AccGetXYZ(pDataXYZ); |
lmottola | 0:0cc3bd737dcb | 58 | printf("\nACCELERO_X = %d\n", pDataXYZ[0]); |
lmottola | 0:0cc3bd737dcb | 59 | printf("ACCELERO_Y = %d\n", pDataXYZ[1]); |
lmottola | 0:0cc3bd737dcb | 60 | printf("ACCELERO_Z = %d\n", pDataXYZ[2]); |
lmottola | 0:0cc3bd737dcb | 61 | |
lmottola | 0:0cc3bd737dcb | 62 | led = 0; |
lmottola | 0:0cc3bd737dcb | 63 | |
lmottola | 0:0cc3bd737dcb | 64 | wait(1); |
lmottola | 0:0cc3bd737dcb | 65 | |
lmottola | 0:0cc3bd737dcb | 66 | } |
lmottola | 0:0cc3bd737dcb | 67 | } |