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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 584 jeremybenn
 
2
/*
3
    FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.
4
 
5
    ***************************************************************************
6
    *                                                                         *
7
    * If you are:                                                             *
8
    *                                                                         *
9
    *    + New to FreeRTOS,                                                   *
10
    *    + Wanting to learn FreeRTOS or multitasking in general quickly       *
11
    *    + Looking for basic training,                                        *
12
    *    + Wanting to improve your FreeRTOS skills and productivity           *
13
    *                                                                         *
14
    * then take a look at the FreeRTOS books - available as PDF or paperback  *
15
    *                                                                         *
16
    *        "Using the FreeRTOS Real Time Kernel - a Practical Guide"        *
17
    *                  http://www.FreeRTOS.org/Documentation                  *
18
    *                                                                         *
19
    * A pdf reference manual is also available.  Both are usually delivered   *
20
    * to your inbox within 20 minutes to two hours when purchased between 8am *
21
    * and 8pm GMT (although please allow up to 24 hours in case of            *
22
    * exceptional circumstances).  Thank you for your support!                *
23
    *                                                                         *
24
    ***************************************************************************
25
 
26
    This file is part of the FreeRTOS distribution.
27
 
28
    FreeRTOS is free software; you can redistribute it and/or modify it under
29
    the terms of the GNU General Public License (version 2) as published by the
30
    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
31
    ***NOTE*** The exception to the GPL is included to allow you to distribute
32
    a combined work that includes FreeRTOS without being obliged to provide the
33
    source code for proprietary components outside of the FreeRTOS kernel.
34
    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT
35
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
36
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
37
    more details. You should have received a copy of the GNU General Public
38
    License and the FreeRTOS license exception along with FreeRTOS; if not it
39
    can be viewed here: http://www.freertos.org/a00114.html and also obtained
40
    by writing to Richard Barry, contact details for whom are available on the
41
    FreeRTOS WEB site.
42
 
43
    1 tab == 4 spaces!
44
 
45
    http://www.FreeRTOS.org - Documentation, latest information, license and
46
    contact details.
47
 
48
    http://www.SafeRTOS.com - A version that is certified for use in safety
49
    critical systems.
50
 
51
    http://www.OpenRTOS.com - Commercial support, development, porting,
52
    licensing and training services.
53
*/
54
 
55
#include <stdlib.h>
56
#include <string.h>
57
 
58
/* Architecture specific header files. */
59 799 filepang
#include "support.h"
60 584 jeremybenn
#include "spr_defs.h"
61
 
62
/* Scheduler header files. */
63
#include "FreeRTOS.h"
64
#include "task.h"
65 649 filepang
#include "queue.h"
66 584 jeremybenn
 
67 649 filepang
/* Demo application includes. */
68
#include "serial.h"
69
#include "partest.h"
70
#include "flash.h"
71
#include "integer.h"
72
#include "blocktim.h"
73
#include "BlockQ.h"
74
#include "comtest2.h"
75
#include "dynamic.h"
76
 
77 800 filepang
#include "or32_dma.h"
78
 
79 649 filepang
/* BSP headers. */
80
#include "support.h"
81
#include "board.h"
82 584 jeremybenn
#include "uart.h"
83 649 filepang
#include "gpio.h"
84 800 filepang
#include "dma.h"
85 649 filepang
 
86 621 filepang
#include "interrupts.h"
87 584 jeremybenn
 
88 649 filepang
/* Demo application task priorities. */
89
#define mainCHECK_TASK_PRIORITY         ( tskIDLE_PRIORITY + 4 )
90
#define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )
91
#define mainLED_TASK_PRIORITY           ( tskIDLE_PRIORITY + 1 )
92
#define mainCOM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 1 )
93 584 jeremybenn
 
94 649 filepang
#define mainPRINT_STACK_SIZE            ( ( unsigned short ) 64 )
95
 
96
/* How often should we check the other tasks? */
97
#define mainCHECK_TASK_CYCLE_TIME       ( 3000 )
98
 
99
/* Baud rate used by the comtest tasks. */
100
#define mainCOM_TEST_BAUD_RATE          ( 115200 )
101
 
102
/* The LED used by the comtest tasks. See the comtest.c file for more
103
information. */
104
#define mainCOM_TEST_LED                        ( 7 )
105
 
106
/*-----------------------------------------------------------*/
107
 
108
/*
109
 * The task that executes at the highest priority and checks the operation of
110
 * all the other tasks in the system.  See the description at the top of the
111
 * file.
112
 */
113
static void vCheckTask( void *pvParameters );
114
 
115
/*
116
 * ST provided routine to configure the processor.
117
 */
118 584 jeremybenn
static void prvSetupHardware(void);
119
 
120 649 filepang
void vApplicationIdleHook( void );
121
void vApplicationTickHook( void );
122
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName );
123
void vApplicationMallocFailedHook( void );
124 584 jeremybenn
 
125 649 filepang
/*-----------------------------------------------------------*/
126
 
