source: examples-v2/led/msg_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.3 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 <stdio.h>
13#include <bsp.h>
14
15#include "../led.h"
16
17rtems_id   Queue_id;
18
19rtems_task Test_task(
20  rtems_task_argument unused
21)
22{
23  uint32_t           count;
24  size_t             received;
25  rtems_status_code  status;
26
27  for ( ; ; ) {
28    count = 0xFFFFFFFF;
29    status = rtems_message_queue_receive(
30      Queue_id,
31      (void *) &count,
32      &received,
33      RTEMS_DEFAULT_OPTIONS,
34      RTEMS_NO_TIMEOUT
35    );
36
37    if ( (count % 2) == 0 ) {
38      LED_OFF();
39    } else {
40      LED_ON();
41    }
42  }
43}
44
45rtems_task Init(
46  rtems_task_argument argument
47)
48{
49  uint32_t          count = 0;
50  rtems_status_code status;
51  rtems_id          task_id;
52  rtems_name        task_name;
53
54  puts( "\n\n*** LED BLINKER -- message receive server ***" );
55
56  LED_INIT();
57
58  status = rtems_message_queue_create(
59    rtems_build_name( 'Q', '1', ' ', ' ' ),
60    1,
61    sizeof(uint32_t),
62    RTEMS_DEFAULT_ATTRIBUTES,
63    &Queue_id
64  );
65
66  task_name = rtems_build_name( 'T', 'A', '1', ' ' );
67
68  status = rtems_task_create(
69    task_name, 1, RTEMS_MINIMUM_STACK_SIZE * 2, RTEMS_DEFAULT_MODES,
70    RTEMS_DEFAULT_ATTRIBUTES, &task_id
71  );
72
73  status = rtems_task_start( task_id, Test_task, 1 );
74
75  for (count=0; ; count++) {
76
77    /* fprintf( stderr, "send 0x%d\n", count ); */
78    status = rtems_message_queue_send( Queue_id, &count, sizeof(uint32_t) );
79    if ( status != RTEMS_SUCCESSFUL )
80      fputs( "send did not work\n", stderr );
81
82    status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
83  }
84
85  status = rtems_task_delete( RTEMS_SELF );
86}
87
88/**************** START OF CONFIGURATION INFORMATION ****************/
89
90#define CONFIGURE_INIT
91
92#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
93#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
94
95#define CONFIGURE_MAXIMUM_TASKS             2
96#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES    1
97
98#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
99
100#define CONFIGURE_EXTRA_TASK_STACKS         (3 * RTEMS_MINIMUM_STACK_SIZE)
101
102#include <rtems/confdefs.h>
103
104/****************  END OF CONFIGURATION INFORMATION  ****************/
Note: See TracBrowser for help on using the repository browser.