]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/portable/MPLAB/PIC18F/port.c
Update version number ready for version 9 release candidate 1.
[freertos] / FreeRTOS / Source / portable / MPLAB / PIC18F / port.c
index c056bb9aa8a8f6e554fdfb6f56967c287bd9cf18..734262a0ec53a978cf8ea0c833daa4b01f4699f5 100644 (file)
@@ -1,59 +1,64 @@
 /*\r
-    FreeRTOS V7.5.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+    FreeRTOS V9.0.0rc1 - Copyright (C) 2016 Real Time Engineers Ltd.\r
+    All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
 \r
-    ***************************************************************************\r
-     *                                                                       *\r
-     *    FreeRTOS provides completely free yet professionally developed,    *\r
-     *    robust, strictly quality controlled, supported, and cross          *\r
-     *    platform software that has become a de facto standard.             *\r
-     *                                                                       *\r
-     *    Help yourself get started quickly and support the FreeRTOS         *\r
-     *    project by purchasing a FreeRTOS tutorial book, reference          *\r
-     *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
-     *                                                                       *\r
-     *    Thank you!                                                         *\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
+    Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.\r
 \r
-    >>! NOTE: The modification to the GPL is included to allow you to distribute\r
-    >>! a combined work that includes FreeRTOS without being obliged to provide\r
-    >>! the source code for proprietary components outside of the FreeRTOS\r
-    >>! kernel.\r
+    ***************************************************************************\r
+    >>!   NOTE: The modification to the GPL is included to allow you to     !<<\r
+    >>!   distribute a combined work that includes FreeRTOS without being   !<<\r
+    >>!   obliged to provide the source code for proprietary components     !<<\r
+    >>!   outside of the FreeRTOS kernel.                                   !<<\r
+    ***************************************************************************\r
 \r
     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
-    FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available on the following\r
     link: http://www.freertos.org/a00114.html\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
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that is more than just the market leader, it     *\r
+     *    is the industry's de facto standard.                               *\r
      *                                                                       *\r
-     *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
+     *    Help yourself get started quickly while simultaneously helping     *\r
+     *    to support the FreeRTOS project by purchasing a FreeRTOS           *\r
+     *    tutorial book, reference manual, or both:                          *\r
+     *    http://www.FreeRTOS.org/Documentation                              *\r
      *                                                                       *\r
     ***************************************************************************\r
 \r
-    http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
-    license and Real Time Engineers Ltd. contact details.\r
+    http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading\r
+    the FAQ page "My application does not run, what could be wrong?".  Have you\r
+    defined configASSERT()?\r
+\r
+    http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+    embedded software for free we request you assist our global community by\r
+    participating in the support forum.\r
+\r
+    http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+    be as productive as possible as early as possible.  Now you can receive\r
+    FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+    Ltd, and the world's leading authority on the world's leading RTOS.\r
 \r
     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
     including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
     compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
 \r
-    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
-    Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
-    licenses offer ticketed support, indemnification and middleware.\r
+    http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
+    Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
+    Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and commercial middleware.\r
 \r
     http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
     engineered and independently SIL3 certified version for use in safety and\r
@@ -103,7 +108,7 @@ Changes from V3.2.0
  *----------------------------------------------------------*/\r
 \r
 /* Hardware setup for tick. */\r
-#define portTIMER_FOSC_SCALE                   ( ( unsigned long ) 4 )\r
+#define portTIMER_FOSC_SCALE                   ( ( uint32_t ) 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
@@ -120,16 +125,16 @@ 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 char ) 0x13 )\r
+#define portCOMPILER_MANAGED_MEMORY_SIZE       ( ( uint8_t ) 0x13 )\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
+typedef void TCB_t;\r
+extern volatile TCB_t * volatile pxCurrentTCB;\r
 \r
 /* IO port constants. */\r
-#define portBIT_SET            ( ( unsigned char ) 1 )\r
-#define portBIT_CLEAR  ( ( unsigned char ) 0 )\r
+#define portBIT_SET            ( ( uint8_t ) 1 )\r
+#define portBIT_CLEAR  ( ( uint8_t ) 0 )\r
 \r
 /*\r
  * The serial port ISR's are defined in serial.c, but are called from portable\r
@@ -242,7 +247,7 @@ static void prvLowInterrupt( void );
        _endasm                                                                                                                                         \\r
                                                                                                                                                                \\r
                /* Store each address from the hardware stack. */                                               \\r
