]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/SAM4L_low_power_tick_management.c
Tidy up the comments and use of static function prototypes in the SAM4L_low_power_tic...
[freertos] / FreeRTOS / Demo / CORTEX_M4_ATSAM4L_Atmel_Studio / src / SAM4L_low_power_tick_management.c
index b34a0f8b3741553f9c3733039e355bf80edce7fb..230f7ae5829f9d6d7c027c57da18bf52fd6f84fd 100644 (file)
@@ -116,6 +116,13 @@ within the Cortex-M core itself. */
  */\r
 void AST_ALARM_Handler(void);\r
 \r
+/* \r
+ * Functions that disable and enable the AST respectively, not returning until\r
+ * the operation is known to have taken effect.\r
+ */\r
+static void prvDisableAST( void );\r
+static void prvEnableAST( void );\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /* Calculate how many clock increments make up a single tick period. */\r
@@ -134,7 +141,7 @@ static volatile uint32_t ulTickFlag = pdFALSE;
 following variable offsets the AST counter alarm value by the number of AST\r
 counts that would typically be missed while the counter was stopped to compensate\r
 for the lost time.  _RB_ Value needs calculating correctly. */\r
-static uint32_t ulStoppedTimerCompensation = 10 / ( configCPU_CLOCK_HZ / configSYSTICK_CLOCK_HZ );\r
+static uint32_t ulStoppedTimerCompensation = 2 / ( configCPU_CLOCK_HZ / configSYSTICK_CLOCK_HZ );\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -175,8 +182,8 @@ void AST_ALARM_Handler(void)
 /*-----------------------------------------------------------*/\r
 \r
 /* Override the default definition of vPortSetupTimerInterrupt() that is weakly\r
-defined in the FreeRTOS Cortex-M3 port layer layer with a version that\r
-configures the asynchronous timer (AST) to generate the tick interrupt. */\r
+defined in the FreeRTOS Cortex-M3 port layer with a version that configures the\r
+asynchronous timer (AST) to generate the tick interrupt. */\r
 void vPortSetupTimerInterrupt( void )\r
 {\r
 struct ast_config ast_conf;\r
@@ -226,7 +233,7 @@ struct ast_config ast_conf;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void prvDisableAST( void )\r
+static void prvDisableAST( void )\r
 {\r
        while( ast_is_busy( AST ) )\r
        {\r
@@ -240,7 +247,7 @@ void prvDisableAST( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void prvEnableAST( void )\r
+static void prvEnableAST( void )\r
 {\r
        while( ast_is_busy( AST ) )\r
        {\r
@@ -255,9 +262,9 @@ void prvEnableAST( void )
 /*-----------------------------------------------------------*/\r
 \r
 /* Override the default definition of vPortSuppressTicksAndSleep() that is weakly\r
-defined in the FreeRTOS Cortex-M3 port layer layer with a version that manages\r
-the asynchronous timer (AST), as the tick is generated from the low power AST\r
-and not the SysTick as would normally be the case on a Cortex-M. */\r
+defined in the FreeRTOS Cortex-M3 port layet with a version that manages the \r
+asynchronous timer (AST), as the tick is generated from the low power AST and \r
+not the SysTick as would normally be the case on a Cortex-M. */\r
 void vPortSuppressTicksAndSleep( portTickType xExpectedIdleTime )\r
 {\r
 uint32_t ulAlarmValue, ulCompleteTickPeriods;\r
@@ -274,10 +281,8 @@ enum sleepmgr_mode xSleepMode;
        }\r
 \r
        /* Calculate the reload value required to wait xExpectedIdleTime tick\r
-       periods.  -1 is used because this code will execute part way through one of\r
-       the tick periods, and the fraction of a tick period is accounted for\r
-       later. */\r
-       ulAlarmValue = ( ulAlarmValueForOneTick * ( xExpectedIdleTime - 1UL ) );\r
+       periods. */\r
+       ulAlarmValue = ulAlarmValueForOneTick * xExpectedIdleTime;\r
        if( ulAlarmValue > ulStoppedTimerCompensation )\r
        {\r
                /* Compensate for the fact that the AST is going to be stopped\r