From 32a48c52a8b6f41bd7162e8d7ee1fc1f46a7c3e4 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Tue, 29 Sep 2009 20:02:16 +0000 Subject: [PATCH] Allow auto switching between creating tasks in ARM mode and THUMB mode. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@880 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Source/portable/IAR/AtmelSAM7S64/port.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Source/portable/IAR/AtmelSAM7S64/port.c b/Source/portable/IAR/AtmelSAM7S64/port.c index cd7d8a2d7..fe0989879 100644 --- a/Source/portable/IAR/AtmelSAM7S64/port.c +++ b/Source/portable/IAR/AtmelSAM7S64/port.c @@ -3,14 +3,14 @@ This file is part of the FreeRTOS distribution. - FreeRTOS is free software; you can redistribute it and/or modify it under - the terms of the GNU General Public License (version 2) as published by the + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the Free Software Foundation and modified by the FreeRTOS exception. **NOTE** The exception to the GPL is included to allow you to distribute a - combined work that includes FreeRTOS without being obliged to provide the - source code for proprietary components outside of the FreeRTOS kernel. - Alternative commercial license and support terms are also available upon - request. See the licensing section of http://www.FreeRTOS.org for full + combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + Alternative commercial license and support terms are also available upon + request. See the licensing section of http://www.FreeRTOS.org for full license details. FreeRTOS is distributed in the hope that it will be useful, but WITHOUT @@ -58,7 +58,8 @@ #include "task.h" /* Constants required to setup the initial stack. */ -#define portINITIAL_SPSR ( ( portSTACK_TYPE ) 0x3f ) /* System mode, THUMB mode, interrupts enabled. */ +#define portINITIAL_SPSR ( ( portSTACK_TYPE ) 0x1f ) /* System mode, ARM mode, interrupts enabled. */ +#define portTHUMB_MODE_BIT ( ( portSTACK_TYPE ) 0x20 ) #define portINSTRUCTION_SIZE ( ( portSTACK_TYPE ) 4 ) /* Constants required to setup the PIT. */ @@ -141,6 +142,13 @@ portSTACK_TYPE *pxOriginalTOS; /* The status register is set for system mode, with interrupts enabled. */ *pxTopOfStack = ( portSTACK_TYPE ) portINITIAL_SPSR; + + if( ( ( unsigned long ) pxCode & 0x01UL ) != 0x00UL ) + { + /* We want the task to start in thumb mode. */ + *pxTopOfStack |= portTHUMB_MODE_BIT; + } + pxTopOfStack--; /* Interrupt flags cannot always be stored on the stack and will -- 2.39.5