]> git.sur5r.net Git - freertos/blobdiff - Source/portable/MPLAB/PIC18F/port.c
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Source / portable / MPLAB / PIC18F / port.c
index 3afabb39ce0502764227159e1d636fbce8b8f5c5..3d91b955bfc4480c3d86081ae7c9becd94246b79 100644 (file)
@@ -1,50 +1,67 @@
 /*\r
-       FreeRTOS.org V5.1.1 - 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
+    FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.\r
+       \r
 \r
     ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS tutorial books are available in pdf and paperback.        *\r
+     *    Complete, revised, and edited pdf reference manuals are also       *\r
+     *    available.                                                         *\r
+     *                                                                       *\r
+     *    Purchasing FreeRTOS documentation will not only help you, by       *\r
+     *    ensuring you get running as quickly as possible and with an        *\r
+     *    in-depth knowledge of how to use FreeRTOS, it will also help       *\r
+     *    the FreeRTOS project to continue with its mission of providing     *\r
+     *    professional grade, cross platform, de facto standard solutions    *\r
+     *    for microcontrollers - completely free of charge!                  *\r
+     *                                                                       *\r
+     *    >>> See http://www.FreeRTOS.org/Documentation for details. <<<     *\r
+     *                                                                       *\r
+     *    Thank you for using FreeRTOS, and thank you for your support!      *\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
+    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 modification to the GPL is included to allow you to\r
+    distribute a combined work that includes FreeRTOS without being obliged to\r
+    provide the source code for proprietary components outside of the FreeRTOS\r
+    kernel.  FreeRTOS is distributed in the hope that it will be useful, but\r
+    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+    or 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
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    Having a problem?  Start by reading the FAQ "My application does   *\r
+     *    not run, what could be wrong?                                      *\r
+     *                                                                       *\r
+     *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
+     *                                                                       *\r
+    ***************************************************************************\r
 \r
-       http://www.OpenRTOS.com - Commercial support, development, porting, \r
-       licensing and training services.\r
+    \r
+    http://www.FreeRTOS.org - Documentation, training, latest information, \r
+    license and contact details.\r
+    \r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool.\r
+\r
+    Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
+    the code with commercial support, indemnification, and middleware, under \r
+    the OpenRTOS brand: http://www.OpenRTOS.com.  High Integrity Systems also\r
+    provide a safety engineered and independently SIL3 certified version under \r
+    the SafeRTOS brand: http://www.SafeRTOS.com.\r
 */\r
 \r
 /* \r
@@ -88,7 +105,7 @@ Changes from V3.2.0
  *----------------------------------------------------------*/\r
 \r
 /* Hardware setup for tick. */\r
-#define portTIMER_FOSC_SCALE                   ( ( unsigned portLONG ) 4 )\r
+#define portTIMER_FOSC_SCALE                   ( ( unsigned long ) 4 )\r
 \r
 /* Initial interrupt enable state for newly created tasks.  This value is\r
 copied into INTCON when a task switches in for the first time. */\r
@@ -105,7 +122,7 @@ enable state to be unchanged when the interrupted task is switched back in. */
 area's get used by the compiler for temporary storage, especially when \r
 performing mathematical operations, or when using 32bit data types.  This\r
 constant defines the size of memory area which must be saved. */\r
-#define portCOMPILER_MANAGED_MEMORY_SIZE       ( ( unsigned portCHAR ) 0x13 )\r
+#define portCOMPILER_MANAGED_MEMORY_SIZE       ( ( unsigned char ) 0x13 )\r
 \r
 /* We require the address of the pxCurrentTCB variable, but don't want to know\r
 any details of its type. */\r
@@ -113,8 +130,8 @@ typedef void tskTCB;
 extern volatile tskTCB * volatile pxCurrentTCB;\r
 \r
 /* IO port constants. */\r
-#define portBIT_SET            ( ( unsigned portCHAR ) 1 )\r
-#define portBIT_CLEAR  ( ( unsigned portCHAR ) 0 )\r
+#define portBIT_SET            ( ( unsigned char ) 1 )\r
+#define portBIT_CLEAR  ( ( unsigned char ) 0 )\r
 \r
 /*\r
  * The serial port ISR's are defined in serial.c, but are called from portable\r
@@ -227,7 +244,7 @@ static void prvLowInterrupt( void );
        _endasm                                                                                                                                         \\r
                                                                                                                                                                \\r
                /* Store each address from the hardware stack. */                                               \\r
