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