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