]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/RL78_RL78G13_Promo_Board_IAR/main.c
Update version number in readiness for V10.3.0 release. Sync SVN with reviewed releas...
[freertos] / FreeRTOS / Demo / RL78_RL78G13_Promo_Board_IAR / main.c
index e16156d0a15e866a6a958ff9788e9dac534afbdf..917e59ebdb6eba0c1d5191475d7719235bb7fce8 100644 (file)
 /*\r
-    FreeRTOS V7.4.0 - 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
-\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
-\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
-\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.\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 itcan 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
-     *    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
-\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, 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
-    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
-/******************************************************************************\r
- * This project provides two demo applications.  A simple blinky style project,\r
- * and a more comprehensive test and demo application.  The\r
- * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this file) is used to\r
- * select between the two.  The simply blinky demo is implemented and described\r
- * in main_blinky.c.  The more comprehensive test and demo application is\r
- * implemented and described in main_full.c.\r
+ * FreeRTOS Kernel V10.3.0\r
+ * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
  *\r
- * This file implements the code that is not demo specific, including the\r
- * hardware setup and FreeRTOS hook functions.\r
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+ * this software and associated documentation files (the "Software"), to deal in\r
+ * the Software without restriction, including without limitation the rights to\r
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
+ * the Software, and to permit persons to whom the Software is furnished to do so,\r
+ * subject to the following conditions:\r
  *\r
- * This project does not provide an example of how to write an RTOS compatible\r
- * interrupt service routine (other than the tick interrupt itself), so this\r
- * file contains the function vAnExampleISR_C_Handler() as a dummy example (that\r
- * is not actually installed) that can be used as a reference.  Also see the\r
- * file ExampleISR.s87, and the documentation page for this demo on the\r
- * FreeRTOS.org website for full instructions.\r
+ * The above copyright notice and this permission notice shall be included in all\r
+ * copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ *\r
+ * http://www.FreeRTOS.org\r
+ * http://aws.amazon.com/freertos\r
+ *\r
+ * 1 tab == 4 spaces!\r
+ */\r
+\r
+/*\r
  *\r
  * ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON\r
  * THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO\r
  * APPLICATION, AND ITS ASSOCIATE FreeRTOS ARCHITECTURE PORT!\r
  *\r
+ *\r
+ * main() creates the demo application tasks and timers, then starts the\r
+ * scheduler.\r
+ *\r
+ * This demo is configured to run on the RL78/G13 Promotion Board, which is\r
+ * fitted with a R5F100LEA microcontroller.  The R5F100LEA contains a little\r
+ * under 4K bytes of usable internal RAM.  The RAM size restricts the number of\r
+ * demo tasks that can be created, and the demo creates 13 tasks, 4 queues and\r
+ * two timers.  The RL78 range does however include parts with up to 32K bytes\r
+ * of RAM (at the time of writing).  Using FreeRTOS on such a part will allow an\r
+ * application to make a more comprehensive use of FreeRTOS tasks, and other\r
+ * FreeRTOS features.\r
+ *\r
+ * In addition to the standard demo tasks, the following tasks, tests and timers\r
+ * are created within this file:\r
+ *\r
+ * "Reg test" tasks - These fill the registers with known values, then check\r
+ * that each register still contains its expected value.  Each task uses a\r
+ * different set of values.  The reg test tasks execute with a very low priority,\r
+ * so get preempted very frequently.  A register containing an unexpected value\r
+ * is indicative of an error in the context switching mechanism.\r
+ *\r
+ * The "Demo" Timer and Callback Function:\r
+ * The demo timer callback function does nothing more than increment a variable.\r
+ * The period of the demo timer is set relative to the period of the check timer\r
+ * (described below).  This allows the check timer to know how many times the\r
+ * demo timer callback function should execute between each execution of the\r
+ * check timer callback function.  The variable incremented in the demo timer\r
+ * callback function is used to determine how many times the callback function\r
+ * has executed.\r
+ *\r
+ * The "Check" Timer and Callback Function:\r
+ * The check timer period is initially set to three seconds.  The check timer\r
+ * callback function checks that all the standard demo tasks, the reg test tasks,\r
+ * and the demo timer are not only still executing, but are executing without\r
+ * reporting any errors.  If the check timer discovers that a task or timer has\r
+ * stalled, or reported an error, then it changes its own period from the\r
+ * initial three seconds, to just 200ms.  The check timer callback function also\r
+ * toggles the user LED each time it is called.  This provides a visual\r
+ * indication of the system status:  If the LED toggles every three seconds,\r
+ * then no issues have been discovered.  If the LED toggles every 200ms, then an\r
+ * issue has been discovered with at least one task.\r
+ *\r
  */\r
 \r
 /* Scheduler include files. */\r
 #include "FreeRTOS.h"\r
 #include "task.h"\r
