source: rtems/cpukit/rtems/src/timerreset.c @ 1dc6662

4.115
Last change on this file since 1dc6662 was 1dc6662, checked in by Sebastian Huber <sebastian.huber@…>, on 04/13/15 at 11:57:57

score: Rename _Watchdog_Reset()

Update #2307.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief RTEMS Timer Reset
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.org/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/thread.h>
25#include <rtems/rtems/timerimpl.h>
26#include <rtems/score/watchdogimpl.h>
27
28/*
29 *  rtems_timer_reset
30 *
31 *  This directive allows a thread to reset a timer.
32 *
33 *  Input parameters:
34 *    id - timer id
35 *
36 *  Output parameters:
37 *    RTEMS_SUCCESSFUL - if successful
38 *    error code       - if unsuccessful
39 */
40
41rtems_status_code rtems_timer_reset(
42  rtems_id id
43)
44{
45  Timer_Control     *the_timer;
46  Objects_Locations  location;
47  rtems_status_code  status = RTEMS_SUCCESSFUL;
48
49  the_timer = _Timer_Get( id, &location );
50  switch ( location ) {
51
52    case OBJECTS_LOCAL:
53      if ( the_timer->the_class == TIMER_INTERVAL ) {
54        _Watchdog_Reset_ticks( &the_timer->Ticker );
55      } else if ( the_timer->the_class == TIMER_INTERVAL_ON_TASK ) {
56        Timer_server_Control *timer_server = _Timer_server;
57
58        /*
59         *  There is no way for a timer to have this class unless
60         *  it was scheduled as a server fire.  That requires that
61         *  the Timer Server be initiated.  So this error cannot
62         *  occur unless something is internally wrong.
63         */
64        #if defined(RTEMS_DEBUG)
65          if ( !timer_server ) {
66            _Objects_Put( &the_timer->Object );
67            return RTEMS_INCORRECT_STATE;
68          }
69        #endif
70        _Watchdog_Remove( &the_timer->Ticker );
71        (*timer_server->schedule_operation)( timer_server, the_timer );
72      } else {
73        /*
74         *  Must be dormant or time of day timer (e.g. TIMER_DORMANT,
75         *  TIMER_TIME_OF_DAY, or TIMER_TIME_OF_DAY_ON_TASK).  We
76         *  can only reset active interval timers.
77         */
78        status = RTEMS_NOT_DEFINED;
79      }
80      _Objects_Put( &the_timer->Object );
81      return status;
82
83#if defined(RTEMS_MULTIPROCESSING)
84    case OBJECTS_REMOTE:            /* should never return this */
85#endif
86    case OBJECTS_ERROR:
87      break;
88  }
89
90  return RTEMS_INVALID_ID;
91}
Note: See TracBrowser for help on using the repository browser.