OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [ucos-ii/] [2.91/] [common/] [main.c] - Blame information for rev 612

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

Line No. Rev Author Line
1 471 julius
/*
2
  ----------------------------------------------------------------------
3
  CHiPES Embedded RTR   Systems Copyright (c) Tim Oliver 2002-2004
4
  ----------------------------------------------------------------------
5
  File      : main.c
6
  Author(s) : Tim Oliver, timtimoliver@yahoo.co.uk
7
              Julius Baxter, julius@opencores.org
8
 
9
  ---------------------------[Description]------------------------------
10
  Very simple MicroC/OS-II test application for the ORP
11
  Uses the UART as standard io
12
  Initialises RTOS
13
  Calls task init hook that should be provided by another file.
14
  Starts multitasking
15
*/
16
 
17
  /*
18
  This program is free software; you can redistribute it and/or modify
19
  it under the terms of the GNU General Public License as published by
20
  the Free Software Foundation; either version 2 of the License, or
21
  (at your option) any later version.
22
 
23
  This program is distributed in the hope that it will be useful,
24
  but WITHOUT ANY WARRANTY; without even the implied warranty of
25
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
  GNU General Public License for more details.
27
 
28
  You should have received a copy of the GNU General Public License
29
  along with this program; if not, write to the Free Software
30
  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31
*/
32
 
33
#include "includes.h"
34
 
35
/* Prototype for function we'll call to install real tasks  */
36
void  TaskStart(void *data);
37
extern void  TaskStartCreateTasks(void); /* Hook to function provided elsewhere */
38
/* main() prototype */
39
void main (void);
40
 
41
#define TASK_STK_SIZE 256
42
 
43
OS_STK TaskStartStk[TASK_STK_SIZE];
44
 
45
/* Main loop */
46
void main(void)
47
{
48
  char c;
49
  /* OS Init function */
50
  OSInit();
51
 
52
  /* Clear console */
53
  console_init(80,24);
54
 
55
  console_puts(28,7,"************************");
56
  console_puts(28,8,"* uC/OS-II on OpenRISC *");
57
  console_puts(28,9,"************************");
58
 
59
  console_puts(1, 14,"OS Initialising...");
60
 
61
  /* Init first task, which will spawn all others */
62
  OSTaskCreate(TaskStart,
63
               (void *)0,
64
               &TaskStartStk[TASK_STK_SIZE - 1],
65
               0);
66
  console_puts(1,12,"Press a key to start OS");
67
  c = getc();
68
  console_puts(1,14,"OS Starting...");
69
 
70
  /* Init OR1K tick timer */
71
  OSInitTick();
72
 
73
  /* Kick off multi-tasking */
74
  OSStart();
75
}
76
 
77
 
78
 
79
/* This task is set to run from main() */
80
void  TaskStart (void *pdata)
81
{
82
    char c;
83
    OS_CPU_SR cpu_sr;
84
 
85
    pdata = pdata;            /* Prevent compiler warning                 */
86
 
87
    /* Do other user task init things here ... */
88
 
89
    OSStatInit();            /* Initialize uC/OS-II's statistics         */
90
 
91
    TaskStartCreateTasks();  /* Create all other tasks                   */
92
 
93
    for (;;) {
94
      /* Maybe do something like update a display here */
95
 
96
      /* Check if UART has received anything, potentialy abort due to it. */
97
      c = testc();
98
      if (c)
99
        {
100
          if (c=='q')
101
            {
102
              /* Clear up console */
103
              console_finish();
104
 
105
              /* Disable interrupts */
106
              OS_ENTER_CRITICAL()
107
 
108
              /* Exit if simulator, reboot if board */
109
              asm("l.ori r3, r0, 0; \
110
                   l.nop 0x1;         \
111
                   l.movhi r3, 0xf000; \
112
                   l.ori r3,r3,0x100; \
113
                   l.jr r3;           \
114
                   l.nop 0x1");
115
            }
116
        }
117
 
118
      OSCtxSwCtr = 0;        /* Clear context switch counter             */
119
      OSTimeDly(OS_TICKS_PER_SEC);  /* Wait one second                   */
120
    }
121
 
122
}

powered by: WebSVN 2.1.0

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