-               while( STKPTR > ( unsigned portCHAR ) 0 )                                                               \\r
+               while( STKPTR > ( unsigned char ) 0 )                                                           \\r
                {                                                                                                                                               \\r
                        _asm                                                                                                                            \\r
                                MOVFF   TOSL, PREINC1                                                                                   \\r
@@ -366,8 +383,8 @@ static void prvLowInterrupt( void );
  */\r
 portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
 {\r
-unsigned portLONG ulAddress;\r
-unsigned portCHAR ucBlock;\r
+unsigned long ulAddress;\r
+unsigned char ucBlock;\r
 \r
        /* Place a few bytes of known values on the bottom of the stack. \r
        This is just useful for debugging. */\r
@@ -385,12 +402,12 @@ unsigned portCHAR ucBlock;
 \r
        First store the function parameters.  This is where the task will expect to\r
        find them when it starts running. */\r
-       ulAddress = ( unsigned portLONG ) pvParameters;\r
-       *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned portLONG ) 0x00ff );\r
+       ulAddress = ( unsigned long ) pvParameters;\r
+       *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );\r
        pxTopOfStack++;\r
 \r
        ulAddress >>= 8;\r
-       *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned portLONG ) 0x00ff );\r
+       *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );\r
        pxTopOfStack++;\r
 \r
        /* Next we just leave a space.  When a context is saved the stack pointer\r
@@ -467,20 +484,20 @@ unsigned portCHAR ucBlock;
 \r
        /* The only function return address so far is the address of the \r
        task. */\r
-       ulAddress = ( unsigned portLONG ) pxCode;\r
+       ulAddress = ( unsigned long ) pxCode;\r
 \r
        /* TOS low. */\r
-       *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned portLONG ) 0x00ff );\r
+       *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );\r
        pxTopOfStack++;\r
        ulAddress >>= 8;\r
 \r
        /* TOS high. */\r
-       *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned portLONG ) 0x00ff );\r
+       *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );\r
        pxTopOfStack++;\r
        ulAddress >>= 8;\r
 \r
        /* TOS even higher. */\r
-       *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned portLONG ) 0x00ff );\r
+       *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );\r
        pxTopOfStack++;\r
 \r
        /* Store the number of return addresses on the hardware stack - so far only\r
@@ -604,9 +621,9 @@ static void prvTickISR( void )
  */\r
 static void prvSetupTimerInterrupt( void )\r
 {\r
-const unsigned portLONG ulConstCompareValue = ( ( configCPU_CLOCK_HZ / portTIMER_FOSC_SCALE ) / configTICK_RATE_HZ );\r
-unsigned portLONG ulCompareValue;\r
-unsigned portCHAR ucByte;\r
+const unsigned long ulConstCompareValue = ( ( configCPU_CLOCK_HZ / portTIMER_FOSC_SCALE ) / configTICK_RATE_HZ );\r
+unsigned long ulCompareValue;\r
+unsigned char ucByte;\r
 \r
        /* Interrupts are disabled when this function is called.\r
 \r
@@ -614,14 +631,14 @@ unsigned portCHAR ucByte;
        1.\r
 \r
        Clear the time count then setup timer. */\r
-       TMR1H = ( unsigned portCHAR ) 0x00;\r
-       TMR1L = ( unsigned portCHAR ) 0x00;\r
+       TMR1H = ( unsigned char ) 0x00;\r
+       TMR1L = ( unsigned char ) 0x00;\r
 \r
        /* Set the compare match value. */\r
        ulCompareValue = ulConstCompareValue;\r
-       CCPR1L = ( unsigned portCHAR ) ( ulCompareValue & ( unsigned portLONG ) 0xff );\r
-       ulCompareValue >>= ( unsigned portLONG ) 8;\r
-       CCPR1H = ( unsigned portCHAR ) ( ulCompareValue & ( unsigned portLONG ) 0xff ); \r
+       CCPR1L = ( unsigned char ) ( ulCompareValue & ( unsigned long ) 0xff );\r
+       ulCompareValue >>= ( unsigned long ) 8;\r
+       CCPR1H = ( unsigned char ) ( ulCompareValue & ( unsigned long ) 0xff ); \r
 \r
        CCP1CONbits.CCP1M0 = portBIT_SET;       /*< Compare match mode. */\r
        CCP1CONbits.CCP1M1 = portBIT_SET;       /*< Compare match mode. */\r