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 <iorx62n.h>
|
44 |
|
|
#include "yrdkrx62ndef.h"
|
45 |
|
|
// #include "lcd.h" Uncomment this if an LCD is present.
|
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 |
|
|
|
67 |
|
|
/******************************************************************************
|
68 |
|
|
* Function Name: HardwareSetup
|
69 |
|
|
* Description : This function does initial setting for CPG port pins used in
|
70 |
|
|
* : the Demo including the MII pins of the Ethernet PHY connection.
|
71 |
|
|
* Arguments : none
|
72 |
|
|
* Return Value : none
|
73 |
|
|
******************************************************************************/
|
74 |
|
|
void HardwareSetup(void)
|
75 |
|
|
{
|
76 |
|
|
uint32_t sckcr = 0;
|
77 |
|
|
|
78 |
|
|
/* Configure system clocks based on header */
|
79 |
|
|
sckcr += (ICLK_MUL==8) ? (0ul << 24) : (ICLK_MUL==4) ? (1ul << 24) : (ICLK_MUL==2) ? (2ul << 24) : (3ul << 24);
|
80 |
|
|
sckcr += (BCLK_MUL==8) ? (0ul << 16) : (BCLK_MUL==4) ? (1ul << 16) : (BCLK_MUL==2) ? (2ul << 16) : (3ul << 16);
|
81 |
|
|
sckcr += (PCLK_MUL==8) ? (0ul << 8) : (PCLK_MUL==4) ? (1ul << 8) : (PCLK_MUL==2) ? (2ul << 8) : (3ul << 8);
|
82 |
|
|
SYSTEM.SCKCR.LONG = sckcr;
|
83 |
|
|
|
84 |
|
|
/* Module standby clear - EtherC, EDMAC */
|
85 |
|
|
SYSTEM.MSTPCRB.BIT.MSTPB15 = 0;
|
86 |
|
|
|
87 |
|
|
PORT0.DDR.BYTE = 0x00 ; // Port 0: inputs (IRQ's from ethernet & WiFi)
|
88 |
|
|
PORT1.DDR.BYTE = 0x00 ; // Port 1: inputs (IIC and USB settings will override these later)
|
89 |
|
|
PORT2.DDR.BYTE = 0x1A ; // Port 2: USB signals
|
90 |
|
|
PORT3.DDR.BYTE = 0x04 ; // Port 3: JTAG (P30, P31, P34), CAN (P32=Tx, P33=Rx), NMI (P35)
|
91 |
|
|
PORT4.DDR.BYTE = 0x00 ; // Port 4: Switches (P40-P42), AIN (P43-P47)
|
92 |
|
|
PORT5.DDR.BYTE = 0x3B ; // Port 5: Audio (P55,P54), BCLK (P53), SCI (P52=Rx, P50=Tx), LCD-RS (P51)
|
93 |
|
|
|
94 |
|
|
PORTA.DR.BYTE = 0x00 ; // Port A outputs all LOW to start
|
95 |
|
|
PORTA.DDR.BYTE = 0xFF ; // Port A: Expansion (PA0-PA2), Ether (PA3-PA5), Audio (PA6-PA7)
|
96 |
|
|
|
97 |
|
|
PORTB.DR.BYTE = 0x00 ;
|
98 |
|
|
PORTB.DDR.BYTE = 0x70 ; // Port B: Ether
|
99 |
|
|
|
100 |
|
|
PORTC.DR.BYTE = 0xF7 ; // Port C: Chip selects, clock = high; IO reset = low (not reset, needed by Ether PHY)
|
101 |
|
|
PORTC.DDR.BYTE = 0x7F ; // Port C: SPI (PC0-2, PC4-7), IO reset (PC3)
|
102 |
|
|
|
103 |
|
|
// Ethernet settings
|
104 |
|
|
IOPORT.PFENET.BYTE = 0x82; // Enable Ether poins, RMII mode, enable LINKSTA
|
105 |
|
|
PORTA.ICR.BIT.B5 = 1; // ET_LINKSTA
|
106 |
|
|
PORTA.ICR.BIT.B3 = 1; // ET_MDIO
|
107 |
|
|
PORTB.ICR.BIT.B0 = 1; // RMII_RXD1
|
108 |
|
|
PORTB.ICR.BIT.B1 = 1; // RMII_RXD0
|
109 |
|
|
PORTB.ICR.BIT.B2 = 1; // REF50CLK
|
110 |
|
|
PORTB.ICR.BIT.B3 = 1; // RMII_RX_ER
|
111 |
|
|
PORTB.ICR.BIT.B7 = 1; // RMII_CRS_DV
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
/* Configure LEDs */
|
115 |
|
|
LED4 = LED_OFF;
|
116 |
|
|
LED5 = LED_OFF;
|
117 |
|
|
LED6 = LED_OFF;
|
118 |
|
|
LED7 = LED_OFF;
|
119 |
|
|
LED8 = LED_OFF;
|
120 |
|
|
LED9 = LED_OFF;
|
121 |
|
|
LED10 = LED_OFF;
|
122 |
|
|
LED11 = LED_OFF;
|
123 |
|
|
LED12 = LED_OFF;
|
124 |
|
|
LED13 = LED_OFF;
|
125 |
|
|
LED14 = LED_OFF;
|
126 |
|
|
LED15 = LED_OFF;
|
127 |
|
|
|
128 |
|
|
LED4_DDR = 1;
|
129 |
|
|
LED5_DDR = 1;
|
130 |
|
|
LED6_DDR = 1;
|
131 |
|
|
LED7_DDR = 1;
|
132 |
|
|
LED8_DDR = 1;
|
133 |
|
|
LED9_DDR = 1;
|
134 |
|
|
LED10_DDR = 1;
|
135 |
|
|
LED11_DDR = 1;
|
136 |
|
|
LED12_DDR = 1;
|
137 |
|
|
LED13_DDR = 1;
|
138 |
|
|
LED14_DDR = 1;
|
139 |
|
|
LED15_DDR = 1;
|
140 |
|
|
|
141 |
|
|
/* Configure push button switches */
|
142 |
|
|
SW1_DDR = 0;
|
143 |
|
|
SW2_DDR = 0;
|
144 |
|
|
SW3_DDR = 0;
|
145 |
|
|
SW1_ICR = 1;
|
146 |
|
|
SW2_ICR = 1;
|
147 |
|
|
SW3_ICR = 1;
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
|