source: rtems/cpukit/rtems/src/timerreset.c @ a29d2e7

4.104.114.84.95
Last change on this file since a29d2e7 was 1095ec1, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/18/05 at 09:03:45

Include config.h.

  • Property mode set to 100644
File size: 2.0 KB
Line 
1/*
2 *  Timer Manager - rtems_timer_reset directive
3 *
4 *
5 *  COPYRIGHT (c) 1989-2002.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems/system.h>
20#include <rtems/rtems/status.h>
21#include <rtems/rtems/support.h>
22#include <rtems/score/object.h>
23#include <rtems/score/thread.h>
24#include <rtems/rtems/timer.h>
25#include <rtems/score/tod.h>
26#include <rtems/score/watchdog.h>
27
28/*PAGE
29 *
30 *  rtems_timer_reset
31 *
32 *  This directive allows a thread to reset a timer.
33 *
34 *  Input parameters:
35 *    id - timer id
36 *
37 *  Output parameters:
38 *    RTEMS_SUCCESSFUL - if successful
39 *    error code       - if unsuccessful
40 */
41
42rtems_status_code rtems_timer_reset(
43  Objects_Id id
44)
45{
46  Timer_Control     *the_timer;
47  Objects_Locations  location;
48
49  the_timer = _Timer_Get( id, &location );
50  switch ( location ) {
51    case OBJECTS_REMOTE:            /* should never return this */
52      return RTEMS_INTERNAL_ERROR;
53
54    case OBJECTS_ERROR:
55      return RTEMS_INVALID_ID;
56
57    case OBJECTS_LOCAL:
58      switch ( the_timer->the_class ) {
59        case TIMER_INTERVAL:
60          _Watchdog_Remove( &the_timer->Ticker );
61          _Watchdog_Insert( &_Watchdog_Ticks_chain, &the_timer->Ticker );
62          break;
63        case TIMER_INTERVAL_ON_TASK:
64          _Timer_Server_stop_ticks_timer();
65          _Watchdog_Remove( &the_timer->Ticker );
66          _Timer_Server_process_ticks_chain();
67          _Watchdog_Insert( &_Timer_Ticks_chain, &the_timer->Ticker );
68          _Timer_Server_reset_ticks_timer();
69          break;
70        case TIMER_TIME_OF_DAY:
71        case TIMER_TIME_OF_DAY_ON_TASK:
72        case TIMER_DORMANT:
73          _Thread_Enable_dispatch();
74          return RTEMS_NOT_DEFINED;
75      }
76      _Thread_Enable_dispatch();
77      return RTEMS_SUCCESSFUL;
78  }
79
80  return RTEMS_INTERNAL_ERROR;   /* unreached - only to remove warnings */
81}
Note: See TracBrowser for help on using the repository browser.