[SOLVED] Useful timeout

Firmware/software/electronics/mechanics
Post Reply
Mitteau
Expert
Posts: 248
Joined: Fri Jan 29, 2016 6:00 am

[SOLVED] Useful timeout

Post by Mitteau »

Hi
To save battery, I restored the STM32 shut down timeout. I put 2 minutes down to it.
But for development needs, I installed a parameter called pm.timeOutSystem to control this timeout. If false, there is no time out. Default value is true.
My cf is cf2.
Here is the code:
In hal/src/pm_f405.c, lines 130..., the function 'pmSystemShutdown' becomes:
////////////////////
/**
* Shutdown system
*/
void pmSystemShutdown(void)
{
//#ifdef ACTIVATE_AUTO_SHUTDOWN
SyslinkPacket slp;
slp.type = SYSLINK_PM_ONOFF_SWITCHOFF;
slp.length = 0;
syslinkSendPacket(&slp);
//#endif
}
////////////////////
and, (line 374 +-)
////////////////////
if ((commanderGetInactivityTime() > PM_SYSTEM_SHUTDOWN_TIMEOUT) && systemStop())
////////////////////

In modules/src/system.c, you should add line 70:
////////////////////
static bool timeOutSys = true;
////////////////////
at the end of the code (around line 270):
////////////////////
bool systemStop(void)
{
return timeOutSys;
}
////////////////////
and, finally, in parameters zone
////////////////////
PARAM_GROUP_START(pm)
PARAM_ADD(PARAM_UINT8, timeOutSystem, &timeOutSys)
PARAM_GROUP_STOP(pm)
////////////////////

To insure communication between system.c and pm...c, add to modules/src/system.h the line "bool systemStop(void);"

It's really simple...
Yours
Jean-Claude
Post Reply