]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_R4F_RZ_T_GCC_IAR/System/GCC/src/r_ram_init.c
FreeRTOS source:
[freertos] / FreeRTOS / Demo / CORTEX_R4F_RZ_T_GCC_IAR / System / GCC / src / r_ram_init.c
diff --git a/FreeRTOS/Demo/CORTEX_R4F_RZ_T_GCC_IAR/System/GCC/src/r_ram_init.c b/FreeRTOS/Demo/CORTEX_R4F_RZ_T_GCC_IAR/System/GCC/src/r_ram_init.c
new file mode 100644 (file)
index 0000000..0decedd
--- /dev/null
@@ -0,0 +1,153 @@
+/***********************************************************************************************************************\r
+* DISCLAIMER\r
+* This software is supplied by Renesas Electronics Corporation and is only\r
+* intended for use with Renesas products. No other uses are authorized. This\r
+* software is owned by Renesas Electronics Corporation and is protected under\r
+* all applicable laws, including copyright laws.\r
+* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING\r
+* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT\r
+* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE\r
+* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.\r
+* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS\r
+* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE\r
+* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR\r
+* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE\r
+* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\r
+* Renesas reserves the right, without notice, to make changes to this software\r
+* and to discontinue the availability of this software. By using this software,\r
+* you agree to the additional terms and conditions found by accessing the\r
+* following link:\r
+* http://www.renesas.com/disclaimer\r
+*\r
+* Copyright (C) 2014 Renesas Electronics Corporation. All rights reserved.\r
+***********************************************************************************************************************/\r
+/***********************************************************************************************************************\r
+* System Name  : RZ/T1 Init program\r
+* File Name    : r_ram_init.c\r
+* Version      : 0.1\r
+* Device       : R7S910018\r
+* Abstract     : API for internal extended RAM function\r
+* Tool-Chain   : GNUARM-NONEv14.02-EABI\r
+* OS           : not use\r
+* H/W Platform : Renesas Starter Kit for RZ/T1(Preliminary)\r
+* Description  : internal extended RAM setting API of RZ/T1\r
+* Limitation   : none\r
+***********************************************************************************************************************/\r
+/***********************************************************************************************************************\r
+* History      : DD.MM.YYYY Version  Description\r
+*              : 21.05.2015 1.00     First Release\r
+***********************************************************************************************************************/\r
+\r
+/***********************************************************************************************************************\r
+Includes <System Includes> , "Project Includes"\r
+***********************************************************************************************************************/\r
+#include <stdint.h>\r
+#include "iodefine.h"\r
+#include "r_system.h"\r
+#include "r_ram_init.h"\r
+#include "r_typedefs.h"\r
+\r
+/***********************************************************************************************************************\r
+Macro definitions\r
+***********************************************************************************************************************/\r
+#define RAM_ECC_ENABLE (0x00000001)\r
+#define RAM_ECC_DISABLE (0x00000000)\r
+#define RAM_PROTECT (0x00000000)\r
+\r
+/***********************************************************************************************************************\r
+Typedef definitions\r
+***********************************************************************************************************************/\r
+\r
+\r
+\r
+/***********************************************************************************************************************\r
+Imported global variables and functions (from other files)\r
+***********************************************************************************************************************/\r
+\r
+\r
+/***********************************************************************************************************************\r
+Exported global variables and functions (to be accessed by other files)\r
+***********************************************************************************************************************/\r
+\r
+\r
+\r
+/***********************************************************************************************************************\r
+Private variables and functions\r
+***********************************************************************************************************************/\r
+\r
+/***********************************************************************************************************************\r
+* Function Name : R_RAM_ECCEnable\r
+* Description   : Enable ECC function for internal extended RAM.\r
+* Arguments    : none\r
+* Return Value : none\r
+***********************************************************************************************************************/\r
+void R_RAM_ECCEnable(void)\r
+{\r
+    /* Enables writing to the protected registers related to RAM function */\r
+    R_RAM_WriteEnable();\r
+  \r
+    /* Enable ECC function */\r
+    ECCRAM.RAMEDC.LONG = RAM_ECC_ENABLE;\r
+    \r
+    /* Disables writing to the protected registers related to RAM function */\r
+    R_RAM_WriteDisable();\r
+    \r
+}\r
+\r
+/***********************************************************************************************************************\r
+ End of function R_RAM_ECCEnable\r
+***********************************************************************************************************************/\r
+\r
+\r
+/***********************************************************************************************************************\r
+* Function Name : R_RAM_WriteEnable\r
+* Description   : Enable writing to the protected registers related to RAM.\r
+*                 And dummy read the register in order to fix the register value.\r
+* Arguments    : none\r
+* Return Value : none\r
+***********************************************************************************************************************/\r
+void R_RAM_WriteEnable(void)\r
+{\r
+    volatile uint32_t dummy=0;\r
+\r
+    UNUSED_VARIABLE(dummy);\r
+    \r
+    /* Special sequence for protect release */\r
+    ECCRAM.RAMPCMD.LONG = 0x000000A5;  // Write fixed value 0x000000A5\r
+    ECCRAM.RAMPCMD.LONG = 0x00000001;  // Write expected value \r
+    ECCRAM.RAMPCMD.LONG = 0x0000FFFE;  // Write inverted value of the expected value\r
+    ECCRAM.RAMPCMD.LONG = 0x00000001;  // Write expected value again\r
+    dummy = ECCRAM.RAMPCMD.LONG;        \r
+    \r
+}\r
+\r
+/***********************************************************************************************************************\r
+ End of function R_RAM_WriteEnable\r
+***********************************************************************************************************************/\r
+\r
+/***********************************************************************************************************************\r
+* Function Name : R_RAM_WriteDisable\r
+* Description   : Disable writing to the protected registers related to RAM.\r
+*                 And dummy read the register in order to fix the register value.\r
+* Arguments    : none\r
+* Return Value : none\r
+***********************************************************************************************************************/\r
+void R_RAM_WriteDisable(void)\r
+{\r
+    volatile uint32_t dummy=0;\r
+\r
+    UNUSED_VARIABLE(dummy);\r
+    \r
+    /* Clear RAMPCMD register to zero */\r
+    ECCRAM.RAMPCMD.LONG = RAM_PROTECT;   \r
+    dummy = ECCRAM.RAMPCMD.LONG; \r
+    \r
+}\r
+\r
+/***********************************************************************************************************************\r
+ End of function R_RAM_WriteDisable\r
+***********************************************************************************************************************/\r
+\r
+/* End of File */\r
+\r
+\r