source: rtems/cpukit/rtems/src/timercreate.c @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS Create Timer
5 *  @ingroup ClassicTimer
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2002.
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
28rtems_status_code rtems_timer_create(
29  rtems_name  name,
30  rtems_id   *id
31)
32{
33  Timer_Control *the_timer;
34
35  if ( !rtems_is_name_valid( name ) )
36    return RTEMS_INVALID_NAME;
37
38  if ( !id )
39    return RTEMS_INVALID_ADDRESS;
40
41  _Thread_Disable_dispatch();         /* to prevent deletion */
42
43  the_timer = _Timer_Allocate();
44
45  if ( !the_timer ) {
46    _Thread_Enable_dispatch();
47    return RTEMS_TOO_MANY;
48  }
49
50  the_timer->the_class = TIMER_DORMANT;
51  _Watchdog_Initialize( &the_timer->Ticker, NULL, 0, NULL );
52
53  _Objects_Open(
54    &_Timer_Information,
55    &the_timer->Object,
56    (Objects_Name) name
57  );
58
59  *id = the_timer->Object.id;
60  _Thread_Enable_dispatch();
61  return RTEMS_SUCCESSFUL;
62}
Note: See TracBrowser for help on using the repository browser.