Add code to the idle hook to test low power mode operation.

This commit is contained in:
Richard Barry 2008-10-19 18:51:16 +00:00
parent 0463a4814b
commit 549dcfa148
3 changed files with 25 additions and 5 deletions

View file

@ -132,6 +132,9 @@ static portSHORT prvCheckOtherTasksAreStillRunning( void );
*/
static void prvSetupHardware( void );
/* Used to detect the idle hook function stalling. */
static volatile unsigned portLONG ulIdleLoops = 0UL;
/*-----------------------------------------------------------*/
/*
@ -201,6 +204,7 @@ portTickType xDelayPeriod = mainNO_ERROR_CHECK_DELAY;
static portSHORT prvCheckOtherTasksAreStillRunning( void )
{
static portSHORT sNoErrorFound = pdTRUE;
static unsigned portLONG ulLastIdleLoops = 0UL;
/* The demo tasks maintain a count that increments every cycle of the task
provided that the task has never encountered an error. This function
@ -223,6 +227,13 @@ static portSHORT sNoErrorFound = pdTRUE;
{
sNoErrorFound = pdFALSE;
}
if( ulLastIdleLoops == ulIdleLoops )
{
sNoErrorFound = pdFALSE;
}
ulLastIdleLoops = ulIdleLoops;
return sNoErrorFound;
}
@ -251,6 +262,15 @@ static void prvSetupHardware( void )
}
/*-----------------------------------------------------------*/
void vApplicationIdleHook( void );
void vApplicationIdleHook( void )
{
/* Simple put the CPU into lowpower mode. */
_BIS_SR( LPM3_bits );
ulIdleLoops++;
}
/*-----------------------------------------------------------*/