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 799

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
/* BSP headers. */
78
#include "support.h"
79
#include "board.h"
80 584 jeremybenn
#include "uart.h"
81 649 filepang
#include "gpio.h"
82
 
83 621 filepang
#include "interrupts.h"
84 584 jeremybenn
 
85 649 filepang
/* Demo application task priorities. */
86
#define mainCHECK_TASK_PRIORITY         ( tskIDLE_PRIORITY + 4 )
87
#define mainBLOCK_Q_PRIORITY            ( tskIDLE_PRIORITY + 2 )
88
#define mainLED_TASK_PRIORITY           ( tskIDLE_PRIORITY + 1 )
89
#define mainCOM_TEST_PRIORITY           ( tskIDLE_PRIORITY + 1 )
90 584 jeremybenn
 
91 649 filepang
#define mainPRINT_STACK_SIZE            ( ( unsigned short ) 64 )
92
 
93
/* How often should we check the other tasks? */
94
#define mainCHECK_TASK_CYCLE_TIME       ( 3000 )
95
 
96
/* Baud rate used by the comtest tasks. */
97
#define mainCOM_TEST_BAUD_RATE          ( 115200 )
98
 
99
/* The LED used by the comtest tasks. See the comtest.c file for more
100
information. */
101
#define mainCOM_TEST_LED                        ( 7 )
102
 
103
/*-----------------------------------------------------------*/
104
 
105
/*
106
 * The task that executes at the highest priority and checks the operation of
107
 * all the other tasks in the system.  See the description at the top of the
108
 * file.
109
 */
110
static void vCheckTask( void *pvParameters );
111
 
112
/*
113
 * ST provided routine to configure the processor.
114
 */
115 584 jeremybenn
static void prvSetupHardware(void);
116
 
117 649 filepang
void vApplicationIdleHook( void );
118
void vApplicationTickHook( void );
119
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName );
120
void vApplicationMallocFailedHook( void );
121 584 jeremybenn
 
122 649 filepang
/*-----------------------------------------------------------*/
123
 
124
/* Create all the demo application tasks, then start the scheduler. */
125
int main( int argc, char **argv )
126
{
127 584 jeremybenn
        argc = argc;
128
        argv = argv;
129
 
130 649 filepang
        /* Perform any hardware setup necessary. */
131
        prvSetupHardware();
132
        vParTestInitialise();
133 584 jeremybenn
 
134 649 filepang
        /* Create the standard demo application tasks.  See the WEB documentation
135
        for more information on these tasks. */
136
        vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
137
        vStartLEDFlashTasks( mainLED_TASK_PRIORITY );
138
        vStartIntegerMathTasks( tskIDLE_PRIORITY );
139
 
140 666 filepang
        vCreateBlockTimeTasks();
141
        vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
142
        vStartDynamicPriorityTasks();
143 584 jeremybenn
 
144 649 filepang
        /* Create the tasks defined within this file. */
145
        xTaskCreate( vCheckTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
146
 
147 584 jeremybenn
        vTaskStartScheduler();
148 649 filepang
 
149
        /* Execution will only reach here if there was insufficient heap to
150
        start the scheduler. */
151 584 jeremybenn
        return 0;
152
}
153 649 filepang
/*-----------------------------------------------------------*/
154 584 jeremybenn
 
155 649 filepang
static void vCheckTask( void *pvParameters )
156
{
157
        static unsigned long ulErrorDetected = pdFALSE;
158
        portTickType xLastExecutionTime;
159
 
160
        /* prevent compiler warning */
161 584 jeremybenn
        pvParameters = pvParameters;
162
 
163 649 filepang
        /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()
164
        works correctly. */
165
        xLastExecutionTime = xTaskGetTickCount();
166
 
167
        for( ;; )
168
        {
169
                /* Wait until it is time for the next cycle. */
170
                vTaskDelayUntil( &xLastExecutionTime, mainCHECK_TASK_CYCLE_TIME );
171
 
172
                /* Has an error been found in any of the standard demo tasks? */
173
 
174
                if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
175 584 jeremybenn
                {
176 649 filepang
                        ulErrorDetected = pdTRUE;
177 584 jeremybenn
                }
178 649 filepang
 
179
                /* FIXME, xAreComTestTasksStillRunning assumed that UART TX is loopbacked to RX
180
                but, current Or1ksim does not surrpot UART loopback. so, ignore it.*/
181
                if( xAreComTestTasksStillRunning() != pdTRUE )
182
                {
183
                        // ulErrorDetected = pdTRUE;
184
                }
185 584 jeremybenn
 
186 666 filepang
                if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
187
                {
188
                        ulErrorDetected = pdTRUE;
189
                }
190 584 jeremybenn
 
191 666 filepang
                if( xAreBlockingQueuesStillRunning() != pdTRUE )
192
                {
193
                        ulErrorDetected = pdTRUE;
194
                }
195 649 filepang
 
196 666 filepang
                if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )
197
                {
198
                        ulErrorDetected = pdTRUE;
199
                }
200 649 filepang
 
201
                if(ulErrorDetected == pdTRUE)
202
                {
203
                        // something was wrong. report negative indicator
204 666 filepang
                        // const char *message = "vCheckTask Error detected!\n\r";
205
                        // vSerialPutString(NULL, (const signed char*)message, strlen(message));
206 584 jeremybenn
 
207 649 filepang
                        report(0xDEADBEEF);
208
                }
209
                else
210 584 jeremybenn
                {
211 649 filepang
                        // we have no error. report positive indicator
212 666 filepang
                        // const char *message = "vCheckTask OK!\n\r";
213
                        // vSerialPutString(NULL, (const signed char*)message, strlen(message));
214 649 filepang
 
215
                        report(0x00000000);
216 584 jeremybenn
                }
217 649 filepang
 
218 584 jeremybenn
        }
219
}
220
 
221 649 filepang
/*-----------------------------------------------------------*/
222
 
223
void prvSetupHardware( void )
224
{
225 584 jeremybenn
        // UART controller use 25 Mhz Wishbone bus clock, define in board.h
226 622 filepang
        uart_init(0);
227 649 filepang
        uart_rxint_enable(0);
228 584 jeremybenn
 
229
        // Initialize internal Programmable Interrupt Controller
230
        int_init();
231 649 filepang
 
232
        // GPIO Initialize
233
        gpio_init(0);
234
 
235
        // set low 8 port is outout
236
        set_gpio_direction(0, 0xFFFFFF00);
237 799 filepang
 
238
        // enable IC/DC if present
239
        cache_init();
240 584 jeremybenn
}
241 649 filepang
/*-----------------------------------------------------------*/
242 584 jeremybenn
 
243 649 filepang
void vApplicationIdleHook( void )
244
{
245 584 jeremybenn
}
246 649 filepang
/*-----------------------------------------------------------*/
247 584 jeremybenn
 
248 649 filepang
void vApplicationTickHook( void )
249
{
250 584 jeremybenn
}
251 649 filepang
/*-----------------------------------------------------------*/
252 584 jeremybenn
 
253 649 filepang
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName )
254
{
255
        /* prevent compiler warning */
256 584 jeremybenn
        pxTask = pxTask;
257
        pcTaskName = pcTaskName;
258
 
259 649 filepang
        report(0x00000099);
260 584 jeremybenn
}
261 649 filepang
/*-----------------------------------------------------------*/
262
 
263
void vApplicationMallocFailedHook( void )
264
{
265
        report(0x00000098);
266
}
267
/*-----------------------------------------------------------*/

powered by: WebSVN 2.1.0

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