source: examples-v2/led/timer_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.0 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     Timer1;
18rtems_id     Timer2;
19
20rtems_timer_service_routine Timer_Routine( rtems_id id, void *ignored )
21{
22  rtems_status_code status;
23
24  if ( id == Timer1 )
25    LED_OFF();
26  else
27    LED_ON();
28
29  status = rtems_timer_server_fire_after(
30    id,
31    2 * rtems_clock_get_ticks_per_second(),
32    Timer_Routine,
33    NULL
34  );
35}
36
37rtems_task Init(
38  rtems_task_argument argument
39)
40{
41  rtems_status_code status;
42
43  puts( "\n\n*** LED BLINKER -- timer_server ***" );
44
45  LED_INIT();
46
47  status = rtems_timer_initiate_server(
48    1, 
49    RTEMS_MINIMUM_STACK_SIZE * 2,
50    RTEMS_DEFAULT_ATTRIBUTES
51  );
52
53  if ( status != RTEMS_SUCCESSFUL )
54    fputs( "timer create server failed\n", stderr );
55
56  status = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '1' ), &Timer1);
57  if ( status != RTEMS_SUCCESSFUL )
58    fputs( "Timer1 create failed\n", stderr );
59
60  status = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '2' ), &Timer2);
61  if ( status != RTEMS_SUCCESSFUL )
62    fputs( "Timer2 create failed\n", stderr );
63
64  Timer_Routine(Timer1, NULL);
65
66  status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
67
68  Timer_Routine(Timer2, NULL);
69
70  status = rtems_task_delete( RTEMS_SELF );
71}
72
73
74/**************** START OF CONFIGURATION INFORMATION ****************/
75
76#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
77#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
78
79#define CONFIGURE_MAXIMUM_TASKS         2
80#define CONFIGURE_MAXIMUM_TIMERS        2
81
82#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
83
84#define CONFIGURE_EXTRA_TASK_STACKS         (3 * RTEMS_MINIMUM_STACK_SIZE)
85
86#define CONFIGURE_INIT
87#include <rtems/confdefs.h>
88/****************  END OF CONFIGURATION INFORMATION  ****************/
Note: See TracBrowser for help on using the repository browser.