]> git.sur5r.net Git - freertos/blob - Demo/CORTEX_AT91SAM3U256_IAR/system/board_memories.c
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / CORTEX_AT91SAM3U256_IAR / system / board_memories.c
1 /* ----------------------------------------------------------------------------\r
2  *         ATMEL Microcontroller Software Support \r
3  * ----------------------------------------------------------------------------\r
4  * Copyright (c) 2009, Atmel Corporation\r
5  *\r
6  * All rights reserved.\r
7  *\r
8  * Redistribution and use in source and binary forms, with or without\r
9  * modification, are permitted provided that the following conditions are met:\r
10  *\r
11  * - Redistributions of source code must retain the above copyright notice,\r
12  * this list of conditions and the disclaimer below.\r
13  *\r
14  * Atmel's name may not be used to endorse or promote products derived from\r
15  * this software without specific prior written permission.\r
16  *\r
17  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR\r
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
20  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,\r
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\r
23  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\r
24  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\r
25  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
26  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
27  * ----------------------------------------------------------------------------\r
28  */\r
29 \r
30 /*\r
31     Title: Memories implementation\r
32 */\r
33 \r
34 //------------------------------------------------------------------------------\r
35 //         Headers\r
36 //------------------------------------------------------------------------------\r
37 \r
38 #include <board.h>\r
39 \r
40 //------------------------------------------------------------------------------\r
41 //         Exported functions\r
42 //------------------------------------------------------------------------------\r
43 //------------------------------------------------------------------------------\r
44 /// Dummy function to initialize and configure the SDRAM\r
45 //------------------------------------------------------------------------------\r
46 void BOARD_ConfigureSdram(unsigned char busWidth)\r
47 {\r
48 }\r
49 \r
50 //------------------------------------------------------------------------------\r
51 /// Configures the EBI for NandFlash access. Pins must be configured after or\r
52 /// before calling this function.\r
53 //------------------------------------------------------------------------------\r
54 void BOARD_ConfigureNandFlash(unsigned char busWidth)\r
55 {\r
56     AT91PS_HSMC4 pHSMC4 = AT91C_BASE_HSMC4;    \r
57     AT91PS_HSMC4_CS pSMC = AT91C_BASE_HSMC4_CS1;\r
58 \r
59     // Open EBI clock\r
60     AT91C_BASE_PMC->PMC_PCER = (1<< AT91C_ID_HSMC4);\r
61  \r
62 #ifdef CHIP_NAND_CTRL    \r
63     // Enable the Nand Flash Controller\r
64     pHSMC4 ->HSMC4_CTRL = AT91C_HSMC4_NFCEN;\r
65 #endif\r
66     \r
67     pSMC->HSMC4_SETUP = 0\r
68                     | ((0 <<  0) & AT91C_HSMC4_NWE_SETUP)\r
69                     | ((1 <<  8) & AT91C_HSMC4_NCS_WR_SETUP)\r
70                     | ((0 << 16) & AT91C_HSMC4_NRD_SETUP)\r
71                     | ((1 << 24) & AT91C_HSMC4_NCS_RD_SETUP);\r
72 \r
73     pSMC->HSMC4_PULSE = 0\r
74                     | ((2 <<  0) & AT91C_HSMC4_NWE_PULSE)\r
75                     | ((3 <<  8) & AT91C_HSMC4_NCS_WR_PULSE)\r
76                     | ((3 << 16) & AT91C_HSMC4_NRD_PULSE)\r
77                     | ((4 << 24) & AT91C_HSMC4_NCS_RD_PULSE);\r
78 \r
79     pSMC->HSMC4_CYCLE = 0\r
80                   | ((4 <<  0) & AT91C_HSMC4_NWE_CYCLE)\r
81                   | ((7 << 16) & AT91C_HSMC4_NRD_CYCLE);\r
82 \r
83     pSMC->HSMC4_TIMINGS = 0\r
84                     | ((1 <<  0) & AT91C_HSMC4_TCLR) // CLE to REN\r
85                     | ((2 <<  4) & AT91C_HSMC4_TADL) // ALE to Data\r
86                     | ((1 <<  8) & AT91C_HSMC4_TAR)  // ALE to REN\r
87                     | ((1 << 16) & AT91C_HSMC4_TRR)  // Ready to REN\r
88                     | ((2 << 24) & AT91C_HSMC4_TWB)  // WEN to REN\r
89                     | (7<<28)\r
90                     |(AT91C_HSMC4_NFSEL)              // Nand Flash Timing\r
91                     ;\r
92     \r
93         \r
94     if (busWidth == 8) {\r
95         pSMC->HSMC4_MODE = AT91C_HSMC4_DBW_WIDTH_EIGTH_BITS | AT91C_HSMC4_READ_MODE | AT91C_HSMC4_WRITE_MODE;\r
96     }\r
97     else if (busWidth == 16) {\r
98         pSMC->HSMC4_MODE = AT91C_HSMC4_DBW_WIDTH_SIXTEEN_BITS | AT91C_HSMC4_READ_MODE | AT91C_HSMC4_WRITE_MODE;\r
99     }\r
100 }\r
101 \r