]> 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 1ea23611c2c1809eb3b76c817a7f0b9848a69736..427898778b48577c4f8f27a356d2a8ea1f18ef85 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V7.4.0 - Copyright (C) 2013 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
     http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
@@ -39,7 +39,7 @@
     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 itcan be\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
@@ -111,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
@@ -154,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
@@ -190,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
@@ -198,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
@@ -210,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
@@ -235,30 +248,49 @@ const unsigned short usCompareMatch = ( usClockHz / configTICK_RATE_HZ ) + 1UL;
        /* Use the internal 15K clock. */\r
        OSMC = ( unsigned char ) 0x16;\r
 \r
-       /* Supply the RTC clock. */\r
-       RTCEN = ( unsigned char ) 1U;\r
-       \r
-       /* Disable ITMC operation. */\r
-       ITMC = ( unsigned char ) 0x0000;\r
-       \r
-       /* Disable INTIT interrupt. */\r
-       ITMK = ( unsigned char ) 1;\r
-       \r
-       /* Set INTIT high priority */\r
-       ITPR1 = ( unsigned char ) 1;\r
-       ITPR0 = ( unsigned char ) 1;\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
-       /* Enable IT operation. */\r
-//     ITMC |= 0x8000;\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