--- /dev/null
+/*\r
+ FreeRTOS.org V5.1.0 - Copyright (C) 2003-2008 Richard Barry.\r
+\r
+ This file is part of the FreeRTOS.org distribution.\r
+\r
+ FreeRTOS.org is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ FreeRTOS.org is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with FreeRTOS.org; if not, write to the Free Software\r
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+ A special exception to the GPL can be applied should you wish to distribute\r
+ a combined work that includes FreeRTOS.org, without being obliged to provide\r
+ the source code for any proprietary components. See the licensing section\r
+ of http://www.FreeRTOS.org for full details of how and when the exception\r
+ can be applied.\r
+\r
+ ***************************************************************************\r
+ ***************************************************************************\r
+ * *\r
+ * SAVE TIME AND MONEY! We can port FreeRTOS.org to your own hardware, *\r
+ * and even write all or part of your application on your behalf. *\r
+ * See http://www.OpenRTOS.com for details of the services we provide to *\r
+ * expedite your project. *\r
+ * *\r
+ ***************************************************************************\r
+ ***************************************************************************\r
+\r
+ Please ensure to read the configuration and relevant port sections of the\r
+ online documentation.\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
+/* Scheduler includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+\r
+/*-----------------------------------------------------------\r
+ * Implementation of functions defined in portable.h for the MSP430 port.\r
+ *----------------------------------------------------------*/\r
+\r
+/* Constants required for hardware setup. The tick ISR runs off the ACLK,\r
+not the MCLK. */\r
+#define portACLK_FREQUENCY_HZ ( ( portTickType ) 32768 )\r
+#define portINITIAL_CRITICAL_NESTING ( ( unsigned portSHORT ) 10 )\r
+#define portFLAGS_INT_ENABLED ( ( portSTACK_TYPE ) 0x08 )\r
+\r
+/* We require the address of the pxCurrentTCB variable, but don't want to know\r
+any details of its type. */\r
+typedef void tskTCB;\r
+extern volatile tskTCB * volatile pxCurrentTCB;\r
+\r
+/* Each task maintains a count of the critical section nesting depth. Each\r
+time a critical section is entered the count is incremented. Each time a\r
+critical section is exited the count is decremented - with interrupts only\r
+being re-enabled if the count is zero.\r
+\r
+usCriticalNesting will get set to zero when the scheduler starts, but must\r
+not be initialised to zero as this will cause problems during the startup\r
+sequence. */\r
+volatile unsigned portSHORT usCriticalNesting = portINITIAL_CRITICAL_NESTING;\r
+/*-----------------------------------------------------------*/\r
+\r
+\r
+/*\r
+ * Sets up the periodic ISR used for the RTOS tick. This uses timer 0, but\r
+ * could have alternatively used the watchdog timer or timer 1.\r
+ */\r
+void vPortSetupTimerInterrupt( void );\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Initialise the stack of a task to look exactly as if a call to\r
+ * portSAVE_CONTEXT had been called.\r
+ *\r
+ * See the header file portable.h.\r
+ */\r
+portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\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
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x1111;\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x2222;\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x3333;\r
+ pxTopOfStack--;\r
+ */\r
+\r
+ /* The msp430 automatically pushes the PC then SR onto the stack before\r
+ executing an ISR. We want the stack to look just as if this has happened\r
+ so place a pointer to the start of the task on the stack first - followed\r
+ by the flags we want the task to use when it starts up. */\r
+ *pxTopOfStack = ( portSTACK_TYPE ) pxCode;\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = portFLAGS_INT_ENABLED;\r
+ pxTopOfStack--;\r
+\r
+ /* Next the general purpose registers. */\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x4444;\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x5555;\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x6666;\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x7777;\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x8888;\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x9999;\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0xaaaa;\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0xbbbb;\r
+ pxTopOfStack--; \r
+ \r
+ /* When the task starts is will expect to find the function parameter in\r
+ R15. */\r
+ *pxTopOfStack = ( portSTACK_TYPE ) pvParameters;\r
+ pxTopOfStack--;\r
+ \r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0xdddd;\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0xeeee;\r
+ pxTopOfStack--;\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0xffff;\r
+ pxTopOfStack--;\r
+\r
+ /* A variable is used to keep track of the critical section nesting.\r
+ This variable has to be stored as part of the task context and is\r
+ initially set to zero. */\r
+ *pxTopOfStack = ( portSTACK_TYPE ) portNO_CRITICAL_SECTION_NESTING; \r
+\r
+ /* Return a pointer to the top of the stack we have generated so this can\r
+ be stored in the task control block for the task. */\r
+ return pxTopOfStack;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortEndScheduler( void )\r
+{\r
+ /* It is unlikely that the MSP430 port will get stopped. If required simply\r
+ disable the tick interrupt here. */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Hardware initialisation to generate the RTOS tick. This uses timer 0\r
+ * but could alternatively use the watchdog timer or timer 1.\r
+ */\r
+void vPortSetupTimerInterrupt( void )\r
+{\r
+ /* Ensure the timer is stopped. */\r
+ TACTL = 0;\r
+\r
+ /* Run the timer of the ACLK. */\r
+ TACTL = TASSEL_1;\r
+\r
+ /* Clear everything to start with. */\r
+ TACTL |= TACLR;\r
+\r
+ /* Set the compare match value according to the tick rate we want. */\r
+ TACCR0 = portACLK_FREQUENCY_HZ / configTICK_RATE_HZ;\r
+\r
+ /* Enable the interrupts. */\r
+ TACCTL0 = CCIE;\r
+\r
+ /* Start up clean. */\r
+ TACTL |= TACLR;\r
+\r
+ /* Up mode. */\r
+ TACTL |= MC_1;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+\r
+ \r
--- /dev/null
+/*\r
+ FreeRTOS.org V5.1.0 - Copyright (C) 2003-2008 Richard Barry.\r
+\r
+ This file is part of the FreeRTOS.org distribution.\r
+\r
+ FreeRTOS.org is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ FreeRTOS.org is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with FreeRTOS.org; if not, write to the Free Software\r
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+ A special exception to the GPL can be applied should you wish to distribute\r
+ a combined work that includes FreeRTOS.org, without being obliged to provide\r
+ the source code for any proprietary components. See the licensing section\r
+ of http://www.FreeRTOS.org for full details of how and when the exception\r
+ can be applied.\r
+\r
+ ***************************************************************************\r
+ ***************************************************************************\r
+ * *\r
+ * SAVE TIME AND MONEY! We can port FreeRTOS.org to your own hardware, *\r
+ * and even write all or part of your application on your behalf. *\r
+ * See http://www.OpenRTOS.com for details of the services we provide to *\r
+ * expedite your project. *\r
+ * *\r
+ ***************************************************************************\r
+ ***************************************************************************\r
+\r
+ Please ensure to read the configuration and relevant port sections of the\r
+ online documentation.\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
+portSAVE_CONTEXT macro\r
+\r
+ IMPORT pxCurrentTCB\r
+ IMPORT usCriticalNesting\r
+\r
+ /* Save the remaining registers. */\r
+ push r4\r
+ push r5\r
+ push r6\r
+ push r7\r
+ push r8\r
+ push r9\r
+ push r10\r
+ push r11\r
+ push r12\r
+ push r13\r
+ push r14\r
+ push r15\r
+ mov.w &usCriticalNesting, r14\r
+ push r14\r
+ mov.w &pxCurrentTCB, r12\r
+ mov.w r1, 0(r12)\r
+ endm\r
+/*-----------------------------------------------------------*/\r
+ \r
+portRESTORE_CONTEXT macro\r
+ mov.w &pxCurrentTCB, r12\r
+ mov.w @r12, r1\r
+ pop r15\r
+ mov.w r15, &usCriticalNesting\r
+ pop r15\r
+ pop r14\r
+ pop r13\r
+ pop r12\r
+ pop r11\r
+ pop r10\r
+ pop r9\r
+ pop r8\r
+ pop r7\r
+ pop r6\r
+ pop r5\r
+ pop r4\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
+ reti\r
+ endm\r
+/*-----------------------------------------------------------*/\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ FreeRTOS.org V5.1.0 - Copyright (C) 2003-2008 Richard Barry.\r
+\r
+ This file is part of the FreeRTOS.org distribution.\r
+\r
+ FreeRTOS.org is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ FreeRTOS.org is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with FreeRTOS.org; if not, write to the Free Software\r
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+ A special exception to the GPL can be applied should you wish to distribute\r
+ a combined work that includes FreeRTOS.org, without being obliged to provide\r
+ the source code for any proprietary components. See the licensing section\r
+ of http://www.FreeRTOS.org for full details of how and when the exception\r
+ can be applied.\r
+\r
+ ***************************************************************************\r
+ ***************************************************************************\r
+ * *\r
+ * SAVE TIME AND MONEY! We can port FreeRTOS.org to your own hardware, *\r
+ * and even write all or part of your application on your behalf. *\r
+ * See http://www.OpenRTOS.com for details of the services we provide to *\r
+ * expedite your project. *\r
+ * *\r
+ ***************************************************************************\r
+ ***************************************************************************\r
+\r
+ Please ensure to read the configuration and relevant port sections of the\r
+ online documentation.\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
+#include "FreeRTOSConfig.h"\r
+#include "portasm.h"\r
+\r
+ IMPORT vTaskIncrementTick\r
+ IMPORT vTaskSwitchContext\r
+ IMPORT vPortSetupTimerInterrupt\r
+\r
+ EXPORT vTickISR\r
+ EXPORT vPortYield\r
+ EXPORT xPortStartScheduler\r
+ \r
+ RSEG CODE\r
+\r
+/*\r
+ * The RTOS tick ISR.\r
+ *\r
+ * If the cooperative scheduler is in use this simply increments the tick\r
+ * count.\r
+ *\r
+ * If the preemptive scheduler is in use a context switch can also occur.\r
+ */\r
+vTickISR:\r
+ portSAVE_CONTEXT\r
+ \r
+ call #vTaskIncrementTick\r
+\r
+ #if configUSE_PREEMPTION == 1\r
+ call #vTaskSwitchContext\r
+ #endif\r
+ \r
+ portRESTORE_CONTEXT\r
+/*-----------------------------------------------------------*/\r
+\r
+\r
+/*\r
+ * Manual context switch called by the portYIELD() macro.\r
+ */\r
+vPortYield:\r
+\r
+ /* Mimic an interrupt by pushing the SR. */\r
+ push SR \r
+\r
+ /* Now the SR is stacked we can disable interrupts. */\r
+ dint \r
+ \r
+ /* Save the context of the current task. */\r
+ portSAVE_CONTEXT \r
+\r
+ /* Switch to the highest priority task that is ready to run. */\r
+ call #vTaskSwitchContext \r
+\r
+ /* Restore the context of the new task. */\r
+ portRESTORE_CONTEXT\r
+/*-----------------------------------------------------------*/\r
+\r
+\r
+/*\r
+ * Start off the scheduler by initialising the RTOS tick timer, then restoring\r
+ * the context of the first task.\r
+ */\r
+xPortStartScheduler:\r
+\r
+ /* Setup the hardware to generate the tick. Interrupts are disabled\r
+ when this function is called. */\r
+ call #vPortSetupTimerInterrupt\r
+\r
+ /* Restore the context of the first task that is going to run. */\r
+ portRESTORE_CONTEXT\r
+/*-----------------------------------------------------------*/\r
+ \r
+\r
+ /* Install vTickISR as the timer A0 interrupt. */\r
+ ASEG\r
+ ORG 0xFFE0 + TIMERA0_VECTOR\r
+ \r
+ _vTickISR_: DC16 vTickISR\r
+ \r
+\r
+ END\r
+ \r
--- /dev/null
+/*\r
+ FreeRTOS.org V5.1.0 - Copyright (C) 2003-2008 Richard Barry.\r
+\r
+ This file is part of the FreeRTOS.org distribution.\r
+\r
+ FreeRTOS.org is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ FreeRTOS.org is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with FreeRTOS.org; if not, write to the Free Software\r
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+ A special exception to the GPL can be applied should you wish to distribute\r
+ a combined work that includes FreeRTOS.org, without being obliged to provide\r
+ the source code for any proprietary components. See the licensing section\r
+ of http://www.FreeRTOS.org for full details of how and when the exception\r
+ can be applied.\r
+\r
+ ***************************************************************************\r
+ ***************************************************************************\r
+ * *\r
+ * SAVE TIME AND MONEY! We can port FreeRTOS.org to your own hardware, *\r
+ * and even write all or part of your application on your behalf. *\r
+ * See http://www.OpenRTOS.com for details of the services we provide to *\r
+ * expedite your project. *\r
+ * *\r
+ ***************************************************************************\r
+ ***************************************************************************\r
+\r
+ Please ensure to read the configuration and relevant port sections of the\r
+ online documentation.\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 PORTMACRO_H\r
+#define PORTMACRO_H\r
+\r
+/*-----------------------------------------------------------\r
+ * Port specific definitions.\r
+ *\r
+ * The settings in this file configure FreeRTOS correctly for the\r
+ * given hardware and compiler.\r
+ *\r
+ * These settings should not be altered.\r
+ *-----------------------------------------------------------\r
+ */\r
+\r
+/* Type definitions. */\r
+#define portCHAR char\r
+#define portFLOAT float\r
+#define portDOUBLE double\r
+#define portLONG long\r
+#define portSHORT int\r
+#define portSTACK_TYPE unsigned portSHORT\r
+#define portBASE_TYPE portSHORT\r
+\r
+#if( configUSE_16_BIT_TICKS == 1 )\r
+ typedef unsigned portSHORT portTickType;\r
+ #define portMAX_DELAY ( portTickType ) 0xffff\r
+#else\r
+ typedef unsigned portLONG portTickType;\r
+ #define portMAX_DELAY ( portTickType ) 0xffffffff\r
+#endif\r
+\r
+/*-----------------------------------------------------------*/ \r
+\r
+/* Interrupt control macros. */\r
+#define portDISABLE_INTERRUPTS() _DINT();\r
+#define portENABLE_INTERRUPTS() _EINT();\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Critical section control macros. */\r
+#define portNO_CRITICAL_SECTION_NESTING ( ( unsigned portSHORT ) 0 )\r
+\r
+#define portENTER_CRITICAL() \\r
+{ \\r
+extern volatile unsigned portSHORT usCriticalNesting; \\r
+ \\r
+ portDISABLE_INTERRUPTS(); \\r
+ \\r
+ /* Now interrupts are disabled usCriticalNesting can be accessed */ \\r
+ /* directly. Increment ulCriticalNesting to keep a count of how many */ \\r
+ /* times portENTER_CRITICAL() has been called. */ \\r
+ usCriticalNesting++; \\r
+}\r
+\r
+#define portEXIT_CRITICAL() \\r
+{ \\r
+extern volatile unsigned portSHORT usCriticalNesting; \\r
+ \\r
+ if( usCriticalNesting > portNO_CRITICAL_SECTION_NESTING ) \\r
+ { \\r
+ /* Decrement the nesting count as we are leaving a critical section. */ \\r
+ usCriticalNesting--; \\r
+ \\r
+ /* If the nesting level has reached zero then interrupts should be */ \\r
+ /* re-enabled. */ \\r
+ if( usCriticalNesting == portNO_CRITICAL_SECTION_NESTING ) \\r
+ { \\r
+ portENABLE_INTERRUPTS(); \\r
+ } \\r
+ } \\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Task utilities. */\r
+\r
+/*\r
+ * Manual context switch called by portYIELD or taskYIELD.\r
+ */\r
+extern void vPortYield( void );\r
+#define portYIELD() vPortYield()\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Hardware specifics. */\r
+#define portBYTE_ALIGNMENT 2\r
+#define portSTACK_GROWTH ( -1 )\r
+#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ ) \r
+#define portNOP() \r
+/*-----------------------------------------------------------*/\r
+\r
+/* Task function macros as described on the FreeRTOS.org WEB site. */\r
+#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
+#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
+\r
+#if configINTERRUPT_EXAMPLE_METHOD == 2\r
+\r
+extern void vTaskSwitchContext( void );\r
+#define portYIELD_FROM_ISR( x ) if( x ) vTaskSwitchContext()\r
+\r
+#endif\r
+\r
+#endif /* PORTMACRO_H */\r
+\r