source: asp/target/cqfrkfm3_gcc/target_config.c@ 129

Last change on this file since 129 was 129, checked in by mmatsu, 7 years ago
File size: 4.4 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) 2008-2011 by Embedded and Real-Time Systems Laboratory
7 * Graduate School of Information Science, Nagoya Univ., JAPAN
8 *
9 * ã‹L’˜ìŒ ŽÒ‚́CˆÈ‰º‚Ì(1)`(4)‚ÌðŒ‚ð–ž‚½‚·ê‡‚ÉŒÀ‚èC–{ƒ\ƒtƒgƒEƒF
10 * ƒAi–{ƒ\ƒtƒgƒEƒFƒA‚ð‰ü•Ï‚µ‚½‚à‚Ì‚ðŠÜ‚ށDˆÈ‰º“¯‚¶j‚ðŽg—pE•¡»E‰ü
11 * •ÏEÄ”z•ziˆÈ‰ºC—˜—p‚ƌĂԁj‚·‚邱‚Ƃ𖳏ž‚Å‹–‘ø‚·‚éD
12 * (1) –{ƒ\ƒtƒgƒEƒFƒA‚ðƒ\[ƒXƒR[ƒh‚ÌŒ`‚Å—˜—p‚·‚éê‡‚ɂ́Cã‹L‚Ì’˜ì
13 * Œ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’肪C‚»‚Ì‚Ü‚Ü‚ÌŒ`‚Ń\[
14 * ƒXƒR[ƒh’†‚ÉŠÜ‚Ü‚ê‚Ä‚¢‚邱‚ƁD
15 * (2) –{ƒ\ƒtƒgƒEƒFƒA‚ðCƒ‰ƒCƒuƒ‰ƒŠŒ`Ž®‚ȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
16 * —p‚Å‚«‚éŒ`‚ōĔz•z‚·‚éê‡‚ɂ́CÄ”z•z‚É”º‚¤ƒhƒLƒ…
17ƒƒ“ƒgi—˜—p
18 * ŽÒƒ}ƒjƒ…
19ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L
20 * ‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
21 * (3) –{ƒ\ƒtƒgƒEƒFƒA‚ðC‹@Ší‚É‘g‚ݍž‚ނȂǁC‘¼‚̃\ƒtƒgƒEƒFƒAŠJ”­‚ÉŽg
22 * —p‚Å‚«‚È‚¢Œ`‚ōĔz•z‚·‚éê‡‚ɂ́CŽŸ‚Ì‚¢‚¸‚ê‚©‚ÌðŒ‚ð–ž‚½‚·‚±
23 * ‚ƁD
24 * (a) Ä”z•z‚É”º‚¤ƒhƒLƒ…
25ƒƒ“ƒgi—˜—pŽÒƒ}ƒjƒ…
26ƒAƒ‹‚Ȃǁj‚ɁCã‹L‚Ì’˜
27 * ìŒ •\Ž¦C‚±‚Ì—˜—pðŒ‚¨‚æ‚щº‹L‚Ì–³•ÛØ‹K’è‚ðŒfÚ‚·‚邱‚ƁD
28 * (b) Ä”z•z‚ÌŒ`‘Ô‚ðC•Ê‚É’è‚ß‚é•û–@‚É‚æ‚Á‚āCTOPPERSƒvƒƒWƒFƒNƒg‚É
29 * •ñ‚·‚邱‚ƁD
30 * (4) –{ƒ\ƒtƒgƒEƒFƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚é‚¢‚©‚Ȃ鑹
31 * ŠQ‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð–Ɛӂ·‚邱‚ƁD
32 * ‚Ü‚½C–{ƒ\ƒtƒgƒEƒFƒA‚̃†[ƒU‚Ü‚½‚̓Gƒ“ƒhƒ†[ƒU‚©‚ç‚Ì‚¢‚©‚Ȃ闝
33 * —R‚ÉŠî‚­¿‹‚©‚ç‚àCã‹L’˜ìŒ ŽÒ‚¨‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚ð
34 * –Ɛӂ·‚邱‚ƁD
35 *
36 * –{ƒ\ƒtƒgƒEƒFƒA‚́C–³•ÛØ‚Å’ñ‹Ÿ‚³‚ê‚Ä‚¢‚é‚à‚Ì‚Å‚ ‚éDã‹L’˜ìŒ ŽÒ‚¨
37 * ‚æ‚ÑTOPPERSƒvƒƒWƒFƒNƒg‚́C–{ƒ\ƒtƒgƒEƒFƒA‚ÉŠÖ‚µ‚āC“Á’è‚ÌŽg—p–Ú“I
38 * ‚ɑ΂·‚é“K‡«‚àŠÜ‚߂āC‚¢‚©‚È‚é•ÛØ‚às‚í‚È‚¢D‚Ü‚½C–{ƒ\ƒtƒgƒEƒF
39 * ƒA‚Ì—˜—p‚É‚æ‚è’¼Ú“I‚Ü‚½‚͊ԐړI‚ɐ¶‚¶‚½‚¢‚©‚Ȃ鑹ŠQ‚ÉŠÖ‚µ‚Ä‚àC‚»
40 * ‚̐ӔC‚𕉂í‚È‚¢D
41 *
42 */
43
44/*
45 * ƒ^[ƒQƒbƒgˆË‘¶ƒ‚ƒWƒ…
46[ƒ‹
47 */
48#include "kernel_impl.h"
49#include <sil.h>
50
51#include "fm3_mb9bxxx.h"
52#include "target_serial.h"
53
54/*
55 * ƒ^[ƒQƒbƒgˆË‘¶‚̏‰Šú‰»
56 */
57void
58target_initialize(void){
59
60 static uint32_t u32IoRegisterRead;
61
62 /*
63 * ƒn[ƒhƒEƒFƒAEƒEƒIƒbƒ`ƒhƒOEƒ^ƒCƒ}‚Ì’âŽ~
64 */
65 sil_wrw_mem((uint32_t*)FM3_HWWDT_WDG_LCK, 0x1ACCE551);
66 sil_wrw_mem((uint32_t*)FM3_HWWDT_WDG_LCK, 0xE5331AAE);
67 sil_wrb_mem((uint8_t*)FM3_HWWDT_WDG_CTL, 0);
68
69 /*
70 * ƒNƒƒbƒN‚̐ݒè
71 */
72 sil_wrb_mem((uint8_t*)FM3_CRG_BSC_PSR, 0);
73 sil_wrb_mem((uint8_t*)FM3_CRG_APBC0_PSR, 0);
74 sil_wrb_mem((uint8_t*)FM3_CRG_APBC1_PSR, APBC1_PSR_APBC1EN | 1);
75 sil_wrb_mem((uint8_t*)FM3_CRG_APBC2_PSR, APBC2_PSR_APBC2EN | 1);
76 sil_wrb_mem((uint8_t*)FM3_CRG_SWC_PSR, SWC_PSR_TESTB | 3);
77 sil_wrb_mem((uint8_t*)FM3_CRG_TTC_PSR, 0);
78
79 sil_wrb_mem((uint8_t*)FM3_CRG_CSW_TMR, (5 << 4) | 0x0C);
80
81 sil_wrb_mem((uint8_t*)FM3_CRG_SCM_CTL, sil_reb_mem((uint8_t*)FM3_CRG_SCM_CTL) | SCM_CTL_MOSCE);
82 while (!(sil_reb_mem((uint8_t*)FM3_CRG_SCM_STR) & SCM_CTL_MOSCE));
83
84 sil_wrb_mem((uint8_t*)FM3_CRG_PSW_TMR, 0);
85 sil_wrb_mem((uint8_t*)FM3_CRG_PLL_CTL1, ((1-1)<<4) | ((2-1)<<0));
86 sil_wrb_mem((uint8_t*)FM3_CRG_PLL_CTL2, 36-1);
87
88 sil_wrb_mem((uint8_t*)FM3_CRG_SCM_CTL, sil_reb_mem((uint8_t*)FM3_CRG_SCM_CTL) | SCM_CTL_PLLE);
89 while (!(sil_reb_mem((uint8_t*)FM3_CRG_SCM_STR) & SCM_CTL_PLLE));
90
91 sil_wrb_mem((uint8_t*)FM3_CRG_SCM_CTL, sil_reb_mem((uint8_t*)FM3_CRG_SCM_CTL) | (2 << 5));
92
93 do
94 {
95 u32IoRegisterRead = (sil_reb_mem((uint8_t*)FM3_CRG_SCM_CTL) & 0xE0);
96 }while ((sil_reb_mem((uint8_t*)FM3_CRG_SCM_STR) & 0xE0) != u32IoRegisterRead);
97
98 /*
99 * ‚‘¬CRƒgƒŠƒ~ƒ“ƒO‚̐ݒè
100 */
101 if( 0x000003FF != (sil_rew_mem((uint32_t*)FM3_FLASH_IF_CRTRMM) & 0x000003FF) )
102 {
103 sil_wrw_mem((uint32_t*)FM3_CRTRIM_MCR_RLR, 0x1ACCE554);
104 sil_wrw_mem((uint32_t*)FM3_CRTRIM_MCR_FTRM, sil_rew_mem((uint32_t*)FM3_FLASH_IF_CRTRMM));
105 sil_wrw_mem((uint32_t*)FM3_CRTRIM_MCR_RLR, 0x00000000);
106 }
107
108 /*
109 * ƒRƒAˆË‘¶‚̏‰Šú‰»
110 */
111 core_initialize();
112
113 /*
114 * ƒoƒi[o—Í—p‚̃VƒŠƒAƒ‹‰Šú‰»
115 */
116 target_uart_init(SIO_PORTID);
117}
118
119
120/*
121 * ƒ^[ƒQƒbƒgˆË‘¶‚̏I—¹ˆ—
122 */
123void
124target_exit(void)
125{
126 /*
127 * ƒRƒAˆË‘¶‚̏I—¹ˆ—
128 */
129 core_terminate();
130
131 /*
132 * ŠJ”­ŠÂ‹«ˆË‘¶‚̏I—¹ˆ—
133 */
134 while(1);
135}
136
137
138/*
139 * ƒVƒXƒeƒ€ƒƒO‚̒჌ƒxƒ‹o—Í‚Ì‚½‚ß‚Ì•¶Žšo—Í
140 */
141void
142target_fput_log(char c)
143{
144 if (c == '\n') {
145 sio_pol_snd_chr('\r', SIO_PORTID);
146 }
147 sio_pol_snd_chr(c, SIO_PORTID);
148}
Note: See TracBrowser for help on using the repository browser.