]> git.sur5r.net Git - freertos/blob - Demo/RX600_RX62N-RDK_GNURX/RTOSDemo/Renesas-Files/hwsetup.c
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / RX600_RX62N-RDK_GNURX / RTOSDemo / Renesas-Files / hwsetup.c
1 /******************************************************************************\r
2 * DISCLAIMER\r
3 \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
6 \r
7 * This software is owned by Renesas Technology Corp. and is protected under \r
8 * all applicable laws, including copyright laws.\r
9 \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
14 * DISCLAIMED.\r
15 \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
21 \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
31 * Version         : 1.00\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
37 \r
38 \r
39 /******************************************************************************\r
40 Includes   <System Includes> , "Project Includes"\r
41 ******************************************************************************/\r
42 #include "iodefine.h"\r
43 #include "yrdkrx62ndef.h"\r
44 // #include "lcd.h" Uncomment this if an LCD is present.\r
45 \r
46 /******************************************************************************\r
47 Typedef definitions\r
48 ******************************************************************************/\r
49 \r
50 /******************************************************************************\r
51 Macro definitions\r
52 ******************************************************************************/\r
53 \r
54 /******************************************************************************\r
55 Imported global variables and functions (from other files)\r
56 ******************************************************************************/\r
57 \r
58 /******************************************************************************\r
59 Exported global variables and functions (to be accessed by other files)\r
60 ******************************************************************************/\r
61 \r
62 /******************************************************************************\r
63 Private global variables and functions\r
64 ******************************************************************************/\r
65 \r
66 /******************************************************************************\r
67 * Function Name: HardwareSetup\r
68 * Description  : This function does initial setting for CPG port pins used in\r
69 *                         : the Demo including the MII pins of the Ethernet PHY connection.\r
70 * Arguments     : none\r
71 * Return Value : none\r
72 ******************************************************************************/\r
73 void HardwareSetup(void)\r
74 {\r
75         unsigned long sckcr = 0;\r
76 \r
77         /* Configure system clocks based on header */\r
78         sckcr += (ICLK_MUL==8) ? (0ul << 24) : (ICLK_MUL==4) ? (1ul << 24) : (ICLK_MUL==2) ? (2ul << 24) : (3ul << 24);\r
79         sckcr += (BCLK_MUL==8) ? (0ul << 16) : (BCLK_MUL==4) ? (1ul << 16) : (BCLK_MUL==2) ? (2ul << 16) : (3ul << 16);\r
80         sckcr += (PCLK_MUL==8) ? (0ul <<  8) : (PCLK_MUL==4) ? (1ul <<  8) : (PCLK_MUL==2) ? (2ul <<  8) : (3ul <<  8);\r
81         SYSTEM.SCKCR.LONG = sckcr;\r
82 \r
83         /* Module standby clear - EtherC, EDMAC */\r
84         SYSTEM.MSTPCRB.BIT.MSTPB15 = 0;\r
85 \r
86         PORT0.DDR.BYTE = 0x00 ;     // Port 0: inputs (IRQ's from ethernet & WiFi)\r
87         PORT1.DDR.BYTE = 0x00 ;     // Port 1: inputs (IIC and USB settings will override these later)\r
88         PORT2.DDR.BYTE = 0x1A ;     // Port 2: USB signals\r
89         PORT3.DDR.BYTE = 0x04 ;     // Port 3: JTAG (P30, P31, P34), CAN (P32=Tx, P33=Rx), NMI (P35)\r
90         PORT4.DDR.BYTE = 0x00 ;     // Port 4: Switches (P40-P42), AIN (P43-P47)\r
91         PORT5.DDR.BYTE = 0x3B ;     // Port 5: Audio (P55,P54), BCLK (P53), SCI (P52=Rx, P50=Tx), LCD-RS (P51)\r
92 \r
93         PORTA.DR.BYTE = 0x00 ;      // Port A outputs all LOW to start\r
94         PORTA.DDR.BYTE = 0xFF ;     // Port A: Expansion (PA0-PA2), Ether (PA3-PA5), Audio (PA6-PA7)\r
95 \r
96         PORTB.DR.BYTE = 0x00 ;\r
97         PORTB.DDR.BYTE = 0x70 ;     // Port B: Ether\r
98 \r
99         PORTC.DR.BYTE = 0xF7 ;      // Port C: Chip selects, clock = high; IO reset = low (not reset, needed by Ether PHY)\r
100         PORTC.DDR.BYTE = 0x7F ;     // Port C: SPI (PC0-2, PC4-7), IO reset (PC3)                \r
101 \r
102         // Ethernet settings\r
103         IOPORT.PFENET.BYTE = 0x82;  // Enable Ether poins, RMII mode, enable LINKSTA\r
104         PORTA.ICR.BIT.B5 = 1;       // ET_LINKSTA \r
105         PORTA.ICR.BIT.B3 = 1;       // ET_MDIO\r
106         PORTB.ICR.BIT.B0 = 1;       // RMII_RXD1\r
107         PORTB.ICR.BIT.B1 = 1;       // RMII_RXD0\r
108         PORTB.ICR.BIT.B2 = 1;       // REF50CLK\r
109         PORTB.ICR.BIT.B3 = 1;       // RMII_RX_ER\r
110         PORTB.ICR.BIT.B7 = 1;       // RMII_CRS_DV\r
111 \r
112 \r
113         /* Configure LEDs */\r
114         LED4 = LED_OFF;\r
115         LED5 = LED_OFF;\r
116         LED6 = LED_OFF;\r
117         LED7 = LED_OFF;\r
118         LED8 = LED_OFF;\r
119         LED9 = LED_OFF;\r
120         LED10 = LED_OFF;\r
121         LED11 = LED_OFF;\r
122         LED12 = LED_OFF;\r
123         LED13 = LED_OFF;\r
124         LED14 = LED_OFF;\r
125         LED15 = LED_OFF;\r
126 \r
127         LED4_DDR = 1;\r
128         LED5_DDR = 1;\r
129         LED6_DDR = 1;\r
130         LED7_DDR = 1;\r
131         LED8_DDR = 1;\r
132         LED9_DDR = 1;\r
133         LED10_DDR = 1;\r
134         LED11_DDR = 1;\r
135         LED12_DDR = 1;\r
136         LED13_DDR = 1;\r
137         LED14_DDR = 1;\r
138         LED15_DDR = 1;\r
139 \r
140         /* Configure push button switches */\r
141         SW1_DDR = 0;\r
142         SW2_DDR = 0;\r
143         SW3_DDR = 0;\r
144         SW1_ICR = 1;\r
145         SW2_ICR = 1;\r
146         SW3_ICR = 1;\r
147 }\r
148 \r
149 \r