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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 577 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
/* Environment includes. */
55
#include <targets/LPC2368.h>
56
 
57
/* Scheduler includes. */
58
#include "FreeRTOS.h"
59
#include "task.h"
60
#include "queue.h"
61
#include "semphr.h"
62
 
63
/* Demo app includes. */
64
#include "BlockQ.h"
65
#include "death.h"
66
#include "integer.h"
67
#include "blocktim.h"
68
#include "portlcd.h"
69
#include "flash.h"
70
#include "partest.h"
71
#include "semtest.h"
72
#include "PollQ.h"
73
 
74
/* Demo application definitions. */
75
#define mainQUEUE_SIZE                                          ( 3 )
76
#define mainCHECK_DELAY                                         ( ( portTickType ) 5000 / portTICK_RATE_MS )
77
#define mainBASIC_WEB_STACK_SIZE            ( configMINIMAL_STACK_SIZE * 2 )
78
 
79
/* Task priorities. */
80
#define mainQUEUE_POLL_PRIORITY                         ( tskIDLE_PRIORITY + 2 )
81
#define mainCHECK_TASK_PRIORITY                         ( tskIDLE_PRIORITY + 3 )
82
#define mainSEM_TEST_PRIORITY                           ( tskIDLE_PRIORITY + 1 )
83
#define mainBLOCK_Q_PRIORITY                            ( tskIDLE_PRIORITY + 2 )
84
#define mainFLASH_PRIORITY                  ( tskIDLE_PRIORITY + 2 )
85
#define mainCREATOR_TASK_PRIORITY           ( tskIDLE_PRIORITY + 3 )
86
#define mainINTEGER_TASK_PRIORITY           ( tskIDLE_PRIORITY )
87
 
88
 
89
/*
90
 * Checks the status of all the demo tasks then prints a message to the
91
 * CrossStudio terminal IO windows.  The message will be either PASS or FAIL
92
 * depending on the status of the demo applications tasks.  A FAIL status will
93
 * be latched.
94
 *
95
 * Messages are not written directly to the terminal, but passed to vPrintTask
96
 * via a queue.
97
 */
98
static void vCheckTask( void *pvParameters );
99
 
100
/*
101
 * The task that handles the uIP stack.  All TCP/IP processing is performed in
102
 * this task.
103
 */
104
extern void vuIP_Task( void *pvParameters );
105
 
106
/*
107
 * The LCD is written two by more than one task so is controlled by a
108
 * 'gatekeeper' task.  This is the only task that is actually permitted to
109
 * access the LCD directly.  Other tasks wanting to display a message send
110
 * the message to the gatekeeper.
111
 */
112
static void vLCDTask( void *pvParameters );
113
 
114
/* The queue used to send messages to the LCD task. */
115
xQueueHandle xLCDQueue;
116
 
117
/*-----------------------------------------------------------*/
118
 
119
int main (void)
120
{
121
        /* Setup the led's on the MCB2300 board */
122
        vParTestInitialise();
123
 
124
        /* Create the queue used by the LCD task.  Messages for display on the LCD
125
        are received via this queue. */
126
        xLCDQueue = xQueueCreate( mainQUEUE_SIZE, sizeof( xLCDMessage ) );
127
 
128
        /* Create the lwIP task.  This uses the lwIP RTOS abstraction layer.*/
129
    xTaskCreate( vuIP_Task, ( signed char * ) "uIP", mainBASIC_WEB_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
130
 
131
        /* Start the standard demo tasks - these serve no useful purpose other than
132
        to demonstrate the FreeRTOS API being used and to test the port. */
133
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
134
    vCreateBlockTimeTasks();
135
    vStartLEDFlashTasks( mainFLASH_PRIORITY );
136
    vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
137
    vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
138
    vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
139
 
140
        /* Start the tasks defined within this file/specific to this demo. */
141
    xTaskCreate( vCheckTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
142
        xTaskCreate( vLCDTask, ( signed char * ) "LCD", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL );
143
 
144
        /* The suicide tasks must be created last as they need to know how many
145
        tasks were running prior to their creation in order to ascertain whether
146
        or not the correct/expected number of tasks are running at any given time. */
147
    vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY );
148
 
149
        /* Start the scheduler. */
150
        vTaskStartScheduler();
151
 
152
    /* Will only get here if there was insufficient memory to create the idle
153
    task. */
154
        return 0;
155
}
156
/*-----------------------------------------------------------*/
157
 
158
static void vCheckTask( void *pvParameters )
159
{
160
portBASE_TYPE xErrorOccurred = pdFALSE;
161
portTickType xLastExecutionTime;
162
unsigned portBASE_TYPE uxColumn = 0;
163
xLCDMessage xMessage;
164
 
165
        xLastExecutionTime = xTaskGetTickCount();
166
 
167
        xMessage.xColumn = 0;
168
        xMessage.pcMessage = "PASS";
169
 
170
    for( ;; )
171
        {
172
                /* Perform this check every mainCHECK_DELAY milliseconds. */
173
                vTaskDelayUntil( &xLastExecutionTime, mainCHECK_DELAY );
174
 
175
                /* Has an error been found in any task? */
176
 
177
        if( xAreBlockingQueuesStillRunning() != pdTRUE )
178
                {
179
                        xErrorOccurred = pdTRUE;
180
                }
181
 
182
                if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
183
                {
184
                        xErrorOccurred = pdTRUE;
185
                }
186
 
187
        if( xAreSemaphoreTasksStillRunning() != pdTRUE )
188
        {
189
            xErrorOccurred = pdTRUE;
190
        }
191
 
192
        if( xArePollingQueuesStillRunning() != pdTRUE )
193
        {
194
            xErrorOccurred = pdTRUE;
195
        }
196
 
197
        if( xIsCreateTaskStillRunning() != pdTRUE )
198
        {
199
            xErrorOccurred = pdTRUE;
200
        }
201
 
202
        if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
203
        {
204
            xErrorOccurred = pdTRUE;
205
        }
206
 
207
        LCD_cls();
208
        xMessage.xColumn++;
209
        LCD_gotoxy( ( uxColumn & 0x07 ) + 1, ( uxColumn & 0x01 ) + 1 );
210
 
211
        if( xErrorOccurred == pdTRUE )
212
        {
213
            xMessage.pcMessage = "FAIL";
214
        }
215
 
216
                /* Send the message to the LCD gatekeeper for display. */
217
                xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY );
218
        }
219
}
220
/*-----------------------------------------------------------*/
221
 
222
void vLCDTask( void *pvParameters )
223
{
224
xLCDMessage xMessage;
225
 
226
        /* Initialise the LCD and display a startup message. */
227
        LCD_init();
228
        LCD_cur_off();
229
    LCD_cls();
230
    LCD_gotoxy( 1, 1 );
231
    LCD_puts( ( signed char * ) "www.FreeRTOS.org" );
232
 
233
        for( ;; )
234
        {
235
                /* Wait for a message to arrive that requires displaying. */
236
                while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS );
237
 
238
                /* Display the message.  Print each message to a different position. */
239
                LCD_cls();
240
                LCD_gotoxy( ( xMessage.xColumn & 0x07 ) + 1, ( xMessage.xColumn & 0x01 ) + 1 );
241
                LCD_puts( xMessage.pcMessage );
242
        }
243
 
244
}
245
/*-----------------------------------------------------------*/
246
 
247
/* Keep the compiler quiet. */
248
#include <stdio.h>
249
int __putchar( int c )
250
{
251
    return EOF;
252
}
253
 
254
 
255
 
256
 
257
 

powered by: WebSVN 2.1.0

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