--- /dev/null
+/*\r
+ FreeRTOS.org V5.3.0 - Copyright (C) 2003-2009 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 it\r
+ under the terms of the GNU General Public License (version 2) as published\r
+ by the 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.org without being obliged to provide\r
+ the source code for any proprietary components. Alternative commercial\r
+ license and support terms are also available upon request. See the \r
+ licensing section of http://www.FreeRTOS.org for full details.\r
+\r
+ FreeRTOS.org 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.\r
+\r
+ You should have received a copy of the GNU General Public License along\r
+ with FreeRTOS.org; if not, write to the Free Software Foundation, Inc., 59\r
+ Temple Place, Suite 330, Boston, MA 02111-1307 USA.\r
+\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * Get the FreeRTOS eBook! See http://www.FreeRTOS.org/Documentation *\r
+ * *\r
+ * This is a concise, step by step, 'hands on' guide that describes both *\r
+ * general multitasking concepts and FreeRTOS specifics. It presents and *\r
+ * explains numerous examples that are written using the FreeRTOS API. *\r
+ * Full source code for all the examples is provided in an accompanying *\r
+ * .zip file. *\r
+ * *\r
+ ***************************************************************************\r
+\r
+ 1 tab == 4 spaces!\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
+/* Kernel includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+\r
+\r
+#define portINITIAL_FORMAT_VECTOR ( ( portSTACK_TYPE ) 0x4000 )\r
+\r
+/* Supervisor mode set. */\r
+#define portINITIAL_STATUS_REGISTER ( ( portSTACK_TYPE ) 0x2000)\r
+\r
+/* The clock prescale into the timer peripheral. */\r
+#define portPRESCALE_VALUE ( ( unsigned portCHAR ) 10 )\r
+\r
+/* The clock frequency into the RTC. */\r
+#define portRTC_CLOCK_HZ ( ( unsigned portLONG ) 1000 )\r
+\r
+asm void interrupt VectorNumber_VL1swi vPortYieldISR( void );\r
+static void prvSetupTimerInterrupt( void );\r
+\r
+/* Used to keep track of the number of nested calls to taskENTER_CRITICAL(). This\r
+will be set to 0 prior to the first task being started. */\r
+static unsigned portLONG ulCriticalNesting = 0x9999UL;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE * pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
+{\r
+\r
+unsigned portLONG ulOriginalA5;\r
+\r
+ __asm{ MOVE.L A5, ulOriginalA5 };\r
+\r
+\r
+ *pxTopOfStack = (portSTACK_TYPE) 0xDEADBEEF;\r
+ pxTopOfStack--;\r
+\r
+ /* Exception stack frame starts with the return address. */\r
+ *pxTopOfStack = ( portSTACK_TYPE ) pxCode;\r
+ pxTopOfStack--;\r
+\r
+ *pxTopOfStack = ( portINITIAL_FORMAT_VECTOR << 16UL ) | ( portINITIAL_STATUS_REGISTER );\r
+ pxTopOfStack--;\r
+\r
+ *pxTopOfStack = ( portSTACK_TYPE ) 0x0; /*FP*/\r
+ pxTopOfStack -= 14; /* A5 to D0. */\r
+\r
+ /* Parameter in A0. */\r
+ *( pxTopOfStack + 8 ) = ( portSTACK_TYPE ) pvParameters;\r
+\r
+ /* A5 must be maintained as it is resurved by the compiler. */\r
+ *( pxTopOfStack + 13 ) = ulOriginalA5;\r
+\r
+ return pxTopOfStack; \r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+portBASE_TYPE xPortStartScheduler( void )\r
+{\r
+extern void vPortStartFirstTask( void );\r
+\r
+ ulCriticalNesting = 0UL;\r
+\r
+ /* Configure a timer to generate the tick interrupt. */\r
+ prvSetupTimerInterrupt();\r
+\r
+ /* Start the first task executing. */\r
+ vPortStartFirstTask();\r
+\r
+ return pdFALSE;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvSetupTimerInterrupt( void )\r
+{ \r
+ /* Prescale by 1 - ie no prescale. */\r
+ RTCSC |= 8;\r
+ \r
+ /* Compare match value. */\r
+ RTCMOD = portRTC_CLOCK_HZ / configTICK_RATE_HZ;\r
+ \r
+ /* Enable the RTC to generate interrupts - interrupts are already disabled\r
+ when this code executes. */\r
+ RTCSC_RTIE = 1;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortEndScheduler( void )\r
+{\r
+ /* Not implemented as there is nothing to return to. */\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortEnterCritical( void )\r
+{\r
+ if( ulCriticalNesting == 0UL )\r
+ {\r
+ /* Guard against context switches being pended simultaneously with a\r
+ critical section being entered. */\r
+ do\r
+ {\r
+ portDISABLE_INTERRUPTS();\r
+ if( INTC_FRC == 0UL )\r
+ {\r
+ break;\r
+ }\r
+\r
+ portENABLE_INTERRUPTS();\r
+\r
+ } while( 1 );\r
+ }\r
+ ulCriticalNesting++;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortExitCritical( void )\r
+{\r
+ ulCriticalNesting--;\r
+ if( ulCriticalNesting == 0 )\r
+ {\r
+ portENABLE_INTERRUPTS();\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortYieldHandler( void )\r
+{\r
+unsigned portLONG ulSavedInterruptMask;\r
+\r
+ ulSavedInterruptMask = portSET_INTERRUPT_MASK_FROM_ISR();\r
+ {\r
+ /* Note this will clear all forced interrupts - this is done for speed. */\r
+ INTC_CFRC = 0x3E;\r
+ vTaskSwitchContext();\r
+ }\r
+ portCLEAR_INTERRUPT_MASK_FROM_ISR( ulSavedInterruptMask );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void interrupt VectorNumber_Vrtc vPortTickISR( void )\r
+{\r
+unsigned portLONG ulSavedInterruptMask;\r
+\r
+ /* Clear the interrupt. */\r
+ RTCSC |= RTCSC_RTIF_MASK;\r
+\r
+ /* Increment the RTOS tick. */\r
+ ulSavedInterruptMask = portSET_INTERRUPT_MASK_FROM_ISR();\r
+ {\r
+ vTaskIncrementTick();\r
+ }\r
+ portCLEAR_INTERRUPT_MASK_FROM_ISR( ulSavedInterruptMask );\r
+\r
+ /* If we are using the pre-emptive scheduler then also request a\r
+ context switch as incrementing the tick could have unblocked a task. */\r
+ #if configUSE_PREEMPTION == 1\r
+ {\r
+ taskYIELD();\r
+ }\r
+ #endif\r
+}\r
+\r
--- /dev/null
+/*\r
+ FreeRTOS.org V5.3.0 - Copyright (C) 2003-2009 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 it\r
+ under the terms of the GNU General Public License (version 2) as published\r
+ by the 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.org without being obliged to provide\r
+ the source code for any proprietary components. Alternative commercial\r
+ license and support terms are also available upon request. See the \r
+ licensing section of http://www.FreeRTOS.org for full details.\r
+\r
+ FreeRTOS.org 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.\r
+\r
+ You should have received a copy of the GNU General Public License along\r
+ with FreeRTOS.org; if not, write to the Free Software Foundation, Inc., 59\r
+ Temple Place, Suite 330, Boston, MA 02111-1307 USA.\r
+\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * Get the FreeRTOS eBook! See http://www.FreeRTOS.org/Documentation *\r
+ * *\r
+ * This is a concise, step by step, 'hands on' guide that describes both *\r
+ * general multitasking concepts and FreeRTOS specifics. It presents and *\r
+ * explains numerous examples that are written using the FreeRTOS API. *\r
+ * Full source code for all the examples is provided in an accompanying *\r
+ * .zip file. *\r
+ * *\r
+ ***************************************************************************\r
+\r
+ 1 tab == 4 spaces!\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
+/*\r
+ * Purpose: Lowest level routines for all ColdFire processors.\r
+ *\r
+ * Notes:\r
+ * \r
+ * ulPortSetIPL() and mcf5xxx_wr_cacr() copied with permission from FreeScale\r
+ * supplied source files.\r
+ */\r
+\r
+ .global ulPortSetIPL\r
+ .global _ulPortSetIPL\r
+ .global mcf5xxx_wr_cacrx\r
+ .global _mcf5xxx_wr_cacrx\r
+ .global vPortYieldISR\r
+ .global _vPortYieldISR\r
+ .global vPortStartFirstTask\r
+ .global _vPortStartFirstTask\r
+ .extern _pxCurrentTCB\r
+ .extern _vPortYieldHandler\r
+\r
+ .text\r
+\r
+.macro portSAVE_CONTEXT\r
+\r
+ lea.l (-60, sp), sp\r
+ movem.l d0-a6, (sp)\r
+ move.l _pxCurrentTCB, a0\r
+ move.l sp, (a0)\r
+\r
+ .endm\r
+\r
+.macro portRESTORE_CONTEXT\r
+\r
+ move.l _pxCurrentTCB, a0\r
+ move.l (a0), sp\r
+ movem.l (sp), d0-a6\r
+ lea.l (60, sp), sp\r
+ rte\r
+\r
+ .endm\r
+\r
+/********************************************************************/\r
+/*\r
+ * This routines changes the IPL to the value passed into the routine.\r
+ * It also returns the old IPL value back.\r
+ * Calling convention from C:\r
+ * old_ipl = asm_set_ipl(new_ipl);\r
+ * For the Diab Data C compiler, it passes return value thru D0.\r
+ * Note that only the least significant three bits of the passed\r
+ * value are used.\r
+ */\r
+\r
+ulPortSetIPL:\r
+_ulPortSetIPL:\r
+ link A6,#-8\r
+ movem.l D6-D7,(SP)\r
+\r
+ move.w SR,D7 /* current sr */\r
+\r
+ move.l D7,D6 /* prepare return value */\r
+ andi.l #0x0700,D6 /* mask out IPL */\r
+ lsr.l #8,D6 /* IPL */\r
+\r
+ andi.l #0x07,D0 /* least significant three bits */\r
+ lsl.l #8,D0 /* move over to make mask */\r
+\r
+ andi.l #0x0000F8FF,D7 /* zero out current IPL */\r
+ or.l D0,D7 /* place new IPL in sr */\r
+ move.w D7,SR\r
+\r
+ move.l D6, D0 /* Return value in D0. */\r
+ movem.l (SP),D6-D7\r
+ lea 8(SP),SP\r
+ unlk A6\r
+ rts\r
+/********************************************************************/\r
+\r
+mcf5xxx_wr_cacrx:\r
+_mcf5xxx_wr_cacrx:\r
+ move.l 4(sp),d0\r
+ .long 0x4e7b0002 /* movec d0,cacr */\r
+ nop\r
+ rts\r
+\r
+/********************************************************************/\r
+\r
+/* Yield interrupt. */\r
+_vPortYieldISR:\r
+vPortYieldISR:\r
+ portSAVE_CONTEXT\r
+ jsr _vPortYieldHandler\r
+ portRESTORE_CONTEXT\r
+\r
+/********************************************************************/\r
+\r
+\r
+vPortStartFirstTask:\r
+_vPortStartFirstTask:\r
+ portRESTORE_CONTEXT\r
+\r
+ .end\r
+\r
+\r
--- /dev/null
+/*\r
+ FreeRTOS.org V5.3.0 - Copyright (C) 2003-2009 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 it\r
+ under the terms of the GNU General Public License (version 2) as published\r
+ by the 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.org without being obliged to provide\r
+ the source code for any proprietary components. Alternative commercial\r
+ license and support terms are also available upon request. See the \r
+ licensing section of http://www.FreeRTOS.org for full details.\r
+\r
+ FreeRTOS.org 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.\r
+\r
+ You should have received a copy of the GNU General Public License along\r
+ with FreeRTOS.org; if not, write to the Free Software Foundation, Inc., 59\r
+ Temple Place, Suite 330, Boston, MA 02111-1307 USA.\r
+\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * Get the FreeRTOS eBook! See http://www.FreeRTOS.org/Documentation *\r
+ * *\r
+ * This is a concise, step by step, 'hands on' guide that describes both *\r
+ * general multitasking concepts and FreeRTOS specifics. It presents and *\r
+ * explains numerous examples that are written using the FreeRTOS API. *\r
+ * Full source code for all the examples is provided in an accompanying *\r
+ * .zip file. *\r
+ * *\r
+ ***************************************************************************\r
+\r
+ 1 tab == 4 spaces!\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
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\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 short\r
+#define portSTACK_TYPE unsigned long\r
+#define portBASE_TYPE long\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
+/* Hardware specifics. */\r
+#define portBYTE_ALIGNMENT 4\r
+#define portSTACK_GROWTH -1\r
+#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )\r
+/*-----------------------------------------------------------*/\r
+\r
+unsigned portLONG ulPortSetIPL( unsigned portLONG );\r
+#define portDISABLE_INTERRUPTS() ulPortSetIPL( configMAX_SYSCALL_INTERRUPT_PRIORITY )\r
+#define portENABLE_INTERRUPTS() ulPortSetIPL( 0 )\r
+\r
+\r
+extern void vPortEnterCritical( void );\r
+extern void vPortExitCritical( void );\r
+#define portENTER_CRITICAL() vPortEnterCritical()\r
+#define portEXIT_CRITICAL() vPortExitCritical()\r
+\r
+extern unsigned portBASE_TYPE uxPortSetInterruptMaskFromISR( void );\r
+extern void vPortClearInterruptMaskFromISR( unsigned portBASE_TYPE );\r
+#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortSetIPL( configMAX_SYSCALL_INTERRUPT_PRIORITY )\r
+#define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedStatusRegister ) ulPortSetIPL( uxSavedStatusRegister )\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Task utilities. */\r
+#define portNOP() asm volatile ( "nop" )\r
+\r
+/* Context switches are requested using the force register. */\r
+#define portYIELD() INTC_SFRC = 0x3E; portNOP(); portNOP(); portNOP(); portNOP(); portNOP()\r
+\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 ) __attribute__((noreturn))\r
+#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
+/*-----------------------------------------------------------*/\r
+\r
+#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired != pdFALSE ) \\r
+ { \\r
+ portYIELD(); \\r
+ }\r
+\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* PORTMACRO_H */\r
+\r