source: rtems/cpukit/rtems/src/timerserverfirewhen.c @ 4c90eb4

4.115
Last change on this file since 4c90eb4 was 4c90eb4, checked in by Mathew Kallada <matkallada@…>, on 12/08/12 at 13:48:37

misc rtems: Clean up Doxygen GCI Task #8

http://www.google-melange.com/gci/task/view/google/gci2012/8024203

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/**
2 * @file
3 *
4 * @brief RTEMS Timer Server Fire When Directive
5 * @ingroup ClassicTimer Timers
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2007.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/rtems/status.h>
23#include <rtems/rtems/support.h>
24#include <rtems/score/object.h>
25#include <rtems/score/thread.h>
26#include <rtems/rtems/timer.h>
27#include <rtems/score/tod.h>
28#include <rtems/score/watchdog.h>
29
30/*
31 *  rtems_timer_server_fire_when
32 *
33 *  This directive allows a thread to start a timer which will by
34 *  executed by the Timer Server when it fires.
35 *
36 *  Input parameters:
37 *    id        - timer id
38 *    wall_time - time of day to fire timer
39 *    routine   - routine to schedule
40 *    user_data - passed as argument to routine when it is fired
41 *
42 *  Output parameters:
43 *    RTEMS_SUCCESSFUL - if successful
44 *    error code       - if unsuccessful
45 */
46
47rtems_status_code rtems_timer_server_fire_when(
48  rtems_id                           id,
49  rtems_time_of_day                  *wall_time,
50  rtems_timer_service_routine_entry  routine,
51  void                              *user_data
52)
53{
54  Timer_Control        *the_timer;
55  Objects_Locations     location;
56  rtems_interval        seconds;
57  Timer_server_Control *timer_server = _Timer_server;
58
59  if ( !timer_server )
60    return RTEMS_INCORRECT_STATE;
61
62  if ( !_TOD.is_set )
63    return RTEMS_NOT_DEFINED;
64
65  if ( !routine )
66    return RTEMS_INVALID_ADDRESS;
67
68  if ( !_TOD_Validate( wall_time ) )
69    return RTEMS_INVALID_CLOCK;
70
71  seconds = _TOD_To_seconds( wall_time );
72  if ( seconds <= _TOD_Seconds_since_epoch() )
73    return RTEMS_INVALID_CLOCK;
74
75  the_timer = _Timer_Get( id, &location );
76  switch ( location ) {
77
78    case OBJECTS_LOCAL:
79      (void) _Watchdog_Remove( &the_timer->Ticker );
80      the_timer->the_class = TIMER_TIME_OF_DAY_ON_TASK;
81      _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
82      the_timer->Ticker.initial = seconds - _TOD_Seconds_since_epoch();
83
84      (*timer_server->schedule_operation)( timer_server, the_timer );
85
86      _Thread_Enable_dispatch();
87      return RTEMS_SUCCESSFUL;
88
89#if defined(RTEMS_MULTIPROCESSING)
90    case OBJECTS_REMOTE:            /* should never return this */
91#endif
92    case OBJECTS_ERROR:
93      break;
94  }
95
96  return RTEMS_INVALID_ID;
97}
Note: See TracBrowser for help on using the repository browser.