]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/portable/GCC/ARM_CM33_NTZ/non_secure/port.c
Add "is inside interrupt" function to MPU ports.
[freertos] / FreeRTOS / Source / portable / GCC / ARM_CM33_NTZ / non_secure / port.c
index b0394fb43de7c013d8a456119c87db5021a8cba1..6ffab561ff8ea320abbb1c3839b38e2cc4e649e7 100644 (file)
 #define portNO_SECURE_CONTEXT                          0\r
 /*-----------------------------------------------------------*/\r
 \r
-/**\r
- * @brief Setup the timer to generate the tick interrupts.\r
- */\r
-static void prvSetupTimerInterrupt( void ) PRIVILEGED_FUNCTION;\r
-\r
 /**\r
  * @brief Used to catch tasks that attempt to return from their implementing\r
  * function.\r
@@ -282,6 +277,22 @@ static void prvTaskExitError( void );
        static void prvSetupFPU( void ) PRIVILEGED_FUNCTION;\r
 #endif /* configENABLE_FPU */\r
 \r
+/**\r
+ * @brief Setup the timer to generate the tick interrupts.\r
+ *\r
+ * The implementation in this file is weak to allow application writers to\r
+ * change the timer used to generate the tick interrupt.\r
+ */\r
+void vPortSetupTimerInterrupt( void ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * @brief Checks whether the current execution context is interrupt.\r
+ *\r
+ * @return pdTRUE if the current execution context is interrupt, pdFALSE\r
+ * otherwise.\r
+ */\r
+BaseType_t xPortIsInsideInterrupt( void );\r
+\r
 /**\r
  * @brief Yield the processor.\r
  */\r
@@ -323,7 +334,7 @@ static volatile uint32_t ulCriticalNesting = 0xaaaaaaaaUL;
 #endif /* configENABLE_TRUSTZONE */\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvSetupTimerInterrupt( void ) /* PRIVILEGED_FUNCTION */\r
+__attribute__(( weak )) void vPortSetupTimerInterrupt( void ) /* PRIVILEGED_FUNCTION */\r
 {\r
        /* Stop and reset the SysTick. */\r
        *( portNVIC_SYSTICK_CTRL ) = 0UL;\r
@@ -773,7 +784,7 @@ BaseType_t xPortStartScheduler( void ) /* PRIVILEGED_FUNCTION */
 \r
        /* Start the timer that generates the tick ISR. Interrupts are disabled\r
         * here already. */\r
-       prvSetupTimerInterrupt();\r
+       vPortSetupTimerInterrupt();\r
 \r
        /* Initialize the critical nesting count ready for the first task. */\r
        ulCriticalNesting = 0;\r
@@ -897,3 +908,26 @@ void vPortEndScheduler( void ) /* PRIVILEGED_FUNCTION */
        }\r
 #endif /* configENABLE_MPU */\r
 /*-----------------------------------------------------------*/\r
+\r
+BaseType_t xPortIsInsideInterrupt( void )\r
+{\r
+uint32_t ulCurrentInterrupt;\r
+BaseType_t xReturn;\r
+\r
+       /* Obtain the number of the currently executing interrupt. Interrupt Program\r
+        * Status Register (IPSR) holds the exception number of the currently-executing\r
+        * exception or zero for Thread mode.*/\r
+       __asm volatile( "mrs %0, ipsr" : "=r"( ulCurrentInterrupt ) :: "memory" );\r
+\r
+       if( ulCurrentInterrupt == 0 )\r
+       {\r
+               xReturn = pdFALSE;\r
+       }\r
+       else\r
+       {\r
+               xReturn = pdTRUE;\r
+       }\r
+\r
+       return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/
\ No newline at end of file