Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:af093354ea03, committed 2017-11-13
- Comitter:
- radovan
- Date:
- Mon Nov 13 15:41:00 2017 +0000
- Parent:
- 0:81c077a20809
- Commit message:
- freefall-sleep
Changed in this revision
MMA8451Q.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/MMA8451Q.lib Mon Nov 06 17:46:51 2017 +0000 +++ b/MMA8451Q.lib Mon Nov 13 15:41:00 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/emilmont/code/MMA8451Q/#3224e40449d8 +https://os.mbed.com/users/radovan/code/MMA8451Q/#3224e40449d8
--- a/main.cpp Mon Nov 06 17:46:51 2017 +0000 +++ b/main.cpp Mon Nov 13 15:41:00 2017 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" #include "MMA8451Q.h" - +#include "cmsis.h" +#include "PeripheralPins.h" #if defined (TARGET_KL25Z) || defined (TARGET_KL46Z) PinName const SDA = PTE25; PinName const SCL = PTE24; @@ -19,16 +20,23 @@ MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS); Serial pc(USBTX, USBRX); - +void sleeep() +{ + SMC->PMPROT = SMC_PMPROT_AVLLS_MASK | SMC_PMPROT_ALLS_MASK | SMC_PMPROT_AVLP_MASK; + + //Normal sleep mode for ARM core: + SCB->SCR = 0; + __WFI(); +} + void intfun(){ - pc.printf("tu\n\r"); uint8_t datan[1]; acc.readRegs(0x0C,datan,1); if((datan[0]&0x04)==0x04){ acc.readRegs(0x16,datan,1); - pc.printf("fall \n\r"); - + pc.printf("fall_sleep \n\r"); + sleeep(); } } @@ -66,8 +74,8 @@ uint8_t krok7[2] = {0x2A, data[0]}; krok7[1] = data[0]; acc.writeRegs(krok7,2); - - + pc.printf("sleep \n\r"); + sleeep(); while (true) { }