1 //*****************************************************************************
2 //
3 // epi.h - Prototypes and macros for the EPI module.
4 //
5 // Copyright (c) 2008-2012 Texas Instruments Incorporated.  All rights reserved.
6 // Software License Agreement
7 //
8 //   Redistribution and use in source and binary forms, with or without
9 //   modification, are permitted provided that the following conditions
10 //   are met:
11 //
12 //   Redistributions of source code must retain the above copyright
13 //   notice, this list of conditions and the following disclaimer.
14 //
15 //   Redistributions in binary form must reproduce the above copyright
16 //   notice, this list of conditions and the following disclaimer in the
17 //   documentation and/or other materials provided with the
18 //   distribution.
19 //
20 //   Neither the name of Texas Instruments Incorporated nor the names of
21 //   its contributors may be used to endorse or promote products derived
22 //   from this software without specific prior written permission.
23 //
24 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 //
36 // This is part of revision 9453 of the Stellaris Peripheral Driver Library.
37 //
38 //*****************************************************************************
39 
40 #ifndef __EPI_H__
41 #define __EPI_H__
42 
43 //*****************************************************************************
44 //
45 // If building with a C++ compiler, make all of the definitions in this header
46 // have a C binding.
47 //
48 //*****************************************************************************
49 #ifdef __cplusplus
50 extern "C"
51 {
52 #endif
53 
54 //*****************************************************************************
55 //
56 // Values that can be passed to EPIModeSet()
57 //
58 //*****************************************************************************
59 #define EPI_MODE_GENERAL                0x00000010
60 #define EPI_MODE_SDRAM                  0x00000011
61 #define EPI_MODE_HB8                    0x00000012
62 #define EPI_MODE_HB16                   0x00000013
63 #define EPI_MODE_DISABLE                0x00000000
64 
65 //*****************************************************************************
66 //
67 // Values that can be passed to EPIConfigSDRAMSet()
68 //
69 //*****************************************************************************
70 #define EPI_SDRAM_CORE_FREQ_0_15        0x00000000
71 #define EPI_SDRAM_CORE_FREQ_15_30       0x40000000
72 #define EPI_SDRAM_CORE_FREQ_30_50       0x80000000
73 #define EPI_SDRAM_CORE_FREQ_50_100      0xC0000000
74 #define EPI_SDRAM_LOW_POWER             0x00000200
75 #define EPI_SDRAM_FULL_POWER            0x00000000
76 #define EPI_SDRAM_SIZE_64MBIT           0x00000000
77 #define EPI_SDRAM_SIZE_128MBIT          0x00000001
78 #define EPI_SDRAM_SIZE_256MBIT          0x00000002
79 #define EPI_SDRAM_SIZE_512MBIT          0x00000003
80 
81 //*****************************************************************************
82 //
83 // Values that can be passed to EPIConfigGPModeSet()
84 //
85 //*****************************************************************************
86 #define EPI_GPMODE_CLKPIN               0x80000000
87 #define EPI_GPMODE_CLKGATE              0x40000000
88 #define EPI_GPMODE_RDYEN                0x10000000
89 #define EPI_GPMODE_FRAMEPIN             0x08000000
90 #define EPI_GPMODE_FRAME50              0x04000000
91 #define EPI_GPMODE_READWRITE            0x00200000
92 #define EPI_GPMODE_WRITE2CYCLE          0x00080000
93 #define EPI_GPMODE_READ2CYCLE           0x00040000
94 #define EPI_GPMODE_ASIZE_NONE           0x00000000
95 #define EPI_GPMODE_ASIZE_4              0x00000010
96 #define EPI_GPMODE_ASIZE_12             0x00000020
97 #define EPI_GPMODE_ASIZE_20             0x00000030
98 #define EPI_GPMODE_DSIZE_8              0x00000000
99 #define EPI_GPMODE_DSIZE_16             0x00000001
100 #define EPI_GPMODE_DSIZE_24             0x00000002
101 #define EPI_GPMODE_DSIZE_32             0x00000003
102 #define EPI_GPMODE_WORD_ACCESS          0x00000100
103 
104 //*****************************************************************************
105 //
106 // Values that can be passed to EPIConfigHB8ModeSet()
107 //
108 //*****************************************************************************
109 #define EPI_HB8_USE_TXEMPTY             0x00800000
110 #define EPI_HB8_USE_RXFULL              0x00400000
111 #define EPI_HB8_WRHIGH                  0x00200000
112 #define EPI_HB8_RDHIGH                  0x00100000
113 #define EPI_HB8_WRWAIT_0                0x00000000
114 #define EPI_HB8_WRWAIT_1                0x00000040
115 #define EPI_HB8_WRWAIT_2                0x00000080
116 #define EPI_HB8_WRWAIT_3                0x000000C0
117 #define EPI_HB8_RDWAIT_0                0x00000000
118 #define EPI_HB8_RDWAIT_1                0x00000010
119 #define EPI_HB8_RDWAIT_2                0x00000020
120 #define EPI_HB8_RDWAIT_3                0x00000030
121 #define EPI_HB8_MODE_ADMUX              0x00000000
122 #define EPI_HB8_MODE_ADDEMUX            0x00000001
123 #define EPI_HB8_MODE_SRAM               0x00000002
124 #define EPI_HB8_MODE_FIFO               0x00000003
125 #define EPI_HB8_WORD_ACCESS             0x00000100
126 #define EPI_HB8_CSCFG_ALE               0x00000000
127 #define EPI_HB8_CSCFG_CS                0x00000200
128 #define EPI_HB8_CSCFG_DUAL_CS           0x00000400
129 #define EPI_HB8_CSCFG_ALE_DUAL_CS       0x00000600
130 #define EPI_HB8_CSBAUD_DUAL             0x00000800
131 
132 #define EPI_HB8_CSCFG_MASK              0x00000600
133 
134 //*****************************************************************************
135 //
136 // Values that can be passed to EPIConfigHB16ModeSet()
137 //
138 //*****************************************************************************
139 #define EPI_HB16_USE_TXEMPTY            0x00800000
140 #define EPI_HB16_USE_RXFULL             0x00400000
141 #define EPI_HB16_WRHIGH                 0x00200000
142 #define EPI_HB16_RDHIGH                 0x00100000
143 #define EPI_HB16_WRWAIT_0               0x00000000
144 #define EPI_HB16_WRWAIT_1               0x00000040
145 #define EPI_HB16_WRWAIT_2               0x00000080
146 #define EPI_HB16_WRWAIT_3               0x000000C0
147 #define EPI_HB16_RDWAIT_0               0x00000000
148 #define EPI_HB16_RDWAIT_1               0x00000010
149 #define EPI_HB16_RDWAIT_2               0x00000020
150 #define EPI_HB16_RDWAIT_3               0x00000030
151 #define EPI_HB16_MODE_ADMUX             0x00000000
152 #define EPI_HB16_MODE_ADDEMUX           0x00000001
153 #define EPI_HB16_MODE_SRAM              0x00000002
154 #define EPI_HB16_MODE_FIFO              0x00000003
155 #define EPI_HB16_BSEL                   0x00000004
156 #define EPI_HB16_WORD_ACCESS            0x00000100
157 #define EPI_HB16_CSCFG_ALE              0x00000000
158 #define EPI_HB16_CSCFG_CS               0x00000200
159 #define EPI_HB16_CSCFG_DUAL_CS          0x00000400
160 #define EPI_HB16_CSCFG_ALE_DUAL_CS      0x00000600
161 #define EPI_HB16_CSBAUD_DUAL            0x00000800
162 
163 #define EPI_HB16_CSCFG_MASK             0x00000600
164 
165 //*****************************************************************************
166 //
167 // Values that can be passed to EPIConfigSDRAMSet()
168 //
169 //*****************************************************************************
170 #define EPI_ADDR_PER_SIZE_256B          0x00000000
171 #define EPI_ADDR_PER_SIZE_64KB          0x00000040
172 #define EPI_ADDR_PER_SIZE_16MB          0x00000080
173 #define EPI_ADDR_PER_SIZE_256MB         0x000000C0
174 #define EPI_ADDR_PER_BASE_NONE          0x00000000
175 #define EPI_ADDR_PER_BASE_A             0x00000010
176 #define EPI_ADDR_PER_BASE_C             0x00000020
177 #define EPI_ADDR_RAM_SIZE_256B          0x00000000
178 #define EPI_ADDR_RAM_SIZE_64KB          0x00000004
179 #define EPI_ADDR_RAM_SIZE_16MB          0x00000008
180 #define EPI_ADDR_RAM_SIZE_256MB         0x0000000C
181 #define EPI_ADDR_RAM_BASE_NONE          0x00000000
182 #define EPI_ADDR_RAM_BASE_6             0x00000001
183 #define EPI_ADDR_RAM_BASE_8             0x00000002
184 
185 //*****************************************************************************
186 //
187 // Values that can be passed to EPINonBlockingReadConfigure()
188 //
189 //*****************************************************************************
190 #define EPI_NBCONFIG_SIZE_8             1
191 #define EPI_NBCONFIG_SIZE_16            2
192 #define EPI_NBCONFIG_SIZE_32            3
193 
194 //*****************************************************************************
195 //
196 // Values that can be passed to EPIFIFOConfig()
197 //
198 //*****************************************************************************
199 #define EPI_FIFO_CONFIG_WTFULLERR       0x00020000
200 #define EPI_FIFO_CONFIG_RSTALLERR       0x00010000
201 #define EPI_FIFO_CONFIG_TX_EMPTY        0x00000000
202 #define EPI_FIFO_CONFIG_TX_1_4          0x00000020
203 #define EPI_FIFO_CONFIG_TX_1_2          0x00000030
204 #define EPI_FIFO_CONFIG_TX_3_4          0x00000040
205 #define EPI_FIFO_CONFIG_RX_1_8          0x00000001
206 #define EPI_FIFO_CONFIG_RX_1_4          0x00000002
207 #define EPI_FIFO_CONFIG_RX_1_2          0x00000003
208 #define EPI_FIFO_CONFIG_RX_3_4          0x00000004
209 #define EPI_FIFO_CONFIG_RX_7_8          0x00000005
210 #define EPI_FIFO_CONFIG_RX_FULL         0x00000006
211 
212 //*****************************************************************************
213 //
214 // Values that can be passed to EPIIntEnable(), EPIIntDisable(), or returned
215 // as flags from EPIIntStatus()
216 //
217 //*****************************************************************************
218 #define EPI_INT_TXREQ                   0x00000004
219 #define EPI_INT_RXREQ                   0x00000002
220 #define EPI_INT_ERR                     0x00000001
221 
222 //*****************************************************************************
223 //
224 // Values that can be passed to EPIIntErrorClear(), or returned as flags from
225 // EPIIntErrorStatus()
226 //
227 //*****************************************************************************
228 #define EPI_INT_ERR_WTFULL              0x00000004
229 #define EPI_INT_ERR_RSTALL              0x00000002
230 #define EPI_INT_ERR_TIMEOUT             0x00000001
231 
232 //*****************************************************************************
233 //
234 // API Function prototypes
235 //
236 //*****************************************************************************
237 extern void EPIModeSet(unsigned long ulBase, unsigned long ulMode);
238 extern void EPIDividerSet(unsigned long ulBase, unsigned long ulDivider);
239 extern void EPIConfigSDRAMSet(unsigned long ulBase, unsigned long ulConfig,
240                               unsigned long ulRefresh);
241 extern void EPIConfigGPModeSet(unsigned long ulBase, unsigned long ulConfig,
242                                unsigned long ulFrameCount,
243                                unsigned long ulMaxWait);
244 extern void EPIConfigHB8Set(unsigned long ulBase, unsigned long ulConfig,
245                             unsigned long ulMaxWait);
246 extern void EPIConfigHB16Set(unsigned long ulBase, unsigned long ulConfig,
247                              unsigned long ulMaxWait);
248 extern void EPIAddressMapSet(unsigned long ulBase, unsigned long ulMap);
249 extern void EPINonBlockingReadConfigure(unsigned long ulBase,
250                                         unsigned long ulChannel,
251                                         unsigned long ulDataSize,
252                                         unsigned long ulAddress);
253 extern void EPINonBlockingReadStart(unsigned long ulBase,
254                                     unsigned long ulChannel,
255                                     unsigned long ulCount);
256 extern void EPINonBlockingReadStop(unsigned long ulBase,
257                                    unsigned long ulChannel);
258 extern unsigned long EPINonBlockingReadCount(unsigned long ulBase,
259                                              unsigned long ulChannel);
260 extern unsigned long EPINonBlockingReadAvail(unsigned long ulBase);
261 extern unsigned long EPINonBlockingReadGet32(unsigned long ulBase,
262                                              unsigned long ulCount,
263                                              unsigned long *pulBuf);
264 extern unsigned long EPINonBlockingReadGet16(unsigned long ulBase,
265                                              unsigned long ulCount,
266                                              unsigned short *pusBuf);
267 extern unsigned long EPINonBlockingReadGet8(unsigned long ulBase,
268                                             unsigned long ulCount,
269                                             unsigned char *pucBuf);
270 extern void EPIFIFOConfig(unsigned long ulBase, unsigned long ulConfig);
271 extern unsigned long EPIWriteFIFOCountGet(unsigned long ulBase);
272 extern void EPIIntEnable(unsigned long ulBase, unsigned long ulIntFlags);
273 extern void EPIIntDisable(unsigned long ulBase, unsigned long ulIntFlags);
274 extern unsigned long EPIIntStatus(unsigned long ulBase, tBoolean bMasked);
275 extern unsigned long EPIIntErrorStatus(unsigned long ulBase);
276 extern void EPIIntErrorClear(unsigned long ulBase, unsigned long ulErrFlags);
277 extern void EPIIntRegister(unsigned long ulBase, void (*pfnHandler)(void));
278 extern void EPIIntUnregister(unsigned long ulBase);
279 
280 //*****************************************************************************
281 //
282 // Several EPI APIs and labels have been renamed, with the original definition
283 // name being deprecated.  These defines provide backward compatibility.
284 //
285 //*****************************************************************************
286 #ifndef DEPRECATED
287 #define EPI_MODE_NONE           EPI_MODE_GENERAL
288 #define EPI_NONMODE_CLKPIN      EPI_GPMODE_CLKPIN
289 #define EPI_NONMODE_CLKSTOP     EPI_GPMODE_CLKGATE
290 #define EPI_NONMODE_CLKENA      EPI_GPMODE_RDYEN
291 #define EPI_NONMODE_FRAMEPIN    EPI_GPMODE_FRAMEPIN
292 #define EPI_NONMODE_FRAME50     EPI_GPMODE_FRAME50
293 #define EPI_NONMODE_READWRITE   EPI_GPMODE_READWRITE
294 #define EPI_NONMODE_WRITE2CYCLE EPI_GPMODE_WRITE2CYCLE
295 #define EPI_NONMODE_READ2CYCLE  EPI_GPMODE_READ2CYCLE
296 #define EPI_NONMODE_ASIZE_NONE  EPI_GPMODE_ASIZE_NONE
297 #define EPI_NONMODE_ASIZE_4     EPI_GPMODE_ASIZE_4
298 #define EPI_NONMODE_ASIZE_12    EPI_GPMODE_ASIZE_12
299 #define EPI_NONMODE_ASIZE_20    EPI_GPMODE_ASIZE_20
300 #define EPI_NONMODE_DSIZE_8     EPI_GPMODE_DSIZE_8
301 #define EPI_NONMODE_DSIZE_16    EPI_GPMODE_DSIZE_16
302 #define EPI_NONMODE_DSIZE_24    EPI_GPMODE_DSIZE_24
303 #define EPI_NONMODE_DSIZE_32    EPI_GPMODE_DSIZE_32
304 #define EPI_NONMODE_WORD_ACCESS EPI_GPMODE_WORD_ACCESS
305 
306 #define EPINonBlockingWriteCount(a) EPIWriteFIFOCountGet(a)
307 #define EPIConfigNoModeSet(a, b, c, d) EPIConfigGPModeSet((a), (b), (c), (d))
308 #endif
309 
310 //*****************************************************************************
311 //
312 // Mark the end of the C bindings section for C++ compilers.
313 //
314 //*****************************************************************************
315 #ifdef __cplusplus
316 }
317 #endif
318 
319 #endif //  __EPI_H__
320