source: rtems/cpukit/rtems/src/taskwakewhen.c @ 4b48ece0

4.115
Last change on this file since 4b48ece0 was 4b48ece0, checked in by Sebastian Huber <sebastian.huber@…>, on 07/22/13 at 08:21:03

score: Create watchdog implementation header

Move implementation specific parts of watchdog.h and watchdog.inl into
new header file watchdogimpl.h. The watchdog.h contains now only the
application visible API.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Task Wake When
5 *  @ingroup ClassicTasks
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-1999.
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/rtems/modes.h>
25#include <rtems/rtems/clock.h>
26#include <rtems/score/object.h>
27#include <rtems/score/stack.h>
28#include <rtems/score/states.h>
29#include <rtems/rtems/tasks.h>
30#include <rtems/score/thread.h>
31#include <rtems/score/threadq.h>
32#include <rtems/score/tod.h>
33#include <rtems/score/wkspace.h>
34#include <rtems/score/apiext.h>
35#include <rtems/score/sysstate.h>
36#include <rtems/score/watchdogimpl.h>
37
38rtems_status_code rtems_task_wake_when(
39  rtems_time_of_day *time_buffer
40)
41{
42  Watchdog_Interval   seconds;
43
44  if ( !_TOD.is_set )
45    return RTEMS_NOT_DEFINED;
46
47  if ( !time_buffer )
48    return RTEMS_INVALID_ADDRESS;
49
50  time_buffer->ticks = 0;
51
52  if ( !_TOD_Validate( time_buffer ) )
53    return RTEMS_INVALID_CLOCK;
54
55  seconds = _TOD_To_seconds( time_buffer );
56
57  if ( seconds <= _TOD_Seconds_since_epoch() )
58    return RTEMS_INVALID_CLOCK;
59
60  _Thread_Disable_dispatch();
61    _Thread_Set_state( _Thread_Executing, STATES_WAITING_FOR_TIME );
62    _Watchdog_Initialize(
63      &_Thread_Executing->Timer,
64      _Thread_Delay_ended,
65      _Thread_Executing->Object.id,
66      NULL
67    );
68    _Watchdog_Insert_seconds(
69      &_Thread_Executing->Timer,
70      seconds - _TOD_Seconds_since_epoch()
71    );
72  _Thread_Enable_dispatch();
73  return RTEMS_SUCCESSFUL;
74}
Note: See TracBrowser for help on using the repository browser.