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) 2012 Renesas Electronics Corporation. All rights reserved.
\r
23 *******************************************************************************/
\r
24 /*******************************************************************************
\r
25 * File Name : bsc_userdef.c
\r
27 * $Date:: 2013-04-10 12:58:44 +0100#$
\r
28 * Device(s) : Aragon
\r
29 * Tool-Chain : DS-5 Ver 5.8
\r
32 * H/W Platform : Aragon CPU Board
\r
33 * Description : Aragon Sample Program - Common driver (User define function)
\r
36 *******************************************************************************/
\r
39 /******************************************************************************
\r
40 Includes <System Includes> , "Project Includes"
\r
41 ******************************************************************************/
\r
42 #include "r_typedefs.h"
\r
43 #include "dev_drv.h" /* Device Driver common header */
\r
44 #include "devdrv_common.h" /* Common Driver Header */
\r
45 #include "iodefine.h"
\r
47 /* Do not include the following pragmas when compiling with IAR. */
\r
49 #pragma arm section code = "CODE_RESET"
\r
50 #pragma arm section rodata = "CONST_RESET"
\r
51 #pragma arm section rwdata = "DATA_RESET"
\r
52 #pragma arm section zidata = "BSS_RESET"
\r
55 /******************************************************************************
\r
57 ******************************************************************************/
\r
60 /******************************************************************************
\r
62 ******************************************************************************/
\r
63 /* The address when writing in a SDRAM mode register */
\r
64 #define SDRAM_MODE_CS2 (*(volatile uint16_t *)(0x3FFFD040))
\r
65 #define SDRAM_MODE_CS3 (*(volatile uint16_t *)(0x3FFFE040))
\r
67 /******************************************************************************
\r
68 Imported global variables and functions (from other files)
\r
69 ******************************************************************************/
\r
72 /******************************************************************************
\r
73 Exported global variables and functions (to be accessed by other files)
\r
74 ******************************************************************************/
\r
77 /******************************************************************************
\r
78 Private global variables and functions
\r
79 ******************************************************************************/
\r
82 /******************************************************************************
\r
83 * Function Name: Userdef_BSC_CS0Init
\r
86 * Return Value : none
\r
87 ******************************************************************************/
\r
88 void Userdef_BSC_CS0Init(void)
\r
90 /* ---- CS0BCR settings ---- */
\r
91 BSC.CS0BCR.LONG = 0x10000C00ul;
\r
92 /* Idle Cycles between Write-read Cycles */
\r
93 /* and Write-write Cycles : 1 idle cycle */
\r
94 /* Data Bus Size: 16-bit */
\r
96 /* ---- CS0WCR settings ---- */
\r
97 BSC.CS0WCR.NORMAL.LONG = 0x00000B40ul;
\r
98 /* Number of Delay Cycles from Address, */
\r
99 /* CS0# Assertion to RD#,WEn Assertion */
\r
101 /* Number of Access Wait Cycles: 6 cycles */
\r
102 /* Delay Cycles from RD,WEn# negation to */
\r
103 /* Address,CSn# negation: 0.5 cycles */
\r
106 /******************************************************************************
\r
107 * Function Name: Userdef_BSC_CS1Init
\r
110 * Return Value : none
\r
111 ******************************************************************************/
\r
112 void Userdef_BSC_CS1Init(void)
\r
114 /* ---- CS1BCR settings ---- */
\r
115 BSC.CS1BCR.LONG = 0x10000C00ul;
\r
116 /* Idle Cycles between Write-read Cycles */
\r
117 /* and Write-write Cycles : 1 idle cycle */
\r
118 /* Data Bus Size: 16-bit */
\r
120 /* ---- CS1WCR settings ---- */
\r
121 BSC.CS1WCR.LONG = 0x00000B40ul;
\r
122 /* Number of Delay Cycles from Address, */
\r
123 /* CS0# Assertion to RD#,WEn Assertion */
\r
125 /* Number of Access Wait Cycles: 6 cycles */
\r
126 /* Delay Cycles from RD,WEn# negation to */
\r
127 /* Address,CSn# negation: 0.5 cycles */
\r
130 /******************************************************************************
\r
131 * Function Name: Userdef_BSC_CS2Init
\r
134 * Return Value : none
\r
135 ******************************************************************************/
\r
136 void Userdef_BSC_CS2Init(void)
\r
138 /* ==== CS2BCR settings ==== */
\r
139 BSC.CS2BCR.LONG = 0x00004C00ul;
\r
140 /* Idle Cycles between Write-read Cycles */
\r
141 /* and Write-write Cycles : 0 idle cycles */
\r
142 /* Memory type :SDRAM */
\r
143 /* Data Bus Size : 16-bit */
\r
145 /* ==== CS2WCR settings ==== */
\r
146 BSC.CS2WCR.SDRAM.LONG = 0x00000480ul;
\r
147 /* CAS latency for Area 2 : 2 cycles */
\r
150 /* ==== Written in SDRAM Mode Register ==== */
\r
151 SDRAM_MODE_CS2 = 0;
\r
152 /* The writing data is arbitrary */
\r
153 /* SDRAM mode register setting CS2 space */
\r
154 /* Burst read (burst length 1)./Burst write */
\r
157 /******************************************************************************
\r
158 * Function Name: Userdef_BSC_CS3Init
\r
161 * Return Value : none
\r
162 ******************************************************************************/
\r
163 void Userdef_BSC_CS3Init(void)
\r
165 volatile int32_t cnt;
\r
173 /* ==== CS3BCR settings ==== */
\r
174 BSC.CS3BCR.LONG = 0x00004C00ul;
\r
175 /* Idle Cycles between Write-read Cycles */
\r
176 /* and Write-write Cycles : 0 idle cycles */
\r
177 /* Memory type :SDRAM */
\r
178 /* Data Bus Size : 16-bit */
\r
180 /* ==== CS3WCR settings ==== */
\r
181 BSC.CS3WCR.SDRAM.LONG = 0x00002492ul;
\r
182 /* Precharge completion wait cycles: 1 cycle */
\r
183 /* Wait cycles between ACTV command */
\r
184 /* and READ(A)/WRITE(A) command : 1 cycles */
\r
185 /* CAS latency for Area 3 : 2 cycles */
\r
186 /* Auto-precharge startup wait cycles : 2 cycles */
\r
187 /* Idle cycles from REF command/self-refresh */
\r
188 /* Release to ACTV/REF/MRS command : 5 cycles */
\r
190 /* ==== SDCR settings ==== */
\r
191 BSC.SDCR.LONG = 0x00120812ul;
\r
192 /* Row address for Area 2 : 13-bit */
\r
193 /* Column Address for Area 2 : 10-bit */
\r
194 /* Refresh Control :Refresh */
\r
195 /* RMODE :Auto-refresh is performed */
\r
196 /* BACTV :Auto-precharge mode */
\r
197 /* Row address for Area 3 : 13-bit */
\r
198 /* Column Address for Area 3 : 10-bit */
\r
200 /* ==== RTCOR settings ==== */
\r
201 BSC.RTCOR.LONG = 0xA55A0020ul;
\r
202 /* 7.813usec /240nsec */
\r
203 /* = 32(0x20)cycles per refresh */
\r
205 /* ==== RTCSR settings ==== */
\r
206 BSC.RTCSR.LONG = 0xA55A0010ul;
\r
207 /* Initialization sequence start */
\r
208 /* Clock select B-phy/16 */
\r
209 /* Refresh count :Once */
\r
211 /* ==== Written in SDRAM Mode Register ==== */
\r
212 SDRAM_MODE_CS3 = 0;
\r
213 /* The writing data is arbitrary */
\r
214 /* SDRAM mode register setting CS3 space */
\r
215 /* Burst read (burst length 1)./Burst write */
\r
218 /******************************************************************************
\r
219 * Function Name: Userdef_BSC_CS4Init
\r
222 * Return Value : none
\r
223 ******************************************************************************/
\r
224 void Userdef_BSC_CS4Init(void)
\r
228 /******************************************************************************
\r
229 * Function Name: Userdef_BSC_CS5Init
\r
232 * Return Value : none
\r
233 ******************************************************************************/
\r
234 void Userdef_BSC_CS5Init(void)
\r