
1st
Dependencies: BSP_B-L475E-IOT01
Diff: main.cpp
- Revision:
- 0:621a9f7b5ce0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Dec 04 07:41:12 2020 +0000 @@ -0,0 +1,75 @@ +#include "mbed.h" + +// Sensors drivers present in the BSP library +#include "stm32l475e_iot01_tsensor.h" +#include "stm32l475e_iot01_hsensor.h" +#include "stm32l475e_iot01_psensor.h" +#include "stm32l475e_iot01_magneto.h" +#include "stm32l475e_iot01_gyro.h" +#include "stm32l475e_iot01_accelero.h" + +#include <math.h> + +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); + +DigitalIn userButton(USER_BUTTON, PullUp); + +int main() +{ + float sensor_value = 0; + int16_t pDataXYZ[3] = {0}; + float pGyroDataXYZ[3] = {0}; + + printf("Start sensor init\r\n"); + + BSP_TSENSOR_Init(); + BSP_HSENSOR_Init(); + BSP_PSENSOR_Init(); + + BSP_MAGNETO_Init(); + BSP_GYRO_Init(); + BSP_ACCELERO_Init(); + + led2 = 1; + led3 = 0; + led4 = 0; + + while(1) { + printf("\r\nNew loop, LED1 should blink during sensor read\r\n"); + + if (!userButton.read()) + { + if (!led2.read() && !led3.read() && !led4.read()) + { + led2 = 1; + } + else if (led2.read() && !led3.read() && !led4.read()) + { + led2 = 0; + led3 = 1; + } + else if (!led2.read() && led3.read() && !led4.read()) + { + led3 = 0; + led4 = 1; + } + else + { + led4 = 0; + led2 = 1; + } + } + else + { + led2 = 0; + led3 = 0; + led4 = 0; + } + + ThisThread::sleep_for(1); + + } +}