source: examples-v2/led/timer_server/init.c @ a3bf3ec

4.11examples-v2-4-10-branch
Last change on this file since a3bf3ec was a3bf3ec, checked in by Glenn Humphrey <glenn.humphrey@…>, on Dec 17, 2009 at 10:07:06 PM

2009-12-17 Glenn Humphrey <glenn.humphrey@…>

  • timer/init.c, timer_server/init.c: Simplified examples to insure consistent behavior for all cases.
  • 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_INIT
77#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
78#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
79
80#define CONFIGURE_MAXIMUM_TASKS         2
81#define CONFIGURE_MAXIMUM_TIMERS        2
82
83#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
84
85#define CONFIGURE_EXTRA_TASK_STACKS         (3 * RTEMS_MINIMUM_STACK_SIZE)
86
87#include <rtems/confdefs.h>
88
89/****************  END OF CONFIGURATION INFORMATION  ****************/
Note: See TracBrowser for help on using the repository browser.