-               while( STKPTR > ( unsigned char ) 0 )                                                           \\r
+               while( STKPTR > ( uint8_t ) 0 )                                                         \\r
                {                                                                                                                                               \\r
                        _asm                                                                                                                            \\r
                                MOVFF   TOSL, PREINC1                                                                                   \\r
@@ -379,10 +384,10 @@ static void prvLowInterrupt( void );
 /* \r
  * See header file for description. \r
  */\r
-portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
+StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )\r
 {\r
-unsigned long ulAddress;\r
-unsigned char ucBlock;\r
+uint32_t ulAddress;\r
+uint8_t ucBlock;\r
 \r
        /* Place a few bytes of known values on the bottom of the stack. \r
        This is just useful for debugging. */\r
@@ -400,12 +405,12 @@ unsigned char 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 long ) pvParameters;\r
-       *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );\r
+       ulAddress = ( uint32_t ) pvParameters;\r
+       *pxTopOfStack = ( StackType_t ) ( ulAddress & ( uint32_t ) 0x00ff );\r
        pxTopOfStack++;\r
 \r
        ulAddress >>= 8;\r
-       *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );\r
+       *pxTopOfStack = ( StackType_t ) ( ulAddress & ( uint32_t ) 0x00ff );\r
        pxTopOfStack++;\r
 \r
        /* Next we just leave a space.  When a context is saved the stack pointer\r
@@ -417,97 +422,97 @@ unsigned char ucBlock;
 \r
        /* Next are all the registers that form part of the task context. */\r
        \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x66; /* WREG. */\r
+       *pxTopOfStack = ( StackType_t ) 0x66; /* WREG. */\r
        pxTopOfStack++;\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0xcc; /* Status. */\r
+       *pxTopOfStack = ( StackType_t ) 0xcc; /* Status. */\r
        pxTopOfStack++;\r
 \r
        /* INTCON is saved with interrupts enabled. */\r
-       *pxTopOfStack = ( portSTACK_TYPE ) portINITAL_INTERRUPT_STATE; /* INTCON */\r
+       *pxTopOfStack = ( StackType_t ) portINITAL_INTERRUPT_STATE; /* INTCON */\r
        pxTopOfStack++;\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x11; /* BSR. */\r
+       *pxTopOfStack = ( StackType_t ) 0x11; /* BSR. */\r
        pxTopOfStack++;\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x22; /* FSR2L. */\r
+       *pxTopOfStack = ( StackType_t ) 0x22; /* FSR2L. */\r
        pxTopOfStack++;\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x33; /* FSR2H. */\r
+       *pxTopOfStack = ( StackType_t ) 0x33; /* FSR2H. */\r
        pxTopOfStack++;\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x44; /* FSR0L. */\r
+       *pxTopOfStack = ( StackType_t ) 0x44; /* FSR0L. */\r
        pxTopOfStack++;\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x55; /* FSR0H. */\r
+       *pxTopOfStack = ( StackType_t ) 0x55; /* FSR0H. */\r
        pxTopOfStack++;\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x66; /* TABLAT. */\r
+       *pxTopOfStack = ( StackType_t ) 0x66; /* TABLAT. */\r
        pxTopOfStack++;\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* TBLPTRU. */\r
+       *pxTopOfStack = ( StackType_t ) 0x00; /* TBLPTRU. */\r
        pxTopOfStack++;\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x88; /* TBLPTRUH. */\r
+       *pxTopOfStack = ( StackType_t ) 0x88; /* TBLPTRUH. */\r
        pxTopOfStack++;\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x99; /* TBLPTRUL. */\r
+       *pxTopOfStack = ( StackType_t ) 0x99; /* TBLPTRUL. */\r
        pxTopOfStack++;\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0xaa; /* PRODH. */\r
+       *pxTopOfStack = ( StackType_t ) 0xaa; /* PRODH. */\r
        pxTopOfStack++;\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0xbb; /* PRODL. */\r
+       *pxTopOfStack = ( StackType_t ) 0xbb; /* PRODL. */\r
        pxTopOfStack++;\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* PCLATU. */\r
+       *pxTopOfStack = ( StackType_t ) 0x00; /* PCLATU. */\r
        pxTopOfStack++;\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* PCLATH. */\r
