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 668

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

powered by: WebSVN 2.1.0

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