1 /***********************************************************************************************************************
\r
3 * This software is supplied by Renesas Electronics Corporation and is only
\r
4 * intended for use with Renesas products. No other uses are authorized. This
\r
5 * software is owned by Renesas Electronics Corporation and is protected under
\r
6 * all applicable laws, including copyright laws.
\r
7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
\r
8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
\r
9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
\r
10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
\r
11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
\r
12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
\r
13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
\r
14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
\r
15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
\r
16 * Renesas reserves the right, without notice, to make changes to this software
\r
17 * and to discontinue the availability of this software. By using this software,
\r
18 * you agree to the additional terms and conditions found by accessing the
\r
20 * http://www.renesas.com/disclaimer
\r
22 * Copyright (C) 2014 Renesas Electronics Corporation. All rights reserved.
\r
23 ***********************************************************************************************************************/
\r
24 /***********************************************************************************************************************
\r
25 * System Name : RZ/T1 Init program
\r
26 * File Name : r_ram_init.c
\r
28 * Device : R7S910018
\r
29 * Abstract : API for internal extended RAM function
\r
30 * Tool-Chain : GNUARM-NONEv14.02-EABI
\r
32 * H/W Platform : Renesas Starter Kit for RZ/T1(Preliminary)
\r
33 * Description : internal extended RAM setting API of RZ/T1
\r
35 ***********************************************************************************************************************/
\r
36 /***********************************************************************************************************************
\r
37 * History : DD.MM.YYYY Version Description
\r
38 * : 21.05.2015 1.00 First Release
\r
39 ***********************************************************************************************************************/
\r
41 /***********************************************************************************************************************
\r
42 Includes <System Includes> , "Project Includes"
\r
43 ***********************************************************************************************************************/
\r
45 #include "iodefine.h"
\r
46 #include "r_system.h"
\r
47 #include "r_ram_init.h"
\r
48 #include "r_typedefs.h"
\r
50 /***********************************************************************************************************************
\r
52 ***********************************************************************************************************************/
\r
53 #define RAM_ECC_ENABLE (0x00000001)
\r
54 #define RAM_ECC_DISABLE (0x00000000)
\r
55 #define RAM_PROTECT (0x00000000)
\r
57 /***********************************************************************************************************************
\r
59 ***********************************************************************************************************************/
\r
63 /***********************************************************************************************************************
\r
64 Imported global variables and functions (from other files)
\r
65 ***********************************************************************************************************************/
\r
68 /***********************************************************************************************************************
\r
69 Exported global variables and functions (to be accessed by other files)
\r
70 ***********************************************************************************************************************/
\r
74 /***********************************************************************************************************************
\r
75 Private variables and functions
\r
76 ***********************************************************************************************************************/
\r
78 /***********************************************************************************************************************
\r
79 * Function Name : R_RAM_ECCEnable
\r
80 * Description : Enable ECC function for internal extended RAM.
\r
82 * Return Value : none
\r
83 ***********************************************************************************************************************/
\r
84 void R_RAM_ECCEnable(void)
\r
86 /* Enables writing to the protected registers related to RAM function */
\r
87 R_RAM_WriteEnable();
\r
89 /* Enable ECC function */
\r
90 ECCRAM.RAMEDC.LONG = RAM_ECC_ENABLE;
\r
92 /* Disables writing to the protected registers related to RAM function */
\r
93 R_RAM_WriteDisable();
\r
97 /***********************************************************************************************************************
\r
98 End of function R_RAM_ECCEnable
\r
99 ***********************************************************************************************************************/
\r
102 /***********************************************************************************************************************
\r
103 * Function Name : R_RAM_WriteEnable
\r
104 * Description : Enable writing to the protected registers related to RAM.
\r
105 * And dummy read the register in order to fix the register value.
\r
107 * Return Value : none
\r
108 ***********************************************************************************************************************/
\r
109 void R_RAM_WriteEnable(void)
\r
111 volatile uint32_t dummy=0;
\r
113 UNUSED_VARIABLE(dummy);
\r
115 /* Special sequence for protect release */
\r
116 ECCRAM.RAMPCMD.LONG = 0x000000A5; // Write fixed value 0x000000A5
\r
117 ECCRAM.RAMPCMD.LONG = 0x00000001; // Write expected value
\r
118 ECCRAM.RAMPCMD.LONG = 0x0000FFFE; // Write inverted value of the expected value
\r
119 ECCRAM.RAMPCMD.LONG = 0x00000001; // Write expected value again
\r
120 dummy = ECCRAM.RAMPCMD.LONG;
\r
124 /***********************************************************************************************************************
\r
125 End of function R_RAM_WriteEnable
\r
126 ***********************************************************************************************************************/
\r
128 /***********************************************************************************************************************
\r
129 * Function Name : R_RAM_WriteDisable
\r
130 * Description : Disable writing to the protected registers related to RAM.
\r
131 * And dummy read the register in order to fix the register value.
\r
133 * Return Value : none
\r
134 ***********************************************************************************************************************/
\r
135 void R_RAM_WriteDisable(void)
\r
137 volatile uint32_t dummy=0;
\r
139 UNUSED_VARIABLE(dummy);
\r
141 /* Clear RAMPCMD register to zero */
\r
142 ECCRAM.RAMPCMD.LONG = RAM_PROTECT;
\r
143 dummy = ECCRAM.RAMPCMD.LONG;
\r
147 /***********************************************************************************************************************
\r
148 End of function R_RAM_WriteDisable
\r
149 ***********************************************************************************************************************/
\r