source: examples-v2/led/event_server/init.c @ a26bba5

4.11
Last change on this file since a26bba5 was a26bba5, checked in by Joel Sherrill <joel.sherrill@…>, on Mar 3, 2011 at 6:00:34 PM

2011-03-03 Joel Sherrill <joel.sherrilL@…>

  • event_server/init.c, msg_server/init.c, sem_server/init.c, timer/init.c, timer_server/init.c: Example clean up.
  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#include <bsp.h>
13#include <inttypes.h>
14#include <stdio.h>
15
16#include "../led.h"
17
18rtems_task Test_task(
19  rtems_task_argument unused
20)
21{
22  rtems_event_set   events;
23  rtems_status_code status;
24
25  for ( ; ; ) {
26    events = 0;
27    status = rtems_event_receive(
28      (RTEMS_EVENT_1 | RTEMS_EVENT_2),
29      RTEMS_EVENT_ANY,
30      RTEMS_NO_TIMEOUT,
31      &events
32    );
33
34    if ( events == RTEMS_EVENT_1 ) {
35      LED_OFF();
36    } else if ( events == RTEMS_EVENT_2 ) {
37      LED_ON();
38    } else {
39      fprintf( stderr, "Incorrect event set 0x%08" PRIx32 "\n", events );
40    }
41  }
42}
43
44rtems_task Init(
45  rtems_task_argument argument
46)
47{
48  uint32_t          count = 0;
49  rtems_event_set   events;
50  rtems_status_code status;
51  rtems_id          task_id;
52  rtems_name        task_name;
53
54  puts( "\n\n*** LED BLINKER -- event receive server ***" );
55
56  LED_INIT();
57
58  task_name = rtems_build_name( 'T', 'A', '1', ' ' );
59
60  status = rtems_task_create(
61    task_name, 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
62    RTEMS_DEFAULT_ATTRIBUTES, &task_id
63  );
64
65  status = rtems_task_start( task_id, Test_task, 1 );
66
67  for (count=0; ; count++) {
68
69    events = ( (count % 2) == 0 ) ?  RTEMS_EVENT_1 : RTEMS_EVENT_2;
70    status = rtems_event_send( task_id, events );
71    if ( status != RTEMS_SUCCESSFUL )
72      fputs( "send did not work\n", stderr );
73
74    status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
75  }
76
77  status = rtems_task_delete( RTEMS_SELF );
78}
79
80/**************** START OF CONFIGURATION INFORMATION ****************/
81
82#define CONFIGURE_INIT
83#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
84#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
85
86#define CONFIGURE_MAXIMUM_TASKS             2
87
88#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
89
90#define CONFIGURE_EXTRA_TASK_STACKS         (RTEMS_MINIMUM_STACK_SIZE)
91
92#include <rtems/confdefs.h>
93
94/****************  END OF CONFIGURATION INFORMATION  ****************/
Note: See TracBrowser for help on using the repository browser.