-#include "semphr.h"\r
+#include "timers.h"\r
+\r
+/* Standard demo includes. */\r
+#include "dynamic.h"\r
+#include "PollQ.h"\r
+#include "blocktim.h"\r
+\r
+/* The period at which the check timer will expire, in ms, provided no errors\r
+have been reported by any of the standard demo tasks.  ms are converted to the\r
+equivalent in ticks using the portTICK_PERIOD_MS constant. */\r
+#define mainCHECK_TIMER_PERIOD_MS                      ( 3000UL / portTICK_PERIOD_MS )\r
 \r
-/* Hardware includes. */\r
-#include "port_iodefine.h"\r
-#include "port_iodefine_ext.h"\r
-#include "LED.h"\r
+/* The period at which the check timer will expire, in ms, if an error has been\r
+reported in one of the standard demo tasks, the check tasks, or the demo timer.\r
+ms are converted to the equivalent in ticks using the portTICK_PERIOD_MS\r
+constant. */\r
+#define mainERROR_CHECK_TIMER_PERIOD_MS        ( 200UL / portTICK_PERIOD_MS )\r
 \r
-/* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,\r
-or 0 to run the more comprehensive test and demo application. */\r
-#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY     1\r
+/* These two definitions are used to set the period of the demo timer.  The demo\r
+timer period is always relative to the check timer period, so the check timer\r
+can determine if the demo timer has expired the expected number of times between\r
+its own executions. */\r
+#define mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEOUT      ( 100UL )\r
+#define mainDEMO_TIMER_PERIOD_MS                       ( mainCHECK_TIMER_PERIOD_MS / mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEOUT )\r
+\r
+/* The LED toggled by the check timer. */\r
+#define mainLED_0                                              P7_bit.no7\r
+\r
+/* A block time of zero simple means "don't block". */\r
+#define mainDONT_BLOCK                                         ( 0U )\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
 /*\r
- * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.\r
- * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.\r
+ * The 'check' timer callback function, as described at the top of this file.\r
+ */\r
+static void prvCheckTimerCallback( TimerHandle_t xTimer );\r
+\r
+/*\r
+ * The 'demo' timer callback function, as described at the top of this file.\r
  */\r
-extern void main_blinky( void );\r
-extern void main_full( void );\r
+static void prvDemoTimerCallback( TimerHandle_t xTimer );\r
 \r
 /*\r
  * This function is called from the C startup routine to setup the processor -\r
@@ -125,18 +128,29 @@ extern void main_full( void );
  */\r
 int __low_level_init(void);\r
 \r
-/* Prototypes for the standard FreeRTOS callback/hook functions implemented\r
-within this file. */\r
-void vApplicationMallocFailedHook( void );\r
-void vApplicationIdleHook( void );\r
-void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName );\r
-void vApplicationTickHook( void );\r
+/*\r
+ * Functions that define the RegTest tasks, as described at the top of this file.\r
+ */\r
+extern void vRegTest1( void *pvParameters );\r
+extern void vRegTest2( void *pvParameters );\r
+\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
-/* This variable is not actually used, but provided to allow an example of how\r
-to write an ISR to be included in this file. */\r
-static xSemaphoreHandle xSemaphore = NULL;\r
+/* If an error is discovered by one of the RegTest tasks then this flag is set\r
+to pdFAIL.  The 'check' timer then inspects this flag to detect errors within\r
+the RegTest tasks. */\r
+static short sRegTestStatus = pdPASS;\r
+\r
+/* The check timer.  This uses prvCheckTimerCallback() as its callback\r
+function. */\r
+static TimerHandle_t xCheckTimer = NULL;\r
+\r
+/* The demo timer.  This uses prvDemoTimerCallback() as its callback function. */\r
+static TimerHandle_t xDemoTimer = NULL;\r
+\r
+/* This variable is incremented each time the demo timer expires. */\r
+static volatile unsigned long ulDemoSoftwareTimerCounter = 0UL;\r
 \r
 /* RL78 Option Byte Definition. Watchdog disabled, LVI enabled, OCD interface\r
 enabled. */\r
