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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [WIN32-MingW/] [main.c] - Blame information for rev 585

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
 *******************************************************************************
56
 * -NOTE- The Win32 port is a simulation (or is that emulation?) only!  Do not
57
 * expect to get real time behaviour from the Win32 port or this demo
58
 * application.  It is provided as a convenient development and demonstration
59
 * test bed only.  This was tested using Windows XP on a dual core laptop.
60
 *
61
 * - READ THE WEB DOCUMENTATION FOR THIS PORT FOR MORE INFORMATION ON USING IT -
62
 *******************************************************************************
63
 *
64
 * main() creates all the demo application tasks, then starts the scheduler.
65
 * The web documentation provides more details of the standard demo application
66
 * tasks, which provide no particular functionality but do provide a good
67
 * example of how to use the FreeRTOS API.
68
 *
69
 * In addition to the standard demo tasks, the following tasks and tests are
70
 * defined and/or created within this file:
71
 *
72
 * "Check" task - This only executes every five seconds but has a high priority
73
 * to ensure it gets processor time.  Its main function is to check that all the
74
 * standard demo tasks are still operational.  While no errors have been
75
 * discovered the check task will print out "OK" and the current simulated tick
76
 * time.  If an error is discovered in the execution of a task then the check
77
 * task will print out an appropriate error message.
78
 *
79
 */
80
 
81
 
82
/* Standard includes. */
83
#include <stdio.h>
84
 
85
/* Kernel includes. */
86
#include <FreeRTOS.h>
87
#include "task.h"
88
#include "queue.h"
89
 
90
/* Standard demo includes. */
91
#include "BlockQ.h"
92
#include "integer.h"
93
#include "semtest.h"
94
#include "PollQ.h"
95
#include "GenQTest.h"
96
#include "QPeek.h"
97
#include "recmutex.h"
98
#include "flop.h"
99
 
100
/* Priorities at which the tasks are created. */
101
#define mainCHECK_TASK_PRIORITY         ( configMAX_PRIORITIES - 1 )
102
#define mainQUEUE_POLL_PRIORITY         ( tskIDLE_PRIORITY + 1 )
103
#define mainSEM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 1 )
104
#define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )
105
#define mainCREATOR_TASK_PRIORITY   ( tskIDLE_PRIORITY + 3 )
106
#define mainFLASH_TASK_PRIORITY         ( tskIDLE_PRIORITY + 1 )
107
#define mainuIP_TASK_PRIORITY           ( tskIDLE_PRIORITY + 2 )
108
#define mainINTEGER_TASK_PRIORITY   ( tskIDLE_PRIORITY )
109
#define mainGEN_QUEUE_TASK_PRIORITY     ( tskIDLE_PRIORITY )
110
#define mainFLOP_TASK_PRIORITY          ( tskIDLE_PRIORITY )
111
 
112
/* Task function prototypes. */
113
static void prvCheckTask( void *pvParameters );
114
 
115
/*-----------------------------------------------------------*/
116
 
117
int main( void )
118
{
119
        /* Start the check task as described at the top of this file. */
120
        xTaskCreate( prvCheckTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
121
 
122
        /* Create the standard demo tasks. */
123
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
124
        vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
125
        vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
126
        vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
127
        vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
128
        vStartQueuePeekTasks();
129
        vStartMathTasks( mainFLOP_TASK_PRIORITY );
130
        vStartRecursiveMutexTasks();
131
 
132
        /* Start the scheduler itself. */
133
        vTaskStartScheduler();
134
 
135
    /* Should never get here unless there was not enough heap space to create
136
        the idle and other system tasks. */
137
    return 0;
138
}
139
/*-----------------------------------------------------------*/
140
 
141
static void prvCheckTask( void *pvParameters )
142
{
143
portTickType xNextWakeTime;
144
const portTickType xCycleFrequency = 5000 / portTICK_RATE_MS;
145
char *pcStatusMessage = "OK";
146
 
147
        /* Just to remove compiler warning. */
148
        ( void ) pvParameters;
149
 
150
        /* Initialise xNextWakeTime - this only needs to be done once. */
151
        xNextWakeTime = xTaskGetTickCount();
152
 
153
        for( ;; )
154
        {
155
                /* Place this task in the blocked state until it is time to run again. */
156
                vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );
157
 
158
                /* Check the standard demo tasks are running without error. */
159
            if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
160
            {
161
                        pcStatusMessage = "Error: IntMath";
162
            }
163
                else if( xAreGenericQueueTasksStillRunning() != pdTRUE )
164
                {
165
                        pcStatusMessage = "Error: GenQueue";
166
                }
167
                else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
168
                {
169
                        pcStatusMessage = "Error: QueuePeek";
170
                }
171
                else if( xAreBlockingQueuesStillRunning() != pdTRUE )
172
                {
173
                        pcStatusMessage = "Error: BlockQueue";
174
                }
175
            else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
176
            {
177
                        pcStatusMessage = "Error: SemTest";
178
            }
179
            else if( xArePollingQueuesStillRunning() != pdTRUE )
180
            {
181
                        pcStatusMessage = "Error: PollQueue";
182
            }
183
                else if( xAreMathsTaskStillRunning() != pdPASS )
184
                {
185
                        pcStatusMessage = "Error: Flop";
186
                }
187
            else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
188
            {
189
                        pcStatusMessage = "Error: RecMutex";
190
                }
191
 
192
                /* This is the only task that uses stdout so its ok to call printf()
193
                directly. */
194
                printf( "%s - %d\r\n", pcStatusMessage, ( int ) xTaskGetTickCount() );
195
                fflush( stdout ); /* Required by Eclipse console. */
196
        }
197
}
198
/*-----------------------------------------------------------*/
199
 
200
void vApplicationIdleHook( void )
201
{
202
const unsigned long ulMSToSleep = 5;
203
 
204
        /* Sleep to reduce CPU load, but don't sleep indefinitely in case there are
205
        tasks waiting to be terminated by the idle task. */
206
        Sleep( ulMSToSleep );
207
}
208
/*-----------------------------------------------------------*/
209
 
210
void vApplicationMallocFailedHook( void )
211
{
212
        /* Can be implemented if required, but probably not required in this
213
        environment and running this demo. */
214
}
215
/*-----------------------------------------------------------*/
216
 
217
void vApplicationStackOverflowHook( void )
218
{
219
        /* Can be implemented if required, but not required in this
220
        environment and running this demo. */
221
}
222
 

powered by: WebSVN 2.1.0

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