]> git.sur5r.net Git - freertos/commitdiff
Replace the function that returns the current run time counter value with a macro...
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 6 Jan 2011 10:06:09 +0000 (10:06 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Thu, 6 Jan 2011 10:06:09 +0000 (10:06 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1229 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Demo/MSP430X_MSP430F5438_CCS4/Demo_Source/FreeRTOSConfig.h
Demo/MSP430X_MSP430F5438_CCS4/Demo_Source/RunTimeStatsConfig.c

index aaa0c5a9b14cedc54807bb9e59d1055ecd9a9cbb..6339845265d427f14670781232d9d830fa42295e 100644 (file)
@@ -57,7 +57,7 @@
  * executed from within CCS4!  Once it has been executed, re-open or refresh \r
  * the CCS4 project and remove the #error line below.\r
  */\r
-#error Ensure CreateProjectDirectoryStructure.bat has been executed before building.  See comment immediately above.\r
+//#error Ensure CreateProjectDirectoryStructure.bat has been executed before building.  See comment immediately above.\r
 \r
 \r
 #ifndef FREERTOS_CONFIG_H\r
@@ -122,12 +122,38 @@ vApplicationSetupTimerInterrupt() generates the tick from timer A0, so in this
 case configTICK_VECTOR is set to TIMER0_A0_VECTOR. */\r
 #define configTICK_VECTOR                              TIMER0_A0_VECTOR\r
 \r
-extern void vConfigureTimerForRunTimeStats( void );\r
-extern unsigned long ulGetRunTimeStatsTime( void );\r
-extern volatile unsigned long ulStatsOverflowCount;\r
+       extern void vConfigureTimerForRunTimeStats( void );\r
+       extern volatile unsigned long ulStatsOverflowCount;\r
 \r
+/* Configure a 16 bit timer to generate the time base for the run time stats.\r
+The timer is configured to interrupt each time it overflows so a count of\r
+overflows can be kept - that way a 32 bit time value can be constructed from\r
+the timers current count value and the number of overflows. */\r
 #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()\r
-#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeStatsTime()\r
-\r
+       \r
+/* Construct a 32 bit time value for use as the run time stats time base.  This\r
+comes from the current value of a 16 bit timer combined with the number of times\r
+the timer has overflowed. */\r
+#define portALT_GET_RUN_TIME_COUNTER_VALUE( ulCountValue )                                             \\r
+       {                                                                                                                                                       \\r
+               /* Stop the counter counting temporarily. */                                                    \\r
+               TA1CTL &= ~MC__CONTINOUS;                                                                                               \\r
+                                                                                                                                                               \\r
+               /* Check to see if any counter overflow interrupts are pending. */              \\r
+               if( ( TA1CTL & TAIFG ) != 0 )                                                                                   \\r
+               {                                                                                                                                               \\r
+                       /* An overflow has occurred but not yet been processed. */                      \\r
+                       ulStatsOverflowCount++;                                                                                         \\r
+                                                                                                                                                               \\r
+                       /* Clear the interrupt. */                                                                                      \\r
+                       TA1CTL &= ~TAIFG;                                                                                                       \\r
+               }                                                                                                                                               \\r
+                                                                                                                                                               \\r
+               /* Generate a 32 bit counter value by combinging the current peripheral \\r
+               counter value with the number of overflows. */                                                  \\r
+               ulCountValue = ( ulStatsOverflowCount << 16UL );                                                \\r
+               ulCountValue |= ( unsigned long ) TA1R;                                                                 \\r
+               TA1CTL |= MC__CONTINOUS;                                                                                                \\r
+       }\r
 #endif /* FREERTOS_CONFIG_H */\r
 \r
index e532d222d07b3a83d1038c97e3a053e8d7422d41..17b0cacb0eef2e3c012e67164a2cdd79c0835d6d 100644 (file)
@@ -102,19 +102,3 @@ interrupt void prvRunTimeStatsOverflowISR( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-unsigned long ulGetRunTimeStatsTime( void )\r
-{\r
-unsigned long ulReturn;\r
-unsigned short usCounterSnapshot;\r
-\r
-       TA1CTL &= ~MC__CONTINOUS;\r
-       _nop();\r
-       _nop();\r
-       ulReturn = ( ulStatsOverflowCount << 16UL );\r
-       usCounterSnapshot = TA1R;\r
-       ulReturn |= ( unsigned long ) usCounterSnapshot;\r
-       TA1CTL |= MC__CONTINOUS;\r
-       \r
-       return ulReturn;\r
-}\r
-/*-----------------------------------------------------------*/\r