From 0439debf8bd10935e4960ba3e70035d0c8c22ebe Mon Sep 17 00:00:00 2001 From: richardbarry Date: Sun, 19 Oct 2008 18:51:16 +0000 Subject: [PATCH] Add code to the idle hook to test low power mode operation. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@505 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Demo/msp430_GCC/FreeRTOSConfig.h | 2 +- Demo/msp430_GCC/main.c | 20 ++++++++++++++++++++ Demo/msp430_GCC/serial/serial.c | 8 ++++---- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Demo/msp430_GCC/FreeRTOSConfig.h b/Demo/msp430_GCC/FreeRTOSConfig.h index 048aaaea3..aa004a230 100644 --- a/Demo/msp430_GCC/FreeRTOSConfig.h +++ b/Demo/msp430_GCC/FreeRTOSConfig.h @@ -65,7 +65,7 @@ *----------------------------------------------------------*/ #define configUSE_PREEMPTION 1 -#define configUSE_IDLE_HOOK 0 +#define configUSE_IDLE_HOOK 1 #define configUSE_TICK_HOOK 0 #define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 7995392 ) /* Clock setup from main.c in the demo application. */ #define configTICK_RATE_HZ ( ( portTickType ) 1000 ) diff --git a/Demo/msp430_GCC/main.c b/Demo/msp430_GCC/main.c index 6cd95e0a3..0b106ea49 100644 --- a/Demo/msp430_GCC/main.c +++ b/Demo/msp430_GCC/main.c @@ -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++; +} +/*-----------------------------------------------------------*/ + diff --git a/Demo/msp430_GCC/serial/serial.c b/Demo/msp430_GCC/serial/serial.c index e78d90829..268dd5a26 100644 --- a/Demo/msp430_GCC/serial/serial.c +++ b/Demo/msp430_GCC/serial/serial.c @@ -83,8 +83,8 @@ static xQueueHandle xCharsForTx; static volatile portSHORT sTHREEmpty; /* Interrupt service routines. */ -interrupt (UART1RX_VECTOR) vRxISR( void ); -interrupt (UART1TX_VECTOR) vTxISR( void ); +interrupt (UART1RX_VECTOR) wakeup vRxISR( void ); +interrupt (UART1TX_VECTOR) wakeup vTxISR( void ); /*-----------------------------------------------------------*/ @@ -208,7 +208,7 @@ signed portBASE_TYPE xReturn; /* * UART RX interrupt service routine. */ -interrupt (UART1RX_VECTOR) vRxISR( void ) +interrupt (UART1RX_VECTOR) wakeup vRxISR( void ) { signed portCHAR cChar; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; @@ -232,7 +232,7 @@ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* * UART Tx interrupt service routine. */ -interrupt (UART1TX_VECTOR) vTxISR( void ) +interrupt (UART1TX_VECTOR) wakeup vTxISR( void ) { signed portCHAR cChar; portBASE_TYPE xTaskWoken = pdFALSE; -- 2.39.5