127
/* Create all the demo application tasks, then start the scheduler. */
128
int main( int argc, char **argv )
129
{
130 584 jeremybenn
        argc = argc;
131
        argv = argv;
132
 
133 649 filepang
        /* Perform any hardware setup necessary. */
134
        prvSetupHardware();
135
        vParTestInitialise();
136 584 jeremybenn
 
137 649 filepang
        /* Create the standard demo application tasks.  See the WEB documentation
138
        for more information on these tasks. */
139
        vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
140
        vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
141
        vStartIntegerMathTasks( tskIDLE_PRIORITY );
142 800 filepang
        vStartDmaDemoTasks( tskIDLE_PRIORITY );
143 649 filepang
 
144 666 filepang
        vCreateBlockTimeTasks();
145
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
146
        vStartDynamicPriorityTasks();
147 584 jeremybenn
 
148 649 filepang
        /* Create the tasks defined within this file. */
149
        xTaskCreate( vCheckTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
150
 
151 584 jeremybenn
        vTaskStartScheduler();
152 649 filepang
 
153
        /* Execution will only reach here if there was insufficient heap to
154
        start the scheduler. */
155 584 jeremybenn
        return 0;
156
}
157 649 filepang
/*-----------------------------------------------------------*/
158 584 jeremybenn
 
159 649 filepang
static void vCheckTask( void *pvParameters )
160
{
161
        static unsigned long ulErrorDetected = pdFALSE;
162
        portTickType xLastExecutionTime;
163
 
164
        /* prevent compiler warning */
165 584 jeremybenn
        pvParameters = pvParameters;
166
 
167 649 filepang
        /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
168
        works correctly. */
169
        xLastExecutionTime = xTaskGetTickCount();
170
 
171
        for( ;; )
172
        {
173
                /* Wait until it is time for the next cycle. */
174
                vTaskDelayUntil( &xLastExecutionTime, mainCHECK_TASK_CYCLE_TIME );
175
 
176
                /* Has an error been found in any of the standard demo tasks? */
177
 
178
                if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
179 584 jeremybenn
                {
180 649 filepang
                        ulErrorDetected = pdTRUE;
181 584 jeremybenn
                }
182 649 filepang
 
183
                /* FIXME, xAreComTestTasksStillRunning assumed that UART TX is loopbacked to RX
184
                but, current Or1ksim does not surrpot UART loopback. so, ignore it.*/
185
                if( xAreComTestTasksStillRunning() != pdTRUE )
186
                {
187
                        // ulErrorDetected = pdTRUE;
188
                }
189 584 jeremybenn
 
190 666 filepang
                if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
191
                {
192
                        ulErrorDetected = pdTRUE;
193
                }
194 584 jeremybenn
 
195 666 filepang
                if( xAreBlockingQueuesStillRunning() != pdTRUE )
196
                {
197
                        ulErrorDetected = pdTRUE;
198
                }
199 649 filepang
 
200 666 filepang
                if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
201
                {
202
                        ulErrorDetected = pdTRUE;
203 800 filepang
                }
204 649 filepang
 
205 800 filepang
                if( xAreDmaDemoTaskStillRunning() != pdTRUE )
206
                {
207
                        ulErrorDetected = pdTRUE;
208
                }
209
 
210 649 filepang
                if(ulErrorDetected == pdTRUE)
211
                {
212
                        // something was wrong. report negative indicator
213 666 filepang
                        // const char *message = "vCheckTask Error detected!\n\r";
214
                        // vSerialPutString(NULL, (const signed char*)message, strlen(message));
215 584 jeremybenn
 
216 649 filepang
                        report(0xDEADBEEF);
217
                }
218
                else
219 584 jeremybenn
                {
220 649 filepang
                        // we have no error. report positive indicator
221 666 filepang
                        // const char *message = "vCheckTask OK!\n\r";
222
                        // vSerialPutString(NULL, (const signed char*)message, strlen(message));
223 649 filepang
 
224
                        report(0x00000000);
225 584 jeremybenn
                }
226 649 filepang
 
227 584 jeremybenn
        }
228
}
229
 
230 649 filepang
/*-----------------------------------------------------------*/
231
 
232
void prvSetupHardware( void )
233
{
234 584 jeremybenn
        // UART controller use 25 Mhz Wishbone bus clock, define in board.h
235 622 filepang
        uart_init(0);
236 649 filepang
        uart_rxint_enable(0);
237 800 filepang
 
238
        // Initialize DMA controller
239
        dma_init((void *)DMA_BASE);
240 584 jeremybenn
 
241
        // Initialize internal Programmable Interrupt Controller
242
        int_init();
243 649 filepang
 
244
        // GPIO Initialize
245
        gpio_init(0);
246
 
247
        // set low 8 port is outout
248
        set_gpio_direction(0, 0xFFFFFF00);
249 799 filepang
 
250
        // enable IC/DC if present
251
        cache_init();
252 584 jeremybenn
}
253 649 filepang
/*-----------------------------------------------------------*/
254 584 jeremybenn
 
255 649 filepang
void vApplicationIdleHook( void )
256
{
257 584 jeremybenn
}
258 649 filepang
/*-----------------------------------------------------------*/
259 584 jeremybenn
 
260 649 filepang
void vApplicationTickHook( void )
261
{
262 584 jeremybenn
}
263 649 filepang
/*-----------------------------------------------------------*/
264 584 jeremybenn
 
265 649 filepang
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )
266
{
267
        /* prevent compiler warning */
268 584 jeremybenn
        pxTask = pxTask;
269
        pcTaskName = pcTaskName;
270
 
271 649 filepang
        report(0x00000099);
272 584 jeremybenn
}
273 649 filepang
/*-----------------------------------------------------------*/
274
 
275
void vApplicationMallocFailedHook( void )
276
{
277
        report(0x00000098);
278
}
279
/*-----------------------------------------------------------*/

powered by: WebSVN 2.1.0

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