From 08df0d9bbd9a00bcbdf01194eda655c794e2cbcd Mon Sep 17 00:00:00 2001 From: KeitaKashima Date: Tue, 15 Oct 2024 09:33:58 +0900 Subject: [PATCH] [Fixed the Issue] Fixed the Issue#1102 of RL78 of the Context switch issue. https://github.com/FreeRTOS/FreeRTOS-Kernel/issues/1102 --- portable/GCC/RL78/portmacro.h | 13 ++++++++++++- portable/IAR/RL78/portmacro.h | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/portable/GCC/RL78/portmacro.h b/portable/GCC/RL78/portmacro.h index a91427257b1..730cf50a3c6 100644 --- a/portable/GCC/RL78/portmacro.h +++ b/portable/GCC/RL78/portmacro.h @@ -106,7 +106,18 @@ typedef unsigned short UBaseType_t; /* Task utilities. */ #define portYIELD() __asm volatile ( "BRK" ) -#define portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) do { if( xHigherPriorityTaskWoken ) vTaskSwitchContext( ); } while( 0 ) +#ifndef configREQUIRE_ASM_ISR_WRAPPER + #define configREQUIRE_ASM_ISR_WRAPPER 1 +#endif +#if( configREQUIRE_ASM_ISR_WRAPPER == 1 ) + /* You must implement an assembly ISR wrapper (see the below for details) if you need an ISR to cause a context switch. + * https://www.freertos.org/Documentation/02-Kernel/03-Supported-devices/04-Demos/Renesas/RTOS_RL78_IAR_Demos#writing-interrupt-service-routines */ + #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) do { if( xHigherPriorityTaskWoken != pdFALSE ) vTaskSwitchContext(); } while( 0 ) +#else + /* You must not implement an assembly ISR wrapper even if you need an ISR to cause a context switch. + * The portYIELD, which is similar to role of an assembly ISR wrapper, runs only when a context switch is required. */ + #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) do { if( xHigherPriorityTaskWoken != pdFALSE ) portYIELD(); } while( 0 ) +#endif #define portNOP() __asm volatile ( "NOP" ) /*-----------------------------------------------------------*/ diff --git a/portable/IAR/RL78/portmacro.h b/portable/IAR/RL78/portmacro.h index a52a6d273bf..544e76e9ee0 100644 --- a/portable/IAR/RL78/portmacro.h +++ b/portable/IAR/RL78/portmacro.h @@ -130,7 +130,18 @@ /* Task utilities. */ #define portNOP() __asm( "NOP" ) #define portYIELD() __asm( "BRK" ) - #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) do { if( xHigherPriorityTaskWoken ) vTaskSwitchContext( ); } while( 0 ) + #ifndef configREQUIRE_ASM_ISR_WRAPPER + #define configREQUIRE_ASM_ISR_WRAPPER 1 + #endif + #if( configREQUIRE_ASM_ISR_WRAPPER == 1 ) + /* You must implement an assembly ISR wrapper (see the below for details) if you need an ISR to cause a context switch. + * https://www.freertos.org/Documentation/02-Kernel/03-Supported-devices/04-Demos/Renesas/RTOS_RL78_IAR_Demos#writing-interrupt-service-routines */ + #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) do { if( xHigherPriorityTaskWoken != pdFALSE ) vTaskSwitchContext(); } while( 0 ) + #else + /* You must not implement an assembly ISR wrapper even if you need an ISR to cause a context switch. + * The portYIELD, which is similar to role of an assembly ISR wrapper, runs only when a context switch is required. */ + #define portYIELD_FROM_ISR( xHigherPriorityTaskWoken ) do { if( xHigherPriorityTaskWoken != pdFALSE ) portYIELD(); } while( 0 ) + #endif /*-----------------------------------------------------------*/ /* Hardware specifics. */