source: uKadecot/trunk/ssp/target/grsakura_ccrx/target_timer.h@ 101

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

TOPPERS/uKadecotのソースコードを追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/plain
File size: 4.9 KB
Line 
1/*
2 * TOPPERS/SSP Kernel
3 * Smallest Set Profile Kernel
4 *
5 * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
6 * Toyohashi Univ. of Technology, JAPAN
7 * Copyright (C) 2003-2004 by Naoki Saito
8 * Nagoya Municipal Industrial Research Institute, JAPAN
9 * Copyright (C) 2003-2004 by Platform Development Center
10 * RICOH COMPANY,LTD. JAPAN
11 * Copyright (C) 2008-2010 by Witz Corporation, JAPAN
12 * Copyright (C) 2013 by Mitsuhiro Matsuura
13 *
14 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
15 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
16 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
17 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
18 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
19 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
20 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
21 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
22ƒƒ“ƒgi—˜—p
23 * ŽÒƒ}ƒjƒ…
24ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
25 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
26 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
27 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
28 * ‚ƁD
29 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
30ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
31ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
32 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
33 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
34 * •ñ‚·‚邱‚ƁD
35 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
36 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
37 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
38 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
39 * –Ɛӂ·‚邱‚ƁD
40 *
41 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
42 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
43 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
44 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
45 * ‚̐ӔC‚𕉂í‚È‚¢D
46 *
47 */
48
49/*
50 * ƒ^ƒCƒ}ƒhƒ‰ƒCƒoiGR-SAKURA—pj
51 */
52
53#ifndef TOPPERS_TARGET_TIMER_H
54#define TOPPERS_TARGET_TIMER_H
55
56#include <sil.h>
57#include "target_config.h"
58#include "grsakura.h"
59#include "target_syssvc.h"
60
61/*
62 * ƒ^ƒCƒ}Š„ž‚݃nƒ“ƒhƒ‰“o˜^‚Ì‚½‚߂̒萔
63 */
64#define INHNO_TIMER INT_CMT0_CMI /* Š„ž‚݃nƒ“ƒhƒ‰”ԍ† */
65#define INTNO_TIMER INT_CMT0_CMI /* Š„ž‚ݔԍ† */
66#define INTPRI_TIMER -5 /* Š„ž‚Ý—Dæ“x */
67#define INTATR_TIMER (TA_ENAINT | TA_EDGE) /* Š„ž‚Ý‘®« */
68
69#ifndef TOPPERS_MACRO_ONLY
70
71/*
72 * ƒ^ƒCƒ}’l‚Ì“à•”•\Œ»‚ÌŒ^
73 */
74typedef uint16_t CLOCK;
75
76/*
77 * ƒ^ƒCƒ}’l‚Ì“à•”•\Œ»‚ƃ~ƒŠ•b’PˆÊ‚Æ‚Ì•ÏŠ·
78 *
79 * 1ms‚̃^ƒCƒ}[Š„‚荞‚Ý‚ðŽg—p‚·‚é‚Ì‚Å‚»‚̃NƒƒbƒN‚ð’è‹`‚·‚éD
80 */
81#define TIMER_CLOCK (FREQ_PCLK / 8U) /* PCLK/Å’ᕪŽü”ä8 = 6MHz */
82#define TO_CLOCK(nume, deno) ((CLOCK)(TIMER_CLOCK * (nume) / (deno)))
83#define TO_USEC(clock) ((SYSUTM)((clock) * 1000U / TIMER_CLOCK))
84
85/*
86 * Ý’è‚Å‚«‚éÅ‘å‚̃^ƒCƒ}ŽüŠúi’PˆÊ‚Í“à•”•\Œ»j
87 */
88#define MAX_CLOCK ((CLOCK) 0xFFFFU)
89
90/*
91 * «”\•]‰¿—pƒVƒXƒeƒ€Žž‚ðŽæ‚èo‚·Û‚̏ˆ—ŽžŠÔ‚ÌŒ©Ï‚è’li’PˆÊ‚Í“à•”•\Œ»j
92 */
93#define GET_TOLERANCE (100U) /* ˆ—’x‚ê‚ÌŒ©Ï‚è’li’PˆÊ‚Í“à•”•\Œ»j*/
94#define BEFORE_IREQ(clock) \
95 ((clock) >= (TO_CLOCK(TIC_NUME, TIC_DENO) - GET_TOLERANCE))
96
97/*
98 * ƒRƒ“ƒyƒAƒ}ƒbƒ`ƒ^ƒCƒ}ƒRƒ“ƒgƒ[ƒ‹ƒŒƒWƒXƒ^‚̐ݒè’l
99 */
100/*
101 * ƒNƒƒbƒN‘I‘ðƒrƒbƒg
102 *
103 * bit7‚Í—\–ñ—̈æ‚Å‚ ‚è, ‘ž‚Ý‚Í1ŒÅ’è
104 */
105#define CMT_PCLK_DIV_8 (0x0080U)
106#define CMT_PCLK_DIV_32 (0x0081U)
107#define CMT_PCLK_DIV_128 (0x0082U)
108#define CMT_PCLK_DIV_512 (0x0083U)
109
110/*
111 * ƒRƒ“ƒyƒAƒ}ƒbƒ`ƒ^ƒCƒ}ƒRƒ“ƒXƒ^ƒ“ƒgƒŒƒWƒXƒ^iCMCORj
112 *
113 * ƒRƒ“ƒyƒAƒ}ƒbƒ`ŽüŠú‚ð1ms‚Æ‚·‚éD
114 * Žü•Óƒ‚ƒWƒ…
115[ƒ‹ƒNƒƒbƒNiPCLKj48MHz‚ð8•ªŽü‚·‚é‚̂ŁC
116 * 1ŽüŠú‚ ‚½‚è166.7nsec‚Æ‚È‚èC6000ŽüŠú‚Å1msiƒ^ƒCƒ€ƒeƒBƒbƒN‚ÌŽüŠúj‚Æ‚·‚éD
117 */
118#define CMCOR_PERIOD (TIMER_CLOCK)
119
120/*
121 * ƒRƒ“ƒyƒAƒ}ƒbƒ`ƒ^ƒCƒ}Š„‚荞‚Ý—v‹æÝ’背ƒWƒXƒ^iiISELRijii= Š„‚荞‚݃xƒNƒ^”ԍ†j
122 */
123#define ICU_ISEL_CPU (0x00U)
124
125
126
127
128/*
129 * ƒ^ƒCƒ}‚Ì‹N“®ˆ—
130 *
131 * ƒ^ƒCƒ}‚ð‰Šú‰»‚µCŽüŠú“I‚ȃ^ƒCƒ}Š„ž‚Ý—v‹‚𔭐¶‚³‚¹‚éD
132 */
133extern void target_timer_initialize(intptr_t exinf);
134
135/*
136 * ƒ^ƒCƒ}‚Ì’âŽ~ˆ—
137 *
138 * ƒ^ƒCƒ}‚Ì“®ì‚ð’âŽ~‚³‚¹‚éD
139 */
140extern void target_timer_terminate(intptr_t exinf);
141
142/*
143 * ƒ^ƒCƒ}ƒŒƒWƒXƒ^’l‚̓ǂݏo‚µ
144 */
145Inline uint16_t rx630_cmt_getcount(void)
146{
147 return sil_reh_mem(CMT0_CMCNT_ADDR);
148}
149
150/*
151 * ƒ^ƒCƒ}ƒŒƒWƒXƒ^’l‚̏‘‚«ž‚Ý
152 */
153Inline void rx630_cmt_setcount(uint16_t count)
154{
155 sil_wrh_mem(CMT0_CMCNT_ADDR, count);
156}
157
158/*
159 * ƒ^ƒCƒ}‚ÌŒ»Ý’l‚̓Ǐo‚µ
160 */
161Inline CLOCK
162target_timer_get_current(void)
163{
164 /* ƒAƒbƒvƒJƒEƒ“ƒg‚Ì‚½‚߃^ƒCƒ}ƒŒƒWƒXƒ^’l‚ð‚»‚Ì‚Ü‚Ü•Ô‚· */
165 return (rx630_cmt_getcount());
166}
167
168/*
169 * ƒ^ƒCƒ}Š„ž‚Ý—v‹‚̃`ƒFƒbƒN
170 */
171Inline bool_t
172target_timer_probe_int(void)
173{
174 return(x_probe_int(INTNO_TIMER));
175}
176
177/*
178 * ƒ^ƒCƒ}Š„ž‚݃nƒ“ƒhƒ‰
179 */
180extern void target_timer_handler(void);
181
182#endif /* TOPPERS_MACRO_ONLY */
183#endif /* TOPPERS_TARGET_TIMER_H */
Note: See TracBrowser for help on using the repository browser.