source: asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/target_timer.c@ 364

Last change on this file since 364 was 364, checked in by coas-nagasima, 5 years ago

TINETとSocket APIなどを更新

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 17.5 KB
Line 
1/*
2 * TOPPERS/ASP Kernel
3 * Toyohashi Open Platform for Embedded Real-Time Systems/
4 * Advanced Standard Profile Kernel
5 *
6 * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
7 * Toyohashi Univ. of Technology, JAPAN
8 * Copyright (C) 2003-2004 by Naoki Saito
9 * Nagoya Municipal Industrial Research Institute, JAPAN
10 * Copyright (C) 2003-2004 by Platform Development Center
11 * RICOH COMPANY,LTD. JAPAN
12 * Copyright (C) 2008-2010 by Witz Corporation, JAPAN
13 * Copyright (C) 2013 by Mitsuhiro Matsuura
14 * Copyright (C) 2017 by Cores Co., Ltd. Japan
15 *
16 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
17 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
18 * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
19 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
20 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
21 * スコード中に含まれていること.
22 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
23 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
24 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
25 * の無保証規定を掲載すること.
26 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
27 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
28 * と.
29 * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
30 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
31 * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
32 * 報告すること.
33 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
34 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
35 * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
36 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
37 * 免責すること.
38 *
39 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
40 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
41 * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
42 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
43 * の責任を負わない.
44 *
45 * @(#) $Id$
46 */
47
48/*
49 * タイマドライバ(GR-SAKURA用)
50 */
51
52#include "kernel_impl.h"
53#include "time_event.h"
54#include <sil.h>
55#include "target_timer.h"
56#ifdef TOPPERS_SUPPORT_OVRHDR
57#include "overrun.h"
58#endif /* TOPPERS_SUPPORT_OVRHDR */
59
60/*
61 * 上位タイマソフトカウンタ
62 */
63static uint16_t elapse_upper_timer = 0;
64
65/*
66 * 上下位タイマ設定カウンタ
67 */
68static uint16_t timer_upper_set_count = 0, timer_lower_set_count = 0;
69
70#ifdef TOPPERS_SUPPORT_OVRHDR
71
72/* オーバラン上下位タイマ設定カウンタ */
73static uint16_t timer_ovr_upper_set_count = 0, timer_ovr_lower_set_count = 0;
74
75/* オーバランタイマ実行中フラグ */
76static bool_t timer_ovr_running_flg = false;
77
78/* オーバランタイマ開始時HRTタイマ値 */
79static HRTCNT timer_ovr_hrt_backup;
80
81/* オーバランタイマ設定時間 */
82static PRCTIM timer_ovr_ovrtim_backup;
83
84/*
85 * オーバランタイマ割込み要求のクリア
86 */
87Inline void
88target_ovrtimer_int_clear()
89{
90 clear_int(INTNO_TIMER2);
91}
92
93#endif /* TOPPERS_SUPPORT_OVRHDR */
94
95/*
96 * タイマの初期化処理
97 */
98void
99target_timer_initialize(intptr_t exinf)
100{
101 /*
102 * モジュールストップ機能の設定 CMTユニット0 解除
103 */
104 sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA502); /* 書込み許可 */
105 sil_wrw_mem(SYSTEM_MSTPCRA_ADDR,
106 sil_rew_mem(SYSTEM_MSTPCRA_ADDR) & ~SYSTEM_MSTPCRA_MSTPA15_BIT);
107 sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA500); /* 書込み禁止 */
108
109 /*
110 * タイマ停止
111 */
112 sil_wrh_mem(CMT_CMSTR0_ADDR,
113 sil_reh_mem(CMT_CMSTR0_ADDR) & ~(CMT_CMSTR0_STR0_BIT | CMT_CMSTR0_STR1_BIT));
114
115 /*
116 * カウントアップに用いられるクロック設定
117 * PCLK/8を選択
118 */
119 sil_wrh_mem(CMT0_CMCR_ADDR, CMT_PCLK_DIV_8);
120 sil_wrh_mem(CMT1_CMCR_ADDR, CMT_PCLK_DIV_8);
121
122 /*
123 * コンペアマッチタイマカウンタ設定
124 */
125 sil_wrh_mem(CMT0_CMCNT_ADDR, 0U);
126 sil_wrh_mem(CMT1_CMCNT_ADDR, 0U);
127
128 /*
129 * コンペアマッチタイマ周期設定
130 */
131 sil_wrh_mem(CMT0_CMCOR_ADDR, 0); /* lower */
132 sil_wrh_mem(CMT1_CMCOR_ADDR, CMCOR_PERIOD - 1); /* upper */
133 elapse_upper_timer = 0;
134
135 /*
136 * コンペアマッチタイマ割り込み要求先設定レジスタ(28,29)
137 */
138 sil_wrb_mem(ICU_ISELR028_ADDR, ICU_ISEL_CPU);
139 sil_wrb_mem(ICU_ISELR029_ADDR, ICU_ISEL_CPU);
140
141 /*
142 * タイマ動作開始前の割込み要求をクリア
143 */
144 clear_int(INTNO_TIMER0);
145 clear_int(INTNO_TIMER1);
146
147 /*
148 * コンペアマッチタイマ割り込みを許可
149 */
150// sil_wrh_mem(CMT0_CMCR_ADDR,
151// sil_reh_mem(CMT0_CMCR_ADDR) | CMT0_CMCR_CMIE_BIT); /* lower */
152 sil_wrh_mem(CMT1_CMCR_ADDR,
153 sil_reh_mem(CMT1_CMCR_ADDR) | CMT1_CMCR_CMIE_BIT); /* upper */
154
155 /*
156 * タイマ動作開始
157 */
158// sil_wrh_mem(CMT_CMSTR0_ADDR,
159// sil_reh_mem(CMT_CMSTR0_ADDR) | CMT_CMSTR0_STR0_BIT); /* lower */
160 sil_wrh_mem(CMT_CMSTR0_ADDR,
161 sil_reh_mem(CMT_CMSTR0_ADDR) | CMT_CMSTR0_STR1_BIT); /* upper */
162}
163
164/*
165 * タイマの停止処理
166 */
167void
168target_timer_terminate(intptr_t exinf)
169{
170 /*
171 * タイマ停止 lower, upper
172 */
173 sil_wrh_mem(CMT_CMSTR0_ADDR,
174 sil_reh_mem(CMT_CMSTR0_ADDR) & ~(CMT_CMSTR0_STR0_BIT | CMT_CMSTR0_STR1_BIT));
175
176 /*
177 * タイマ割り込み禁止 lower,upper
178 */
179 sil_wrh_mem(CMT0_CMCR_ADDR,
180 sil_reh_mem(CMT0_CMCR_ADDR) & ~CMT0_CMCR_CMIE_BIT);
181 sil_wrh_mem(CMT1_CMCR_ADDR,
182 sil_reh_mem(CMT1_CMCR_ADDR) & ~CMT1_CMCR_CMIE_BIT);
183
184 /*
185 * タイマ割込み要求をクリア
186 */
187 clear_int(INTNO_TIMER0);
188 clear_int(INTNO_TIMER1);
189
190 /*
191 * モジュールストップ機能の設定 CMTユニット0 停止
192 */
193 sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA502); /* 書込み許可 */
194 sil_wrw_mem(SYSTEM_MSTPCRA_ADDR,
195 sil_rew_mem(SYSTEM_MSTPCRA_ADDR) | SYSTEM_MSTPCRA_MSTPA15_BIT);
196 sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA500); /* 書込み禁止 */
197}
198
199/*
200 * 下位タイマ割込みハンドラ(CMT0)
201 */
202void target_lower_timer_handler(void)
203{
204 /*
205 * タイマ停止
206 */
207 sil_wrh_mem(CMT_CMSTR0_ADDR,
208 sil_reh_mem(CMT_CMSTR0_ADDR) & ~CMT_CMSTR0_STR0_BIT);
209
210 /*
211 * タイマ割り込み禁止
212 */
213 sil_wrh_mem(CMT0_CMCR_ADDR,
214 sil_reh_mem(CMT0_CMCR_ADDR) & ~CMT0_CMCR_CMIE_BIT);
215
216 /*
217 * 割り込み要因クリア
218 */
219 clear_int(INTNO_TIMER0);
220
221 /*
222 * カウント設定クリア
223 */
224 timer_lower_set_count = 0;
225
226 /*
227 * タイマ割り込み処理
228 */
229 signal_time();
230}
231
232/*
233 * 上位タイマ割込みハンドラ(CMT1)
234 */
235void target_upper_timer_handler(void)
236{
237 /*
238 * 上位タイマソフトカウンタ更新
239 */
240 elapse_upper_timer++;
241
242 /*
243 * 上位タイマ設定値更新
244 */
245 if(timer_upper_set_count > 0) {
246 timer_upper_set_count--;
247 }
248
249 /*
250 * 上位タイママッチ処理
251 */
252 if(timer_upper_set_count == 0){
253 if(timer_lower_set_count > 0){
254 /*
255 * 下位タイマ設定、開始
256 */
257 sil_wrh_mem(CMT0_CMCOR_ADDR, timer_lower_set_count);
258 clear_int(INTNO_TIMER0);
259 sil_wrh_mem(CMT0_CMCR_ADDR,
260 sil_reh_mem(CMT0_CMCR_ADDR) | CMT0_CMCR_CMIE_BIT);
261 sil_wrh_mem(CMT_CMSTR0_ADDR,
262 sil_reh_mem(CMT_CMSTR0_ADDR) | CMT_CMSTR0_STR0_BIT);
263 }
264 else{
265 /*
266 * 下位タイマ割り込み強制起動
267 */
268 target_hrt_raise_event();
269 }
270 }
271
272#ifdef TOPPERS_SUPPORT_OVRHDR
273 if(timer_ovr_running_flg == true) {
274 /*
275 * オーバラン上位タイマ設定値更新
276 */
277 if(timer_ovr_upper_set_count > 0) {
278 timer_ovr_upper_set_count--;
279 }
280
281 /*
282 * オーバラン上位タイママッチ処理
283 */
284 if(timer_ovr_upper_set_count == 0) {
285 if(timer_ovr_lower_set_count > 0){
286 /*
287 * オーバラン下位タイマ設定、開始
288 */
289 sil_wrh_mem(CMT2_CMCNT_ADDR, 0U);
290 sil_wrh_mem(CMT2_CMCOR_ADDR, timer_ovr_lower_set_count);
291 target_ovrtimer_int_clear();
292 sil_wrh_mem(CMT2_CMCR_ADDR,
293 sil_reh_mem(CMT2_CMCR_ADDR) | CMT2_CMCR_CMIE_BIT);
294 sil_wrh_mem(CMT_CMSTR1_ADDR,
295 sil_reh_mem(CMT_CMSTR1_ADDR) | CMT_CMSTR1_STR2_BIT);
296 }
297 else {
298 /*
299 * オーバラン下位タイマ割り込み強制起動
300 */
301 target_ovrtimer_raise_event();
302 }
303 }
304 }
305#endif /* TOPPERS_SUPPORT_OVRHDR */
306}
307
308/*
309 * 高分解能タイマへの割込みタイミングの設定
310 */
311void
312target_hrt_set_event(HRTCNT hrtcnt)
313{
314 uint32_t current_timer_count_work;
315 uint32_t total_timer_count;
316
317 /*
318 * 時間 -> タイマカウンタ 変換
319 */
320 total_timer_count = hrtcnt * USEC_CONVERT_VALUE;
321 timer_upper_set_count = total_timer_count / CMCOR_PERIOD;
322 timer_lower_set_count = total_timer_count % CMCOR_PERIOD;
323
324 /*
325 * 上位タイマカウンタ現在値で調整
326 */
327 current_timer_count_work = timer_lower_set_count + sil_reh_mem(CMT1_CMCNT_ADDR);
328 if(current_timer_count_work >= CMCOR_PERIOD) {
329 timer_upper_set_count++;
330 timer_lower_set_count = current_timer_count_work - CMCOR_PERIOD;
331 }
332
333 /*
334 * 下位タイマ設定
335 */
336 if(timer_upper_set_count == 0 && timer_lower_set_count > 0) {
337 /*
338 * コンペアマッチタイマカウンタ設定
339 */
340 sil_wrh_mem(CMT0_CMCNT_ADDR, 0U);
341
342 /*
343 * 割り込み要因クリア
344 */
345 clear_int(INTNO_TIMER0);
346
347 /*
348 * コンペアマッチタイマ周期設定
349 */
350 sil_wrh_mem(CMT0_CMCOR_ADDR, timer_lower_set_count);
351
352 /*
353 * タイマ割り込み許可
354 */
355 sil_wrh_mem(CMT0_CMCR_ADDR,
356 sil_reh_mem(CMT0_CMCR_ADDR) | CMT0_CMCR_CMIE_BIT);
357
358 /*
359 * タイマ開始
360 */
361 sil_wrh_mem(CMT_CMSTR0_ADDR,
362 sil_reh_mem(CMT_CMSTR0_ADDR) | CMT_CMSTR0_STR0_BIT);
363 }
364}
365
366/*
367 * 高分解能タイマ割込みの要求
368 */
369void
370target_hrt_raise_event(void)
371{
372 /*
373 * 下位タイマ強制割り込み起動
374 * 注意:停止するまで割り込みが繰り返し発生する
375 */
376 sil_wrh_mem(CMT0_CMCNT_ADDR, 0U); /* カウンタ初期化 */
377 clear_int(INTNO_TIMER0); /* 要求クリア */
378 sil_wrh_mem(CMT0_CMCOR_ADDR, 0U); /* マッチ周期設定 */
379 sil_wrh_mem(CMT0_CMCR_ADDR, /* 割り込み許可 */
380 sil_reh_mem(CMT0_CMCR_ADDR) | CMT0_CMCR_CMIE_BIT);
381 sil_wrh_mem(CMT_CMSTR0_ADDR, /* タイマ起動 */
382 sil_reh_mem(CMT_CMSTR0_ADDR) | CMT_CMSTR0_STR0_BIT);
383}
384
385/*
386 * 高分解能タイマの現在のカウント値の読出し 内部処理
387 */
388HRTCNT target_hrt_get_current_convert(void)
389{
390 uint16_t local_cnt, local_eut;
391 HRTCNT time;
392
393 local_eut = elapse_upper_timer;
394 local_cnt = sil_reh_mem(CMT1_CMCNT_ADDR);
395
396 /*
397 * 上位タイマ コンペアマッチチェック
398 */
399 if (probe_int(INTNO_TIMER1)) {
400 if (local_cnt < 0x8000)
401 local_eut += 1;
402 }
403
404 time = (((HRTCNT)local_eut * CMCOR_PERIOD) + (HRTCNT)local_cnt) / USEC_CONVERT_VALUE;
405
406 return time;
407}
408
409/*
410 * オーバランタイマドライバ
411 */
412#ifdef TOPPERS_SUPPORT_OVRHDR
413
414/*
415 * オーバランタイマの初期化処理
416 */
417void
418target_ovrtimer_initialize(intptr_t exinf)
419{
420 /*
421 * モジュールストップ機能の設定 CMTユニット1 解除
422 */
423 sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA502); /* 書込み許可 */
424 sil_wrw_mem(SYSTEM_MSTPCRA_ADDR,
425 sil_rew_mem(SYSTEM_MSTPCRA_ADDR) & ~SYSTEM_MSTPCRA_MSTPA14_BIT);
426 sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA500); /* 書込み禁止 */
427
428 /*
429 * タイマ停止 CMT2
430 */
431 sil_wrh_mem(CMT_CMSTR1_ADDR,
432 sil_reh_mem(CMT_CMSTR1_ADDR) & ~CMT_CMSTR1_STR2_BIT);
433
434 /*
435 * カウントアップに用いられるクロック設定 CMT2
436 * PCLK/8を選択
437 */
438 sil_wrh_mem(CMT2_CMCR_ADDR, CMT_PCLK_DIV_8);
439
440 /*
441 * コンペアマッチタイマカウンタ設定 CMT2
442 */
443 sil_wrh_mem(CMT2_CMCNT_ADDR, 0U);
444
445 /*
446 * コンペアマッチタイマ周期設定 CMT2
447 */
448 sil_wrh_mem(CMT2_CMCOR_ADDR, 0U);
449
450 /*
451 * コンペアマッチタイマ割り込み要求先設定レジスタ(30)
452 */
453 sil_wrb_mem(ICU_ISELR030_ADDR, ICU_ISEL_CPU);
454
455 /*
456 * タイマ動作開始前の割込み要求をクリア
457 */
458 target_ovrtimer_int_clear();
459}
460
461void
462target_ovrtimer_start(PRCTIM ovrtim)
463{
464 uint32_t current_timer_count_work;
465 uint32_t total_timer_count;
466
467 /*
468 * 時間 -> タイマカウンタ 変換
469 */
470 total_timer_count = ovrtim * USEC_CONVERT_VALUE;
471 timer_ovr_upper_set_count = total_timer_count / CMCOR_PERIOD;
472 timer_ovr_lower_set_count = total_timer_count % CMCOR_PERIOD;
473
474 /*
475 * 高分解能上位タイマカウンタ現在値で調整
476 */
477 timer_ovr_ovrtim_backup = ovrtim;
478 timer_ovr_hrt_backup = target_hrt_get_current();
479 current_timer_count_work = timer_ovr_lower_set_count + sil_reh_mem(CMT1_CMCNT_ADDR);
480 if(current_timer_count_work >= CMCOR_PERIOD) {
481 timer_ovr_upper_set_count++;
482 timer_ovr_lower_set_count = current_timer_count_work - CMCOR_PERIOD;
483 }
484
485 /*
486 * オーバランタイマ動作中フラグ
487 */
488 timer_ovr_running_flg = true;
489
490 /*
491 * 下位タイマ設定
492 */
493 if(timer_ovr_upper_set_count == 0) {
494 if(timer_ovr_lower_set_count == 0) {
495 target_ovrtimer_raise_event();
496 }
497 else {
498 /*
499 * コンペアマッチタイマカウンタクリア CMT2
500 */
501 sil_wrh_mem(CMT2_CMCNT_ADDR, 0U);
502
503 /*
504 * コンペアマッチタイマ周期設定 CMT2
505 */
506 sil_wrh_mem(CMT2_CMCOR_ADDR, timer_ovr_lower_set_count);
507
508 /*
509 * タイマ動作開始前の割込み要求をクリア
510 */
511 target_ovrtimer_int_clear();
512
513 /*
514 * コンペアマッチタイマ割り込みを許可 CMT2
515 */
516 sil_wrh_mem(CMT2_CMCR_ADDR,
517 sil_reh_mem(CMT2_CMCR_ADDR) | CMT2_CMCR_CMIE_BIT);
518
519 /*
520 * タイマ動作開始 CMT2
521 */
522 sil_wrh_mem(CMT_CMSTR1_ADDR,
523 sil_reh_mem(CMT_CMSTR1_ADDR) | CMT_CMSTR1_STR2_BIT);
524 }
525 }
526}
527
528/*
529 * オーバランタイマの停止処理
530 */
531void
532target_ovrtimer_terminate(intptr_t exinf)
533{
534 /*
535 * タイマ停止
536 */
537 sil_wrh_mem(CMT_CMSTR1_ADDR,
538 sil_reh_mem(CMT_CMSTR1_ADDR) & ~CMT_CMSTR1_STR2_BIT);
539
540 /*
541 * タイマ割り込み禁止
542 */
543 sil_wrh_mem(CMT2_CMCR_ADDR,
544 sil_reh_mem(CMT2_CMCR_ADDR) & ~CMT2_CMCR_CMIE_BIT);
545
546 /*
547 * タイマ割込み要求をクリア
548 */
549 target_ovrtimer_int_clear();
550
551 /*
552 * オーバランタイマ動作中フラグ
553 */
554 timer_ovr_running_flg = false;
555
556 /*
557 * モジュールストップ機能の設定 CMTユニット0 停止
558 */
559 sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA502); /* 書込み許可 */
560 sil_wrw_mem(SYSTEM_MSTPCRA_ADDR,
561 sil_rew_mem(SYSTEM_MSTPCRA_ADDR) | SYSTEM_MSTPCRA_MSTPA14_BIT);
562 sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA500); /* 書込み禁止 */
563}
564
565/*
566 * オーバランタイマの停止
567 */
568PRCTIM
569target_ovrtimer_stop(uint_t int_num)
570{
571 uint32_t cnt;
572
573 /*
574 * タイマ停止
575 */
576 sil_wrh_mem(CMT_CMSTR1_ADDR,
577 sil_reh_mem(CMT_CMSTR1_ADDR) & ~CMT_CMSTR1_STR2_BIT);
578
579 /*
580 * オーバランタイマ動作中フラグ
581 */
582 timer_ovr_running_flg = false;
583
584 if(int_num == INTNO_TIMER2) {
585 /*
586 * オーバラン割込みの場合
587 */
588 target_ovrtimer_int_clear();
589 return(0U);
590 }
591 else {
592 HRTCNT timer_ovr_hrt_current = target_hrt_get_current();
593 if((timer_ovr_hrt_current < timer_ovr_hrt_backup) && (int_num == INTNO_OVR_BASE_TIMER)) {
594 timer_ovr_hrt_current += (CMCOR_PERIOD / USEC_CONVERT_VALUE);
595 }
596
597 cnt = timer_ovr_ovrtim_backup - (timer_ovr_hrt_current - timer_ovr_hrt_backup);
598 if(timer_ovr_hrt_current < timer_ovr_hrt_backup) {
599 cnt += TCYC_HRTCNT;
600 }
601
602 if(cnt > timer_ovr_ovrtim_backup) { /* 設定時間を過ぎた */
603 cnt = 0;
604 }
605 return (PRCTIM)cnt;
606 }
607}
608
609/*
610 * オーバランタイマの現在値の読出し
611 */
612PRCTIM
613target_ovrtimer_get_current(void)
614{
615 uint32_t cnt;
616
617 if (probe_int(INTNO_TIMER2)) {
618 /*
619 * 割込み要求が発生している場合
620 */
621 return(0U);
622 }
623 else {
624 HRTCNT timer_ovr_hrt_current = target_hrt_get_current();
625 cnt = timer_ovr_ovrtim_backup - (timer_ovr_hrt_current - timer_ovr_hrt_backup);
626 if(timer_ovr_hrt_current < timer_ovr_hrt_backup) {
627 cnt += TCYC_HRTCNT;
628 }
629
630 if(cnt > timer_ovr_ovrtim_backup) { /* 設定時間を過ぎた */
631 cnt = 0;
632 }
633 return (PRCTIM)cnt;
634 }
635}
636
637/*
638 * 高分解能タイマ割込みの要求
639 */
640void
641target_ovrtimer_raise_event(void)
642{
643 /*
644 * オーバラン下位タイマ強制割り込み起動
645 * 注意:停止するまで割り込みが繰り返し発生する
646 */
647 sil_wrh_mem(CMT2_CMCNT_ADDR, 0U); /* カウンタ初期化 */
648 clear_int(INTNO_TIMER2); /* 要求クリア */
649 sil_wrh_mem(CMT2_CMCOR_ADDR, 0U); /* マッチ周期設定 */
650 sil_wrh_mem(CMT2_CMCR_ADDR, /* 割り込み許可 */
651 sil_reh_mem(CMT2_CMCR_ADDR) | CMT2_CMCR_CMIE_BIT);
652 sil_wrh_mem(CMT_CMSTR1_ADDR, /* タイマ起動 */
653 sil_reh_mem(CMT_CMSTR1_ADDR) | CMT_CMSTR1_STR2_BIT);
654}
655
656/*
657 * オーバランタイマ割込みハンドラ
658 *
659 * このルーチンに来るまでに,target_ovrtimer_stopが呼ばれているため,
660 * OSタイマを停止する必要はない.
661 */
662void
663target_ovrtimer_handler(void)
664{
665 /*
666 * タイマ割り込み禁止
667 */
668 sil_wrh_mem(CMT2_CMCR_ADDR,
669 sil_reh_mem(CMT2_CMCR_ADDR) & ~CMT2_CMCR_CMIE_BIT);
670
671 /*
672 * 上下位タイマカウンタクリア
673 */
674 timer_ovr_upper_set_count = 0;
675 timer_ovr_lower_set_count = 0;
676
677 call_ovrhdr(); /* オーバランハンドラの起動処理 */
678}
679
680#endif /* TOPPERS_SUPPORT_OVRHDR */
Note: See TracBrowser for help on using the repository browser.