OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [WizNET_DEMO_TERN_186/] [main.c] - Blame information for rev 637

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 585 jeremybenn
/*
2
    FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.
3
 
4
    ***************************************************************************
5
    *                                                                         *
6
    * If you are:                                                             *
7
    *                                                                         *
8
    *    + New to FreeRTOS,                                                   *
9
    *    + Wanting to learn FreeRTOS or multitasking in general quickly       *
10
    *    + Looking for basic training,                                        *
11
    *    + Wanting to improve your FreeRTOS skills and productivity           *
12
    *                                                                         *
13
    * then take a look at the FreeRTOS books - available as PDF or paperback  *
14
    *                                                                         *
15
    *        "Using the FreeRTOS Real Time Kernel - a Practical Guide"        *
16
    *                  http://www.FreeRTOS.org/Documentation                  *
17
    *                                                                         *
18
    * A pdf reference manual is also available.  Both are usually delivered   *
19
    * to your inbox within 20 minutes to two hours when purchased between 8am *
20
    * and 8pm GMT (although please allow up to 24 hours in case of            *
21
    * exceptional circumstances).  Thank you for your support!                *
22
    *                                                                         *
23
    ***************************************************************************
24
 
25
    This file is part of the FreeRTOS distribution.
26
 
27
    FreeRTOS is free software; you can redistribute it and/or modify it under
28
    the terms of the GNU General Public License (version 2) as published by the
29
    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
30
    ***NOTE*** The exception to the GPL is included to allow you to distribute
31
    a combined work that includes FreeRTOS without being obliged to provide the
32
    source code for proprietary components outside of the FreeRTOS kernel.
33
    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
34
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
35
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
36
    more details. You should have received a copy of the GNU General Public
37
    License and the FreeRTOS license exception along with FreeRTOS; if not it
38
    can be viewed here: http://www.freertos.org/a00114.html and also obtained
39
    by writing to Richard Barry, contact details for whom are available on the
40
    FreeRTOS WEB site.
41
 
42
    1 tab == 4 spaces!
43
 
44
    http://www.FreeRTOS.org - Documentation, latest information, license and
45
    contact details.
46
 
47
    http://www.SafeRTOS.com - A version that is certified for use in safety
48
    critical systems.
49
 
50
    http://www.OpenRTOS.com - Commercial support, development, porting,
51
    licensing and training services.
52
*/
53
 
54
/*
55
 * Creates all the demo application tasks then starts the scheduler.  In
56
 * addition to the standard demo application tasks main() creates the
57
 * HTTPServer task, and a "Check" task.  The Check task periodically inspects
58
 * all the other tasks in the system to see if any errors have been reported.
59
 * The error status is then displayed on the served WEB page.
60
 */
61
 
62
/* Tern includes. */
63
#include <ae.h>
64
#include <embedded.h>
65
 
66
/* FreeRTOS.org includes. */
67
#include <FreeRTOS.h>
68
#include <task.h>
69
 
70
/* Demo application includes. */
71
#include "HTTPTask.h"
72
#include "integer.h"
73
#include "PollQ.h"
74
#include "semtest.h"
75
#include "dynamic.h"
76
#include "BlockQ.h"
77
#include "death.h"
78
#include "serial.h"
79
#include "comtest.h"
80
 
81
/* How often should the "check" task execute? */
82
#define mainCHECK_DELAY         ( 3000 / portTICK_RATE_MS )
83
 
84
/* Priorities allocated to the various tasks. */
85
#define mainQUEUE_POLL_PRIORITY         ( tskIDLE_PRIORITY + 2 )
86
#define mainCHECK_TASK_PRIORITY         ( tskIDLE_PRIORITY + 4 )
87
#define mainSEM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 1 )
88
#define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )
89
#define mainHTTP_TASK_PRIORITY          ( tskIDLE_PRIORITY + 3 )
90
#define mainSUICIDE_TASKS_PRIORITY  ( tskIDLE_PRIORITY + 1 )
91
#define mainCOM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 2 )
92
 
