source: UsbWattMeter/trunk/asp_dcre/kernel/time_manage.c@ 164

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

TOPPERS/ECNLサンプルアプリ「USB充電器電力計」を追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csrc
File size: 3.8 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) 2005-2010 by Embedded and Real-Time Systems Laboratory
9 * Graduate School of Information Science, Nagoya Univ., JAPAN
10 *
11 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
12 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
13 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
14 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
15 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
16 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
17 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
18 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
19ƒƒ“ƒgi—˜—p
20 * ŽÒƒ}ƒjƒ…
21ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
22 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
23 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
24 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
25 * ‚ƁD
26 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
27ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
28ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
29 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
30 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
31 * •ñ‚·‚邱‚ƁD
32 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
33 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
34 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
35 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
36 * –Ɛӂ·‚邱‚ƁD
37 *
38 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
39 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
40 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
41 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
42 * ‚̐ӔC‚𕉂í‚È‚¢D
43 *
44 * $Id: time_manage.c 164 2016-03-07 11:33:50Z coas-nagasima $
45 */
46
47/*
48 * ƒVƒXƒeƒ€ŽžŠÇ—‹@”\
49 */
50
51#include "kernel_impl.h"
52#include "check.h"
53#include "time_event.h"
54
55/*
56 * ƒgƒŒ[ƒXƒƒOƒ}ƒNƒ‚̃fƒtƒHƒ‹ƒg’è‹`
57 */
58#ifndef LOG_GET_TIM_ENTER
59#define LOG_GET_TIM_ENTER(p_systim)
60#endif /* LOG_GET_TIM_ENTER */
61
62#ifndef LOG_GET_TIM_LEAVE
63#define LOG_GET_TIM_LEAVE(ercd, systim)
64#endif /* LOG_GET_TIM_LEAVE */
65
66#ifndef LOG_GET_UTM_ENTER
67#define LOG_GET_UTM_ENTER(p_sysutm)
68#endif /* LOG_GET_UTM_ENTER */
69
70#ifndef LOG_GET_UTM_LEAVE
71#define LOG_GET_UTM_LEAVE(ercd, sysutm)
72#endif /* LOG_GET_UTM_LEAVE */
73
74/*
75 * ƒVƒXƒeƒ€Žž‚ÌŽQÆ
76 */
77#ifdef TOPPERS_get_tim
78
79ER
80get_tim(SYSTIM *p_systim)
81{
82 ER ercd;
83
84 LOG_GET_TIM_ENTER(p_systim);
85 CHECK_TSKCTX_UNL();
86
87 t_lock_cpu();
88 *p_systim = current_time;
89 ercd = E_OK;
90 t_unlock_cpu();
91
92 error_exit:
93 LOG_GET_TIM_LEAVE(ercd, *p_systim);
94 return(ercd);
95}
96
97#endif /* TOPPERS_get_tim */
98
99/*
100 * «”\•]‰¿—pƒVƒXƒeƒ€Žž‚ÌŽQÆ
101 */
102#ifdef TOPPERS_get_utm
103#ifdef TOPPERS_SUPPORT_GET_UTM
104#ifndef OMIT_GET_UTM
105#include "target_timer.h"
106
107ER
108get_utm(SYSUTM *p_sysutm)
109{
110 SYSUTM utime;
111 SYSTIM time;
112#if TIC_DENO != 1
113 uint_t subtime;
114#endif /* TIC_DENO != 1 */
115 CLOCK clock1, clock2;
116 bool_t ireq;
117 SIL_PRE_LOC;
118
119 LOG_GET_UTM_ENTER(p_sysutm);
120
121 SIL_LOC_INT();
122 time = next_time;
123#if TIC_DENO != 1
124 subtime = next_subtime;
125#endif /* TIC_DENO != 1 */
126 clock1 = target_timer_get_current();
127 ireq = target_timer_probe_int();
128 clock2 = target_timer_get_current();
129 SIL_UNL_INT();
130
131 utime = ((SYSUTM) time) * 1000U;
132#if TIC_DENO != 1
133 utime += subtime * 1000U / TIC_DENO;
134#endif /* TIC_DENO != 1 */
135
136 if (!ireq || clock1 > clock2) {
137 utime -= TIC_NUME * 1000U / TIC_DENO;
138 }
139 utime += TO_USEC(clock1);
140 *p_sysutm = utime;
141
142 LOG_GET_UTM_LEAVE(E_OK, *p_sysutm);
143 return(E_OK);
144}
145
146#endif /* OMIT_GET_UTM */
147#endif /* TOPPERS_SUPPORT_GET_UTM */
148#endif /* TOPPERS_get_utm */
Note: See TracBrowser for help on using the repository browser.