]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/RX600_RX63N-RSK_Renesas/RTOSDemo/Renesas-Files/board/rskrx63n/hwsetup.c
a72bd3fdd03875b24fb44ae0d59a26e636e777c8
[freertos] / FreeRTOS / Demo / RX600_RX63N-RSK_Renesas / RTOSDemo / Renesas-Files / board / rskrx63n / 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 : RSK+RX63N\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 *         : 22.11.2011 1.00     First Release\r
28 ***********************************************************************************************************************/\r
29 \r
30 /***********************************************************************************************************************\r
31 Includes   <System Includes> , "Project Includes"\r
32 ***********************************************************************************************************************/\r
33 /* I/O Register and board definitions */\r
34 #include "platform.h"\r
35 /* Contains delcarations for the functions defined in this file */
36 #include "hwsetup.h"\r
37 \r
38 /***********************************************************************************************************************\r
39 Private global variables and functions\r
40 ***********************************************************************************************************************/\r
41 /* MCU I/O port configuration function delcaration */
42 static void output_ports_configure(void);\r
43
44 /* Interrupt configuration function delcaration */
45 static void interrupts_configure(void);\r
46
47 /* MCU peripheral module configuration function declaration */
48 static void peripheral_modules_enable(void);
49
50
51 /***********************************************************************************************************************\r
52 * Function name: hardware_setup\r
53 * Description  : Contains setup functions called at device restart\r
54 * Arguments    : none\r
55 * Return value : none\r
56 ***********************************************************************************************************************/\r
57 void hardware_setup(void)
58 {
59     output_ports_configure();
60     interrupts_configure();
61     peripheral_modules_enable();
62 }
63
64 /***********************************************************************************************************************\r
65 * Function name: output_ports_configure
66 * Description  : Configures the port and pin direction settings, and sets the pin outputs to a safe level.\r
67 * Arguments    : none\r
68 * Return value : none\r
69 ***********************************************************************************************************************/\r
70 void output_ports_configure(void)
71 {
72     SYSTEM.PRCR.WORD = 0xA50B;                  /* Protect off */\r
73     MPC.PWPR.BIT.B0WI = 0 ;                     /* Unlock protection register */\r
74     MPC.PWPR.BIT.PFSWE = 1 ;                    /* Unlock MPC registers */\r
75 \r
76     /* Enable LEDs. */\r
77     /* Start with LEDs off. */\r
78     LED0 = LED_OFF;\r
79     LED1 = LED_OFF;\r
80     LED2 = LED_OFF;\r
81     LED3 = LED_OFF;\r
82 \r
83     /* Set LED pins as outputs. */\r
84     LED0_PDR = 1;\r
85     LED1_PDR = 1;\r
86     LED2_PDR = 1;\r
87     LED3_PDR = 1;\r
88 \r
89     /* Enable switches. */\r
90     /* Set pins as inputs. */\r
91     SW1_PDR = 0;\r
92     SW2_PDR = 0;\r
93     SW3_PDR = 0;\r
94 \r
95     /* Set port mode registers for switches. */\r
96     SW1_PMR = 0;\r
97     SW2_PMR = 0;\r
98     SW3_PMR = 0;\r
99     \r
100     /* Initialize RSPI pins that are used with on-board SPI flash. */\r
101     /* Set pin outputs to low to begin with. */\r
102     PORT2.PODR.BIT.B7 = 0x00;    /* RSPCKB */\r
103     PORT2.PODR.BIT.B6 = 0x00;    /* MOSIB */\r
104     PORT3.PODR.BIT.B0 = 0x00;    /* MISOB */\r
105     PORT3.PODR.BIT.B1 = 0x00;    /* SSLB0 */\r
106     \r
107     /* All GPIO for now */\r
108     PORT2.PMR.BIT.B7 = 0x00;    \r
109     PORT2.PMR.BIT.B6 = 0x00;    \r
110     PORT3.PMR.BIT.B0 = 0x00;\r
111     PORT3.PMR.BIT.B1 = 0x00;\r
112 \r
113     /* Unlock MPC registers to enable writing to them. */\r
114     MPC.PWPR.BIT.B0WI = 0 ;     /* Unlock protection register */\r
115     MPC.PWPR.BIT.PFSWE = 1 ;    /* Unlock MPC registers */\r
116         \r
117     /* Set MPC for RSPI pins */\r
118     MPC.P27PFS.BYTE = 0x0D;    \r
119     MPC.P26PFS.BYTE = 0x0D;    \r
120     MPC.P30PFS.BYTE = 0x0D;    \r
121     \r
122     /* RSPI pins assigned to RSPI peripheral. */\r
123     PORT2.PMR.BIT.B7 = 1;    \r
124     PORT2.PMR.BIT.B6 = 1;    \r
125     PORT3.PMR.BIT.B0 = 1;\r
126     PORT3.PMR.BIT.B1 = 1;    \r
127     \r
128     /* RSPCKB is output. */\r
129     PORT2.PDR.BIT.B7 = 1;\r
130     /* MOSIB is output. */\r
131     PORT2.PDR.BIT.B6 = 1;\r
132     /* MISOB is input. */\r
133     PORT3.PDR.BIT.B0 = 0;\r
134     /* SSLB0 is output. */\r
135     PORT3.PDR.BIT.B1 = 1;\r
136     \r
137     /* Configure the pin connected to the ADC Pot as an input */\r
138     PORT4.PDR.BIT.B0 = 0;\r
139 }
140
141 /***********************************************************************************************************************\r
142 * Function name: interrupts_configure\r
143 * Description  : Configures interrupts used\r
144 * Arguments    : none\r
145 * Return value : none\r
146 ***********************************************************************************************************************/\r
147 void interrupts_configure(void)
148 {\r
149     /* Add code here to setup additional interrupts */\r
150 }
151
152 /***********************************************************************************************************************\r
153 * Function name: peripheral_modules_enable\r
154 * Description  : Enables and configures peripheral devices on the MCU\r
155 * Arguments    : none\r
156 * Return value : none\r
157 ***********************************************************************************************************************/\r
158 void peripheral_modules_enable(void)
159 {
160     /* Add code here to enable peripherals used by the application */
161 }