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

Last change on this file since 101 was 101, checked in by coas-nagasima, 9 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: 3.8 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#include "kernel_impl.h"
54#include <sil.h>
55#include "target_timer.h"
56#include "time_event.h"
57
58/*
59 * ƒ^ƒCƒ}‚̏‰Šú‰»ˆ—
60 */
61void
62target_timer_initialize(intptr_t exinf)
63{
64 /*
65 * ƒ‚ƒWƒ…
66[ƒ‹ƒXƒgƒbƒv‹@”\‚̐ݒè
67 */
68 sil_wrh_mem(SYSTEM_PRCR_ADDR, (uint16_t)0xA502); /* ‘ž‚Ý‹–‰Â */
69 sil_wrw_mem(SYSTEM_MSTPCRA_ADDR,
70 sil_rew_mem(SYSTEM_MSTPCRA_ADDR) & ~SYSTEM_MSTPCRA_MSTPA15_BIT); /* CMT0 */
71 sil_wrh_mem(SYSTEM_PRCR_ADDR, (uint16_t)0xA500); /* ‘ž‚Ý‹ÖŽ~ */
72
73 /*
74 * ƒ^ƒCƒ}’âŽ~
75 */
76 sil_wrh_mem(CMT_CMSTR0_ADDR,
77 sil_reh_mem(CMT_CMSTR0_ADDR) & ~CMT_CMSTR0_STR0_BIT);
78
79 /*
80 * ƒJƒEƒ“ƒgƒAƒbƒv‚É—p‚¢‚ç‚ê‚éƒNƒƒbƒNÝ’è
81 * PCLK/32‚ð‘I‘ð
82 */
83 sil_wrh_mem(CMT0_CMCR_ADDR, CMT_PCLK_DIV_8);
84
85 /*
86 * ƒRƒ“ƒyƒAƒ}ƒbƒ`ƒ^ƒCƒ}ƒJƒEƒ“ƒ^Ý’è
87 */
88 sil_wrh_mem(CMT0_CMCNT_ADDR, 0U);
89
90 /*
91 * ƒRƒ“ƒyƒAƒ}ƒbƒ`ƒ^ƒCƒ}ŽüŠúÝ’è
92 */
93 sil_wrh_mem(CMT0_CMCOR_ADDR, CMCOR_PERIOD);
94
95 /*
96 * ƒRƒ“ƒyƒAƒ}ƒbƒ`ƒ^ƒCƒ}Š„‚荞‚Ý—v‹æÝ’背ƒWƒXƒ^iISELR28j
97 */
98 sil_wrb_mem(ICU_ISELR028_ADDR, ICU_ISEL_CPU);
99
100 /*
101 * ƒ^ƒCƒ}“®ìŠJŽn‘O‚ÌŠ„ž‚Ý—v‹‚ðƒNƒŠƒA
102 */
103 x_clear_int(INTNO_TIMER);
104
105 /*
106 * ƒRƒ“ƒyƒAƒ}ƒbƒ`ƒ^ƒCƒ}Š„‚荞‚Ý‚ð‹–‰Â
107 */
108 sil_wrh_mem(CMT0_CMCR_ADDR,
109 sil_reh_mem(CMT0_CMCR_ADDR) | CMT0_CMCR_CMIE_BIT);
110
111 /*
112 * ƒ^ƒCƒ}“®ìŠJŽn
113 */
114 sil_wrh_mem(CMT_CMSTR0_ADDR,
115 sil_reh_mem(CMT_CMSTR0_ADDR) | CMT_CMSTR0_STR0_BIT);
116}
117
118/*
119 * ƒ^ƒCƒ}‚Ì’âŽ~ˆ—
120 */
121void
122target_timer_terminate(intptr_t exinf)
123{
124 /*
125 * ƒ^ƒCƒ}’âŽ~
126 */
127 sil_wrh_mem(CMT_CMSTR0_ADDR,
128 sil_reh_mem(CMT_CMSTR0_ADDR) & ~CMT_CMSTR0_STR0_BIT);
129}
130
131/*
132 * ƒ^ƒCƒ}Š„ž‚݃nƒ“ƒhƒ‰
133 */
134void target_timer_handler(void)
135{
136 i_begin_int(INTNO_TIMER);
137
138 signal_time(); /* ƒ^ƒCƒ€ƒeƒBƒbƒN‚Ì‹Ÿ‹‹ */
139
140 i_end_int(INTNO_TIMER);
141}
Note: See TracBrowser for help on using the repository browser.