1st

Dependencies:   BSP_B-L475E-IOT01

Committer:
voltxd
Date:
Fri Dec 04 07:41:12 2020 +0000
Revision:
0:621a9f7b5ce0
1st

Who changed what in which revision?

UserRevisionLine numberNew contents of line
voltxd 0:621a9f7b5ce0 1 #include "mbed.h"
voltxd 0:621a9f7b5ce0 2
voltxd 0:621a9f7b5ce0 3 // Sensors drivers present in the BSP library
voltxd 0:621a9f7b5ce0 4 #include "stm32l475e_iot01_tsensor.h"
voltxd 0:621a9f7b5ce0 5 #include "stm32l475e_iot01_hsensor.h"
voltxd 0:621a9f7b5ce0 6 #include "stm32l475e_iot01_psensor.h"
voltxd 0:621a9f7b5ce0 7 #include "stm32l475e_iot01_magneto.h"
voltxd 0:621a9f7b5ce0 8 #include "stm32l475e_iot01_gyro.h"
voltxd 0:621a9f7b5ce0 9 #include "stm32l475e_iot01_accelero.h"
voltxd 0:621a9f7b5ce0 10
voltxd 0:621a9f7b5ce0 11 #include <math.h>
voltxd 0:621a9f7b5ce0 12
voltxd 0:621a9f7b5ce0 13 DigitalOut led1(LED1);
voltxd 0:621a9f7b5ce0 14 DigitalOut led2(LED2);
voltxd 0:621a9f7b5ce0 15 DigitalOut led3(LED3);
voltxd 0:621a9f7b5ce0 16 DigitalOut led4(LED4);
voltxd 0:621a9f7b5ce0 17
voltxd 0:621a9f7b5ce0 18 DigitalIn userButton(USER_BUTTON, PullUp);
voltxd 0:621a9f7b5ce0 19
voltxd 0:621a9f7b5ce0 20 int main()
voltxd 0:621a9f7b5ce0 21 {
voltxd 0:621a9f7b5ce0 22 float sensor_value = 0;
voltxd 0:621a9f7b5ce0 23 int16_t pDataXYZ[3] = {0};
voltxd 0:621a9f7b5ce0 24 float pGyroDataXYZ[3] = {0};
voltxd 0:621a9f7b5ce0 25
voltxd 0:621a9f7b5ce0 26 printf("Start sensor init\r\n");
voltxd 0:621a9f7b5ce0 27
voltxd 0:621a9f7b5ce0 28 BSP_TSENSOR_Init();
voltxd 0:621a9f7b5ce0 29 BSP_HSENSOR_Init();
voltxd 0:621a9f7b5ce0 30 BSP_PSENSOR_Init();
voltxd 0:621a9f7b5ce0 31
voltxd 0:621a9f7b5ce0 32 BSP_MAGNETO_Init();
voltxd 0:621a9f7b5ce0 33 BSP_GYRO_Init();
voltxd 0:621a9f7b5ce0 34 BSP_ACCELERO_Init();
voltxd 0:621a9f7b5ce0 35
voltxd 0:621a9f7b5ce0 36 led2 = 1;
voltxd 0:621a9f7b5ce0 37 led3 = 0;
voltxd 0:621a9f7b5ce0 38 led4 = 0;
voltxd 0:621a9f7b5ce0 39
voltxd 0:621a9f7b5ce0 40 while(1) {
voltxd 0:621a9f7b5ce0 41 printf("\r\nNew loop, LED1 should blink during sensor read\r\n");
voltxd 0:621a9f7b5ce0 42
voltxd 0:621a9f7b5ce0 43 if (!userButton.read())
voltxd 0:621a9f7b5ce0 44 {
voltxd 0:621a9f7b5ce0 45 if (!led2.read() && !led3.read() && !led4.read())
voltxd 0:621a9f7b5ce0 46 {
voltxd 0:621a9f7b5ce0 47 led2 = 1;
voltxd 0:621a9f7b5ce0 48 }
voltxd 0:621a9f7b5ce0 49 else if (led2.read() && !led3.read() && !led4.read())
voltxd 0:621a9f7b5ce0 50 {
voltxd 0:621a9f7b5ce0 51 led2 = 0;
voltxd 0:621a9f7b5ce0 52 led3 = 1;
voltxd 0:621a9f7b5ce0 53 }
voltxd 0:621a9f7b5ce0 54 else if (!led2.read() && led3.read() && !led4.read())
voltxd 0:621a9f7b5ce0 55 {
voltxd 0:621a9f7b5ce0 56 led3 = 0;
voltxd 0:621a9f7b5ce0 57 led4 = 1;
voltxd 0:621a9f7b5ce0 58 }
voltxd 0:621a9f7b5ce0 59 else
voltxd 0:621a9f7b5ce0 60 {
voltxd 0:621a9f7b5ce0 61 led4 = 0;
voltxd 0:621a9f7b5ce0 62 led2 = 1;
voltxd 0:621a9f7b5ce0 63 }
voltxd 0:621a9f7b5ce0 64 }
voltxd 0:621a9f7b5ce0 65 else
voltxd 0:621a9f7b5ce0 66 {
voltxd 0:621a9f7b5ce0 67 led2 = 0;
voltxd 0:621a9f7b5ce0 68 led3 = 0;
voltxd 0:621a9f7b5ce0 69 led4 = 0;
voltxd 0:621a9f7b5ce0 70 }
voltxd 0:621a9f7b5ce0 71
voltxd 0:621a9f7b5ce0 72 ThisThread::sleep_for(1);
voltxd 0:621a9f7b5ce0 73
voltxd 0:621a9f7b5ce0 74 }
voltxd 0:621a9f7b5ce0 75 }