Rev 1 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ingob | 1 | /******************** (C) COPYRIGHT 2006 STMicroelectronics ******************** |
2 | * File Name : 91x_emi.c |
||
3 | * Author : MCD Application Team |
||
4 | * Date First Issued : 05/18/2006 : Version 1.0 |
||
5 | * Description : This file provides all the EMI software functions. |
||
6 | ******************************************************************************** |
||
7 | * History: |
||
8 | * 05/22/2007 : Version 1.2 |
||
9 | * 05/24/2006 : Version 1.1 |
||
10 | * 05/18/2006 : Version 1.0 |
||
11 | ******************************************************************************** |
||
12 | * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
||
13 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. |
||
14 | * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, |
||
15 | * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE |
||
16 | * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING |
||
17 | * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
||
18 | *******************************************************************************/ |
||
19 | |||
20 | /* Includes ------------------------------------------------------------------*/ |
||
21 | #include "91x_emi.h" |
||
22 | #include "91x_scu.h" |
||
23 | /* Private typedef -----------------------------------------------------------*/ |
||
24 | /* Private define ------------------------------------------------------------*/ |
||
25 | |||
26 | /* These constant variables are used as masks to handle the EMI registers. */ |
||
27 | |||
28 | #define EMI_PageModeRead_TL_Mask 0xFFFFF3FF |
||
29 | #define EMI_PageModeRead_Sel_Mask 0xFFFFFEFF |
||
30 | #define EMI_MemWidth_Mask 0xFFFFFFCF |
||
31 | #define EMI_WriteProtect_Mask 0xFFFFFEF7 |
||
32 | |||
33 | |||
34 | /* Private macro -------------------------------------------------------------*/ |
||
35 | /* Private variables ---------------------------------------------------------*/ |
||
36 | /* Registers reset value */ |
||
37 | /* Private function prototypes -----------------------------------------------*/ |
||
38 | /* Private functions ---------------------------------------------------------*/ |
||
39 | |||
40 | /****************************************************************************** |
||
41 | * Function Name : EMI_DeInit |
||
42 | * Description : Deinitializes the EMI peripheral registers to their default |
||
43 | * reset values. |
||
44 | * Input : None |
||
45 | * Output : None |
||
46 | * Return : None |
||
47 | *******************************************************************************/ |
||
48 | |||
49 | void EMI_DeInit(void) |
||
50 | { |
||
51 | |||
52 | SCU_AHBPeriphReset(__EMI, ENABLE); /* EMI peripheral under Reset */ |
||
53 | SCU_AHBPeriphReset(__EMI,DISABLE ); /* EMI not under Reset */ |
||
54 | |||
55 | } |
||
56 | |||
57 | /******************************************************************************* |
||
58 | * Function Name : EMI_StructInit |
||
59 | * Description : Fills the EMI_InitTypeDef structure member with its reset |
||
60 | * value. |
||
61 | * Input : EMI_InitStruct : pointer to a EMI_InitTypeDef structure |
||
62 | * which will be initialized. |
||
63 | * Output : None |
||
64 | * Return : None |
||
65 | *******************************************************************************/ |
||
66 | |||
67 | void EMI_StructInit( EMI_InitTypeDef *EMI_InitStruct) |
||
68 | { |
||
69 | |||
70 | /* Number of bus turnaround cycles added between read and write accesses.*/ |
||
71 | /*This member can be 0x01,0x02,0x03, ....0xF (Reset value:0xF "15 cycles"*/ |
||
72 | |||
73 | EMI_InitStruct->EMI_Bank_IDCY =0xF; |
||
74 | |||
75 | |||
76 | /* Number of wait states for read accesses*/ |
||
77 | /*This member can be: 0x01,0x02,0x03, ....0x1F (Reset value:0x1F "31 cycles"*/ |
||
78 | |||
79 | EMI_InitStruct->EMI_Bank_WSTRD =0x1F; |
||
80 | |||
81 | |||
82 | /* Number of wait states for write accesses*/ |
||
83 | /*This member can be: 0x01,0x02,0x03, ....0x1F (Reset value:0x1F "31 cycles"*/ |
||
84 | |||
85 | EMI_InitStruct->EMI_Bank_WSTWR =0x1F; |
||
86 | |||
87 | /*Output enable assertion delay from chip select assertion*/ |
||
88 | /*This member can be: 0x01,0x02,0x03, ....0xF (Reset value:0x01 "1 cycle"*/ |
||
89 | |||
90 | EMI_InitStruct->EMI_Bank_WSTROEN =0x01; |
||
91 | |||
92 | |||
93 | /*Write enable assertion delay from chip select assertion*/ |
||
94 | /*This member can be: 0x01,0x02,0x03, ....0xF (Reset value:0x00 "0 cycle"*/ |
||
95 | |||
96 | EMI_InitStruct->EMI_Bank_WSTWEN =0x00; |
||
97 | |||
98 | |||
99 | /*This member Controls the memory width*/ |
||
100 | /*This member can be :"EMI_Width_Byte" = 8 bits width or "EMI_Width_HalfWord" = 16 bits width*/ |
||
101 | |||
102 | EMI_InitStruct->EMI_Bank_MemWidth = EMI_Width_Byte; |
||
103 | |||
104 | |||
105 | /*Write protection feature */ |
||
106 | /*This member can be :"EMI_Bank_NonWriteProtect" = No write protection or "EMI_Bank_WriteProtect" = bank is write protected*/ |
||
107 | |||
108 | EMI_InitStruct-> EMI_Bank_WriteProtection= EMI_Bank_NonWriteProtect; |
||
109 | |||
110 | |||
111 | /* page transfer length for page mode read */ |
||
112 | /*This member can be :"EMI_4Data" = 4 transfers burst or "EMI_8Data" = 8 transfers burst*/ |
||
113 | |||
114 | EMI_InitStruct->EMI_PageModeRead_TransferLength= EMI_4Data; |
||
115 | |||
116 | /*Select or deselect the page mode read*/ |
||
117 | /*This member can be :"EMI_NormalMode" =Normal Mode or "EMI_PageModeRead" = Page Mode Read*/ |
||
118 | |||
119 | EMI_InitStruct->EMI_PageModeRead_Selection = EMI_NormalMode; |
||
120 | |||
121 | |||
122 | } |
||
123 | |||
124 | /******************************************************************************* |
||
125 | * Function Name : EMI_Init |
||
126 | * Description : Initializes EMI peripheral according to the specified |
||
127 | * parameters in the EMI_InitStruct. |
||
128 | |||
129 | * Input : EMI_Bankx:where x can be 0,1,2 or 3 to select the EMI Bank. |
||
130 | EMI_InitStruct: pointer to a EMI_InitTypeDef structure |
||
131 | ( Structure Config to be loaded in EMI Registers). . |
||
132 | |||
133 | * Output : None |
||
134 | * Return : None |
||
135 | *******************************************************************************/ |
||
136 | |||
137 | void EMI_Init( EMI_Bank_TypeDef* EMI_Bankx, EMI_InitTypeDef* EMI_InitStruct) |
||
138 | |||
139 | { |
||
140 | |||
141 | EMI_Bankx->ICR = EMI_InitStruct-> EMI_Bank_IDCY ; |
||
142 | |||
143 | EMI_Bankx->RCR = EMI_InitStruct->EMI_Bank_WSTRD ; |
||
144 | |||
145 | EMI_Bankx->WCR = EMI_InitStruct->EMI_Bank_WSTWR ; |
||
146 | |||
147 | EMI_Bankx->OECR = EMI_InitStruct->EMI_Bank_WSTROEN; |
||
148 | |||
149 | EMI_Bankx->WECR = EMI_InitStruct->EMI_Bank_WSTWEN ; |
||
150 | |||
151 | EMI_Bankx->BCR &= EMI_MemWidth_Mask; |
||
152 | EMI_Bankx->BCR |= EMI_InitStruct->EMI_Bank_MemWidth; |
||
153 | |||
154 | EMI_Bankx->BCR &= EMI_WriteProtect_Mask; |
||
155 | EMI_Bankx->BCR |= EMI_InitStruct->EMI_Bank_WriteProtection; |
||
156 | |||
157 | EMI_Bankx->BCR &= EMI_PageModeRead_TL_Mask; |
||
158 | EMI_Bankx->BCR |= EMI_InitStruct->EMI_PageModeRead_TransferLength; |
||
159 | |||
160 | EMI_Bankx->BCR &= EMI_PageModeRead_Sel_Mask; |
||
161 | EMI_Bankx->BCR |= EMI_InitStruct->EMI_PageModeRead_Selection; |
||
162 | |||
163 | |||
164 | } |
||
165 | |||
166 | |||
167 | |||
168 | /******************* (C) COPYRIGHT 2006 STMicroelectronics *****END OF FILE****/ |