From 89fe045afa8024b4f6671fb1d459efb412f45520 Mon Sep 17 00:00:00 2001 From: Larry May <192939+mayl@users.noreply.github.com> Date: Tue, 6 Aug 2024 17:15:28 -0400 Subject: [PATCH] Remove hardware dependence in portmacros.h The IAR MSP430X port `#include "msp430.h"` which pulls all the hardware register definitions into anything which `#include "FreeRTOS.h"`. This removes that hardware dependency "leak" by removing the header file and re-defining the `portDISABLE_INTERRUPTS()` and `portENABLE_INTERRUPTS()` macros in terms of `__asm`. --- portable/IAR/MSP430X/port.c | 3 +++ portable/IAR/MSP430X/portmacro.h | 9 +++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/portable/IAR/MSP430X/port.c b/portable/IAR/MSP430X/port.c index a6f81580b..6c5b21c3a 100644 --- a/portable/IAR/MSP430X/port.c +++ b/portable/IAR/MSP430X/port.c @@ -30,6 +30,9 @@ #include "FreeRTOS.h" #include "task.h" +/* Hardware includes. */ +#include "msp430.h" + /*----------------------------------------------------------- * Implementation of functions defined in portable.h for the MSP430X port. *----------------------------------------------------------*/ diff --git a/portable/IAR/MSP430X/portmacro.h b/portable/IAR/MSP430X/portmacro.h index e426154e8..9d0dcc111 100644 --- a/portable/IAR/MSP430X/portmacro.h +++ b/portable/IAR/MSP430X/portmacro.h @@ -39,9 +39,6 @@ *----------------------------------------------------------- */ -/* Hardware includes. */ -#include "msp430.h" - /* Type definitions. */ #define portCHAR char #define portFLOAT float @@ -75,8 +72,8 @@ typedef unsigned short UBaseType_t; /*-----------------------------------------------------------*/ /* Interrupt control macros. */ -#define portDISABLE_INTERRUPTS() _DINT(); _NOP() -#define portENABLE_INTERRUPTS() _EINT(); _NOP() +#define portDISABLE_INTERRUPTS() __asm volatile ( "DINT\n" "NOP" ) +#define portENABLE_INTERRUPTS() __asm volatile ( "EINT\n" "NOP" ) /*-----------------------------------------------------------*/ /* Critical section control macros. */ @@ -126,7 +123,7 @@ extern void vPortYield( void ); #define portBYTE_ALIGNMENT 2 #define portSTACK_GROWTH ( -1 ) #define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ ) -#define portNOP() __no_operation() +#define portNOP() __asm volatile ( "NOP" ) /*-----------------------------------------------------------*/ /* Task function macros as described on the FreeRTOS.org WEB site. */