1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
@c
@c COPYRIGHT (c) 1988-1998.
@c On-Line Applications Research Corporation (OAR).
@c All rights reserved.
@c
@c $Id$
@c
@ifinfo
@node Example Application, Glossary, Directive Status Codes, Top
@end ifinfo
@chapter Example Application
@example
/* example.c
*
* This file contains an example of a simple RTEMS
* application. It contains a Configuration Table, a
* user initialization task, and a simple task.
*
* This example assumes that a board support package exists
* and invokes the initialize_executive() directive.
*/
#include "rtems.h"
rtems_task init_task();
#define INIT_NAME rtems_build_name( 'A', 'B', 'C', ' ' ' )
rtems_initialization_tasks_table init_task = @{
@{ INIT_NAME, /* init task name "ABC" */
1024, /* init task stack size */
1, /* init task priority */
DEFAULT_ATTRIBUTES, /* init task attributes */
init_task, /* init task entry point */
TIMESLICE, /* init task initial mode */
0 /* init task argument */
@}
@};
rtems_configuration_table User_Configuration_Table = @{
NULL, /* filled in by the BSP */
65536, /* executive RAM size */
2, /* maximum tasks */
0, /* maximum timers */
0, /* maximum semaphores */
0, /* maximum message queues */
0, /* maximum messages */
0, /* maximum partitions */
0, /* maximum regions */
0, /* maximum ports */
0, /* maximum periods */
0, /* maximum extensions */
RTEMS_MILLISECONDS_TO_MICROSECONDS(10), /* number of ms in a tick */
1, /* num of ticks in a timeslice */
1, /* number of user init tasks */
init_task_tbl, /* user init task(s) table */
0, /* number of device drivers */
NULL, /* ptr to driver address table */
NULL, /* ptr to extension table */
NULL /* ptr to MP config table */
@};
task user_application(
rtems_task_argument ignored
);
#define USER_APP_NAME 1 /* any 32-bit name; unique helps */
rtems_task init_task(
rtems_task_argument ignored
)
@{
rtems_id tid;
/* example assumes SUCCESSFUL return value */
(void) rtems_task_create( USER_APP_NAME, 1, 1024,
RTEMS_NO_PREEMPT, RTEMS_FLOATING_POINT, &tid );
(void) rtems_task_start( tid, user_application, 0 );
(void) rtems_task_delete( SELF );
@}
rtems_task user_application()
@{
/* application specific initialization goes here */
while ( 1 ) @{ /* infinite loop */
/* APPLICATION CODE GOES HERE
*
* This code will typically include at least one
* directive which causes the calling task to
* give up the processor.
*/
@}
@}
@end example
|