]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/portable/IAR/RL78/port.c
Update version number ready to release the FAT file system demo.
[freertos] / FreeRTOS / Source / portable / IAR / RL78 / port.c
index 3f7742a6a8649ae932aae5d9655f411d8fe005d2..427898778b48577c4f8f27a356d2a8ea1f18ef85 100644 (file)
@@ -1,7 +1,7 @@
 /*\r
-    FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
+    FreeRTOS V7.4.2 - Copyright (C) 2013 Real Time Engineers Ltd.\r
 \r
-    FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT \r
+    FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT\r
     http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
 \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
+\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
+    kernel.\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.  See the GNU General Public License for more\r
+    details. You should have received a copy of the GNU General Public License\r
+    and the FreeRTOS license exception along with FreeRTOS; if not it can be\r
+    viewed here: http://www.freertos.org/a00114.html and also obtained by\r
+    writing to Real Time Engineers Ltd., contact details for whom are available\r
+    on the FreeRTOS WEB site.\r
 \r
     1 tab == 4 spaces!\r
-    \r
+\r
     ***************************************************************************\r
      *                                                                       *\r
      *    Having a problem?  Start by reading the FAQ "My application does   *\r
      *                                                                       *\r
     ***************************************************************************\r
 \r
-    \r
-    http://www.FreeRTOS.org - Documentation, training, latest versions, license \r
-    and contact details.  \r
-    \r
+\r
+    http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
+    license and Real Time Engineers Ltd. contact details.\r
+\r
     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
-    including FreeRTOS+Trace - an indispensable productivity tool.\r
+    including FreeRTOS+Trace - an indispensable productivity tool, and our new\r
+    fully thread aware and reentrant UDP/IP stack.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+    Integrity Systems, who sell the code with commercial support,\r
+    indemnification and middleware, under the OpenRTOS brand.\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
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
 */\r
 \r
 /* Scheduler includes. */\r
@@ -105,9 +111,17 @@ volatile unsigned short usCriticalNesting = portINITIAL_CRITICAL_NESTING;
 /*-----------------------------------------------------------*/\r
 \r
 /*\r
- * Sets up the periodic ISR used for the RTOS tick.\r
+ * Sets up the periodic ISR used for the RTOS tick using the interval timer.\r
+ * The application writer can define configSETUP_TICK_INTERRUPT() (in\r
+ * FreeRTOSConfig.h) such that their own tick interrupt configuration is used\r
+ * in place of prvSetupTimerInterrupt().\r
  */\r
 static void prvSetupTimerInterrupt( void );\r
+#ifndef configSETUP_TICK_INTERRUPT\r
+       /* The user has not provided their own tick interrupt configuration so use\r
+    the definition in this file (which uses the interval timer). */\r
+       #define configSETUP_TICK_INTERRUPT() prvSetupTimerInterrupt()\r
+#endif /* configSETUP_TICK_INTERRUPT */\r
 \r
 /*\r
  * Defined in portasm.s87, this function starts the scheduler by loading the\r
@@ -148,7 +162,7 @@ unsigned long *pulLocal;
                /* The start address / PSW value is also written in as a 32bit value,\r
                so leave a space for the second two bytes. */\r
                pxTopOfStack--;\r
-       \r
+\r
                /* Task function start address combined with the PSW. */\r
                pulLocal = ( unsigned long * ) pxTopOfStack;\r
                *pulLocal = ( ( ( unsigned long ) pxCode ) | ( portPSW << 24UL ) );\r
@@ -184,7 +198,7 @@ unsigned long *pulLocal;
        *pxTopOfStack = ( portSTACK_TYPE ) 0x0F00;\r
        pxTopOfStack--;\r
 \r
-       /* Finally the remaining general purpose registers DE and BC */\r
+       /* The remaining general purpose registers DE and BC */\r
        *pxTopOfStack = ( portSTACK_TYPE ) 0xDEDE;\r
        pxTopOfStack--;\r
        *pxTopOfStack = ( portSTACK_TYPE ) 0xBCBC;\r
@@ -192,9 +206,9 @@ unsigned long *pulLocal;
 \r
        /* Finally the critical section nesting count is set to zero when the task\r
        first starts. */\r
-       *pxTopOfStack = ( portSTACK_TYPE ) portNO_CRITICAL_SECTION_NESTING;     \r
+       *pxTopOfStack = ( portSTACK_TYPE ) portNO_CRITICAL_SECTION_NESTING;\r
 \r
