1 /*******************************************************************************
\r
3 * This software is supplied by Renesas Electronics Corporation and is only
\r
4 * intended for use with Renesas products. No other uses are authorized. This
\r
5 * software is owned by Renesas Electronics Corporation and is protected under
\r
6 * all applicable laws, including copyright laws.
\r
7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
\r
8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
\r
9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
\r
10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
\r
11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
\r
12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
\r
13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
\r
14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
\r
15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
\r
16 * Renesas reserves the right, without notice, to make changes to this software
\r
17 * and to discontinue the availability of this software. By using this software,
\r
18 * you agree to the additional terms and conditions found by accessing the
\r
20 * http://www.renesas.com/disclaimer
\r
22 * Copyright (C) 2012 Renesas Electronics Corporation. All rights reserved.
\r
23 *******************************************************************************/
\r
24 /*******************************************************************************
\r
25 * File Name : peripheral_init_basic.c
\r
27 * $Date:: 2013-04-10 12:58:44 +0100#$
\r
28 * Device(s) : Aragon
\r
29 * Tool-Chain : DS-5 Ver 5.8
\r
32 * H/W Platform : Aragon CPU Board
\r
33 * Description : Aragon Sample Program - Initialize peripheral function sample
\r
36 *******************************************************************************/
\r
39 /******************************************************************************
\r
40 Includes <System Includes> , "Project Includes"
\r
41 ******************************************************************************/
\r
42 #include "r_typedefs.h"
\r
43 #include "devdrv_common.h" /* Common Driver Header */
\r
44 #include "iodefine.h"
\r
46 /* Do not include the following pragmas when compiling with IAR. */
\r
48 #pragma arm section code = "CODE_BASIC_SETUP"
\r
49 #pragma arm section rodata = "CONST_BASIC_SETUP"
\r
50 #pragma arm section rwdata = "DATA_BASIC_SETUP"
\r
51 #pragma arm section zidata = "BSS_BASIC_SETUP"
\r
54 /******************************************************************************
\r
56 ******************************************************************************/
\r
59 /******************************************************************************
\r
61 ******************************************************************************/
\r
64 /******************************************************************************
\r
65 Imported global variables and functions (from other files)
\r
66 ******************************************************************************/
\r
69 /******************************************************************************
\r
70 Exported global variables and functions (to be accessed by other files)
\r
71 ******************************************************************************/
\r
72 void Peripheral_BasicInit(void);
\r
74 /******************************************************************************
\r
75 Private global variables and functions
\r
76 ******************************************************************************/
\r
77 static void CPG_Init(void);
\r
78 static void CS0_PORTInit(void);
\r
81 /******************************************************************************
\r
82 * Function Name: PeripheralBasicInit
\r
87 * Return Value : none
\r
88 ******************************************************************************/
\r
89 void Peripheral_BasicInit(void)
\r
91 /* ==== Clock Pulse Generator (CPG) setting ====*/
\r
94 /* ==== Port setting ==== */
\r
97 /* ==== Bus State Controller (BSC) setting ==== */
\r
98 R_BSC_Init((uint8_t)(BSC_AREA_CS0 | BSC_AREA_CS1));
\r
101 /******************************************************************************
\r
102 * Function Name: CPG_Init
\r
105 * Return Value : none
\r
106 ******************************************************************************/
\r
107 static void CPG_Init(void)
\r
109 volatile uint32_t dummy_buf_32b;
\r
110 volatile uint8_t dummy_buf_8b;
\r
112 *(volatile uint32_t *)(0x3fffff80) = 0x00000001;
\r
113 dummy_buf_32b = *(volatile uint32_t *)(0x3fffff80);
\r
115 /* ==== CPG Settings ==== */
\r
116 CPG.FRQCR.WORD = 0x1035u; /* PLL(x30), I:G:B:P1:P0 = 30:20:10:5:5/2 */
\r
117 CPG.FRQCR2.WORD = 0x0001u; /* CKIO:Output at time usually, */
\r
118 /* Output when bus right is opened, */
\r
119 /* output at standby"L" */
\r
120 /* Clockin = 13.33MHz, CKIO = 66.67MHz, */
\r
121 /* I Clock = 400.00MHz, */
\r
122 /* G Clock = 266.67MHz, */
\r
123 /* B Clock = 133.33MHz, */
\r
124 /* P1 Clock = 66.67MHz, */
\r
125 /* P0 Clock = 33.33MHz */
\r
127 /* ---- Writing to On-Chip Data-Retention RAM is enabled. ---- */
\r
128 CPG.SYSCR3.BYTE = 0x0Fu;
\r
129 dummy_buf_8b = CPG.SYSCR3.BYTE;
\r
132 /******************************************************************************
\r
133 * Function Name: CS0_PORTInit
\r
136 * Return Value : none
\r
137 ******************************************************************************/
\r
138 static void CS0_PORTInit(void)
\r
140 /* ==== BSC settings ==== */
\r
142 /* ---- P9_1 : A25 ---- */
\r
143 PORT9.PMCn.BIT.PMCn1 = 1;
\r
144 PORT9.PFCAEn.BIT.PFCAEn1 = 0;
\r
145 PORT9.PFCEn.BIT.PFCEn1 = 0;
\r
146 PORT9.PFCn.BIT.PFCn1 = 0;
\r
147 PORT9.PIPCn.BIT.PIPCn1 = 1;
\r
149 /* ---- P9_0 : A24 ---- */
\r
150 PORT9.PMCn.BIT.PMCn0 = 1;
\r
151 PORT9.PFCAEn.BIT.PFCAEn0 = 0;
\r
152 PORT9.PFCEn.BIT.PFCEn0 = 0;
\r
153 PORT9.PFCn.BIT.PFCn0 = 0;
\r
154 PORT9.PIPCn.BIT.PIPCn0 = 1;
\r
156 /* ---- P8_15 : A23 ---- */
\r
157 PORT8.PMCn.BIT.PMCn15 = 1;
\r
158 PORT8.PFCAEn.BIT.PFCAEn15 = 0;
\r
159 PORT8.PFCEn.BIT.PFCEn15 = 0;
\r
160 PORT8.PFCn.BIT.PFCn15 = 0;
\r
161 PORT8.PIPCn.BIT.PIPCn15 = 1;
\r
163 /* ---- P8_14 : A22 ---- */
\r
164 PORT8.PMCn.BIT.PMCn14 = 1;
\r
165 PORT8.PFCAEn.BIT.PFCAEn14 = 0;
\r
166 PORT8.PFCEn.BIT.PFCEn14 = 0;
\r
167 PORT8.PFCn.BIT.PFCn14 = 0;
\r
168 PORT8.PIPCn.BIT.PIPCn14 = 1;
\r
170 /* ---- P8_13 : A21 ---- */
\r
171 PORT8.PMCn.BIT.PMCn13 = 1;
\r
172 PORT8.PFCAEn.BIT.PFCAEn13 = 0;
\r
173 PORT8.PFCEn.BIT.PFCEn13 = 0;
\r
174 PORT8.PFCn.BIT.PFCn13 = 0;
\r
175 PORT8.PIPCn.BIT.PIPCn13 = 1;
\r
177 /* ---- P7_6 : WE0# / DQMLL# ---- */
\r
178 PORT7.PMCn.BIT.PMCn6 = 1;
\r
179 PORT7.PFCAEn.BIT.PFCAEn6 = 0;
\r
180 PORT7.PFCEn.BIT.PFCEn6 = 0;
\r
181 PORT7.PFCn.BIT.PFCn6 = 0;
\r
182 PORT7.PIPCn.BIT.PIPCn6 = 1;
\r
184 /* ---- P7_8 : RD ---- */
\r
185 PORT7.PMCn.BIT.PMCn8 = 1;
\r
186 PORT7.PFCAEn.BIT.PFCAEn8 = 0;
\r
187 PORT7.PFCEn.BIT.PFCEn8 = 0;
\r
188 PORT7.PFCn.BIT.PFCn8 = 0;
\r
189 PORT7.PIPCn.BIT.PIPCn8 = 1;
\r
191 /* ---- P7_0 : CS0 ---- */
\r
192 PORT7.PMCn.BIT.PMCn0 = 1;
\r
193 PORT7.PFCAEn.BIT.PFCAEn0 = 0;
\r
194 PORT7.PFCEn.BIT.PFCEn0 = 0;
\r
195 PORT7.PFCn.BIT.PFCn0 = 0;
\r
196 PORT7.PIPCn.BIT.PIPCn0 = 1;
\r
198 /* ---- P3_7 : CS1 ---- */
\r
199 PORT3.PMCn.BIT.PMCn7 = 1;
\r
200 PORT3.PFCAEn.BIT.PFCAEn7 = 1;
\r
201 PORT3.PFCEn.BIT.PFCEn7 = 1;
\r
202 PORT3.PFCn.BIT.PFCn7 = 0;
\r
203 PORT3.PIPCn.BIT.PIPCn7 = 1;
\r