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