init
Dependencies: aconno_I2C Lis2dh12 WatchdogTimer
Diff: main.cpp
- Revision:
- 10:c8798fd9773b
- Parent:
- 9:b0a1535b8ef2
- Child:
- 11:60eb0ff945f2
--- a/main.cpp Sat Dec 15 13:45:28 2018 +0000 +++ b/main.cpp Sat Dec 15 14:33:59 2018 +0000 @@ -16,6 +16,7 @@ bool requireSoftReset = false; bool motionFlagTriggered = false; bool debugLED = false; +bool needToConfigureLis3dh = false; //------------------------------------------------------------------------------ //RETAINED NOINIT RAM VARS @@ -34,6 +35,7 @@ static char RET_buffer[64] __attribute__((section("noinit"),zero_init)); //MOTION SETTINGS +static bool RET_impactTriggered __attribute__((section("noinit"),zero_init)); static bool RET_motionTriggered __attribute__((section("noinit"),zero_init)); static time_t RET_motionStartTime __attribute__((section("noinit"),zero_init)); static time_t RET_motionStopTime __attribute__((section("noinit"),zero_init)); @@ -150,6 +152,8 @@ RET_eventTime_wakeFromDormant = 0; RET_motionPendingOffState = 0; RET_motionPendingOnState = 0; + RET_motionTriggered = 0; + RET_impactTriggered = 0; RET_motionState = 0; RET_motionStartTime = 0; RET_motionStopTime = 0; @@ -160,6 +164,9 @@ RET_buttonPressCount = 0; RET_buttonHoldTime = 0; + //CONFIGURE ACCELL DEFAULT + lis3dh_configureForSleep(10,127); + //SET IDENTIFIER //uint32_t nv_value = 12345678; //int rc = nvstore.set(NV_IDENTIFIER, sizeof(nv_value), &nv_value); @@ -195,6 +202,7 @@ if (lis3dh_int2) { if (debugLED) LED1blink(2,100); RET_motionTriggered = true; + needToConfigureLis3dh = true; //interrupt has fire so need to clear it if (!RET_motionPendingOnState) { RET_motionPendingOnState = true; RET_motionPendingOffState = false; @@ -329,7 +337,9 @@ mainStateEngine(); //PRE-SLEEP ACTIONS - lis3dh_configureForSleep(10,127); + if (needToConfigureLis3dh) { //ONLY RESET ACCELL IF WE NEED TO + lis3dh_configureForSleep(10,127); + } RET_coldBoot = 0;