]> git.sur5r.net Git - freertos/commitdiff
Replace the static prvSetupTimerInterrupt() function in the Cortex-M port layers...
authorrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 30 Dec 2019 21:16:09 +0000 (21:16 +0000)
committerrtel <rtel@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 30 Dec 2019 21:16:09 +0000 (21:16 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2779 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Source/portable/GCC/ARM_CM0/port.c
FreeRTOS/Source/portable/IAR/ARM_CM0/port.c
FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c
FreeRTOS/Source/portable/RVDS/ARM_CM3/port.c
FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c
FreeRTOS/Source/portable/RVDS/ARM_CM7/r0p1/port.c

index 18a668b9b64c57dfa18bd2da429dd75a8300df98..15a5795efc2eca81852d56690c9052451f254fff 100644 (file)
@@ -71,9 +71,11 @@ debugger. */
 #endif\r
 \r
 /*\r
- * Setup the timer to generate the tick interrupts.\r
+ * Setup the timer to generate the tick interrupts.  The implementation in this\r
+ * file is weak to allow application writers to change the timer used to\r
+ * generate the tick interrupt.\r
  */\r
-static void prvSetupTimerInterrupt( void );\r
+void vPortSetupTimerInterrupt( void );\r
 \r
 /*\r
  * Exception handlers.\r
@@ -217,7 +219,7 @@ BaseType_t xPortStartScheduler( void )
 \r
        /* Start the timer that generates the tick ISR.  Interrupts are disabled\r
        here already. */\r
-       prvSetupTimerInterrupt();\r
+       vPortSetupTimerInterrupt();\r
 \r
        /* Initialise the critical nesting count ready for the first task. */\r
        uxCriticalNesting = 0;\r
@@ -370,7 +372,7 @@ uint32_t ulPreviousMask;
  * Setup the systick timer to generate the tick interrupts at the required\r
  * frequency.\r
  */\r
-void prvSetupTimerInterrupt( void )\r
+__attribute__(( weak )) void vPortSetupTimerInterrupt( void )\r
 {\r
        /* Calculate the constants required to configure the tick interrupt. */\r
        #if( configUSE_TICKLESS_IDLE == 1 )\r
index 3dd08209d07ad4a5dd67f79b90c953d1e8507824..84f1e66e06cf04cd2ea8778efd4a7b93a100a5a7 100644 (file)
@@ -92,9 +92,11 @@ power functionality only. */
 #endif /* configUSE_TICKLESS_IDLE */\r
 \r
 /*\r
- * Setup the timer to generate the tick interrupts.\r
+ * Setup the timer to generate the tick interrupts.  The implementation in this\r
+ * file is weak to allow application writers to change the timer used to\r
+ * generate the tick interrupt.\r
  */\r
-static void prvSetupTimerInterrupt( void );\r
+void vPortSetupTimerInterrupt( void );\r
 \r
 /*\r
  * Exception handlers.\r
@@ -159,7 +161,7 @@ BaseType_t xPortStartScheduler( void )
 \r
        /* Start the timer that generates the tick ISR.  Interrupts are disabled\r
        here already. */\r
-       prvSetupTimerInterrupt();\r
+       vPortSetupTimerInterrupt();\r
 \r
        /* Initialise the critical nesting count ready for the first task. */\r
        uxCriticalNesting = 0;\r
@@ -233,7 +235,7 @@ uint32_t ulPreviousMask;
  * Setup the systick timer to generate the tick interrupts at the required\r
  * frequency.\r
  */\r
-static void prvSetupTimerInterrupt( void )\r
+__weak void vPortSetupTimerInterrupt( void )\r
 {\r
        /* Calculate the constants required to configure the tick interrupt. */\r
        #if( configUSE_TICKLESS_IDLE == 1 )\r
@@ -243,7 +245,7 @@ static void prvSetupTimerInterrupt( void )
                ulStoppedTimerCompensation = portMISSED_COUNTS_FACTOR;\r
        }\r
        #endif /* configUSE_TICKLESS_IDLE */\r
-        \r
+\r
        /* Stop and reset the SysTick. */\r
        portNVIC_SYSTICK_CTRL_REG = 0UL;\r
        portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
@@ -349,12 +351,12 @@ TickType_t xModifiableIdleTime;
                __DSB();\r
                __ISB();\r
 \r
-               /* Disable the SysTick clock without reading the \r
+               /* Disable the SysTick clock without reading the\r
                portNVIC_SYSTICK_CTRL_REG register to ensure the\r
-               portNVIC_SYSTICK_COUNT_FLAG_BIT is not cleared if it is set.  Again, \r
-               the time the SysTick is stopped for is accounted for as best it can \r
-               be, but using the tickless mode will inevitably result in some tiny \r
-               drift of the time maintained by the kernel with respect to calendar \r
+               portNVIC_SYSTICK_COUNT_FLAG_BIT is not cleared if it is set.  Again,\r
+               the time the SysTick is stopped for is accounted for as best it can\r
+               be, but using the tickless mode will inevitably result in some tiny\r
+               drift of the time maintained by the kernel with respect to calendar\r
                time*/\r
                portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT );\r
 \r
index 8282984b507a06e5c83bf6c7f318c36550d0126f..be659fd4f49b3a11bae389cd9c0e16783120d12c 100644 (file)
 /* Constants used with memory barrier intrinsics. */\r
 #define portSY_FULL_READ_WRITE         ( 15 )\r
 \r
+/* Legacy macro for backward compatibility only.  This macro used to be used to\r
+replace the function that configures the clock used to generate the tick\r
+interrupt (prvSetupTimerInterrupt()), but now the function is declared weak so\r
+the application writer can override it by simply defining a function of the\r
+same name (vApplicationSetupTickInterrupt()). */\r
+#ifndef configOVERRIDE_DEFAULT_TICK_CONFIGURATION\r
+       #define configOVERRIDE_DEFAULT_TICK_CONFIGURATION 0\r
+#endif\r
+\r
 /* Each task maintains its own interrupt status in the critical nesting\r
 variable. */\r
 static UBaseType_t uxCriticalNesting = 0xaaaaaaaa;\r
@@ -87,9 +96,11 @@ static UBaseType_t uxCriticalNesting = 0xaaaaaaaa;
 #endif /* configUSE_TICKLESS_IDLE */\r
 \r
 /*\r
- * Setup the timer to generate the tick interrupts.\r
+ * Setup the timer to generate the tick interrupts.  The implementation in this\r
+ * file is weak to allow application writers to change the timer used to\r
+ * generate the tick interrupt.\r
  */\r
-static void prvSetupTimerInterrupt( void );\r
+void vPortSetupTimerInterrupt( void );\r
 \r
 /*\r
  * Exception handlers.\r
@@ -192,7 +203,7 @@ BaseType_t xPortStartScheduler( void )
 \r
        /* Start the timer that generates the tick ISR.  Interrupts are disabled\r
        here already. */\r
-       prvSetupTimerInterrupt();\r
+       vPortSetupTimerInterrupt();\r
 \r
        /* Initialise the critical nesting count ready for the first task. */\r
        uxCriticalNesting = 0;\r
@@ -327,23 +338,27 @@ uint32_t ulPreviousMask;
  * Setup the systick timer to generate the tick interrupts at the required\r
  * frequency.\r
  */\r
-void prvSetupTimerInterrupt( void )\r
-{\r
-       /* Calculate the constants required to configure the tick interrupt. */\r
-       #if( configUSE_TICKLESS_IDLE == 1 )\r
-               ulTimerCountsForOneTick = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ );\r
-               xMaximumPossibleSuppressedTicks = portMAX_24_BIT_NUMBER / ulTimerCountsForOneTick;\r
-               ulStoppedTimerCompensation = portMISSED_COUNTS_FACTOR;\r
-       #endif /* configUSE_TICKLESS_IDLE */\r
-\r
-       /* Stop and reset the SysTick. */\r
-       portNVIC_SYSTICK_CTRL_REG = 0UL;\r
-       portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
-\r
-       /* Configure SysTick to interrupt at the requested rate. */\r
-       portNVIC_SYSTICK_LOAD_REG = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
-       portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT;\r
-}\r
+#if( configOVERRIDE_DEFAULT_TICK_CONFIGURATION == 0 )\r
+\r
+       __weak void vPortSetupTimerInterrupt( void )\r
+       {\r
+               /* Calculate the constants required to configure the tick interrupt. */\r
+               #if( configUSE_TICKLESS_IDLE == 1 )\r
+                       ulTimerCountsForOneTick = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ );\r
+                       xMaximumPossibleSuppressedTicks = portMAX_24_BIT_NUMBER / ulTimerCountsForOneTick;\r
+                       ulStoppedTimerCompensation = portMISSED_COUNTS_FACTOR;\r
+               #endif /* configUSE_TICKLESS_IDLE */\r
+\r
+               /* Stop and reset the SysTick. */\r
+               portNVIC_SYSTICK_CTRL_REG = 0UL;\r
+               portNVIC_SYSTICK_CURRENT_VALUE_REG = 0UL;\r
+\r
+               /* Configure SysTick to interrupt at the requested rate. */\r
+               portNVIC_SYSTICK_LOAD_REG = ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) - 1UL;\r
+               portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT;\r
+       }\r
+\r
+#endif /* configOVERRIDE_DEFAULT_TICK_CONFIGURATION */\r
 /*-----------------------------------------------------------*/\r
 \r
 #if( configUSE_TICKLESS_IDLE == 1 )\r
