Skip to content

Commit 2faa8bc

Browse files
maylaggarg
andauthored
Remove hardware dependence in portmacros.h (#1112)
* 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`. * Code review suggestions Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> --------- Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com> Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com> Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
1 parent 49e8831 commit 2faa8bc

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

portable/CCS/MSP430X/port.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
*
2727
*/
2828

29+
/* Hardware includes. */
30+
#include "msp430.h"
31+
2932
/* Scheduler includes. */
3033
#include "FreeRTOS.h"
3134
#include "task.h"

portable/CCS/MSP430X/portmacro.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
*-----------------------------------------------------------
4040
*/
4141

42-
/* Hardware includes. */
43-
#include "msp430.h"
44-
4542
/* Type definitions. */
4643
#define portCHAR char
4744
#define portFLOAT float
@@ -75,8 +72,8 @@ typedef unsigned short UBaseType_t;
7572
/*-----------------------------------------------------------*/
7673

7774
/* Interrupt control macros. */
78-
#define portDISABLE_INTERRUPTS() _disable_interrupt(); _nop()
79-
#define portENABLE_INTERRUPTS() _enable_interrupt(); _nop()
75+
#define portDISABLE_INTERRUPTS() __asm volatile ( " DINT\n" " NOP" )
76+
#define portENABLE_INTERRUPTS() __asm volatile ( " NOP\n" " EINT\n" " NOP" )
8077
/*-----------------------------------------------------------*/
8178

8279
/* Critical section control macros. */
@@ -126,7 +123,7 @@ extern void vPortYield( void );
126123
#define portBYTE_ALIGNMENT 2
127124
#define portSTACK_GROWTH ( -1 )
128125
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
129-
#define portNOP() __no_operation()
126+
#define portNOP() __asm volatile ( " NOP" )
130127
/*-----------------------------------------------------------*/
131128

132129
/* Task function macros as described on the FreeRTOS.org WEB site. */

portable/IAR/MSP430X/port.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
#include "FreeRTOS.h"
3131
#include "task.h"
3232

33+
/* Hardware includes. */
34+
#include "msp430.h"
35+
3336
/*-----------------------------------------------------------
3437
* Implementation of functions defined in portable.h for the MSP430X port.
3538
*----------------------------------------------------------*/

portable/IAR/MSP430X/portmacro.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
*-----------------------------------------------------------
4040
*/
4141

42-
/* Hardware includes. */
43-
#include "msp430.h"
44-
4542
/* Type definitions. */
4643
#define portCHAR char
4744
#define portFLOAT float
@@ -75,8 +72,8 @@ typedef unsigned short UBaseType_t;
7572
/*-----------------------------------------------------------*/
7673

7774
/* Interrupt control macros. */
78-
#define portDISABLE_INTERRUPTS() _DINT(); _NOP()
79-
#define portENABLE_INTERRUPTS() _EINT(); _NOP()
75+
#define portDISABLE_INTERRUPTS() __asm volatile ( "DINT\n" "NOP" )
76+
#define portENABLE_INTERRUPTS() __asm volatile ( "NOP\n" "EINT\n" "NOP" )
8077
/*-----------------------------------------------------------*/
8178

8279
/* Critical section control macros. */
@@ -126,7 +123,7 @@ extern void vPortYield( void );
126123
#define portBYTE_ALIGNMENT 2
127124
#define portSTACK_GROWTH ( -1 )
128125
#define portTICK_PERIOD_MS ( ( TickType_t ) 1000 / configTICK_RATE_HZ )
129-
#define portNOP() __no_operation()
126+
#define portNOP() __asm volatile ( "NOP" )
130127
/*-----------------------------------------------------------*/
131128

132129
/* Task function macros as described on the FreeRTOS.org WEB site. */

0 commit comments

Comments
 (0)