Farrukh Hussain
/
stm32f407
simple stm32f407 discovery board mbed demo
explanation here https://youtu.be/S4V5B7kTqII
Revision 0:4650fee31cf1, committed 2018-01-17
- Comitter:
- programmer5
- Date:
- Wed Jan 17 17:17:29 2018 +0000
- Commit message:
- first commit of stm32f407 discovery kit MBED demo
Changed in this revision
diff -r 000000000000 -r 4650fee31cf1 LIS3DSH.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LIS3DSH.lib Wed Jan 17 17:17:29 2018 +0000 @@ -0,0 +1,1 @@ +http://os.mbed.com/users/grantphillips/code/LIS3DSH/#e6a312714223
diff -r 000000000000 -r 4650fee31cf1 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Jan 17 17:17:29 2018 +0000 @@ -0,0 +1,52 @@ +#include "mbed.h" +#include "LIS3DSH.h" +DigitalOut myledG(PD_12); +DigitalOut myledO(PD_13); +DigitalOut myledR(PD_14); +DigitalOut myledB(PD_15); +InterruptIn button(PA_0); +Serial uart(PC_6,PC_7); + +LIS3DSH acc(PA_7, PA_6, PA_5, PE_3); + // mosi, miso, clk , cs + +char buttonDetectFlag=0; +void buttonISr(){ + buttonDetectFlag=1; + } +int main() { + uart.baud(9600); + button.fall(&buttonISr); + int16_t X, Y, Z; //signed integer variables for raw X,Y,Z values + float roll, pitch; //float variables for angles + + if(acc.Detect() != 1) { + uart.printf("LIS3DSH Acceleromoter not detected!\n"); + while(1){ }; + } + + while(1) { + wait(0.5); + static char counter=0; + acc.ReadData(&X, &Y, &Z); //read X, Y, Z values + acc.ReadAngles(&roll, &pitch); //read roll and pitch angles + uart.printf("X: %d Y: %d Z: %d\n", X, Y, Z); + uart.printf("Roll: %f Pitch: %f\n", roll, pitch); + + if(buttonDetectFlag) + { + buttonDetectFlag=0; + if(counter==0) + myledG=!myledG; + else if(counter==1) + myledO=!myledO; + else if(counter==2) + myledR=!myledR; + else if(counter==3) + myledB=!myledB; + counter++; + if(counter>=4) + counter=0; + } + } +}
diff -r 000000000000 -r 4650fee31cf1 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jan 17 17:17:29 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7130f322cb7e \ No newline at end of file