index 76dcb57272bc1b09f89cfb0ecff435670039535f..6e4e77f977cd3e8f7b5000e15a7e49927018c7ac 100644 (file)
        #define portNVIC_SYSTICK_CLK_BIT        ( 0 )\r
 #endif\r
 \r
-/* The __weak attribute does not work as you might expect with the Keil tools\r
-so the configOVERRIDE_DEFAULT_TICK_CONFIGURATION constant must be set to 1 if\r
-the application writer wants to provide their own implementation of\r
-vPortSetupTimerInterrupt().  Ensure configOVERRIDE_DEFAULT_TICK_CONFIGURATION\r
-is defined. */\r
+/* Legacy macro for backward compatibility only.  This macro used to be used to\r
+replace the function that configures the clock used to generate the tick\r
+interrupt (prvSetupTimerInterrupt()), but now the function is declared weak so\r
+the application writer can override it by simply defining a function of the\r
+same name (vApplicationSetupTickInterrupt()). */\r
 #ifndef configOVERRIDE_DEFAULT_TICK_CONFIGURATION\r
        #define configOVERRIDE_DEFAULT_TICK_CONFIGURATION 0\r
 #endif\r
@@ -523,13 +523,13 @@ void xPortSysTickHandler( void )
                        __disable_irq();\r
                        __dsb( portSY_FULL_READ_WRITE );\r
                        __isb( portSY_FULL_READ_WRITE );\r