93
/* Used to indicate the error status.  A value of 0 means that an error has not
94
been detected in any task.  A non zero value indicates which group of demo
95
tasks has reported an error.  See prvCheckTask() for bit definitions. */
96
unsigned short usCheckStatus = 0;
97
 
98
/*-----------------------------------------------------------*/
99
 
100
/*
101
 * Setup any hardware required by the demo - other than the RTOS tick which
102
 * is configured when the scheduler is started.
103
 */
104
static void prvSetupHardware( void );
105
 
106
/*
107
 * Periodically inspect all the other tasks, updating usCheckStatus should an
108
 * error be discovered in any task.
109
 */
110
static void prvCheckTask( void *pvParameters );
111
/*-----------------------------------------------------------*/
112
 
113
void main(void)
114
{
115
        prvSetupHardware();
116
 
117
    /* Start the HTTP server task. */
118
        xTaskCreate( vHTTPTask, "WizNet", configMINIMAL_STACK_SIZE, NULL, mainHTTP_TASK_PRIORITY, NULL );
119
 
120
        /* Start the demo/test application tasks.  See the demo application
121
        section of the FreeRTOS.org WEB site for more information. */
122
        vStartIntegerMathTasks( tskIDLE_PRIORITY );
123
        vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
124
        vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
125
        vStartDynamicPriorityTasks();
126
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
127
    vStartComTestTasks( mainCOM_TEST_PRIORITY, serCOM2, ser57600 );
128
 
129
        /* Start the task that checks the other demo tasks for errors. */
130
    xTaskCreate( prvCheckTask, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
131
 
132
        /* The suicide tasks must be created last as they monitor the number of
133
        tasks in the system to ensure there are no more or fewer than expected
134
        compared to the number that were executing when the task started. */
135
        vCreateSuicidalTasks( mainSUICIDE_TASKS_PRIORITY );
136
 
137
        /* Finally start the scheduler. */
138
    vTaskStartScheduler();
139
 
140
        /* Should not get here! */
141
        for( ;; );
142
}
143
/*-----------------------------------------------------------*/
144
 
145
static void prvSetupHardware( void )
146
{
147
        ae_init();
148
}
149
/*-----------------------------------------------------------*/
150
 
151
static void prvCheckTask( void *pvParameters )
152
{
153
        ( void ) pvParameters;
154
 
155
        /* Check all the demo tasks to ensure that they are all still running, and
156
    that none of them have detected     an error. */
157
    for( ;; )
158
    {
159
                /* Block until it is time to check again. */
160
        vTaskDelay( mainCHECK_DELAY );
161
 
162
                if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
163
                {
164
                        usCheckStatus |= 0x01;
165
                }
166
 
167
                if( xArePollingQueuesStillRunning() != pdTRUE )
168
                {
169
                        usCheckStatus |= 0x02;
170
                }
171
 
172
                if( xAreSemaphoreTasksStillRunning() != pdTRUE )
173
                {
174
                        usCheckStatus |= 0x04;
175
                }
176
 
177
                if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
178
                {
179
                        usCheckStatus |= 0x08;
180
                }
181
 
182
                if( xAreBlockingQueuesStillRunning() != pdTRUE )
183
                {
184
                        usCheckStatus |= 0x10;
185
                }
186
 
187
        if( xIsCreateTaskStillRunning() != pdTRUE )
188
        {
189
                usCheckStatus |= 0x20;
190
        }
191
 
192
        if( xAreComTestTasksStillRunning() != pdTRUE )
193
        {
194
                usCheckStatus |= 0x40;
195
        }
196
        }
197
}
198
/*-----------------------------------------------------------*/
199
 
200
/* This is included to prevent link errors - allowing the 'full' version of
201
the comtest tasks to be used.  It can be ignored. */
202
void vPrintDisplayMessage( const char * const * ppcMessageToSend )
203
{
204
        ( void ) ppcMessageToSend;
205
}
206
 
207
 
208
 
209
 
210
 
211
 
212
 
213
 
214
 
215
 
216
 
217
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.