]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/SAM4L_low_power_tick_management.c
Update version number to V8.0.0 (without the release candidate number).
[freertos] / FreeRTOS / Demo / CORTEX_M4_ATSAM4L_Atmel_Studio / src / SAM4L_low_power_tick_management.c
index a00f30b35618784943720353ee22639b497c6bee..d43497db17a3b89331a6dde337ee9e01bba58a91 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. \r
+    FreeRTOS V8.0.0 - Copyright (C) 2014 Real Time Engineers Ltd.\r
     All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
@@ -88,7 +88,6 @@
 /* Constants required to pend a PendSV interrupt from the tick ISR if the\r
 preemptive scheduler is being used.  These are just standard bits and registers\r
 within the Cortex-M core itself. */\r
-#define portNVIC_INT_CTRL_REG  ( * ( ( volatile unsigned long * ) 0xe000ed04 ) )\r
 #define portNVIC_PENDSVSET_BIT ( 1UL << 28UL )\r
 \r
 /* The alarm used to generate interrupts in the asynchronous timer. */\r
@@ -122,7 +121,7 @@ static const uint32_t ulAlarmValueForOneTick = ( configSYSTICK_CLOCK_HZ / config
 /* Holds the maximum number of ticks that can be suppressed - which is\r
 basically how far into the future an interrupt can be generated. Set\r
 during initialisation. */\r
-static portTickType xMaximumPossibleSuppressedTicks = 0;\r
+static TickType_t xMaximumPossibleSuppressedTicks = 0;\r
 \r
 /* Flag set from the tick interrupt to allow the sleep processing to know if\r
 sleep mode was exited because of an AST interrupt or a different interrupt. */\r
@@ -248,14 +247,14 @@ static void prvEnableAST( void )
 /*-----------------------------------------------------------*/\r
 \r
 /* Override the default definition of vPortSuppressTicksAndSleep() that is weakly\r
-defined in the FreeRTOS Cortex-M3 port layet with a version that manages the\r
+defined in the FreeRTOS Cortex-M3 port layer 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
+void vPortSuppressTicksAndSleep( TickType_t xExpectedIdleTime )\r
 {\r
-uint32_t ulAlarmValue, ulCompleteTickPeriods;\r
+uint32_t ulAlarmValue, ulCompleteTickPeriods, ulInterruptStatus;\r
 eSleepModeStatus eSleepAction;\r
-portTickType xModifiableIdleTime;\r
+TickType_t xModifiableIdleTime;\r
 enum sleepmgr_mode xSleepMode;\r
 \r
        /* THIS FUNCTION IS CALLED WITH THE SCHEDULER SUSPENDED. */\r
@@ -284,8 +283,7 @@ enum sleepmgr_mode xSleepMode;
 \r
        /* Enter a critical section but don't use the taskENTER_CRITICAL() method as\r
        that will mask interrupts that should exit sleep mode. */\r
-       __asm volatile( "cpsid i                \n\t"\r
-                                       "dsb                    \n\t" );\r
+       ulInterruptStatus = cpu_irq_save();\r
 \r
        /* The tick flag is set to false before sleeping.  If it is true when sleep\r
        mode is exited then sleep mode was probably exited because the tick was\r
@@ -303,7 +301,7 @@ enum sleepmgr_mode xSleepMode;
 \r
                /* Re-enable interrupts - see comments above the cpsid instruction()\r
                above. */\r
-               __asm volatile( "cpsie i" );\r
+               cpu_irq_restore( ulInterruptStatus );\r
        }\r
        else\r
        {\r
@@ -345,7 +343,7 @@ enum sleepmgr_mode xSleepMode;
 \r
                /* Re-enable interrupts - see comments above the cpsid instruction()\r
                above. */\r
-               __asm volatile( "cpsie i" );\r
+               cpu_irq_restore( ulInterruptStatus );\r
 \r
                if( ulTickFlag != pdFALSE )\r
                {\r
@@ -373,6 +371,12 @@ enum sleepmgr_mode xSleepMode;
                        /* The alarm value is set to whatever fraction of a single tick\r
                        period remains. */\r
                        ulAlarmValue = ast_read_counter_value( AST ) - ( ulCompleteTickPeriods * ulAlarmValueForOneTick );\r
+                       if( ulAlarmValue == 0 )\r
+                       {\r
+                               /* There is no fraction remaining. */\r
+                               ulAlarmValue = ulAlarmValueForOneTick;\r
+                               ulCompleteTickPeriods++;\r
+                       }\r
                        ast_write_alarm0_value( AST, ulAlarmValue );\r
                }\r
 \r