1st

Dependencies:   BSP_B-L475E-IOT01

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

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 #include <math.h>
00012 
00013 DigitalOut led1(LED1);
00014 DigitalOut led2(LED2);
00015 DigitalOut led3(LED3);
00016 DigitalOut led4(LED4);
00017 
00018 DigitalIn userButton(USER_BUTTON, PullUp);
00019 
00020 int main()
00021 {
00022     float sensor_value = 0;
00023     int16_t pDataXYZ[3] = {0};
00024     float pGyroDataXYZ[3] = {0};
00025 
00026     printf("Start sensor init\r\n");
00027 
00028     BSP_TSENSOR_Init();
00029     BSP_HSENSOR_Init();
00030     BSP_PSENSOR_Init();
00031 
00032     BSP_MAGNETO_Init();
00033     BSP_GYRO_Init();
00034     BSP_ACCELERO_Init();
00035     
00036     led2 = 1;
00037     led3 = 0;
00038     led4 = 0;
00039 
00040     while(1) {
00041         printf("\r\nNew loop, LED1 should blink during sensor read\r\n");
00042         
00043         if (!userButton.read())
00044         {
00045             if (!led2.read() && !led3.read() && !led4.read())
00046             {
00047                 led2 = 1;
00048             }
00049             else if (led2.read() && !led3.read() && !led4.read())
00050             {
00051                 led2 = 0;
00052                 led3 = 1;
00053             }
00054             else if (!led2.read() && led3.read() && !led4.read())
00055             {
00056                 led3 = 0;
00057                 led4 = 1;
00058             }
00059             else 
00060             {
00061                 led4 = 0;
00062                 led2 = 1;
00063             }
00064         }
00065         else
00066         {
00067             led2 = 0;
00068             led3 = 0;
00069             led4 = 0;
00070         }
00071 
00072         ThisThread::sleep_for(1);
00073 
00074     }
00075 }