]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RX600_RX63N-RDK_Renesas/RTOSDemo/Renesas-Files/board/rdkrx63n/hwsetup.c
Add FreeRTOS-Plus directory.
[freertos] / FreeRTOS / Demo / RX600_RX63N-RDK_Renesas / RTOSDemo / Renesas-Files / board / rdkrx63n / hwsetup.c
1 /***********************************************************************************************************************\r
2 * DISCLAIMER\r
3 * This software is supplied by Renesas Electronics Corporation and is only intended for use with Renesas products. No \r
4 * other uses are authorized. This software is owned by Renesas Electronics Corporation and is protected under all \r
5 * applicable laws, including copyright laws. \r
6 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING\r
7 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, \r
8 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. TO THE MAXIMUM \r
9 * EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES \r
10 * SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON RELATED TO THIS \r
11 * SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\r
12 * Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of \r
13 * this software. By using this software, you agree to the additional terms and conditions found by accessing the \r
14 * following link:\r
15 * http://www.renesas.com/disclaimer \r
16 *\r
17 * Copyright (C) 2012 Renesas Electronics Corporation. All rights reserved.    \r
18 ***********************************************************************************************************************/\r
19 /***********************************************************************************************************************\r
20 * File Name        : hwsetup.c\r
21 * Device(s)    : RX\r
22 * H/W Platform : YRDKRX63N\r
23 * Description  : Defines the initialisation routines used each time the MCU is restarted.\r
24 ***********************************************************************************************************************/\r
25 /***********************************************************************************************************************\r
26 * History : DD.MM.YYYY Version  Description\r
27 *         : 26.10.2011 1.00     First Release\r
28 ***********************************************************************************************************************/\r
29 \r
30 /***********************************************************************************************************************\r
31 Includes   <System Includes> , "Project Includes"\r
32 ***********************************************************************************************************************/\r
33 #include <stdint.h>\r
34 /* I/O Register and board definitions */\r
35 #include "platform.h"\r
36 \r
37 /***********************************************************************************************************************\r
38 Private global variables and functions\r
39 ***********************************************************************************************************************/\r
40 /* MCU I/O port configuration function delcaration */
41 static void output_ports_configure(void);\r
42
43 /* Interrupt configuration function delcaration */
44 static void interrupts_configure(void);\r
45
46 /* MCU peripheral module configuration function declaration */
47 static void peripheral_modules_enable(void);
48
49
50 /***********************************************************************************************************************\r
51 * Function name: hardware_setup\r
52 * Description  : Contains setup functions called at device restart\r
53 * Arguments    : none\r
54 * Return value : none\r
55 ***********************************************************************************************************************/\r
56 void hardware_setup(void)
57 {
58     output_ports_configure();
59     interrupts_configure();
60     peripheral_modules_enable();
61 }
62
63 /***********************************************************************************************************************\r
64 * Function name: output_ports_configure
65 * Description  : Configures the port and pin direction settings, and sets the pin outputs to a safe level.\r
66 * Arguments    : none\r
67 * Return value : none\r
68 ***********************************************************************************************************************/\r
69 void output_ports_configure(void)
70 {
71     SYSTEM.PRCR.WORD = 0xA50B;                  /* Protect off */\r
72     MPC.PWPR.BIT.B0WI = 0 ;                     /* Unlock protection register */\r
73     MPC.PWPR.BIT.PFSWE = 1 ;                    /* Unlock MPC registers */\r
74     \r
75     MSTP(EDMAC) = 0 ;                   /* Power up ethernet block */\r
76     \r
77     /* Port 0 - DAC & ethernet IRQ */\r
78     PORT0.PODR.BYTE = 0x00 ;    /* All outputs low to start */\r
79     PORT0.PDR.BYTE  = 0x10 ;    /* DA1 is an ouput, all others are inputs */\r
80     \r
81     /* Port 1 - I2C and USB over-current & pull-up control */\r
82     PORT1.PODR.BYTE = 0x00 ;    /* All outputs low to start */\r
83     PORT1.PDR.BYTE  = 0x80 ;    /* AUD_R (P1.7) is an output, all others are inputs (I2C lines setup by \r
84     *                              I2C driver later */\r
85     \r
86     /* Port 2 - USB control and some expansion signals */\r
87     PORT2.PODR.BYTE = 0x02 ;    /* All outputs low to start except backlight enable */\r
88     PORT2.PDR.BYTE  = 0x02 ;    /* All inputs except backlight enable - some will be overridden by USB driver later */\r
89     \r
90     /* Port 3 - Serial port & JTAG */\r
91     PORT3.PODR.BYTE = 0x00 ;    /* All outputs low to start */\r
92     PORT3.PDR.BIT.B2  = 0x01 ;  /* Transmit line for SCI6/ CAN 0 TxD is an output */\r
93     \r
94     /* Port 4 -  */\r
95     PORT4.PODR.BYTE = 0x00 ;    /* These are all inputs */\r
96     PORT4.PDR.BYTE  = 0x00 ;    /* Analog inputs and switches, all inputs */\r
97     PORT4.PMR.BYTE  = 0x00 ;\r
98 \r
99     /* Port 5 -  */\r
100     PORT5.PODR.BYTE = 0x00 ;    /* All outputs low to start */\r
101     PORT5.PDR.BYTE  = 0x13 ;    /* SCI 2 TxD, LCD_RS, PWMLP_OUT are outputs */\r
102     MPC.P50PFS.BYTE = 0x0A ;    /* P50 is TXD2. */\r
103     MPC.P52PFS.BYTE = 0x0A ;    /* P52 is RXD2. */\r
104     PORT5.PMR.BYTE  = 0x05 ;    /* P50 and P52 are used for SCI2. */\r
105 \r
106     /* Port A - Ethernet MDIO */\r
107     PORTA.PODR.BYTE = 0x00 ;    /* */\r
108     PORTA.PMR.BYTE  = 0x00 ;    /* All GPIO for now */\r
109     MPC.PA3PFS.BYTE = 0x11 ;    /* PA3 is RMII MDIO */\r
110     MPC.PA4PFS.BYTE = 0x11 ;    /* PA4 is RMII MDC */\r
111     MPC.PA5PFS.BYTE = 0x11 ;    /* PA5 is RMII LINK_STA */\r
112     PORTA.PMR.BYTE  = 0x38 ;    /* PA3-5 are used by Ethernet peripheral */\r
113     PORTA.PDR.BYTE  = 0xFF ;    /* */\r
114     \r
115     /* Port B - Ethernet signals */\r
116     PORTB.PODR.BYTE = 0x00 ;    /* */\r
117     PORTB.PMR.BYTE  = 0x00 ;    /* All GPIO for now */\r
118     MPC.PB0PFS.BYTE = 0x12 ;    /* PB0 is RMII_RXD1 */\r
119     MPC.PB1PFS.BYTE = 0x12 ;    /* PB1 is RMII_RXD0 */\r
120     MPC.PB2PFS.BYTE = 0x12 ;    /* PB2 is REF50CK */\r
121     MPC.PB3PFS.BYTE = 0x12 ;    /* PB3 is RMI_RX_ERR */\r
122     MPC.PB4PFS.BYTE = 0x12 ;    /* PB4 is RMII_TXD_EN */\r
123     MPC.PB5PFS.BYTE = 0x12 ;    /* PB5 is RMII_TXD0 */\r
124     MPC.PB6PFS.BYTE = 0x12 ;    /* PB6 is RMII_TXD1 */\r
125     MPC.PB7PFS.BYTE = 0x12 ;    /* PB7 is RMII_CRS_DV */\r
126     PORTB.PMR.BYTE  = 0xFF ;    /* All pins assigned to peripheral */\r
127     PORTB.PDR.BYTE  = 0xF0 ;    /* */\r
128     \r
129     /* Port C -  SPI signals, chip selects, peripheral reset */\r
130     PORTC.PODR.BYTE = 0x00 ;    /* */\r
131     PORTC.PMR.BYTE  = 0x00 ;    /* All GPIO for now */\r
132     MPC.PC5PFS.BYTE = 0x0D ;    /* PC5 is RSPCKA */\r
133     MPC.PC6PFS.BYTE = 0x0D ;    /* PC6 is MOSIA */\r
134     MPC.PC7PFS.BYTE = 0x0D ;    /* PC7 is MISOA */\r
135     PORTC.PMR.BYTE  = 0xE0 ;    /* PC5-7 assigned to SPI peripheral */\r
136     PORTC.PODR.BYTE = 0x17 ;    /* All outputs low to start */\r
137     PORTC.PDR.BYTE  = 0x7F ;    /* All outputs except MISO */\r
138 \r
139 \r
140     /* Port D -  LED's */\r
141     PORTD.PODR.BYTE = 0xFF ;    /* All outputs LED's off */\r
142     PORTD.PDR.BYTE  = 0xFF ;    /* All outputs */\r
143 \r
144     /* Port E -  LED's, WiFi & PMOD control */\r
145     PORTE.PODR.BYTE = 0xFF ;    /* All LED's off, all chip selects inactive */\r
146     PORTE.PDR.BYTE  = 0x7F ;    /* All outputs except PMOD_MISO */\r
147 \r
148     /* Port J -  WiFi chip select */\r
149     PORTJ.PODR.BYTE = 0x04 ;    /* WiFi CS de-asserted at power up */\r
150     PORTJ.PDR.BYTE  = 0x04 ;    /* WiFi CS is an output */
151 }
152
153 /***********************************************************************************************************************\r
154 * Function name: interrupts_configure\r
155 * Description  : Configures interrupts used\r
156 * Arguments    : none\r
157 * Return value : none\r
158 ***********************************************************************************************************************/\r
159 void interrupts_configure(void)
160 {\r
161     /* Add code here to setup additional interrupts */\r
162 }
163
164 /***********************************************************************************************************************\r
165 * Function name: peripheral_modules_enable\r
166 * Description  : Enables and configures peripheral devices on the MCU\r
167 * Arguments    : none\r
168 * Return value : none\r
169 ***********************************************************************************************************************/\r
170 void peripheral_modules_enable(void)
171 {
172     /* Add code here to enable peripherals used by the application */
173 }