]> git.sur5r.net Git - freertos/commitdiff
Allow auto switching between creating tasks in ARM mode and THUMB mode.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 29 Sep 2009 20:03:09 +0000 (20:03 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 29 Sep 2009 20:03:09 +0000 (20:03 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@881 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/portable/IAR/LPC2000/port.c

index b02f9e58f12abe175e01f42048e5c369db118f35..e431d3de7f930a05e912b155161071d791ede120 100644 (file)
@@ -3,14 +3,14 @@
 \r
        This file is part of the FreeRTOS distribution.\r
 \r
 \r
        This file is part of the FreeRTOS distribution.\r
 \r
-       FreeRTOS is free software; you can redistribute it and/or modify it     under \r
-       the terms of the GNU General Public License (version 2) as published by the \r
+       FreeRTOS is free software; you can redistribute it and/or modify it     under\r
+       the terms of the GNU General Public License (version 2) as published by the\r
        Free Software Foundation and modified by the FreeRTOS exception.\r
        **NOTE** The exception to the GPL is included to allow you to distribute a\r
        Free Software Foundation and modified by the FreeRTOS exception.\r
        **NOTE** The exception to the GPL is included to allow you to distribute a\r
-       combined work that includes FreeRTOS without being obliged to provide the \r
-       source code for proprietary components outside of the FreeRTOS kernel.  \r
-       Alternative commercial license and support terms are also available upon \r
-       request.  See the licensing section of http://www.FreeRTOS.org for full \r
+       combined work that includes FreeRTOS without being obliged to provide the\r
+       source code for proprietary components outside of the FreeRTOS kernel.\r
+       Alternative commercial license and support terms are also available upon\r
+       request.  See the licensing section of http://www.FreeRTOS.org for full\r
        license details.\r
 \r
        FreeRTOS is distributed in the hope that it will be useful,     but WITHOUT\r
        license details.\r
 \r
        FreeRTOS is distributed in the hope that it will be useful,     but WITHOUT\r
@@ -72,7 +72,8 @@
 #define portRESET_COUNT_ON_MATCH       ( ( unsigned portLONG ) 0x02 )\r
 \r
 /* Constants required to setup the initial stack. */\r
 #define portRESET_COUNT_ON_MATCH       ( ( unsigned portLONG ) 0x02 )\r
 \r
 /* Constants required to setup the initial stack. */\r
-#define portINITIAL_SPSR                               ( ( portSTACK_TYPE ) 0x3f ) /* System mode, THUMB mode, interrupts enabled. */\r
+#define portINITIAL_SPSR                               ( ( portSTACK_TYPE ) 0x1f ) /* System mode, ARM mode, interrupts enabled. */\r
+#define portTHUMB_MODE_BIT                             ( ( portSTACK_TYPE ) 0x20 )\r
 #define portINSTRUCTION_SIZE                   ( ( portSTACK_TYPE ) 4 )\r
 \r
 /* Constants required to setup the PIT. */\r
 #define portINSTRUCTION_SIZE                   ( ( portSTACK_TYPE ) 4 )\r
 \r
 /* Constants required to setup the PIT. */\r
@@ -165,6 +166,13 @@ portSTACK_TYPE *pxOriginalTOS;
 \r
        /* The status register is set for system mode, with interrupts enabled. */\r
        *pxTopOfStack = ( portSTACK_TYPE ) portINITIAL_SPSR;\r
 \r
        /* The status register is set for system mode, with interrupts enabled. */\r
        *pxTopOfStack = ( portSTACK_TYPE ) portINITIAL_SPSR;\r
+       \r
+       if( ( ( unsigned long ) pxCode & 0x01UL ) != 0x00UL )\r
+       {\r
+               /* We want the task to start in thumb mode. */\r
+               *pxTopOfStack |= portTHUMB_MODE_BIT;\r
+       }\r
+       \r
        pxTopOfStack--;\r
 \r
        /* Interrupt flags cannot always be stored on the stack and will\r
        pxTopOfStack--;\r
 \r
        /* Interrupt flags cannot always be stored on the stack and will\r