-                       \r
-                       /* Disable the SysTick clock without reading the \r
+\r
+                       /* Disable the SysTick clock without reading the\r
                        portNVIC_SYSTICK_CTRL_REG register to ensure the\r
-                       portNVIC_SYSTICK_COUNT_FLAG_BIT is not cleared if it is set.  Again, \r
-                       the time the SysTick is stopped for is accounted for as best it can \r
-                       be, but using the tickless mode will inevitably result in some tiny \r
-                       drift of the time maintained by the kernel with respect to calendar \r
+                       portNVIC_SYSTICK_COUNT_FLAG_BIT is not cleared if it is set.  Again,\r
+                       the time the SysTick is stopped for is accounted for as best it can\r
+                       be, but using the tickless mode will inevitably result in some tiny\r
+                       drift of the time maintained by the kernel with respect to calendar\r
                        time*/\r
                        portNVIC_SYSTICK_CTRL_REG = ( portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT );\r
 \r
index 6a9cbbf2515c99ade5e929a7d1695c690b089ada..99ffeaa39680156c11f88db2966a66c2e7e660f9 100644 (file)
        #define portNVIC_SYSTICK_CLK_BIT        ( 0 )\r
 #endif\r
 \r
-/* The __weak attribute does not work as you might expect with the Keil tools\r
-so the configOVERRIDE_DEFAULT_TICK_CONFIGURATION constant must be set to 1 if\r
-the application writer wants to provide their own implementation of\r
-vPortSetupTimerInterrupt().  Ensure configOVERRIDE_DEFAULT_TICK_CONFIGURATION\r
-is defined. */\r
+/* Legacy macro for backward compatibility only.  This macro used to be used to\r
+replace the function that configures the clock used to generate the tick\r
+interrupt (prvSetupTimerInterrupt()), but now the function is declared weak so\r
+the application writer can override it by simply defining a function of the\r
+same name (vApplicationSetupTickInterrupt()). */\r
 #ifndef configOVERRIDE_DEFAULT_TICK_CONFIGURATION\r
        #define configOVERRIDE_DEFAULT_TICK_CONFIGURATION 0\r
 #endif\r
index 967f5f10e25db16ad6e4cade9fe1c95ce851cffe..fa63025a2dbd1b15529cf6b39b2c935a6ac3f9d3 100644 (file)
@@ -679,7 +679,7 @@ void xPortSysTickHandler( void )
  */\r
 #if( configOVERRIDE_DEFAULT_TICK_CONFIGURATION == 0 )\r
 \r
-       void vPortSetupTimerInterrupt( void )\r
+       __weak void vPortSetupTimerInterrupt( void )\r
        {\r
                /* Calculate the constants required to configure the tick interrupt. */\r
                #if( configUSE_TICKLESS_IDLE == 1 )\r