1 /***********************************************************************************************************************
\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
15 * http://www.renesas.com/disclaimer
\r
17 * Copyright (C) 2012 Renesas Electronics Corporation. All rights reserved.
\r
18 ***********************************************************************************************************************/
\r
19 /***********************************************************************************************************************
\r
20 * File Name : hwsetup.c
\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
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
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
44 /* Interrupt configuration function delcaration */
45 static void interrupts_configure(void);
\r
47 /* MCU peripheral module configuration function declaration */
48 static void peripheral_modules_enable(void);
51 /***********************************************************************************************************************
\r
52 * Function name: hardware_setup
\r
53 * Description : Contains setup functions called at device restart
\r
55 * Return value : none
\r
56 ***********************************************************************************************************************/
\r
57 void hardware_setup(void)
59 output_ports_configure();
60 interrupts_configure();
61 peripheral_modules_enable();
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
68 * Return value : none
\r
69 ***********************************************************************************************************************/
\r
70 void output_ports_configure(void)
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
77 /* Start with LEDs off. */
\r
83 /* Set LED pins as outputs. */
\r
89 /* Enable switches. */
\r
90 /* Set pins as inputs. */
\r
95 /* Set port mode registers for switches. */
\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
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
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
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
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
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
137 /* Configure the pin connected to the ADC Pot as an input */
\r
138 PORT4.PDR.BIT.B0 = 0;
\r
141 /***********************************************************************************************************************
\r
142 * Function name: interrupts_configure
\r
143 * Description : Configures interrupts used
\r
145 * Return value : none
\r
146 ***********************************************************************************************************************/
\r
147 void interrupts_configure(void)
149 /* Add code here to setup additional interrupts */
\r
152 /***********************************************************************************************************************
\r
153 * Function name: peripheral_modules_enable
\r
154 * Description : Enables and configures peripheral devices on the MCU
\r
156 * Return value : none
\r
157 ***********************************************************************************************************************/
\r
158 void peripheral_modules_enable(void)
160 /* Add code here to enable peripherals used by the application */