source: rtems/doc/user/example.texi @ e630235

4.115
Last change on this file since e630235 was d51ecd6, checked in by Joel Sherrill <joel.sherrill@…>, on 04/05/07 at 15:27:18

2007-04-05 Joel Sherrill <joel@…>

  • user/example.texi: Change all obsoleted CONFIGURE_TEST_NEEDS_XXX configuration constants to CONFIGURE_APPLICATION_NEEDS_XXX.
  • Property mode set to 100644
File size: 2.1 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-2002.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6@c  $Id$
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
26rtems_task user_application(rtems_task_argument argument);
27
28rtems_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
59rtems_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_APPLICATION_NEEDS_CONSOLE_DRIVER  /* for stdio */
75#define CONFIGURE_APPLICATION_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
Note: See TracBrowser for help on using the repository browser.