summaryrefslogtreecommitdiffstats
path: root/cpukit/itron/src/itrontime.c
blob: 13621a9e6a659207031620f42480b8288d2c0921 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/*
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.OARcorp.com/rtems/license.html.
 *
 *  $Id$
 */

#include <itron.h>

#include <rtems/score/thread.h>
#include <rtems/score/tod.h>

#include <rtems/itron/time.h>

/*
 *  set_tim - Set System Clock
 */

void converTime(SYSTIME ms, TOD_Control *time)
{
  int millisecond;

/* XXX need to dereference structure */
#if 0
  milisecond = ms % 1000;
  tempSecond = ms / 1000;
#else
   millisecond = 0;
#endif
}
   

/*
 *  set_tim - Set System Clock
 */

ER set_tim(
  SYSTIME *pk_tim
)
{
 Watchdog_Interval temp; /* an integer in seconds after conversion from SYSTIME */
 TOD_Control the_tod;
 
/* convert *pk_tim which is 48 bits integer in binary into an ordinary
 integer in milliseconds */
 
/* XXX */ temp = 0;
  if(temp > 0) {
    _Thread_Disable_dispatch();
      _TOD_Set(&the_tod, temp);
    _Thread_Enable_dispatch();
      if(_TOD_Validate(&the_tod)){
      return E_OK;
      }
  }
  return E_SYS;
}

/*
 *  get_tim - Get System Clock
 */

ER get_tim(
  SYSTIME *pk_tim
)
{
  return E_OK;
}

/*
 *  dly_tsk - Delay Task
 */

ER dly_tsk(
  DLYTIME dlytim
)
{
  Watchdog_Interval ticks;

  ticks = TOD_MILLISECONDS_TO_TICKS(dlytim);

  _Thread_Disable_dispatch();
    if ( ticks == 0 ) {
      _Thread_Yield_processor();
    } else {
      _Thread_Set_state( _Thread_Executing, STATES_DELAYING );
      _Watchdog_Initialize(
        &_Thread_Executing->Timer,
        _Thread_Delay_ended,
        _Thread_Executing->Object.id,
        NULL
      );
      _Watchdog_Insert_ticks( &_Thread_Executing->Timer, ticks );
    }
  _Thread_Enable_dispatch();
  return E_OK;
}

/*
 *  def_cyc - Define Cyclic Handler
 */

ER def_cyc(
  HNO     cycno,
  T_DCYC *pk_dcyc
)
{
  Watchdog_Control *object;
#if 0
  Watchdog_Interval timeInterval;
#endif
  
/* XXX */ object = 0;
  if ( pk_dcyc->cycatr != TA_HLNG)
     return E_RSATR;
#if 0
  timeInterval = pk_dcyc->cyctim / 1000;
  object->delta_interval = timeInterval;
#endif
  _Watchdog_Initialize(
         object,
         pk_dcyc->cychdr,
         cycno,
         pk_dcyc->exinf);
  _Watchdog_Deactivate(object);
               
  return E_OK;
}

/*
 *  act_cyc - Activate Cyclic Handler
 */

ER act_cyc(
  HNO   cycno,
  UINT  cycact
)
{
  Watchdog_Control *object;
   
  if(cycact != TCY_OFF || cycact != TCY_ON)
     return E_PAR;

#if 0
  if( object->Object_ID != cycno)
     return E_NOEXS;
#endif
  
  _Watchdog_Activate(object);
         
  return E_OK;
}

/*
 *  ref_cyc - Reference Cyclic Handler Status
 */

ER ref_cyc(
  T_RCYC *pk_rcyc,
  HNO     cycno
)
{
#if 0
  int timeElapse_since_actCyclic;
#endif
  T_DCYC *pk_dcyc;
#if 0
  Watchdog_Control *object;
#endif

/* XXX */ pk_dcyc = 0; 
  
/* XXX will to use a "get" routine to map from id to object pointer */
/* XXX and the object pointer should be of type specific to this manager */
#if 0
  if( object->Object_ID == cycno))
#else
  if ( 1 )
#endif
  {
     pk_rcyc->exinf = pk_dcyc->exinf;
     pk_rcyc->cycact = pk_dcyc->cycact;
#if 0
     pk_rcyc->lfttim = pk_dcyc->cyctim - timeElapse_since_actCyclic;
#endif
     
     return E_OK;
  }
  else
     return E_NOEXS;   
}

/*
 *  def_alm - Define Alarm Handler
 */

ER def_alm(
  HNO     almno,
  T_DALM *pk_dalm
)
{  
#if 0
  Objects_Control *objectAlrm;
  Watchdog_Interval timeInterval;
  
  timeInterval = pk_dalm->almtim / 1000;
  (void) _Watchdog_Remove(&objectAlrm);
  _Watchdog_Initialize(
           objectAlrm,
           pk_dalm->almhdr,
           almno,
           pk_dalm->exinf);
  _Watchdong_Insert_seconds(objectAlrm,timeInterval);
  _Thread_Enable_dispatch();
#endif
              
  return E_OK;
}

/*
 *  ref_alm - Reference Alarm Handler Status
 */

ER ref_alm(
  T_RALM *pk_ralm,
  HNO     almno
)
{
   
  return E_OK;
}

/*
 *  ret_tmr - Return from Timer Handler
 */

void ret_tmr( void )
{
}