-       /* Return a pointer to the top of the stack that has beene generated so it\r
+       /* Return a pointer to the top of the stack that has been generated so it\r
        can     be stored in the task control block for the task. */\r
        return pxTopOfStack;\r
 }\r
@@ -204,20 +218,25 @@ portBASE_TYPE xPortStartScheduler( void )
 {\r
        /* Setup the hardware to generate the tick.  Interrupts are disabled when\r
        this function is called. */\r
-       prvSetupTimerInterrupt();\r
+       configSETUP_TICK_INTERRUPT();\r
 \r
        /* Restore the context of the first task that is going to run. */\r
        vPortStartFirstTask();\r
 \r
-       /* Execution should not reach here as the tasks are now running! */\r
+       /* Execution should not reach here as the tasks are now running!\r
+       prvSetupTimerInterrupt() is called here to prevent the compiler outputting\r
+       a warning about a statically declared function not being referenced in the\r
+       case that the application writer has provided their own tick interrupt\r
+       configuration routine (and defined configSETUP_TICK_INTERRUPT() such that\r
+       their own routine will be called in place of prvSetupTimerInterrupt()). */\r
+       prvSetupTimerInterrupt();\r
        return pdTRUE;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 void vPortEndScheduler( void )\r
 {\r
-       /* It is unlikely that the RL78/G13 port will get stopped.  If required simply\r
-       disable the tick interrupt here. */\r
+       /* It is unlikely that the RL78 port will get stopped. */\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -227,32 +246,51 @@ const unsigned short usClockHz = 15000UL; /* Internal clock. */
 const unsigned short usCompareMatch = ( usClockHz / configTICK_RATE_HZ ) + 1UL;\r
 \r
        /* Use the internal 15K clock. */\r
-       OSMC = 0x16U;\r
-\r
-       /* Supply the RTC clock. */\r
-       RTCEN = 1U;\r
-       \r
-       /* Disable ITMC operation. */\r
-       ITMC = 0x0000;\r
-       \r
-       /* Disable INTIT interrupt. */\r
-       ITMK = 1U;\r
-       \r
-       /* Set INTIT high priority */\r
-       ITPR1 = 1U;\r
-       ITPR0 = 1U;\r
-       \r
-       /* Set interval. */\r
-       ITMC = usCompareMatch;\r
-\r
-       /* Clear INIT interrupt. */\r
-       ITIF = 0U;\r
-       \r
-       /* Enable INTIT interrupt. */\r
-       ITMK = 0U;\r
-       \r
-       /* Enable IT operation. */\r
-       ITMC |= 0x8000;\r
+       OSMC = ( unsigned char ) 0x16;\r
+\r
+       #ifdef RTCEN\r
+       {\r
+               /* Supply the interval timer clock. */\r
+               RTCEN = ( unsigned char ) 1U;\r
+\r
+               /* Disable INTIT interrupt. */\r
+               ITMK = ( unsigned char ) 1;\r
+\r
+               /* Disable ITMC operation. */\r
+               ITMC = ( unsigned char ) 0x0000;\r
+\r
+               /* Clear INIT interrupt. */\r
+               ITIF = ( unsigned char ) 0;\r
+\r
+               /* Set interval and enable interrupt operation. */\r
+               ITMC = usCompareMatch | 0x8000U;\r
+\r
+               /* Enable INTIT interrupt. */\r
+               ITMK = ( unsigned char ) 0;\r
+       }\r
+       #endif\r
+\r
+       #ifdef TMKAEN\r
+       {\r
+               /* Supply the interval timer clock. */\r
+               TMKAEN = ( unsigned char ) 1U;\r
+\r
+               /* Disable INTIT interrupt. */\r
+               TMKAMK = ( unsigned char ) 1;\r
+\r
+               /* Disable ITMC operation. */\r
+               ITMC = ( unsigned char ) 0x0000;\r
+\r
+               /* Clear INIT interrupt. */\r
+               TMKAIF = ( unsigned char ) 0;\r
+\r
+               /* Set interval and enable interrupt operation. */\r
+               ITMC = usCompareMatch | 0x8000U;\r
+\r
+               /* Enable INTIT interrupt. */\r
+               TMKAMK = ( unsigned char ) 0;\r
+       }\r
+       #endif\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r