@@ -146,58 +160,130 @@ __root __far const unsigned char OptionByte[] @ 0x00C0 =
 };\r
 \r
 /* Security byte definition */\r
-__root __far const unsigned char ucSecurityCode[]  @ 0x00C4 =\r
+__root __far const unsigned char SecuIDCode[]  @ 0x00C4 =\r
 {\r
-       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\r
+       0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x54\r
 };\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
-void main( void )\r
+short main( void )\r
 {\r
-       /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top\r
-       of this file. */\r
-       #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1\r
+       /* Creates all the tasks and timers, then starts the scheduler. */\r
+\r
+       /* First create the 'standard demo' tasks.  These are used to demonstrate\r
+       API functions being used and also to test the kernel port.  More information\r
+       is provided on the FreeRTOS.org WEB site. */\r
+       vStartDynamicPriorityTasks();\r
+       vStartPolledQueueTasks( tskIDLE_PRIORITY );\r
+       vCreateBlockTimeTasks();\r
+\r
+       /* Create the RegTest tasks as described at the top of this file. */\r
+       xTaskCreate( vRegTest1, "Reg1", configMINIMAL_STACK_SIZE, NULL, 0, NULL );\r
+       xTaskCreate( vRegTest2, "Reg2", configMINIMAL_STACK_SIZE, NULL, 0, NULL );\r
+\r
+       /* Create the software timer that performs the 'check' functionality,\r
+       as described at the top of this file. */\r
+       xCheckTimer = xTimerCreate( "CheckTimer",/* A text name, purely to help debugging. */\r
+                                                               ( mainCHECK_TIMER_PERIOD_MS ),          /* The timer period, in this case 3000ms (3s). */\r
+                                                               pdTRUE,                                                         /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */\r
+                                                               ( void * ) 0,                                           /* The ID is not used, so can be set to anything. */\r
+                                                               prvCheckTimerCallback                           /* The callback function that inspects the status of all the other tasks. */\r
+                                                         );\r
+\r
+       /* Create the software timer that just increments a variable for demo\r
+       purposes. */\r
+       xDemoTimer = xTimerCreate( "DemoTimer",/* A text name, purely to help debugging. */\r
+                                                               ( mainDEMO_TIMER_PERIOD_MS ),           /* The timer period, in this case it is always calculated relative to the check timer period (see the definition of mainDEMO_TIMER_PERIOD_MS). */\r
+                                                               pdTRUE,                                                         /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */\r
+                                                               ( void * ) 0,                                           /* The ID is not used, so can be set to anything. */\r
+                                                               prvDemoTimerCallback                            /* The callback function that inspects the status of all the other tasks. */\r
+                                                         );\r
+\r
+       /* Start both the check timer and the demo timer.  The timers won't actually\r
+       start until the scheduler is started. */\r
+       xTimerStart( xCheckTimer, mainDONT_BLOCK );\r
+       xTimerStart( xDemoTimer, mainDONT_BLOCK );\r
+\r
+       /* Finally start the scheduler running. */\r
+       vTaskStartScheduler();\r
+\r
+       /* If this line is reached then vTaskStartScheduler() returned because there\r
+       was insufficient heap memory remaining for the idle task to be created. */\r
+       for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvDemoTimerCallback( TimerHandle_t xTimer )\r
+{\r
+       /* The demo timer has expired.  All it does is increment a variable.  The\r
+       period of the demo timer is relative to that of the check timer, so the\r
+       check timer knows how many times this variable should have been incremented\r
+       between each execution of the check timer's own callback. */\r
+       ulDemoSoftwareTimerCounter++;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCheckTimerCallback( TimerHandle_t xTimer )\r
+{\r
+static portBASE_TYPE xChangedTimerPeriodAlready = pdFALSE, xErrorStatus = pdPASS;\r
+\r
+       /* Inspect the status of the standard demo tasks. */\r
+       if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
        {\r
-               main_blinky();\r
+               xErrorStatus = pdFAIL;\r
        }\r
-       #else\r
+\r
+       if( xArePollingQueuesStillRunning() != pdTRUE )\r
        {\r
-               main_full();\r
+               xErrorStatus = pdFAIL;\r
        }\r
-       #endif\r
-}\r
-/*-----------------------------------------------------------*/\r
 \r
-void vAnExampleISR_C_Handler( void )\r
-{\r
-       /*\r
-        * This demo does not include a functional interrupt service routine - so\r
-        * this dummy handler (which is not actually installed) is provided as an\r
-        * example of how an ISR that needs to cause a context switch needs to be\r
-        * implemented.  ISRs that do not cause a context switch have no special\r
-        * requirements and can be written as per the compiler documentation.\r
-        *\r
-        * This C function is called from a wrapper function that is implemented\r
-        * in assembly code.  See vANExampleISR_ASM_Wrapper() in ExampleISR.s87.\r
-        * Also see the documentation page for this demo on the FreeRTOS.org website\r
-         * for full instructions.\r
-        */\r
-short sHigherPriorityTaskWoken = pdFALSE;\r
-\r
-       /* Handler code goes here...*/\r
-\r
-       /* For purposes of demonstration, assume at some point the hander calls\r
-       xSemaphoreGiveFromISR().*/\r
-       xSemaphoreGiveFromISR( xSemaphore, &sHigherPriorityTaskWoken );\r
-\r
-       /* If giving the semaphore unblocked a task, and the unblocked task has a\r
-       priority higher than or equal to the currently running task, then\r
-       sHigherPriorityTaskWoken will have been set to pdTRUE internally within the\r
-       xSemaphoreGiveFromISR() function.  Passing a pdTRUE     value to\r
-       portYIELD_FROM_ISR() will cause this interrupt to return directly to the\r
-       higher priority unblocked task. */\r
-       portYIELD_FROM_ISR( sHigherPriorityTaskWoken );\r
+       if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
+       {\r
+               xErrorStatus = pdFAIL;\r
+       }\r
+\r
+       /* Inspect the status of the reg test tasks. */\r
+       if( sRegTestStatus != pdPASS )\r
+       {\r
+               xErrorStatus = pdFAIL;\r
+       }\r
+\r
+       /* Ensure that the demo software timer has expired\r
+       mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEOUT times in between\r
+       each call of this function.  A critical section is not required to access\r
+       ulDemoSoftwareTimerCounter as the variable is only accessed from another\r
+       software timer callback, and only one software timer callback can be\r
+       executing at any time. */\r
+       if( ( ulDemoSoftwareTimerCounter < ( mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEOUT - 1 ) ) ||\r
+           ( ulDemoSoftwareTimerCounter > ( mainDEMO_TIMER_INCREMENTS_PER_CHECK_TIMER_TIMEOUT + 1 ) )\r
+         )\r
+       {\r
+               xErrorStatus = pdFAIL;\r
+       }\r
+       else\r
+       {\r
+               ulDemoSoftwareTimerCounter = 0UL;\r
+       }\r
+\r
+       if( ( xErrorStatus == pdFAIL ) && ( xChangedTimerPeriodAlready == pdFALSE ) )\r
+       {\r
+               /* An error has occurred, but the timer's period has not yet been changed,\r
+               change it now, and remember that it has been changed.  Shortening the\r
+               timer's period means the LED will toggle at a faster rate, giving a\r
+               visible indication that something has gone wrong. */\r
+               xChangedTimerPeriodAlready = pdTRUE;\r
+\r
+               /* This call to xTimerChangePeriod() uses a zero block time.  Functions\r
+               called from inside of a timer callback function must *never* attempt to\r
+               block. */\r
+               xTimerChangePeriod( xCheckTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );\r
+       }\r
+\r
+       /* Toggle the LED.  The toggle rate will depend on whether or not an error\r
+       has been found in any tasks. */\r
+       mainLED_0 = !mainLED_0;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -207,30 +293,86 @@ unsigned char ucResetFlag = RESF;
 \r
        portDISABLE_INTERRUPTS();\r
 \r
-       /* Set fMX */\r
-       CMC = 0x00;\r
-       MSTOP = 1U;\r
+       /* Clock Configuration:\r
+       In this port, to use the internal high speed clock source of the\r
+       microcontroller, define the configCLOCK_SOURCE as 1 in FreeRTOSConfig.h.  To\r
+       use an external clock define configCLOCK_SOURCE as 0. */\r
+       #if configCLOCK_SOURCE == 1\r
+       {\r
+               /* Set fMX */\r
+               CMC = 0x00;\r
+               MSTOP = 1U;\r
+\r
+               /* Set fMAIN */\r
+               MCM0 = 0U;\r
 \r
-       /* Set fMAIN */\r
-       MCM0 = 0U;\r
+               /* Set fSUB */\r
+               XTSTOP = 1U;\r
+               OSMC = 0x10;\r
 \r
-       /* Set fSUB */\r
-       XTSTOP = 1U;\r
-       OSMC = 0x10;\r
+               /* Set fCLK */\r
+               CSS = 0U;\r
 \r
-       /* Set fCLK */\r
-       CSS = 0U;\r
+               /* Set fIH */\r
+               HIOSTOP = 0U;\r
+       }\r
+       #else\r
+       {\r
+               unsigned char ucTempStabset, ucTempStabWait;\r
+\r
+               /* Set fMX */\r
+               CMC = 0x41;\r
+               OSTS = 0x07;\r
+               MSTOP = 0U;\r
+               ucTempStabset = 0xFF;\r
+\r
+               do\r
+               {\r
+                       ucTempStabWait = OSTC;\r
+                       ucTempStabWait &= ucTempStabset;\r
+               }\r
+               while( ucTempStabWait != ucTempStabset );\r
+\r
+               /* Set fMAIN */\r
+               MCM0 = 1U;\r
+\r
+               /* Set fSUB */\r
+               XTSTOP = 1U;\r
+               OSMC = 0x10;\r
+\r
+               /* Set fCLK */\r
+               CSS = 0U;\r
+\r
+               /* Set fIH */\r
+               HIOSTOP = 0U;\r
+       }\r
+       #endif /* configCLOCK_SOURCE == 1 */\r
 \r
-       /* Set fIH */\r
-       HIOSTOP = 0U;\r
+       /* LED port initialization - set port register. */\r
+       P7 &= 0x7F;\r
 \r
-       /* LED port initialization. */\r
-       LED_INIT();\r
+       /* Set port mode register. */\r
+       PM7 &= 0x7F;\r
+\r
+       /* Switch pin initialization - enable pull-up resistor. */\r
+       PU12_bit.no0  = 1;\r
 \r
        return pdTRUE;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
+void vRegTestError( void )\r
+{\r
+       /* Called by the RegTest tasks if an error is found.  lRegTestStatus is\r
+       inspected by the check task. */\r
+       sRegTestStatus = pdFAIL;\r
+\r
+       /* Do not return from here as the reg test tasks clobber all registers so\r
+       function calls may not function correctly. */\r
+       for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
 void vApplicationMallocFailedHook( void )\r
 {\r
        /* Called if a call to pvPortMalloc() fails because there is insufficient\r
@@ -243,7 +385,7 @@ void vApplicationMallocFailedHook( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName )\r
+void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )\r
 {\r
        ( void ) pcTaskName;\r
        ( void ) pxTask;\r
@@ -268,9 +410,5 @@ volatile size_t xFreeHeapSpace;
        configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up\r
        RAM. */\r
        xFreeHeapSpace = xPortGetFreeHeapSize();\r
-\r
-       /* Remove compiler warning about xFreeHeapSpace being set but never used. */\r
-       ( void ) xFreeHeapSpace;\r
 }\r
 \r
-\r