source: UsbWattMeter/trunk/asp_dcre/include/sil.h@ 164

Last change on this file since 164 was 164, checked in by coas-nagasima, 6 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-chdr
File size: 6.8 KB
Line 
1/*
2 * TOPPERS Software
3 * Toyohashi Open Platform for Embedded Real-Time Systems
4 *
5 * Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
6 * Toyohashi Univ. of Technology, JAPAN
7 * Copyright (C) 2004-2011 by Embedded and Real-Time Systems Laboratory
8 * Graduate School of Information Science, Nagoya Univ., JAPAN
9 *
10 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
11 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
12 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
13 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
14 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
15 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
16 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
17 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
18ƒƒ“ƒgi—˜—p
19 * ŽÒƒ}ƒjƒ…
20ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
21 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
22 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
23 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
24 * ‚ƁD
25 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
26ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
27ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
28 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
29 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
30 * •ñ‚·‚邱‚ƁD
31 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
32 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
33 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
34 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
35 * –Ɛӂ·‚邱‚ƁD
36 *
37 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
38 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
39 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
40 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
41 * ‚̐ӔC‚𕉂í‚È‚¢D
42 *
43 * @(#) $Id: sil.h 164 2016-03-07 11:33:50Z coas-nagasima $
44 */
45
46/*
47 * ƒVƒXƒeƒ€ƒCƒ“ƒ^ƒtƒF[ƒXƒŒƒCƒ„
48 *
49 * ƒVƒXƒeƒ€ƒCƒ“ƒ^ƒtƒF[ƒXƒŒƒCƒ„‚̃T[ƒrƒXƒR[ƒ‹‚Ì’è‹`EéŒ¾‚ƃ}ƒNƒ‚È
50 * ‚Ç‚Ì’è‹`‚ðŠÜ‚Þƒwƒbƒ_ƒtƒ@ƒCƒ‹D
51 *
52 * ƒAƒZƒ“ƒuƒŠŒ¾Œê‚̃\[ƒXƒtƒ@ƒCƒ‹‚©‚炱‚̃tƒ@ƒCƒ‹‚ðƒCƒ“ƒNƒ‹[ƒh‚·‚鎞
53 * ‚́CTOPPERS_MACRO_ONLY‚ð’è‹`‚µ‚Ä‚¨‚­‚±‚ƂŁCƒ}ƒNƒ’è‹`ˆÈŠO‚Ì‹Lq‚ð
54 * œ‚­‚±‚Æ‚ª‚Å‚«‚éD
55 *
56 * ‚±‚̃tƒ@ƒCƒ‹‚ðƒCƒ“ƒNƒ‹[ƒh‚·‚é‘O‚ɃCƒ“ƒNƒ‹[ƒh‚µ‚Ä‚¨‚­‚ׂ«ƒtƒ@ƒCƒ‹
57 * ‚Í‚È‚¢D
58 */
59
60#ifndef TOPPERS_SIL_H
61#define TOPPERS_SIL_H
62
63#ifdef __cplusplus
64extern "C" {
65#endif
66
67/*
68 * TOPPERS‹¤’ʂ̃f[ƒ^Œ^E’萔Eƒ}ƒNƒ
69 */
70#include <t_stddef.h>
71
72/*
73 * ƒ^[ƒQƒbƒgˆË‘¶•”
74 */
75#include "target_sil.h"
76
77#ifndef TOPPERS_MACRO_ONLY
78
79/*
80 * ‘SŠ„ž‚݃ƒbƒNó‘Ԃ̐§Œä
81 *
82 * SIL_PRE_LOCCSIL_LOC_INT()CSIL_UNL_INT()‚́Cƒ^[ƒQƒbƒgˆË‘¶•”‚Å—p
83 * ˆÓ‚·‚éDƒfƒtƒHƒ‹ƒg‚Ì’è‹`‚Í—pˆÓ‚µ‚Ä‚¢‚È‚¢D
84 */
85
86/*
87 * ”÷­ŽžŠÔ‘Ò‚¿
88 */
89extern void sil_dly_nse(ulong_t dlytim) throw();
90
91/*
92 * ƒGƒ“ƒfƒBƒAƒ“‚Ì”½“]
93 */
94#ifndef TOPPERS_SIL_REV_ENDIAN_UINT16
95#define TOPPERS_SIL_REV_ENDIAN_UINT16(data) \
96 ((((data) & 0xffU) << 8) | (((data) >> 8) & 0xffU))
97#endif /* TOPPERS_SIL_REV_ENDIAN_UINT16 */
98
99#ifndef TOPPERS_SIL_REV_ENDIAN_UINT32
100#define TOPPERS_SIL_REV_ENDIAN_UINT32(data) \
101 ((((data) & 0xffU) << 24) | (((data) & 0xff00U) << 8) \
102 | (((data) >> 8) & 0xff00U) | (((data) >> 24) & 0xffU))
103#endif /* TOPPERS_SIL_REV_ENDIAN_UINT32 */
104
105/*
106 * ƒƒ‚ƒŠ‹óŠÔƒAƒNƒZƒXŠÖ”
107 */
108#ifndef TOPPERS_OMIT_SIL_ACCESS
109
110/*
111 * 8ƒrƒbƒg’PˆÊ‚̓Ǐo‚µ^‘ž‚Ý
112 */
113#ifdef UINT8_MAX
114
115Inline uint8_t
116sil_reb_mem(const uint8_t *mem)
117{
118 uint8_t data;
119
120 data = *((const volatile uint8_t *) mem);
121 return(data);
122}
123
124Inline void
125sil_wrb_mem(uint8_t *mem, uint8_t data)
126{
127 *((volatile uint8_t *) mem) = data;
128}
129
130#endif /* UINT8_MAX */
131
132/*
133 * 16ƒrƒbƒg’PˆÊ‚̓Ǐo‚µ^‘ž‚Ý
134 */
135
136Inline uint16_t
137sil_reh_mem(const uint16_t *mem)
138{
139 uint16_t data;
140
141 data = *((const volatile uint16_t *) mem);
142 return(data);
143}
144
145Inline void
146sil_wrh_mem(uint16_t *mem, uint16_t data)
147{
148 *((volatile uint16_t *) mem) = data;
149}
150
151#ifdef SIL_ENDIAN_BIG /* ƒrƒbƒOƒGƒ“ƒfƒBƒAƒ“ƒvƒƒZƒbƒT */
152
153#define sil_reh_bem(mem) sil_reh_mem(mem)
154#define sil_wrh_bem(mem, data) sil_wrh_mem(mem, data)
155
156#ifndef TOPPERS_OMIT_SIL_REH_LEM
157
158Inline uint16_t
159sil_reh_lem(const uint16_t *mem)
160{
161 uint16_t data;
162
163 data = *((const volatile uint16_t *) mem);
164 return(TOPPERS_SIL_REV_ENDIAN_UINT16(data));
165}
166
167#endif /* TOPPERS_OMIT_SIL_REH_LEM */
168#ifndef TOPPERS_OMIT_SIL_WRH_LEM
169
170Inline void
171sil_wrh_lem(uint16_t *mem, uint16_t data)
172{
173 *((volatile uint16_t *) mem) = TOPPERS_SIL_REV_ENDIAN_UINT16(data);
174}
175
176#endif /* TOPPERS_OMIT_SIL_WRH_LEM */
177#else /* SIL_ENDIAN_BIG */
178#ifdef SIL_ENDIAN_LITTLE /* ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“ƒvƒƒZƒbƒT */
179
180#define sil_reh_lem(mem) sil_reh_mem(mem)
181#define sil_wrh_lem(mem, data) sil_wrh_mem(mem, data)
182
183#ifndef TOPPERS_OMIT_SIL_REH_BEM
184
185Inline uint16_t
186sil_reh_bem(const uint16_t *mem)
187{
188 uint16_t data;
189
190 data = *((const volatile uint16_t *) mem);
191 return(TOPPERS_SIL_REV_ENDIAN_UINT16(data));
192}
193
194#endif /* TOPPERS_OMIT_SIL_REH_BEM */
195#ifndef TOPPERS_OMIT_SIL_WRH_BEM
196
197Inline void
198sil_wrh_bem(uint16_t *mem, uint16_t data)
199{
200 *((volatile uint16_t *) mem) = TOPPERS_SIL_REV_ENDIAN_UINT16(data);
201}
202
203#endif /* TOPPERS_OMIT_SIL_WRH_BEM */
204#else /* SIL_ENDIAN_LITTLE */
205
206#error Neither SIL_ENDIAN_BIG nor SIL_ENDIAN_LITTLE is defined.
207
208#endif /* SIL_ENDIAN_LITTLE */
209#endif /* SIL_ENDIAN_BIG */
210
211/*
212 * 32ƒrƒbƒg’PˆÊ‚̓Ǐo‚µ^‘ž‚Ý
213 */
214
215Inline uint32_t
216sil_rew_mem(const uint32_t *mem)
217{
218 uint32_t data;
219
220 data = *((const volatile uint32_t *) mem);
221 return(data);
222}
223
224Inline void
225sil_wrw_mem(uint32_t *mem, uint32_t data)
226{
227 *((volatile uint32_t *) mem) = data;
228}
229
230#ifdef SIL_ENDIAN_BIG /* ƒrƒbƒOƒGƒ“ƒfƒBƒAƒ“ƒvƒƒZƒbƒT */
231
232#define sil_rew_bem(mem) sil_rew_mem(mem)
233#define sil_wrw_bem(mem, data) sil_wrw_mem(mem, data)
234
235#ifndef TOPPERS_OMIT_SIL_REW_LEM
236
237Inline uint32_t
238sil_rew_lem(const uint32_t *mem)
239{
240 uint32_t data;
241
242 data = *((const volatile uint32_t *) mem);
243 return(TOPPERS_SIL_REV_ENDIAN_UINT32(data));
244}
245
246#endif /* TOPPERS_OMIT_SIL_REW_LEM */
247#ifndef TOPPERS_OMIT_SIL_WRW_LEM
248
249Inline void
250sil_wrw_lem(uint32_t *mem, uint32_t data)
251{
252 *((volatile uint32_t *) mem) = TOPPERS_SIL_REV_ENDIAN_UINT32(data);
253}
254
255#endif /* TOPPERS_OMIT_SIL_WRW_LEM */
256#else /* SIL_ENDIAN_BIG */ /* ƒŠƒgƒ‹ƒGƒ“ƒfƒBƒAƒ“ƒvƒƒZƒbƒT */
257
258#define sil_rew_lem(mem) sil_rew_mem(mem)
259#define sil_wrw_lem(mem, data) sil_wrw_mem(mem, data)
260
261#ifndef TOPPERS_OMIT_SIL_REW_BEM
262
263Inline uint32_t
264sil_rew_bem(const uint32_t *mem)
265{
266 uint32_t data;
267
268 data = *((const volatile uint32_t *) mem);
269 return(TOPPERS_SIL_REV_ENDIAN_UINT32(data));
270}
271
272#endif /* TOPPERS_OMIT_SIL_REW_BEM */
273#ifndef TOPPERS_OMIT_SIL_WRW_BEM
274
275Inline void
276sil_wrw_bem(uint32_t *mem, uint32_t data)
277{
278 *((volatile uint32_t *) mem) = TOPPERS_SIL_REV_ENDIAN_UINT32(data);
279}
280
281#endif /* TOPPERS_OMIT_SIL_WRW_BEM */
282#endif /* SIL_ENDIAN_BIG */
283#endif /* TOPPERS_OMIT_SIL_ACCESS */
284
285#endif /* TOPPERS_MACRO_ONLY */
286
287#ifdef __cplusplus
288}
289#endif
290
291#endif /* TOPPERS_SIL_H */
Note: See TracBrowser for help on using the repository browser.