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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [doc/] [user/] [example.texi] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
@c
2
@c  COPYRIGHT (c) 1988-2002.
3
@c  On-Line Applications Research Corporation (OAR).
4
@c  All rights reserved.
5
@c
6
@c  example.texi,v 1.11 2002/01/17 21:47:47 joel Exp
7
@c
8
 
9
@ifinfo
10
@node Example Application, Glossary, Directive Status Codes, Top
11
@end ifinfo
12
@chapter Example Application
13
 
14
@example
15
/*
16
 *  This file contains an example of a simple RTEMS
17
 *  application.  It instantiates the RTEMS Configuration
18
 *  Information using confdef.h and contains two tasks:
19
 *  a *  user initialization task and a simple task.
20
 *
21
 *  This example assumes that a board support package exists.
22
 */
23
 
24
#include <rtems.h>
25
 
26
rtems_task user_application(rtems_task_argument argument);
27
 
28
rtems_task init_task(
29
  rtems_task_argument ignored
30
)
31
@{
32
  rtems_id          tid;
33
  rtems_status_code status;
34
  rtems_name        name;
35
 
36
  name = rtems_build_name( 'A', 'P', 'P', '1' )
37
 
38
  status = rtems_task_create(
39
     name, 1, RTEMS_MINIMUM_STACK_SIZE,
40
     RTEMS_NO_PREEMPT, RTEMS_FLOATING_POINT, &tid
41
  );
42
  if ( status != RTEMS_STATUS_SUCCESSFUL ) @{
43
    printf( "rtems_task_create failed with status of %d.\n", status );
44
    exit( 1 );
45
  @}
46
 
47
  status = rtems_task_start( tid, user_application, 0 );
48
  if ( status != RTEMS_STATUS_SUCCESSFUL ) @{
49
    printf( "rtems_task_start failed with status of %d.\n", status );
50
    exit( 1 );
51
  @}
52
 
53
  status = rtems_task_delete( SELF );    /* should not return */
54
  printf( "rtems_task_delete returned with status of %d.\n", status );
55
  exit( 1 );
56
@}
57
 
58
 
59
rtems_task user_application(rtems_task_argument argument)
60
@{
61
  /* application specific initialization goes here */
62
 
63
  while ( 1 )  @{              /* infinite loop */
64
 
65
    /*  APPLICATION CODE GOES HERE
66
     *
67
     *  This code will typically include at least one
68
     *  directive which causes the calling task to
69
     *  give up the processor.
70
     */
71
  @}
72
@}
73
 
74
#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER  /* for stdio */
75
#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER    /* for time services */
76
 
77
#define CONFIGURE_MAXIMUM_TASKS 2
78
 
79
#define CONFIGURE_INIT_TASK_NAME rtems_build_name( 'E', 'X', 'A', 'M' )
80
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
81
 
82
#define CONFIGURE_INIT
83
 
84
#include <confdefs.h>
85
@end example
86
 
87
 
88
 

powered by: WebSVN 2.1.0

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