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