]> git.sur5r.net Git - freertos/commitdiff
Renamed MAIN.c to main.c.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 12 Feb 2008 17:39:23 +0000 (17:39 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 12 Feb 2008 17:39:23 +0000 (17:39 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@168 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Demo/MB96340_Softune/FreeRTOS_96348hs_SK16FX100PMC/Src/main.c [new file with mode: 0644]

diff --git a/Demo/MB96340_Softune/FreeRTOS_96348hs_SK16FX100PMC/Src/main.c b/Demo/MB96340_Softune/FreeRTOS_96348hs_SK16FX100PMC/Src/main.c
new file mode 100644 (file)
index 0000000..3c3c06a
--- /dev/null
@@ -0,0 +1,456 @@
+/*\r
+       FreeRTOS.org V4.7.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
+\r
+       ***************************************************************************\r
+\r
+       Please ensure to read the configuration and relevant port sections of the \r
+       online documentation.\r
+\r
+       +++ http://www.FreeRTOS.org +++\r
+       Documentation, latest information, license and contact details.  \r
+\r
+       +++ http://www.SafeRTOS.com +++\r
+       A version that is certified for use in safety critical systems.\r
+\r
+       +++ http://www.OpenRTOS.com +++\r
+       Commercial support, development, porting, licensing and training services.\r
+\r
+       ***************************************************************************\r
+*/\r
+\r
+/*---------------------------------------------------------------------------\r
+  MAIN.C\r
+  - description\r
+  - See README.TXT for project description and disclaimer.\r
+\r
+/*---------------------------------------------------------------------------*/\r
+\r
+/* 16FX includes */\r
+#include "mb96348hs.h"\r
+\r
+/* Scheduler includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+#include "semphr.h"\r
+#include <watchdog.h>\r
+#include <config.h>\r
+\r
+/*---------------------------------------------------------------------------*/\r
+\r
+/* Demo task priorities. */\r
+#define WTC_TASK_PRIORITY                      ( tskIDLE_PRIORITY + 5 )\r
+#define mainCHECK_TASK_PRIORITY                ( tskIDLE_PRIORITY + 4 )\r
+#define TASK_UTILITY_PRIORITY          ( tskIDLE_PRIORITY + 3 )\r
+#define mainSEM_TEST_PRIORITY          ( tskIDLE_PRIORITY + 3 )\r
+#define mainCOM_TEST_PRIORITY          ( tskIDLE_PRIORITY + 2 )\r
+#define mainQUEUE_POLL_PRIORITY                ( tskIDLE_PRIORITY + 2 )\r
+#define mainQUEUE_BLOCK_PRIORITY       ( tskIDLE_PRIORITY + 2 )\r
+#define mainDEATH_PRIORITY                     ( tskIDLE_PRIORITY + 1 )\r
+#define mainLED_TASK_PRIORITY          ( tskIDLE_PRIORITY + 1 )\r
+#define mainGENERIC_QUEUE_PRIORITY     ( tskIDLE_PRIORITY )\r
+\r
+/* Baud rate used by the COM test tasks. */\r
+#define mainCOM_TEST_BAUD_RATE ( ( unsigned portLONG ) 19200 )\r
+\r
+/* The frequency at which the 'Check' tasks executes.  See the comments at the \r
+top of the page.  When the system is operating error free the 'Check' task\r
+toggles an LED every three seconds.  If an error is discovered in any task the\r
+rate is increased to 500 milliseconds.  [in this case the '*' characters on the \r
+LCD represent LED's]*/\r
+#define mainNO_ERROR_CHECK_DELAY       ( (portTickType) 3000 / portTICK_RATE_MS )\r
+#define mainERROR_CHECK_DELAY          ( (portTickType) 500 / portTICK_RATE_MS )\r
+\r
+/*---------------------------------------------------------------------------*/\r
+#define ledNUMBER_OF_LEDS      8\r
+#define mainCOM_TEST_LED       0x05\r
+#define mainCHECK_TEST_LED     0x07\r
+\r
+/*---------------------------------------------------------------------------*/\r
+\r
+/* \r
+ * The function that implements the Check task.  See the comments at the head\r
+ * of the page for implementation details.\r
+ */\r
+static void                                    vErrorChecks( void *pvParameters );\r
+\r
+/*\r
+ * Called by the Check task.  Returns pdPASS if all the other tasks are found\r
+ * to be operating without error - otherwise returns pdFAIL.\r
+ */\r
+static portSHORT                       prvCheckOtherTasksAreStillRunning( void );\r
+\r
+/*---------------------------------------------------------------------------*/\r
+static unsigned portCHAR       sState[2] = { 0xFF, 0xFF };\r
+\r
+/*---------------------------------------------------------------------------\r
+ * The below callback function is called from Tick ISR if configUSE_TICK_HOOK \r
+ * is configured as 1.\r
+ *---------------------------------------------------------------------------*/\r
+\r
+/*void vApplicationTickHook ( void )\r
+{\r
+#if WATCHDOG == WTC_IN_TICK\r
+       Kick_Watchdog();\r
+#endif\r
+}*/\r
+\r
+/*---------------------------------------------------------------------------\r
+ * The below callback function is called from Delayed ISR if configUSE_IDLE_HOOK \r
+ * is configured as 1.\r
+ *---------------------------------------------------------------------------*/\r
+void vApplicationIdleHook( void )\r
+{\r
+       #if WATCHDOG == WTC_IN_IDLE\r
+       Kick_Watchdog();\r
+       #endif\r
+       #if ( INCLUDE_StartFlashCoRoutines == 1 || INCLUDE_StartHookCoRoutines == 1 )\r
+       vCoRoutineSchedule();\r
+       #endif\r
+}\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Initialize Port 00\r
+ *---------------------------------------------------------------------------*/\r
+static void prvInitPort00( void )\r
+{\r
+       DDR00 = 0xFF;\r
+       PDR00 = 0xFF;\r
+       DDR09 = 0xFF;\r
+       PDR09 = 0xFF;\r
+}\r
+\r
+/*---------------------------------------------------------------------------\r
+ * Setup the hardware\r
+ *---------------------------------------------------------------------------*/\r
+static void prvSetupHardware( void )\r
+{\r
+       prvInitPort00();\r
+\r
+       #if WATCHDOG != WTC_NONE\r
+       InitWatchdog();\r
+       #endif\r
+}\r
+\r
+/*---------------------------------------------------------------------------\r
+ * main()\r
+ *---------------------------------------------------------------------------*/\r
+void main( void )\r
+{\r
+       InitIrqLevels();                /* Initialize interrupts */\r
+       __set_il( 7 );                  /* Allow all levels      */\r
+\r
+       prvSetupHardware();\r
+\r
+       #if WATCHDOG == WTC_IN_TASK\r
+       vStartWatchdogTask( WTC_TASK_PRIORITY );\r
+       #endif\r
+\r
+       /* Start the standard demo application tasks. */\r
+       #if ( INCLUDE_StartLEDFlashTasks == 1 )\r
+       vStartLEDFlashTasks( mainLED_TASK_PRIORITY );\r
+       #endif\r
+       #if ( INCLUDE_StartIntegerMathTasks == 1 )\r
+       vStartIntegerMathTasks( tskIDLE_PRIORITY );\r
+       #endif\r
+       #if ( INCLUDE_AltStartComTestTasks == 1 )\r
+       vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED - 1 );\r
+       #endif\r
+       #if ( INCLUDE_StartPolledQueueTasks == 1 )\r
+       vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
+       #endif\r
+       #if ( INCLUDE_StartSemaphoreTasks == 1 )\r
+       vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
+       #endif\r
+       #if ( INCLUDE_StartBlockingQueueTasks == 1 )\r
+       vStartBlockingQueueTasks( mainQUEUE_BLOCK_PRIORITY );\r
+       #endif\r
+       #if ( INCLUDE_StartDynamicPriorityTasks == 1 )\r
+       vStartDynamicPriorityTasks();\r
+       #endif\r
+       #if ( INCLUDE_StartMathTasks == 1 )\r
+       vStartMathTasks( tskIDLE_PRIORITY );\r
+       #endif\r
+       #if ( INCLUDE_StartFlashCoRoutines == 1 )\r
+       vStartFlashCoRoutines( ledNUMBER_OF_LEDS );\r
+       #endif\r
+       #if ( INCLUDE_StartHookCoRoutines == 1 )\r
+       vStartHookCoRoutines();\r
+       #endif\r
+       #if ( INCLUDE_StartGenericQueueTasks == 1 )\r
+       vStartGenericQueueTasks( mainGENERIC_QUEUE_PRIORITY );\r
+       #endif\r
+       #if ( INCLUDE_StartQueuePeekTasks == 1 )\r
+       vStartQueuePeekTasks();\r
+       #endif\r
+       #if ( INCLUDE_CreateBlockTimeTasks == 1 )\r
+       vCreateBlockTimeTasks();\r
+       #endif\r
+       #if ( INCLUDE_CreateSuicidalTasks == 1 )\r
+       vCreateSuicidalTasks( mainDEATH_PRIORITY );\r
+       #endif\r
+       #if ( INCLUDE_TraceListTasks == 1 )\r
+       vTraceListTasks( TASK_UTILITY_PRIORITY );\r
+       #endif\r
+\r
+       /* Start the 'Check' task which is defined in this file. */\r
+       xTaskCreate( vErrorChecks, (signed portCHAR *) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
+\r
+       vTaskStartScheduler();\r
+\r
+       /* Should not reach here */\r
+       while( 1 )\r
+       {\r
+               __asm( " NOP " );       /*  //  */\r
+       }\r
+}\r
+\r
+/*-----------------------------------------------------------*/\r
+void vParTestToggleLED( unsigned portBASE_TYPE uxLED )\r
+{\r
+       if( uxLED < ledNUMBER_OF_LEDS )\r
+       {\r
+               vTaskSuspendAll();\r
+\r
+               /* Toggle the state of the single genuine on board LED. */\r
+               if( (sState[0] & ((portCHAR) (1 << uxLED))) == 0 )\r
+               {\r
+                       PDR09 |= ( 1 << uxLED );\r
+                       sState[0] |= ( 1 << uxLED );\r
+               }\r
+               else\r
+               {\r
+                       PDR09 &= ~( 1 << uxLED );\r
+                       sState[0] &= ~( 1 << uxLED );\r
+               }\r
+\r
+               xTaskResumeAll();\r
+       }\r
+       else\r
+       {\r
+               vTaskSuspendAll();\r
+\r
+               uxLED -= ledNUMBER_OF_LEDS;\r
+\r
+               if( (sState[1] & ((portCHAR) (1 << uxLED))) == 0 )\r
+               {\r
+                       PDR00 |= ( 1 << uxLED );\r
+                       sState[1] |= ( 1 << uxLED );\r
+               }\r
+               else\r
+               {\r
+                       PDR00 &= ~( 1 << uxLED );\r
+                       sState[1] &= ~( 1 << uxLED );\r
+               }\r
+\r
+               xTaskResumeAll();\r
+       }\r
+}\r
+\r
+/*-----------------------------------------------------------*/\r
+void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )\r
+{\r
+       /* Set or clear the output [in this case show or hide the '*' character. */\r
+       if( uxLED < ledNUMBER_OF_LEDS )\r
+       {\r
+               vTaskSuspendAll();\r
+               {\r
+                       if( xValue )\r
+                       {\r
+                               PDR09 &= ~( 1 << uxLED );\r
+                               sState[0] &= ~( 1 << uxLED );\r
+                       }\r
+                       else\r
+                       {\r
+                               PDR09 |= ( 1 << uxLED );\r
+                               sState[0] |= ( 1 << uxLED );\r
+                       }\r
+               }\r
+\r
+               xTaskResumeAll();\r
+       }\r
+       else\r
+       {\r
+               vTaskSuspendAll();\r
+               {\r
+                       if( xValue )\r
+                       {\r
+                               PDR00 &= ~( 1 << uxLED );\r
+                               sState[1] &= ~( 1 << uxLED );\r
+                       }\r
+                       else\r
+                       {\r
+                               PDR00 |= ( 1 << uxLED );\r
+                               sState[1] |= ( 1 << uxLED );\r
+                       }\r
+               }\r
+\r
+               xTaskResumeAll();\r
+       }\r
+}\r
+\r
+/*-----------------------------------------------------------*/\r
+static void vErrorChecks( void *pvParameters )\r
+{\r
+       static volatile unsigned portLONG       ulDummyVariable = 3UL;\r
+       portTickType                                            xDelayPeriod = mainNO_ERROR_CHECK_DELAY;\r
+       ( void ) pvParameters;\r
+\r
+       /* Cycle for ever, delaying then checking all the other tasks are still\r
+       operating without error. */\r
+       for( ;; )\r
+       {\r
+               /* Wait until it is time to check again.  The time we wait here depends\r
+               on whether an error has been detected or not.  When an error is \r
+               detected the time is shortened resulting in a faster LED flash rate. */\r
+               vTaskDelay( xDelayPeriod );\r
+\r
+               /* Perform a bit of 32bit maths to ensure the registers used by the \r
+               integer tasks get some exercise outside of the integer tasks \r
+               themselves. The result here is not important we are just deliberately\r
+               changing registers used by other tasks to ensure that their context\r
+               switch is operating as required. - see the demo application \r
+               documentation for more info. */\r
+               ulDummyVariable *= 3UL;\r
+\r
+               /* See if the other tasks are all ok. */\r
+               if( prvCheckOtherTasksAreStillRunning() != pdPASS )\r
+               {\r
+                       /* An error occurred in one of the tasks so shorten the delay \r
+                       period - which has the effect of increasing the frequency of the\r
+                       LED toggle. */\r
+                       xDelayPeriod = mainERROR_CHECK_DELAY;\r
+               }\r
+\r
+               /* Flash! */\r
+               vParTestToggleLED( mainCHECK_TEST_LED );\r
+       }\r
+}\r
+\r
+/*-----------------------------------------------------------*/\r
+static portSHORT prvCheckOtherTasksAreStillRunning( void )\r
+{\r
+       static portSHORT        sNoErrorFound = pdTRUE;\r
+\r
+       /* The demo tasks maintain a count that increments every cycle of the task\r
+       provided that the task has never encountered an error.  This function \r
+       checks the counts maintained by the tasks to ensure they are still being\r
+       incremented.  A count remaining at the same value between calls therefore\r
+       indicates that an error has been detected.  Only tasks that do not flash\r
+       an LED are checked. */\r
+       #if ( INCLUDE_StartIntegerMathTasks == 1 )\r
+       if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
+       {\r
+               sNoErrorFound = pdFALSE;\r
+       }\r
+\r
+       #endif\r
+       #if ( INCLUDE_AltStartComTestTasks == 1 )\r
+       if( xAreComTestTasksStillRunning() != pdTRUE )\r
+       {\r
+               sNoErrorFound = pdFALSE;\r
+       }\r
+\r
+       #endif\r
+       #if ( INCLUDE_StartPolledQueueTasks == 1 )\r
+       if( xArePollingQueuesStillRunning() != pdTRUE )\r
+       {\r
+               sNoErrorFound = pdFALSE;\r
+       }\r
+\r
+       #endif\r
+       #if ( INCLUDE_StartSemaphoreTasks == 1 )\r
+       if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
+       {\r
+               sNoErrorFound = pdFALSE;\r
+       }\r
+\r
+       #endif\r
+       #if ( INCLUDE_StartBlockingQueueTasks == 1 )\r
+       if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
+       {\r
+               sNoErrorFound = pdFALSE;\r
+       }\r
+\r
+       #endif\r
+       #if ( INCLUDE_StartDynamicPriorityTasks == 1 )\r
+       if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
+       {\r
+               sNoErrorFound = pdFALSE;\r
+       }\r
+\r
+       #endif\r
+       #if ( INCLUDE_StartMathTasks == 1 )\r
+       if( xAreMathsTaskStillRunning() != pdTRUE )\r
+       {\r
+               sNoErrorFound = pdFALSE;\r
+       }\r
+\r
+       #endif\r
+       #if ( INCLUDE_StartFlashCoRoutines == 1 )\r
+       if( xAreFlashCoRoutinesStillRunning() != pdTRUE )\r
+       {\r
+               sNoErrorFound = pdFALSE;\r
+       }\r
+\r
+       #endif\r
+       #if ( INCLUDE_StartHookCoRoutines == 1 )\r
+       if( xAreHookCoRoutinesStillRunning() != pdTRUE )\r
+       {\r
+               sNoErrorFound = pdFALSE;\r
+       }\r
+\r
+       #endif\r
+       #if ( INCLUDE_StartGenericQueueTasks == 1 )\r
+       if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
+       {\r
+               sNoErrorFound = pdFALSE;\r
+       }\r
+\r
+       #endif\r
+       #if ( INCLUDE_StartQueuePeekTasks == 1 )\r
+       if( xAreQueuePeekTasksStillRunning() != pdTRUE )\r
+       {\r
+               sNoErrorFound = pdFALSE;\r
+       }\r
+\r
+       #endif\r
+       #if ( INCLUDE_CreateBlockTimeTasks == 1 )\r
+       if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
+       {\r
+               sNoErrorFound = pdFALSE;\r
+       }\r
+\r
+       #endif\r
+       #if ( INCLUDE_CreateSuicidalTasks == 1 )\r
+       if( xIsCreateTaskStillRunning() != pdTRUE )\r
+       {\r
+               sNoErrorFound = pdFALSE;\r
+       }\r
+\r
+       #endif\r
+       return sNoErrorFound;\r
+}\r
+\r
+/*---------------------------------------------------------------------------*/\r