Example Application

42. Example Application#

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