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