1 /******************************************************************************
\r
4 * This software is supplied by Renesas Technology Corp. and is only
\r
5 * intended for use with Renesas products. No other uses are authorized.
\r
7 * This software is owned by Renesas Technology Corp. and is protected under
\r
8 * all applicable laws, including copyright laws.
\r
10 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES
\r
11 * REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY,
\r
12 * INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
\r
13 * PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY
\r
16 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
\r
17 * TECHNOLOGY CORP. NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
\r
18 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
\r
19 * FOR ANY REASON RELATED TO THE THIS SOFTWARE, EVEN IF RENESAS OR ITS
\r
20 * AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
\r
22 * Renesas reserves the right, without notice, to make changes to this
\r
23 * software and to discontinue the availability of this software.
\r
24 * By using this software, you agree to the additional terms and
\r
25 * conditions found by accessing the following link:
\r
26 * http://www.renesas.com/disclaimer
\r
27 ******************************************************************************
\r
28 * Copyright (C) 2008. Renesas Technology Corp., All Rights Reserved.
\r
29 *******************************************************************************
\r
30 * File Name : hwsetup.c
\r
32 * Description : Power up hardware initializations
\r
33 ******************************************************************************
\r
34 * History : DD.MM.YYYY Version Description
\r
35 * : 15.02.2010 1.00 First Release
\r
36 ******************************************************************************/
\r
39 /******************************************************************************
\r
40 Includes <System Includes> , "Project Includes"
\r
41 ******************************************************************************/
\r
43 #include "iodefine.h"
\r
44 #include "r_ether.h"
\r
46 /******************************************************************************
\r
48 ******************************************************************************/
\r
50 /******************************************************************************
\r
52 ******************************************************************************/
\r
54 /******************************************************************************
\r
55 Imported global variables and functions (from other files)
\r
56 ******************************************************************************/
\r
58 /******************************************************************************
\r
59 Exported global variables and functions (to be accessed by other files)
\r
60 ******************************************************************************/
\r
62 /******************************************************************************
\r
63 Private global variables and functions
\r
64 ******************************************************************************/
\r
65 void io_set_cpg(void);
\r
66 void ConfigurePortPins(void);
\r
67 void EnablePeripheralModules(void);
\r
69 /******************************************************************************
\r
70 * Function Name: HardwareSetup
\r
71 * Description : This function does initial setting for CPG port pins used in
\r
72 * : the Demo including the MII pins of the Ethernet PHY connection.
\r
74 * Return Value : none
\r
75 ******************************************************************************/
\r
76 void HardwareSetup(void)
\r
81 /* Setup the port pins */
\r
82 ConfigurePortPins();
\r
84 /* Enables peripherals */
\r
85 EnablePeripheralModules();
\r
87 #if INCLUDE_LCD == 1
\r
88 /* Initialize display */
\r
89 InitialiseDisplay();
\r
93 /******************************************************************************
\r
94 * Function Name: EnablePeripheralModules
\r
95 * Description : Enables Peripheral Modules before use
\r
97 * Return Value : none
\r
98 ******************************************************************************/
\r
99 void EnablePeripheralModules(void)
\r
101 /* Module standby clear */
\r
102 SYSTEM.MSTPCRB.BIT.MSTPB15 = 0; /* EtherC, EDMAC */
\r
103 SYSTEM.MSTPCRA.BIT.MSTPA15 = 0; /* CMT0 */
\r
106 /******************************************************************************
\r
107 * Function Name: ConfigurePortPins
\r
108 * Description : Configures port pins.
\r
110 * Return Value : none
\r
111 ******************************************************************************/
\r
112 void ConfigurePortPins(void)
\r
114 /* Port pins default to inputs. To ensure safe initialisation set the pin states
\r
115 before changing the data direction registers. This will avoid any unintentional
\r
116 state changes on the external ports.
\r
117 Many peripheral modules will override the setting of the port registers. Ensure
\r
118 that the state is safe for external devices if the internal peripheral module is
\r
119 disabled or powered down. */
\r
121 /* ==== MII/RMII Pins setting ==== */
\r
122 /*--------------------------------------*/
\r
123 /* Port Function Control Register */
\r
124 /*--------------------------------------*/
\r
125 #if ETH_MODE_SEL == ETH_MII_MODE
\r
126 /* EE=1, PHYMODE=1, ENETE3=1, ENETE2=0, ENETE1=1, ENETE0=0 (Ethernet) */
\r
127 IOPORT.PFENET.BYTE = 0x9A;
\r
128 #endif /* ETH_MODE_SEL */
\r
129 #if ETH_MODE_SEL == ETH_RMII_MODE
\r
130 /* EE=1, PHYMODE=0, ENETE3=0, ENETE2=0, ENETE1=1, ENETE0=0 (Ethernet) */
\r
131 IOPORT.PFENET.BYTE = 0x82;
\r
132 #endif /* ETH_MODE_SEL */
\r
133 /*-------------------------------------------*/
\r
134 /* Input Buffer Control Register (ICR) */
\r
135 /*-------------------------------------------*/
\r
136 #if ETH_MODE_SEL == ETH_MII_MODE
\r
137 /* P54=1 Set ET_LINKSTA input */
\r
138 PORT5.ICR.BIT.B4 = 1;
\r
139 /* P71=1 Set ET_MDIO input */
\r
140 PORT7.ICR.BIT.B1 = 1;
\r
141 /* P74=1 Set ET_ERXD1 input */
\r
142 PORT7.ICR.BIT.B4 = 1;
\r
143 /* P75=1 Set ET_ERXD0 input */
\r
144 PORT7.ICR.BIT.B5 = 1;
\r
145 /* P76=1 Set ET_RX_CLK input */
\r
146 PORT7.ICR.BIT.B6 = 1;
\r
147 /* P77=1 Set ET_RX_ER input */
\r
148 PORT7.ICR.BIT.B7 = 1;
\r
149 /* P83=1 Set ET_CRS input */
\r
150 PORT8.ICR.BIT.B3 = 1;
\r
151 /* PC0=1 Set ET_ERXD3 input */
\r
152 PORTC.ICR.BIT.B0 = 1;
\r
153 /* PC1=1 Set ET_ERXD2 input */
\r
154 PORTC.ICR.BIT.B1 = 1;
\r
155 /* PC2=1 Set ET_RX_DV input */
\r
156 PORTC.ICR.BIT.B2 = 1;
\r
157 /* PC4=1 Set EX_TX_CLK input */
\r
158 PORTC.ICR.BIT.B4 = 1;
\r
159 /* PC7=1 Set ET_COL input */
\r
160 PORTC.ICR.BIT.B7 = 1;
\r
161 #endif /* ETH_MODE_SEL */
\r
162 #if ETH_MODE_SEL == ETH_RMII_MODE
\r
163 /* P54=1 Set ET_LINKSTA input */
\r
164 PORT5.ICR.BIT.B4 = 1;
\r
165 /* P71=1 Set ET_MDIO input */
\r
166 PORT7.ICR.BIT.B1 = 1;
\r
167 /* P74=1 Set RMII_RXD1 input */
\r
168 PORT7.ICR.BIT.B4 = 1;
\r
169 /* P75=1 Set RMII_RXD0 input */
\r
170 PORT7.ICR.BIT.B5 = 1;
\r
171 /* P76=1 Set REF50CLK input */
\r
172 PORT7.ICR.BIT.B6 = 1;
\r
173 /* P77=1 Set RMII_RX_ER input */
\r
174 PORT7.ICR.BIT.B7 = 1;
\r
175 /* P83=1 Set RMII_CRS_DV input */
\r
176 PORT8.ICR.BIT.B3 = 1;
\r
177 #endif /* ETH_MODE_SEL */
\r
179 /* Configure LED 0-5 pin settings */
\r
180 PORT0.DR.BIT.B2 = 1;
\r
181 PORT0.DR.BIT.B3 = 1;
\r
182 PORT0.DR.BIT.B5 = 1;
\r
183 PORT3.DR.BIT.B4 = 1;
\r
184 PORT6.DR.BIT.B0 = 1;
\r
185 PORT7.DR.BIT.B3 = 1;
\r
186 PORT0.DDR.BIT.B2 = 1;
\r
187 PORT0.DDR.BIT.B3 = 1;
\r
188 PORT0.DDR.BIT.B5 = 1;
\r
189 PORT3.DDR.BIT.B4 = 1;
\r
190 PORT6.DDR.BIT.B0 = 1;
\r
191 PORT7.DDR.BIT.B3 = 1;
\r
193 /* Configure SW 1-3 pin settings */
\r
194 PORT0.DDR.BIT.B0 = 0;
\r
195 PORT0.DDR.BIT.B1 = 0;
\r
196 PORT0.DDR.BIT.B7 = 0;
\r
197 PORT0.ICR.BIT.B0 = 1;
\r
198 PORT0.ICR.BIT.B1 = 1;
\r
199 PORT0.ICR.BIT.B7 = 1;
\r
201 #if INCLUDE_LCD == 1
\r
202 /* Set LCD pins as outputs */
\r
204 PORT8.DDR.BIT.B4 = 1;
\r
206 PORT8.DDR.BIT.B5 = 1;
\r
208 PORT9.DDR.BYTE = 0xF0;
\r
212 /******************************************************************************
\r
213 * Function Name: io_set_cpg
\r
214 * Description : Sets up operating speed
\r
216 * Return Value : none
\r
217 ******************************************************************************/
\r
218 void io_set_cpg(void)
\r
220 /* Set CPU PLL operating frequencies. Changes to the peripheral clock will require
\r
221 changes to the debugger and flash kernel BRR settings. */
\r
223 /* ==== CPG setting ==== */
\r
224 SYSTEM.SCKCR.LONG = 0x00020100; /* Clockin = 12MHz */
\r
225 /* I Clock = 96MHz, B Clock = 24MHz, */
\r
226 /* P Clock = 48MHz */
\r