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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [RX600_RX62N-RSK_Renesas/] [RTOSDemo/] [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 <stdint.h>
43
#include "iodefine.h"
44
#include "r_ether.h"
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
#endif  /*      ETH_MODE_SEL    */
129
#if ETH_MODE_SEL == ETH_RMII_MODE
130
        /*      EE=1, PHYMODE=0, ENETE3=0, ENETE2=0, ENETE1=1, ENETE0=0 (Ethernet)      */
131
        IOPORT.PFENET.BYTE = 0x82;
132
#endif  /*      ETH_MODE_SEL    */
133
        /*-------------------------------------------*/
134
        /*    Input Buffer Control Register (ICR)    */
135
        /*-------------------------------------------*/
136
#if ETH_MODE_SEL == ETH_MII_MODE
137
        /*      P54=1 Set ET_LINKSTA input      */
138
        PORT5.ICR.BIT.B4 = 1;
139
        /*      P71=1 Set ET_MDIO input */
140
        PORT7.ICR.BIT.B1 = 1;
141
        /*      P74=1 Set ET_ERXD1 input        */
142
        PORT7.ICR.BIT.B4 = 1;
143
        /*      P75=1 Set ET_ERXD0 input        */
144
        PORT7.ICR.BIT.B5 = 1;
145
        /*      P76=1 Set ET_RX_CLK input       */
146
        PORT7.ICR.BIT.B6 = 1;
147
        /*      P77=1 Set ET_RX_ER input        */
148
        PORT7.ICR.BIT.B7 = 1;
149
        /*      P83=1 Set ET_CRS input  */
150
        PORT8.ICR.BIT.B3 = 1;
151
        /*      PC0=1 Set ET_ERXD3 input        */
152
        PORTC.ICR.BIT.B0 = 1;
153
        /*      PC1=1 Set ET_ERXD2 input        */
154
        PORTC.ICR.BIT.B1 = 1;
155
        /*      PC2=1 Set ET_RX_DV input        */
156
        PORTC.ICR.BIT.B2 = 1;
157
        /*      PC4=1 Set EX_TX_CLK input       */
158
        PORTC.ICR.BIT.B4 = 1;
159
        /*      PC7=1 Set ET_COL input  */
160
        PORTC.ICR.BIT.B7 = 1;
161
#endif  /*      ETH_MODE_SEL    */
162
#if ETH_MODE_SEL == ETH_RMII_MODE
163
        /*      P54=1 Set ET_LINKSTA input      */
164
        PORT5.ICR.BIT.B4 = 1;
165
        /*      P71=1 Set ET_MDIO input */
166
        PORT7.ICR.BIT.B1 = 1;
167
        /* P74=1 Set RMII_RXD1 input    */
168
        PORT7.ICR.BIT.B4 = 1;
169
        /* P75=1 Set RMII_RXD0 input    */
170
        PORT7.ICR.BIT.B5 = 1;
171
        /* P76=1 Set REF50CLK input     */
172
        PORT7.ICR.BIT.B6 = 1;
173
        /* P77=1 Set RMII_RX_ER input   */
174
        PORT7.ICR.BIT.B7 = 1;
175
        /* P83=1 Set RMII_CRS_DV input  */
176
        PORT8.ICR.BIT.B3 = 1;
177
#endif  /*      ETH_MODE_SEL    */
178
 
179
    /* Configure LED 0-5 pin settings */
180
    PORT0.DR.BIT.B2 = 1;
181
    PORT0.DR.BIT.B3 = 1;
182
    PORT0.DR.BIT.B5 = 1;
183
    PORT3.DR.BIT.B4 = 1;
184
    PORT6.DR.BIT.B0 = 1;
185
    PORT7.DR.BIT.B3 = 1;
186
    PORT0.DDR.BIT.B2 = 1;
187
    PORT0.DDR.BIT.B3 = 1;
188
    PORT0.DDR.BIT.B5 = 1;
189
    PORT3.DDR.BIT.B4 = 1;
190
    PORT6.DDR.BIT.B0 = 1;
191
    PORT7.DDR.BIT.B3 = 1;
192
 
193
    /* Configure SW 1-3 pin settings */
194
    PORT0.DDR.BIT.B0 = 0;
195
    PORT0.DDR.BIT.B1 = 0;
196
    PORT0.DDR.BIT.B7 = 0;
197
    PORT0.ICR.BIT.B0 = 1;
198
    PORT0.ICR.BIT.B1 = 1;
199
    PORT0.ICR.BIT.B7 = 1;
200
 
201
#if INCLUDE_LCD == 1
202
    /* Set LCD pins as outputs */
203
    /* LCD-RS */
204
    PORT8.DDR.BIT.B4 = 1;
205
    /* LCD-EN */
206
    PORT8.DDR.BIT.B5 = 1;
207
    /*LCD-data */
208
    PORT9.DDR.BYTE = 0xF0;
209
#endif
210
}
211
 
212
/******************************************************************************
213
* Function Name: io_set_cpg
214
* Description  : Sets up operating speed
215
* Arguments    : none
216
* Return Value : none
217
******************************************************************************/
218
void io_set_cpg(void)
219
{
220
/* Set CPU PLL operating frequencies. Changes to the peripheral clock will require
221
changes to the debugger and flash kernel BRR settings. */
222
 
223
        /* ==== CPG setting ==== */
224
        SYSTEM.SCKCR.LONG = 0x00020100; /* Clockin = 12MHz */
225
                                                                        /* I Clock = 96MHz, B Clock = 24MHz, */
226
                                                                        /* P Clock = 48MHz */
227
 
228
}
229
 

powered by: WebSVN 2.1.0

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