OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [RX600_RX62N-RSK_IAR/] [Renesas-Files/] [hwsetup.c] - Blame information for rev 585

Details | Compare with Previous | View Log

Line No. Rev Author Line
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 <iorx62n.h>
43
#include "rskrx62ndef.h"
44
// #include "lcd.h" Uncomment this if an LCD is present.
45
#include "r_ether.h"
46
 
47
/******************************************************************************
48
Typedef definitions
49
******************************************************************************/
50
 
51
/******************************************************************************
52
Macro definitions
53
******************************************************************************/
54
 
55
/******************************************************************************
56
Imported global variables and functions (from other files)
57
******************************************************************************/
58
 
59
/******************************************************************************
60
Exported global variables and functions (to be accessed by other files)
61
******************************************************************************/
62
 
63
/******************************************************************************
64
Private global variables and functions
65
******************************************************************************/
66
void io_set_cpg(void);
67
void ConfigurePortPins(void);
68
void EnablePeripheralModules(void);
69
 
70
/******************************************************************************
71
* Function Name: HardwareSetup
72
* Description  : This function does initial setting for CPG port pins used in
73
*              : the Demo including the MII pins of the Ethernet PHY connection.
74
* Arguments    : none
75
* Return Value : none
76
******************************************************************************/
77
void HardwareSetup(void)
78
{
79
        /* CPG setting */
80
        io_set_cpg();
81
 
82
        /* Setup the port pins */
83
        ConfigurePortPins();
84
 
85
    /* Enables peripherals */
86
    EnablePeripheralModules();
87
 
88
#if INCLUDE_LCD == 1
89
    /* Initialize display */
90
    InitialiseDisplay();
91
#endif
92
}
93
 
94
/******************************************************************************
95
* Function Name: EnablePeripheralModules
96
* Description  : Enables Peripheral Modules before use
97
* Arguments    : none
98
* Return Value : none
99
******************************************************************************/
100
void EnablePeripheralModules(void)
101
{
102
        /*  Module standby clear */
103
        SYSTEM.MSTPCRB.BIT.MSTPB15 = 0;                          /* EtherC, EDMAC */
104
    SYSTEM.MSTPCRA.BIT.MSTPA15 = 0;             /* CMT0 */
105
}
106
 
