summaryrefslogtreecommitdiffstats
path: root/doc/user/example.texi
blob: 1b16e367b8b5344cdb05729883c78a918d9be418 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
@c
@c  COPYRIGHT (c) 1988-1999.
@c  On-Line Applications Research Corporation (OAR).
@c  All rights reserved.
@c
@c  $Id$
@c

@ifinfo
@node Example Application, Glossary, Directive Status Codes, Top
@end ifinfo
@chapter Example Application

@example
/*
 *  This file contains an example of a simple RTEMS
 *  application.  It instantiates the RTEMS Configuration 
 *  Information using confdef.h and contains two tasks:
 *  a *  user initialization task and a simple task.
 *
 *  This example assumes that a board support package exists.
 */

#include <rtems.h>

rtems_task user_application(rtems_task_argument argument);

rtems_task init_task(
  rtems_task_argument ignored
)
@{
  rtems_id tid;

  /* example assumes SUCCESSFUL return value */

  (void) rtems_task_create( USER_APP_NAME, 1, RTEMS_MINIMUM_STACK_SIZE,
                        RTEMS_NO_PREEMPT, RTEMS_FLOATING_POINT, &tid );
  (void) rtems_task_start( tid, user_application, 0 );
  (void) rtems_task_delete( SELF );
@}


rtems_task user_application(rtems_task_argument argument)
@{
  /* application specific initialization goes here */

  while ( 1 )  @{              /* infinite loop */

    /*  APPLICATION CODE GOES HERE
     *
     *  This code will typically include at least one
     *  directive which causes the calling task to
     *  give up the processor.
     */
  @}
@}

#define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER  /* for stdio */
#define CONFIGURE_TEST_NEEDS_CLOCK_DRIVER    /* for time services */

#define CONFIGURE_INIT_TASK_NAME rtems_build_name( 'E', 'X', 'A', 'M' )
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE

#define CONFIGURE_INIT

#include <confdefs.h>
@end example