source: rtems/cpukit/rtems/src/timerfirewhen.c @ 2903090

4.115
Last change on this file since 2903090 was 2903090, checked in by Sebastian Huber <sebastian.huber@…>, on 04/15/15 at 09:26:46

score: Add header to _Watchdog_Remove()

Add watchdog header parameter to _Watchdog_Remove() to be in line with
the other operations. Add _Watchdog_Remove_ticks() and
_Watchdog_Remove_seconds() for convenience.

Update #2307.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Timer Fire When
5 *  @ingroup ClassicTimer
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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/rtems/timerimpl.h>
22#include <rtems/rtems/clock.h>
23#include <rtems/score/todimpl.h>
24#include <rtems/score/watchdogimpl.h>
25
26rtems_status_code rtems_timer_fire_when(
27  rtems_id                            id,
28  rtems_time_of_day                  *wall_time,
29  rtems_timer_service_routine_entry   routine,
30  void                               *user_data
31)
32{
33  Timer_Control       *the_timer;
34  Objects_Locations    location;
35  rtems_interval       seconds;
36
37  if ( !_TOD_Is_set() )
38    return RTEMS_NOT_DEFINED;
39
40  if ( !_TOD_Validate( wall_time ) )
41    return RTEMS_INVALID_CLOCK;
42
43  if ( !routine )
44    return RTEMS_INVALID_ADDRESS;
45
46  seconds = _TOD_To_seconds( wall_time );
47  if ( seconds <= _TOD_Seconds_since_epoch() )
48    return RTEMS_INVALID_CLOCK;
49
50  the_timer = _Timer_Get( id, &location );
51  switch ( location ) {
52
53    case OBJECTS_LOCAL:
54      _Timer_Cancel( the_timer );
55      the_timer->the_class = TIMER_TIME_OF_DAY;
56      _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data );
57      _Watchdog_Insert_seconds(
58         &the_timer->Ticker,
59         seconds - _TOD_Seconds_since_epoch()
60       );
61      _Objects_Put( &the_timer->Object );
62      return RTEMS_SUCCESSFUL;
63
64#if defined(RTEMS_MULTIPROCESSING)
65    case OBJECTS_REMOTE:            /* should never return this */
66#endif
67    case OBJECTS_ERROR:
68      break;
69  }
70
71  return RTEMS_INVALID_ID;
72}
Note: See TracBrowser for help on using the repository browser.