107
/******************************************************************************
108
* Function Name: ConfigurePortPins
109
* Description  : Configures port pins.
110
* Arguments    : none
111
* Return Value : none
112
******************************************************************************/
113
void ConfigurePortPins(void)
114
{
115
/* Port pins default to inputs. To ensure safe initialisation set the pin states
116
before changing the data direction registers. This will avoid any unintentional
117
state changes on the external ports.
118
Many peripheral modules will override the setting of the port registers. Ensure
119
that the state is safe for external devices if the internal peripheral module is
120
disabled or powered down. */
121
 
122
        /* ==== MII/RMII Pins setting ==== */
123
        /*--------------------------------------*/
124
        /*    Port Function Control Register    */
125
        /*--------------------------------------*/
126
#if ETH_MODE_SEL == ETH_MII_MODE
127
        /*      EE=1, PHYMODE=1, ENETE3=1, ENETE2=0, ENETE1=1, ENETE0=0 (Ethernet)      */
128
        IOPORT.PFENET.BYTE = 0x9A;
129
#endif  /*      ETH_MODE_SEL    */
130
#if ETH_MODE_SEL == ETH_RMII_MODE
131
        /*      EE=1, PHYMODE=0, ENETE3=0, ENETE2=0, ENETE1=1, ENETE0=0 (Ethernet)      */
132
        IOPORT.PFENET.BYTE = 0x82;
133
#endif  /*      ETH_MODE_SEL    */
134
        /*-------------------------------------------*/
135
        /*    Input Buffer Control Register (ICR)    */
136
        /*-------------------------------------------*/
137
#if ETH_MODE_SEL == ETH_MII_MODE
138
        /*      P54=1 Set ET_LINKSTA input      */
139
        PORT5.ICR.BIT.B4 = 1;
140
        /*      P71=1 Set ET_MDIO input */
141
        PORT7.ICR.BIT.B1 = 1;
142
        /*      P74=1 Set ET_ERXD1 input        */
143
        PORT7.ICR.BIT.B4 = 1;
144
        /*      P75=1 Set ET_ERXD0 input        */
145
        PORT7.ICR.BIT.B5 = 1;
146
        /*      P76=1 Set ET_RX_CLK input       */
147
        PORT7.ICR.BIT.B6 = 1;
148
        /*      P77=1 Set ET_RX_ER input        */
149
        PORT7.ICR.BIT.B7 = 1;
150
        /*      P83=1 Set ET_CRS input  */
151
        PORT8.ICR.BIT.B3 = 1;
152
        /*      PC0=1 Set ET_ERXD3 input        */
153
        PORTC.ICR.BIT.B0 = 1;
154
        /*      PC1=1 Set ET_ERXD2 input        */
155
        PORTC.ICR.BIT.B1 = 1;
156
        /*      PC2=1 Set ET_RX_DV input        */
157
        PORTC.ICR.BIT.B2 = 1;
158
        /*      PC4=1 Set EX_TX_CLK input       */
159
        PORTC.ICR.BIT.B4 = 1;
160
        /*      PC7=1 Set ET_COL input  */
161
        PORTC.ICR.BIT.B7 = 1;
162
#endif  /*      ETH_MODE_SEL    */
163
#if ETH_MODE_SEL == ETH_RMII_MODE
164
        /*      P54=1 Set ET_LINKSTA input      */
165
        PORT5.ICR.BIT.B4 = 1;
166
        /*      P71=1 Set ET_MDIO input */
167
        PORT7.ICR.BIT.B1 = 1;
168
        /* P74=1 Set RMII_RXD1 input    */
169
        PORT7.ICR.BIT.B4 = 1;
170
        /* P75=1 Set RMII_RXD0 input    */
171
        PORT7.ICR.BIT.B5 = 1;
172
        /* P76=1 Set REF50CLK input     */
173
        PORT7.ICR.BIT.B6 = 1;
174
        /* P77=1 Set RMII_RX_ER input   */
175
        PORT7.ICR.BIT.B7 = 1;
176
        /* P83=1 Set RMII_CRS_DV input  */
177
        PORT8.ICR.BIT.B3 = 1;
178
#endif  /*      ETH_MODE_SEL    */
179
 
180
    /* Configure LED 0-5 pin settings */
181
    PORT0.DR.BIT.B2 = 1;
182
    PORT0.DR.BIT.B3 = 1;
183
    PORT0.DR.BIT.B5 = 1;
184
    PORT3.DR.BIT.B4 = 1;
185
    PORT6.DR.BIT.B0 = 1;
186
    PORT7.DR.BIT.B3 = 1;
187
    PORT0.DDR.BIT.B2 = 1;
188
    PORT0.DDR.BIT.B3 = 1;
189
    PORT0.DDR.BIT.B5 = 1;
190
    PORT3.DDR.BIT.B4 = 1;
191
    PORT6.DDR.BIT.B0 = 1;
192
    PORT7.DDR.BIT.B3 = 1;
193
 
194
    /* Configure SW 1-3 pin settings */
195
    PORT0.DDR.BIT.B0 = 0;
196
    PORT0.DDR.BIT.B1 = 0;
197
    PORT0.DDR.BIT.B7 = 0;
198
    PORT0.ICR.BIT.B0 = 1;
199
    PORT0.ICR.BIT.B1 = 1;
200
    PORT0.ICR.BIT.B7 = 1;
201
 
202
#if INCLUDE_LCD == 1
203
    /* Set LCD pins as outputs */
204
    /* LCD-RS */
205
    PORT8.DDR.BIT.B4 = 1;
206
    /* LCD-EN */
207
    PORT8.DDR.BIT.B5 = 1;
208
    /*LCD-data */
209
    PORT9.DDR.BYTE = 0xF0;
210
#endif
211
}
212
 
213
/******************************************************************************
214
* Function Name: io_set_cpg
215
* Description  : Sets up operating speed
216
* Arguments    : none
217
* Return Value : none
218
******************************************************************************/
219
void io_set_cpg(void)
220
{
221
/* Set CPU PLL operating frequencies. Changes to the peripheral clock will require
222
changes to the debugger and flash kernel BRR settings. */
223
 
224
        /* ==== CPG setting ==== */
225
        SYSTEM.SCKCR.LONG = 0x00020100; /* Clockin = 12MHz */
226
                                                                        /* I Clock = 96MHz, B Clock = 24MHz, */
227
                                                                        /* P Clock = 48MHz */
228
 
229
}
230
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.