+       *pxTopOfStack = ( StackType_t ) 0x00; /* PCLATH. */\r
        pxTopOfStack++;\r
 \r
        /* Next the .tmpdata and MATH_DATA sections. */\r
        for( ucBlock = 0; ucBlock <= portCOMPILER_MANAGED_MEMORY_SIZE; ucBlock++ )\r
        {\r
-               *pxTopOfStack = ( portSTACK_TYPE ) ucBlock;\r
+               *pxTopOfStack = ( StackType_t ) ucBlock;\r
                *pxTopOfStack++;\r
        }\r
 \r
        /* Store the top of the global data section. */\r
-       *pxTopOfStack = ( portSTACK_TYPE ) portCOMPILER_MANAGED_MEMORY_SIZE; /* Low. */\r
+       *pxTopOfStack = ( StackType_t ) portCOMPILER_MANAGED_MEMORY_SIZE; /* Low. */\r
        pxTopOfStack++;\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x00; /* High. */\r
+       *pxTopOfStack = ( StackType_t ) 0x00; /* High. */\r
        pxTopOfStack++;\r
 \r
        /* The only function return address so far is the address of the \r
        task. */\r
-       ulAddress = ( unsigned long ) pxCode;\r
+       ulAddress = ( uint32_t ) pxCode;\r
 \r
        /* TOS low. */\r
-       *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );\r
+       *pxTopOfStack = ( StackType_t ) ( ulAddress & ( uint32_t ) 0x00ff );\r
        pxTopOfStack++;\r
        ulAddress >>= 8;\r
 \r
        /* TOS high. */\r
-       *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );\r
+       *pxTopOfStack = ( StackType_t ) ( ulAddress & ( uint32_t ) 0x00ff );\r
        pxTopOfStack++;\r
        ulAddress >>= 8;\r
 \r
        /* TOS even higher. */\r
-       *pxTopOfStack = ( portSTACK_TYPE ) ( ulAddress & ( unsigned long ) 0x00ff );\r
+       *pxTopOfStack = ( StackType_t ) ( ulAddress & ( uint32_t ) 0x00ff );\r
        pxTopOfStack++;\r
 \r
        /* Store the number of return addresses on the hardware stack - so far only\r
        the address of the task entry point. */\r
-       *pxTopOfStack = ( portSTACK_TYPE ) 1;\r
+       *pxTopOfStack = ( StackType_t ) 1;\r
        pxTopOfStack++;\r
 \r
        return pxTopOfStack;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-portBASE_TYPE xPortStartScheduler( void )\r
+BaseType_t xPortStartScheduler( void )\r
 {\r
        /* Setup a timer for the tick ISR is using the preemptive scheduler. */\r
        prvSetupTimerInterrupt(); \r
@@ -616,9 +621,9 @@ static void prvTickISR( void )
  */\r
 static void prvSetupTimerInterrupt( void )\r
 {\r
-const unsigned long ulConstCompareValue = ( ( configCPU_CLOCK_HZ / portTIMER_FOSC_SCALE ) / configTICK_RATE_HZ );\r
-unsigned long ulCompareValue;\r
-unsigned char ucByte;\r
+const uint32_t ulConstCompareValue = ( ( configCPU_CLOCK_HZ / portTIMER_FOSC_SCALE ) / configTICK_RATE_HZ );\r
+uint32_t ulCompareValue;\r
+uint8_t ucByte;\r
 \r
        /* Interrupts are disabled when this function is called.\r
 \r
@@ -626,14 +631,14 @@ unsigned char ucByte;
        1.\r
 \r
        Clear the time count then setup timer. */\r
-       TMR1H = ( unsigned char ) 0x00;\r
-       TMR1L = ( unsigned char ) 0x00;\r
+       TMR1H = ( uint8_t ) 0x00;\r
+       TMR1L = ( uint8_t ) 0x00;\r
 \r
        /* Set the compare match value. */\r
        ulCompareValue = ulConstCompareValue;\r
-       CCPR1L = ( unsigned char ) ( ulCompareValue & ( unsigned long ) 0xff );\r
-       ulCompareValue >>= ( unsigned long ) 8;\r
-       CCPR1H = ( unsigned char ) ( ulCompareValue & ( unsigned long ) 0xff ); \r
+       CCPR1L = ( uint8_t ) ( ulCompareValue & ( uint32_t ) 0xff );\r
+       ulCompareValue >>= ( uint32_t ) 8;\r
+       CCPR1H = ( uint8_t ) ( ulCompareValue & ( uint32_t ) 0xff );    \r
 \r
        CCP1CONbits.CCP1M0 = portBIT_SET;       /*< Compare match mode. */\r
        CCP1CONbits.CCP1M1 = portBIT_SET;       /*< Compare match mode. */\r