Mac Lobdell
/
FXOS8700CQ_Int_example
example for forked FXOS8700CQ library that enables motion detection interrupts
Revision 0:2def406689b4, committed 2016-01-10
- Comitter:
- maclobdell
- Date:
- Sun Jan 10 21:21:32 2016 +0000
- Commit message:
- initial;
Changed in this revision
diff -r 000000000000 -r 2def406689b4 FXOS8700CQ.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FXOS8700CQ.lib Sun Jan 10 21:21:32 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/maclobdell/code/FXOS8700CQ/#7bdb0d5e5287
diff -r 000000000000 -r 2def406689b4 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Jan 10 21:21:32 2016 +0000 @@ -0,0 +1,46 @@ +#include "mbed.h" +#include "FXOS8700CQ.h" + +DigitalOut led(LED_RED); +InterruptIn accel_int_pin(PTC13); //FRDM-K64F +Serial pc(USBTX, USBRX); +FXOS8700CQ fxos(PTE25, PTE24, FXOS8700CQ_SLAVE_ADDR1); //FRDM-K64F + +uint8_t motion_detected; + +void accel_interrupt(void) +{ + led = 0; //turn led on + motion_detected = 1; + fxos.clear_int(); +} + +int main() +{ + pc.baud(9600); + + pc.printf("ready to rock!\n"); + + motion_detected = 0; + accel_int_pin.fall(&accel_interrupt); + accel_int_pin.mode(PullUp); + + led = 1; //turn led off + + fxos.config_int(); //enabled interrupts from accelerometer + fxos.config_feature(); //turn on motion detection + fxos.enable(); //enable accelerometer + + while (true) { + + if(motion_detected == 1) + { + wait(1); + + led = 1; //turn led off + motion_detected = 0; + + sleep(); + } + } +}
diff -r 000000000000 -r 2def406689b4 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Jan 10 21:21:32 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c \ No newline at end of file