--- /dev/null
+/*\r
+ FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd.\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * If you are: *\r
+ * *\r
+ * + New to FreeRTOS, *\r
+ * + Wanting to learn FreeRTOS or multitasking in general quickly *\r
+ * + Looking for basic training, *\r
+ * + Wanting to improve your FreeRTOS skills and productivity *\r
+ * *\r
+ * then take a look at the FreeRTOS books - available as PDF or paperback *\r
+ * *\r
+ * "Using the FreeRTOS Real Time Kernel - a Practical Guide" *\r
+ * http://www.FreeRTOS.org/Documentation *\r
+ * *\r
+ * A pdf reference manual is also available. Both are usually delivered *\r
+ * to your inbox within 20 minutes to two hours when purchased between 8am *\r
+ * and 8pm GMT (although please allow up to 24 hours in case of *\r
+ * exceptional circumstances). Thank you for your support! *\r
+ * *\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
+ Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
+ ***NOTE*** The exception to the GPL is included to allow you to distribute\r
+ a combined work that includes FreeRTOS without being obliged to provide the\r
+ source code for proprietary components outside of the FreeRTOS kernel.\r
+ FreeRTOS is distributed in the hope that it will be useful, but WITHOUT\r
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
+ more details. You should have received a copy of the GNU General Public\r
+ License and the FreeRTOS license exception along with FreeRTOS; if not it\r
+ can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
+ by writing to Richard Barry, contact details for whom are available on the\r
+ FreeRTOS WEB site.\r
+\r
+ 1 tab == 4 spaces!\r
+\r
+ http://www.FreeRTOS.org - Documentation, latest information, license and\r
+ contact details.\r
+\r
+ http://www.SafeRTOS.com - A version that is certified for use in safety\r
+ critical systems.\r
+\r
+ http://www.OpenRTOS.com - Commercial support, development, porting,\r
+ licensing and training services.\r
+*/\r
+\r
+#ifndef DATA_MODEL_H\r
+#define DATA_MODEL_H\r
+\r
+#ifdef __DATA_MODEL_SMALL__\r
+ #define pushm_x pushm.w\r
+ #define popm_x popm.w\r
+ #define push_x push.w\r
+ #define pop_x pop.w\r
+ #define mov_x mov.w\r
+ #define cmp_x cmp.w\r
+#else /* DATA_MODEL_SMALL__ */\r
+ #define pushm_x pushm.a\r
+ #define popm_x popm.a\r
+ #define push_x pushx.a\r
+ #define pop_x popx.a\r
+ #define mov_x movx.a\r
+ #define cmp_x cmpx.a\r
+#endif /* __DATA_MODEL_SMALL__\r
+\r
+#endif /* DATA_MODEL_H */\r
+\r
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
{\r
unsigned short *pusTopOfStack;\r
+unsigned long *pulTopOfStack;\r
\r
/*\r
Place a few bytes of known values on the bottom of the stack.\r
This is just useful for debugging and can be included if required.\r
-\r
+ \r
*pxTopOfStack = ( portSTACK_TYPE ) 0x1111;\r
pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x2222;\r
pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) 0x3333;\r
- pxTopOfStack--;\r
*/\r
\r
- *pxTopOfStack = ( portSTACK_TYPE ) pxCode;\r
- pusTopOfStack = ( unsigned short * ) pxTopOfStack;\r
+ /* portSTACK_TYPE is either 16 bits or 32 bits depending on the data model.\r
+ Some stacked items do not change size depending on the data model so have\r
+ to be explicitly cast to the correct size so this function will work\r
+ whichever data model is being used. */\r
+ if( sizeof( portSTACK_TYPE ) == sizeof( unsigned short ) )\r
+ {\r
+ /* Make room for a 20 bit value stored as a 32 bit value. */\r
+ pusTopOfStack = ( unsigned short * ) pxTopOfStack;\r
+ pusTopOfStack--;\r
+ pulTopOfStack = ( unsigned long * ) pusTopOfStack;\r
+ }\r
+ else\r
+ {\r
+ pulTopOfStack = ( unsigned long * ) pxTopOfStack;\r
+ }\r
+ *pulTopOfStack = ( unsigned long ) pxCode;\r
+ \r
+ pusTopOfStack = ( unsigned short * ) pulTopOfStack;\r
pusTopOfStack--;\r
*pusTopOfStack = portFLAGS_INT_ENABLED;\r
- pusTopOfStack -= 2;\r
+ pusTopOfStack -= ( sizeof( portSTACK_TYPE ) / 2 );\r
+ \r
+ /* From here on the size of stacked items depends on the memory model. */\r
pxTopOfStack = ( portSTACK_TYPE * ) pusTopOfStack;\r
\r
/* Next the general purpose registers. */\r
- *pxTopOfStack = ( portSTACK_TYPE ) 0xffffff;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0xfffff;\r
pxTopOfStack--;\r
- *pxTopOfStack = ( portSTACK_TYPE ) 0xeeeeee;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0xeeeee;\r
pxTopOfStack--;\r
- *pxTopOfStack = ( portSTACK_TYPE ) 0xdddddd;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0xddddd;\r
pxTopOfStack--;\r
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters;\r
pxTopOfStack--;\r
- *pxTopOfStack = ( portSTACK_TYPE ) 0xbbbbbb;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0xbbbbb;\r
pxTopOfStack--;\r
- *pxTopOfStack = ( portSTACK_TYPE ) 0xaaaaaa;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0xaaaaa;\r
pxTopOfStack--;\r
- *pxTopOfStack = ( portSTACK_TYPE ) 0x999999;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x99999;\r
pxTopOfStack--;\r
- *pxTopOfStack = ( portSTACK_TYPE ) 0x888888;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x88888;\r
pxTopOfStack--; \r
- *pxTopOfStack = ( portSTACK_TYPE ) 0x555555;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x55555;\r
pxTopOfStack--;\r
- *pxTopOfStack = ( portSTACK_TYPE ) 0x666666;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x66666;\r
pxTopOfStack--;\r
- *pxTopOfStack = ( portSTACK_TYPE ) 0x555555;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x55555;\r
pxTopOfStack--;\r
- *pxTopOfStack = ( portSTACK_TYPE ) 0x444444;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x44444;\r
pxTopOfStack--;\r
\r
/* A variable is used to keep track of the critical section nesting.\r
+++ /dev/null
-/*\r
- FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd.\r
-\r
- ***************************************************************************\r
- * *\r
- * If you are: *\r
- * *\r
- * + New to FreeRTOS, *\r
- * + Wanting to learn FreeRTOS or multitasking in general quickly *\r
- * + Looking for basic training, *\r
- * + Wanting to improve your FreeRTOS skills and productivity *\r
- * *\r
- * then take a look at the FreeRTOS books - available as PDF or paperback *\r
- * *\r
- * "Using the FreeRTOS Real Time Kernel - a Practical Guide" *\r
- * http://www.FreeRTOS.org/Documentation *\r
- * *\r
- * A pdf reference manual is also available. Both are usually delivered *\r
- * to your inbox within 20 minutes to two hours when purchased between 8am *\r
- * and 8pm GMT (although please allow up to 24 hours in case of *\r
- * exceptional circumstances). Thank you for your support! *\r
- * *\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
- Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
- ***NOTE*** The exception to the GPL is included to allow you to distribute\r
- a combined work that includes FreeRTOS without being obliged to provide the\r
- source code for proprietary components outside of the FreeRTOS kernel.\r
- FreeRTOS is distributed in the hope that it will be useful, but WITHOUT\r
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
- more details. You should have received a copy of the GNU General Public\r
- License and the FreeRTOS license exception along with FreeRTOS; if not it\r
- can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
- by writing to Richard Barry, contact details for whom are available on the\r
- FreeRTOS WEB site.\r
-\r
- 1 tab == 4 spaces!\r
-\r
- http://www.FreeRTOS.org - Documentation, latest information, license and\r
- contact details.\r
-\r
- http://www.SafeRTOS.com - A version that is certified for use in safety\r
- critical systems.\r
-\r
- http://www.OpenRTOS.com - Commercial support, development, porting,\r
- licensing and training services.\r
-*/\r
-\r
-#ifndef PORTASM_H\r
-#define PORTASM_H\r
-\r
- IMPORT pxCurrentTCB\r
- IMPORT usCriticalNesting\r
-\r
-portSAVE_CONTEXT macro\r
-\r
- /* Save the remaining registers. */\r
- pushm.a #12, r15\r
- movx.w &usCriticalNesting, r14\r
- pushx.a r14\r
- movx.a &pxCurrentTCB, r12\r
- movx.a sp, 0( r12 )\r
- endm\r
-/*-----------------------------------------------------------*/\r
- \r
-portRESTORE_CONTEXT macro\r
-\r
- movx.a &pxCurrentTCB, r12\r
- movx.a @r12, sp\r
- popx.a r15\r
- movx.w r15, &usCriticalNesting\r
- popm.a #12, r15\r
- \r
- /* The last thing on the stack will be the status register.\r
- Ensure the power down bits are clear ready for the next\r
- time this power down register is popped from the stack. */\r
- bic.w #0xf0, 0( sp )\r
- \r
- pop.w sr\r
- reta\r
- endm\r
-/*-----------------------------------------------------------*/\r
-\r
-#endif\r
-\r
*/\r
#include "msp430.h"\r
#include "FreeRTOSConfig.h"\r
-#include "portasm.h"\r
+#include "data_model.h"\r
\r
IMPORT vTaskIncrementTick\r
IMPORT vTaskSwitchContext\r
IMPORT vPortSetupTimerInterrupt\r
+ IMPORT pxCurrentTCB\r
+ IMPORT usCriticalNesting\r
\r
EXPORT vPortTickISR\r
EXPORT vPortYield\r
EXPORT xPortStartScheduler\r
\r
+portSAVE_CONTEXT macro\r
+\r
+ /* Save the remaining registers. */\r
+ pushm_x #12, r15\r
+ mov.w &usCriticalNesting, r14\r
+ push_x r14\r
+ mov_x &pxCurrentTCB, r12\r
+ mov_x sp, 0( r12 )\r
+ endm\r
+/*-----------------------------------------------------------*/\r
+ \r
+portRESTORE_CONTEXT macro\r
+\r
+ mov_x &pxCurrentTCB, r12\r
+ mov_x @r12, sp\r
+ pop_x r15\r
+ mov.w r15, &usCriticalNesting\r
+ popm_x #12, r15\r
+ \r
+ /* The last thing on the stack will be the status register.\r
+ Ensure the power down bits are clear ready for the next\r
+ time this power down register is popped from the stack. */\r
+ bic.w #0xf0, 0( sp )\r
+ \r
+ pop.w sr\r
+ reta\r
+ endm\r
+/*-----------------------------------------------------------*/\r
+\r
\r
/*\r
* The RTOS tick ISR.\r
* If the preemptive scheduler is in use a context switch can also occur.\r
*/\r
\r
- RSEG ISR_CODE\r
+ RSEG CODE\r
\r
vPortTickISR:\r
\r
portRESTORE_CONTEXT\r
/*-----------------------------------------------------------*/\r
\r
- RSEG CODE\r
-\r
/*\r
* Manual context switch called by the portYIELD() macro.\r
*/\r
#define portDOUBLE double\r
#define portLONG long\r
#define portSHORT int\r
-#define portSTACK_TYPE unsigned portLONG\r
#define portBASE_TYPE portSHORT\r
\r
+/* The stack type changes depending on the data model. */\r
+#if( __DATA_MODEL__ == __DATA_MODEL_SMALL__ )\r
+ #define portSTACK_TYPE unsigned short\r
+#else\r
+ #define portSTACK_TYPE unsigned long\r
+#endif\r
+\r
#if( configUSE_16_BIT_TICKS == 1 )\r
typedef unsigned portSHORT portTickType;\r
#define portMAX_DELAY ( portTickType ) 0xffff\r