1 /***************************************************************************//**
\r
3 * @brief External Bus Iterface (EBI) peripheral API
\r
5 *******************************************************************************
\r
7 * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>
\r
8 *******************************************************************************
\r
10 * Permission is granted to anyone to use this software for any purpose,
\r
11 * including commercial applications, and to alter it and redistribute it
\r
12 * freely, subject to the following restrictions:
\r
14 * 1. The origin of this software must not be misrepresented; you must not
\r
15 * claim that you wrote the original software.
\r
16 * 2. Altered source versions must be plainly marked as such, and must not be
\r
17 * misrepresented as being the original software.
\r
18 * 3. This notice may not be removed or altered from any source distribution.
\r
20 * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
\r
21 * obligation to support this Software. Silicon Labs is providing the
\r
22 * Software "AS IS", with no express or implied warranties of any kind,
\r
23 * including, but not limited to, any implied warranties of merchantability
\r
24 * or fitness for any particular purpose or warranties against infringement
\r
25 * of any proprietary rights of a third party.
\r
27 * Silicon Labs will not be liable for any consequential, incidental, or
\r
28 * special damages, or any other relief, or for any claim by any third party,
\r
29 * arising from your use of this Software.
\r
31 ******************************************************************************/
\r
33 #ifndef __SILICON_LABS_EM_EBI_H__
\r
34 #define __SILICON_LABS_EM_EBI_H__
\r
36 #include "em_device.h"
\r
37 #if defined(EBI_COUNT) && (EBI_COUNT > 0)
\r
40 #include <stdbool.h>
\r
41 #include "em_assert.h"
\r
47 /***************************************************************************//**
\r
48 * @addtogroup EM_Library
\r
50 ******************************************************************************/
\r
52 /***************************************************************************//**
\r
55 ******************************************************************************/
\r
57 /***************************************************************************//**
\r
60 * --------- ---------
\r
61 * | | /| |\ | Ext. |
\r
62 * | EBI | / --------- \ | Async |
\r
63 * | | \ --------- / | Device|
\r
65 * --------- ---------
\r
66 * Parallel interface
\r
69 ******************************************************************************/
\r
71 /*******************************************************************************
\r
72 ******************************* DEFINES ***********************************
\r
73 ******************************************************************************/
\r
75 #define EBI_BANK0 (uint32_t)(1 << 1) /**< EBI address bank 0 */
\r
76 #define EBI_BANK1 (uint32_t)(1 << 2) /**< EBI address bank 1 */
\r
77 #define EBI_BANK2 (uint32_t)(1 << 3) /**< EBI address bank 2 */
\r
78 #define EBI_BANK3 (uint32_t)(1 << 4) /**< EBI address bank 3 */
\r
80 #define EBI_CS0 (uint32_t)(1 << 1) /**< EBI chip select line 0 */
\r
81 #define EBI_CS1 (uint32_t)(1 << 2) /**< EBI chip select line 1 */
\r
82 #define EBI_CS2 (uint32_t)(1 << 3) /**< EBI chip select line 2 */
\r
83 #define EBI_CS3 (uint32_t)(1 << 4) /**< EBI chip select line 3 */
\r
85 /*******************************************************************************
\r
86 ******************************** ENUMS ************************************
\r
87 ******************************************************************************/
\r
89 /** EBI Mode of operation */
\r
92 /** 8 data bits, 8 address bits */
\r
93 ebiModeD8A8 = EBI_CTRL_MODE_D8A8,
\r
94 /** 16 data bits, 16 address bits, using address latch enable */
\r
95 ebiModeD16A16ALE = EBI_CTRL_MODE_D16A16ALE,
\r
96 /** 8 data bits, 24 address bits, using address latch enable */
\r
97 ebiModeD8A24ALE = EBI_CTRL_MODE_D8A24ALE,
\r
98 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
\r
100 ebiModeD16 = EBI_CTRL_MODE_D16,
\r
102 } EBI_Mode_TypeDef;
\r
104 /** EBI Polarity configuration */
\r
111 } EBI_Polarity_TypeDef;
\r
113 /** EBI Pin Line types */
\r
116 /** Address Ready line */
\r
118 /** Address Latch Enable line */
\r
120 /** Write Enable line */
\r
122 /** Read Enable line */
\r
124 /** Chip Select line */
\r
126 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
\r
130 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
\r
131 /** TFT VSYNC line */
\r
133 /** TFT HSYNC line */
\r
135 /** TFT Data enable line */
\r
137 /** TFT DCLK line */
\r
139 /** TFT Chip select line */
\r
142 } EBI_Line_TypeDef;
\r
144 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
\r
145 /** Address Pin Enable, lower limit - lower range of pins to enable */
\r
148 /** Adress lines EBI_A[0] and upwards are enabled by APEN */
\r
149 ebiALowA0 = EBI_ROUTE_ALB_A0,
\r
150 /** Adress lines EBI_A[8] and upwards are enabled by APEN */
\r
151 ebiALowA8 = EBI_ROUTE_ALB_A8,
\r
152 /** Adress lines EBI_A[16] and upwards are enabled by APEN */
\r
153 ebiALowA16 = EBI_ROUTE_ALB_A16,
\r
154 /** Adress lines EBI_A[24] and upwards are enabled by APEN */
\r
155 ebiALowA24 = EBI_ROUTE_ALB_A24,
\r
156 } EBI_ALow_TypeDef;
\r
158 /** Adress Pin Enable, high limit - higher limit of pins to enable */
\r
161 /** All EBI_A pins are disabled */
\r
162 ebiAHighA0 = EBI_ROUTE_APEN_A0,
\r
163 /** All EBI_A[4:ALow] are enabled */
\r
164 ebiAHighA5 = EBI_ROUTE_APEN_A5,
\r
165 /** All EBI_A[5:ALow] are enabled */
\r
166 ebiAHighA6 = EBI_ROUTE_APEN_A6,
\r
167 /** All EBI_A[6:ALow] are enabled */
\r
168 ebiAHighA7 = EBI_ROUTE_APEN_A7,
\r
169 /** All EBI_A[7:ALow] are enabled */
\r
170 ebiAHighA8 = EBI_ROUTE_APEN_A8,
\r
171 /** All EBI_A[8:ALow] are enabled */
\r
172 ebiAHighA9 = EBI_ROUTE_APEN_A9,
\r
173 /** All EBI_A[9:ALow] are enabled */
\r
174 ebiAHighA10 = EBI_ROUTE_APEN_A10,
\r
175 /** All EBI_A[10:ALow] are enabled */
\r
176 ebiAHighA11 = EBI_ROUTE_APEN_A11,
\r
177 /** All EBI_A[11:ALow] are enabled */
\r
178 ebiAHighA12 = EBI_ROUTE_APEN_A12,
\r
179 /** All EBI_A[12:ALow] are enabled */
\r
180 ebiAHighA13 = EBI_ROUTE_APEN_A13,
\r
181 /** All EBI_A[13:ALow] are enabled */
\r
182 ebiAHighA14 = EBI_ROUTE_APEN_A14,
\r
183 /** All EBI_A[14:ALow] are enabled */
\r
184 ebiAHighA15 = EBI_ROUTE_APEN_A15,
\r
185 /** All EBI_A[15:ALow] are enabled */
\r
186 ebiAHighA16 = EBI_ROUTE_APEN_A16,
\r
187 /** All EBI_A[16:ALow] are enabled */
\r
188 ebiAHighA17 = EBI_ROUTE_APEN_A17,
\r
189 /** All EBI_A[17:ALow] are enabled */
\r
190 ebiAHighA18 = EBI_ROUTE_APEN_A18,
\r
191 /** All EBI_A[18:ALow] are enabled */
\r
192 ebiAHighA19 = EBI_ROUTE_APEN_A19,
\r
193 /** All EBI_A[19:ALow] are enabled */
\r
194 ebiAHighA20 = EBI_ROUTE_APEN_A20,
\r
195 /** All EBI_A[20:ALow] are enabled */
\r
196 ebiAHighA21 = EBI_ROUTE_APEN_A21,
\r
197 /** All EBI_A[21:ALow] are enabled */
\r
198 ebiAHighA22 = EBI_ROUTE_APEN_A22,
\r
199 /** All EBI_A[22:ALow] are enabled */
\r
200 ebiAHighA23 = EBI_ROUTE_APEN_A23,
\r
201 /** All EBI_A[23:ALow] are enabled */
\r
202 ebiAHighA24 = EBI_ROUTE_APEN_A24,
\r
203 /** All EBI_A[24:ALow] are enabled */
\r
204 ebiAHighA25 = EBI_ROUTE_APEN_A25,
\r
205 /** All EBI_A[25:ALow] are enabled */
\r
206 ebiAHighA26 = EBI_ROUTE_APEN_A26,
\r
207 /** All EBI_A[26:ALow] are enabled */
\r
208 ebiAHighA27 = EBI_ROUTE_APEN_A27,
\r
209 /** All EBI_A[27:ALow] are enabled */
\r
210 ebiAHighA28 = EBI_ROUTE_APEN_A28,
\r
211 } EBI_AHigh_TypeDef;
\r
213 /** EBI I/O Alternate Pin Location */
\r
215 /** EBI PIN I/O Location 0 */
\r
216 ebiLocation0 = EBI_ROUTE_LOCATION_LOC0,
\r
217 /** EBI PIN I/O Location 1 */
\r
218 ebiLocation1 = EBI_ROUTE_LOCATION_LOC1,
\r
219 /** EBI PIN I/O Location 2 */
\r
220 ebiLocation2 = EBI_ROUTE_LOCATION_LOC2
\r
221 } EBI_Location_TypeDef;
\r
225 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
\r
226 /** EBI TFT Graphics Bank Select */
\r
229 /** Memory BANK0 contains frame buffer */
\r
230 ebiTFTBank0 = EBI_TFTCTRL_BANKSEL_BANK0,
\r
231 /** Memory BANK1 contains frame buffer */
\r
232 ebiTFTBank1 = EBI_TFTCTRL_BANKSEL_BANK1,
\r
233 /** Memory BANK2 contains frame buffer */
\r
234 ebiTFTBank2 = EBI_TFTCTRL_BANKSEL_BANK2,
\r
235 /** Memory BANK3 contains frame buffer */
\r
236 ebiTFTBank3 = EBI_TFTCTRL_BANKSEL_BANK3
\r
237 } EBI_TFTBank_TypeDef;
\r
239 /** Masking and Alpha blending source color*/
\r
242 /** Use memory as source color for masking/alpha blending */
\r
243 ebiTFTColorSrcMem = EBI_TFTCTRL_COLOR1SRC_MEM,
\r
244 /** Use PIXEL1 register as source color for masking/alpha blending */
\r
245 ebiTFTColorSrcPixel1 = EBI_TFTCTRL_COLOR1SRC_PIXEL1,
\r
246 } EBI_TFTColorSrc_TypeDef;
\r
248 /** Bus Data Interleave Mode */
\r
251 /** Unlimited interleaved accesses per EBI_DCLK period. Can cause jitter */
\r
252 ebiTFTInterleaveUnlimited = EBI_TFTCTRL_INTERLEAVE_UNLIMITED,
\r
253 /** Allow 1 interleaved access per EBI_DCLK period */
\r
254 ebiTFTInterleaveOnePerDClk = EBI_TFTCTRL_INTERLEAVE_ONEPERDCLK,
\r
255 /** Only allow accesses during porch periods */
\r
256 ebiTFTInterleavePorch = EBI_TFTCTRL_INTERLEAVE_PORCH,
\r
257 } EBI_TFTInterleave_TypeDef;
\r
259 /** Control frame base pointer copy */
\r
262 /** Trigger update of frame buffer pointer on vertical sync */
\r
263 ebiTFTFrameBufTriggerVSync = EBI_TFTCTRL_FBCTRIG_VSYNC,
\r
264 /** Trigger update of frame buffer pointer on horizontal sync */
\r
265 ebiTFTFrameBufTriggerHSync = EBI_TFTCTRL_FBCTRIG_HSYNC,
\r
266 } EBI_TFTFrameBufTrigger_TypeDef;
\r
268 /** Control of mask and alpha blending mode */
\r
271 /** Masking and blending are disabled */
\r
272 ebiTFTMBDisabled = EBI_TFTCTRL_MASKBLEND_DISABLED,
\r
273 /** Internal masking */
\r
274 ebiTFTMBIMask = EBI_TFTCTRL_MASKBLEND_IMASK,
\r
275 /** Internal alpha blending */
\r
276 ebiTFTMBIAlpha = EBI_TFTCTRL_MASKBLEND_IALPHA,
\r
277 /** Internal masking and alpha blending are enabled */
\r
278 ebiTFTMBIMaskAlpha = EBI_TFTCTRL_MASKBLEND_IMASKIALPHA,
\r
279 /** External masking */
\r
280 ebiTFTMBEMask = EBI_TFTCTRL_MASKBLEND_EMASK,
\r
281 /** External alpha blending */
\r
282 ebiTFTMBEAlpha = EBI_TFTCTRL_MASKBLEND_EALPHA,
\r
283 /** External masking and alpha blending */
\r
284 ebiTFTMBEMaskAlpha = EBI_TFTCTRL_MASKBLEND_EMASKEALPHA,
\r
285 } EBI_TFTMaskBlend_TypeDef;
\r
287 /** TFT Direct Drive mode */
\r
291 ebiTFTDDModeDisabled = EBI_TFTCTRL_DD_DISABLED,
\r
292 /** Direct Drive from internal memory */
\r
293 ebiTFTDDModeInternal = EBI_TFTCTRL_DD_INTERNAL,
\r
294 /** Direct Drive from external memory */
\r
295 ebiTFTDDModeExternal = EBI_TFTCTRL_DD_EXTERNAL,
\r
296 } EBI_TFTDDMode_TypeDef;
\r
298 /** TFT Data Increment Width */
\r
301 /** Pixel increments are 1 byte at a time */
\r
302 ebiTFTWidthByte = EBI_TFTCTRL_WIDTH_BYTE,
\r
303 /** Pixel increments are 2 bytes (half word) */
\r
304 ebiTFTWidthHalfWord = EBI_TFTCTRL_WIDTH_HALFWORD,
\r
305 } EBI_TFTWidth_TypeDef;
\r
309 /*******************************************************************************
\r
310 ******************************* STRUCTS ***********************************
\r
311 ******************************************************************************/
\r
313 /** EBI Initialization structure */
\r
316 /** EBI operation mode, data and address limits */
\r
317 EBI_Mode_TypeDef mode;
\r
318 /** Address Ready pin polarity, active high or low */
\r
319 EBI_Polarity_TypeDef ardyPolarity;
\r
320 /** Address Latch Enable pin polarity, active high or low */
\r
321 EBI_Polarity_TypeDef alePolarity;
\r
322 /** Write Enable pin polarity, active high or low */
\r
323 EBI_Polarity_TypeDef wePolarity;
\r
324 /** Read Enable pin polarity, active high or low */
\r
325 EBI_Polarity_TypeDef rePolarity;
\r
326 /** Chip Select pin polarity, active high or low */
\r
327 EBI_Polarity_TypeDef csPolarity;
\r
328 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
\r
329 /** Byte Lane pin polaritym, active high or low */
\r
330 EBI_Polarity_TypeDef blPolarity;
\r
331 /** Flag to enable or disable Byte Lane support */
\r
333 /** Flag to enable or disable idle state insertion between transfers */
\r
336 /** Flag to enable or disable Address Ready support */
\r
338 /** Set to turn off 32 cycle timeout ability */
\r
339 bool ardyDisableTimeout;
\r
340 /** Mask of flags which selects address banks to configure EBI_BANK<0-3> */
\r
342 /** Mask of flags which selects chip select lines to configure EBI_CS<0-3> */
\r
344 /** Number of cycles address is held after Adress Latch Enable is asserted */
\r
345 int addrSetupCycles;
\r
346 /** Number of cycles address is driven onto the ADDRDAT bus before ALE is asserted */
\r
347 int addrHoldCycles;
\r
348 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
\r
349 /** Enable or disables half cycle duration of the ALE strobe in the last address setup cycle */
\r
352 /** Number of cycles for address setup before REn is asserted */
\r
353 int readSetupCycles;
\r
354 /** Number of cycles REn is held active */
\r
355 int readStrobeCycles;
\r
356 /** Number of cycles CSn is held active after REn is deasserted */
\r
357 int readHoldCycles;
\r
358 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
\r
359 /** Enable or disable page mode reads */
\r
361 /** Enables or disable prefetching from sequential addresses */
\r
363 /** Enabled or disables half cycle duration of the REn signal in the last strobe cycle */
\r
366 /** Number of cycles for address setup before WEn is asserted */
\r
367 int writeSetupCycles;
\r
368 /** Number of cycles WEn is held active */
\r
369 int writeStrobeCycles;
\r
370 /** Number of cycles CSn is held active after WEn is deasserted */
\r
371 int writeHoldCycles;
\r
372 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
\r
373 /** Enable or disable the write buffer */
\r
374 bool writeBufferDisable;
\r
375 /** Enables or disables half cycle duration of the WEn signal in the last strobe cycle */
\r
377 /** Lower address pin limit to enable */
\r
378 EBI_ALow_TypeDef aLow;
\r
379 /** High address pin limit to enable */
\r
380 EBI_AHigh_TypeDef aHigh;
\r
381 /** Pin Location */
\r
382 EBI_Location_TypeDef location;
\r
384 /** Flag, if EBI should be enabled after configuration */
\r
386 } EBI_Init_TypeDef;
\r
388 /** Default config for EBI init structures */
\r
389 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
\r
390 #define EBI_INIT_DEFAULT \
\r
392 ebiModeD8A8, /* 8 bit address, 8 bit data */ \
\r
393 ebiActiveLow, /* ARDY polarity */ \
\r
394 ebiActiveLow, /* ALE polarity */ \
\r
395 ebiActiveLow, /* WE polarity */ \
\r
396 ebiActiveLow, /* RE polarity */ \
\r
397 ebiActiveLow, /* CS polarity */ \
\r
398 ebiActiveLow, /* BL polarity */ \
\r
399 false, /* enable BL */ \
\r
400 false, /* enable NOIDLE */ \
\r
401 false, /* enable ARDY */ \
\r
402 false, /* don't disable ARDY timeout */ \
\r
403 EBI_BANK0, /* enable bank 0 */ \
\r
404 EBI_CS0, /* enable chip select 0 */ \
\r
405 0, /* addr setup cycles */ \
\r
406 1, /* addr hold cycles */ \
\r
407 false, /* do not enable half cycle ALE strobe */ \
\r
408 0, /* read setup cycles */ \
\r
409 0, /* read strobe cycles */ \
\r
410 0, /* read hold cycles */ \
\r
411 false, /* disable page mode */ \
\r
412 false, /* disable prefetch */ \
\r
413 false, /* do not enable half cycle REn strobe */ \
\r
414 0, /* write setup cycles */ \
\r
415 0, /* write strobe cycles */ \
\r
416 1, /* write hold cycles */ \
\r
417 false, /* do not disable the write buffer */ \
\r
418 false, /* do not enable halc cycle WEn strobe */ \
\r
419 ebiALowA0, /* ALB - Low bound, address lines */ \
\r
420 ebiAHighA0, /* APEN - High bound, address lines */ \
\r
421 ebiLocation0, /* Use Location 0 */ \
\r
422 true, /* enable EBI */ \
\r
425 #define EBI_INIT_DEFAULT \
\r
427 ebiModeD8A8, /* 8 bit address, 8 bit data */ \
\r
428 ebiActiveLow, /* ARDY polarity */ \
\r
429 ebiActiveLow, /* ALE polarity */ \
\r
430 ebiActiveLow, /* WE polarity */ \
\r
431 ebiActiveLow, /* RE polarity */ \
\r
432 ebiActiveLow, /* CS polarity */ \
\r
433 false, /* enable ARDY */ \
\r
434 false, /* don't disable ARDY timeout */ \
\r
435 EBI_BANK0, /* enable bank 0 */ \
\r
436 EBI_CS0, /* enable chip select 0 */ \
\r
437 0, /* addr setup cycles */ \
\r
438 1, /* addr hold cycles */ \
\r
439 0, /* read setup cycles */ \
\r
440 0, /* read strobe cycles */ \
\r
441 0, /* read hold cycles */ \
\r
442 0, /* write setup cycles */ \
\r
443 0, /* write strobe cycles */ \
\r
444 1, /* write hold cycles */ \
\r
445 true, /* enable EBI */ \
\r
449 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
\r
451 /** TFT Initialization structure */
\r
454 /** External memory bank for driving display */
\r
455 EBI_TFTBank_TypeDef bank;
\r
457 EBI_TFTWidth_TypeDef width;
\r
458 /** Color source for masking and alpha blending */
\r
459 EBI_TFTColorSrc_TypeDef colSrc;
\r
460 /** Bus Interleave mode */
\r
461 EBI_TFTInterleave_TypeDef interleave;
\r
462 /** Trigger for updating frame buffer pointer */
\r
463 EBI_TFTFrameBufTrigger_TypeDef fbTrigger;
\r
464 /** Drive DCLK from negative clock edge of internal clock */
\r
466 /** Masking and alpha blending mode */
\r
467 EBI_TFTMaskBlend_TypeDef maskBlend;
\r
468 /** TFT Direct Drive mode */
\r
469 EBI_TFTDDMode_TypeDef driveMode;
\r
470 /** TFT Polarity for Chip Select (CS) Line */
\r
471 EBI_Polarity_TypeDef csPolarity;
\r
472 /** TFT Polarity for Data Clock (DCLK) Line */
\r
473 EBI_Polarity_TypeDef dclkPolarity;
\r
474 /** TFT Polarity for Data Enable (DATAEN) Line */
\r
475 EBI_Polarity_TypeDef dataenPolarity;
\r
476 /** TFT Polarity for Horizontal Sync (HSYNC) Line */
\r
477 EBI_Polarity_TypeDef hsyncPolarity;
\r
478 /** TFT Polarity for Vertical Sync (VSYNC) Line */
\r
479 EBI_Polarity_TypeDef vsyncPolarity;
\r
480 /** Horizontal size in pixels */
\r
482 /** Horizontal Front Porch Size */
\r
484 /** Horizontal Back Porch Size */
\r
486 /** Horizontal Synchronization Pulse Width */
\r
488 /** Vertical size in pixels */
\r
490 /** Vertical Front Porch Size */
\r
492 /** Vertical Back Porch Size */
\r
494 /** Vertical Synchronization Pulse Width */
\r
496 /** TFT Frame Buffer address, offset to EBI bank base address */
\r
497 uint32_t addressOffset;
\r
498 /** TFT DCLK period in internal cycles */
\r
500 /** Starting position of External Direct Drive relative to DCLK inactive edge */
\r
502 /** Number of cycles RGB data is driven before active edge of DCLK */
\r
504 /** Number of cycles RGB data is held after active edge of DCLK */
\r
506 } EBI_TFTInit_TypeDef;
\r
508 /** Default configuration for EBI TFT init structure */
\r
509 #define EBI_TFTINIT_DEFAULT \
\r
511 ebiTFTBank0, /* Select EBI Bank 0 */ \
\r
512 ebiTFTWidthHalfWord, /* Select 2-byte increments */ \
\r
513 ebiTFTColorSrcMem, /* Use memory as source for mask/blending */ \
\r
514 ebiTFTInterleaveUnlimited, /* Unlimited interleaved accesses */ \
\r
515 ebiTFTFrameBufTriggerVSync, /* VSYNC as frame buffer update trigger */ \
\r
516 false, /* Drive DCLK from negative edge of internal clock */ \
\r
517 ebiTFTMBDisabled, /* No masking and alpha blending enabled */ \
\r
518 ebiTFTDDModeExternal, /* Drive from external memory */ \
\r
519 ebiActiveLow, /* CS Active Low polarity */ \
\r
520 ebiActiveLow, /* DCLK Active Low polarity */ \
\r
521 ebiActiveLow, /* DATAEN Active Low polarity */ \
\r
522 ebiActiveLow, /* HSYNC Active Low polarity */ \
\r
523 ebiActiveLow, /* VSYNC Active Low polarity */ \
\r
524 320, /* Horizontal size in pixels */ \
\r
525 1, /* Horizontal Front Porch */ \
\r
526 29, /* Horizontal Back Porch */ \
\r
527 2, /* Horizontal Synchronization Pulse Width */ \
\r
528 240, /* Vertical size in pixels */ \
\r
529 1, /* Vertical Front Porch */ \
\r
530 4, /* Vertical Back Porch */ \
\r
531 2, /* Vertical Synchronization Pulse Width */ \
\r
532 0x0000, /* Address offset to EBI memory base */ \
\r
533 5, /* DCLK Period */ \
\r
534 2, /* DCLK Start */ \
\r
535 1, /* DCLK Setup cycles */ \
\r
536 1, /* DCLK Hold cycles */ \
\r
540 /*******************************************************************************
\r
541 ***************************** PROTOTYPES **********************************
\r
542 ******************************************************************************/
\r
544 void EBI_Init(const EBI_Init_TypeDef *ebiInit);
\r
545 void EBI_Disable(void);
\r
546 uint32_t EBI_BankAddress(uint32_t bank);
\r
547 void EBI_BankEnable(uint32_t banks, bool enable);
\r
549 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
\r
550 void EBI_TFTInit(const EBI_TFTInit_TypeDef *ebiTFTInit);
\r
551 void EBI_TFTSizeSet(uint32_t horizontal, uint32_t vertical);
\r
552 void EBI_TFTHPorchSet(int front, int back, int pulseWidth);
\r
553 void EBI_TFTVPorchSet(int front, int back, int pulseWidth);
\r
554 void EBI_TFTTimingSet(int dclkPeriod, int start, int setup, int hold);
\r
557 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)
\r
558 /* This functionality is only available on devices with independent timing support */
\r
559 void EBI_BankReadTimingSet(uint32_t bank, int setupCycles, int strobeCycles, int holdCycles);
\r
560 void EBI_BankReadTimingConfig(uint32_t bank, bool pageMode, bool prefetch, bool halfRE);
\r
562 void EBI_BankWriteTimingSet(uint32_t bank, int setupCycles, int strobeCycles, int holdCycles);
\r
563 void EBI_BankWriteTimingConfig(uint32_t bank, bool writeBufDisable, bool halfWE);
\r
565 void EBI_BankAddressTimingSet(uint32_t bank, int setupCycles, int holdCycles);
\r
566 void EBI_BankAddressTimingConfig(uint32_t bank, bool halfALE);
\r
568 void EBI_BankPolaritySet(uint32_t bank, EBI_Line_TypeDef line, EBI_Polarity_TypeDef polarity);
\r
569 void EBI_BankByteLaneEnable(uint32_t bank, bool enable);
\r
570 void EBI_AltMapEnable(bool enable);
\r
572 /***************************************************************************//**
\r
574 * Enable or disable TFT Direct Drive
\r
577 * Drive from Internal or External memory, or Disable Direct Drive
\r
578 ******************************************************************************/
\r
579 __STATIC_INLINE void EBI_TFTEnable(EBI_TFTDDMode_TypeDef mode)
\r
581 EBI->TFTCTRL = (EBI->TFTCTRL & ~(_EBI_TFTCTRL_DD_MASK)) | (uint32_t) mode;
\r
585 /***************************************************************************//**
\r
587 * Configure frame buffer pointer
\r
589 * @param[in] address
\r
590 * Frame pointer address, as offset by EBI base address
\r
591 ******************************************************************************/
\r
592 __STATIC_INLINE void EBI_TFTFrameBaseSet(uint32_t address)
\r
594 EBI->TFTFRAMEBASE = (uint32_t) address;
\r
598 /***************************************************************************//**
\r
599 * @brief Set TFT Pixel Color 0 or 1
\r
602 * Which pixel instance to set
\r
604 * Color of pixel, 16-bit value
\r
605 ******************************************************************************/
\r
606 __STATIC_INLINE void EBI_TFTPixelSet(int pixel, uint32_t color)
\r
608 EFM_ASSERT(pixel == 0 || pixel == 1);
\r
612 EBI->TFTPIXEL0 = color;
\r
616 EBI->TFTPIXEL1 = color;
\r
621 /***************************************************************************//**
\r
622 * @brief Masking and Blending Mode Set
\r
624 * @param[in] maskBlend
\r
625 * Masking and alpha blending mode
\r
626 ******************************************************************************/
\r
627 __STATIC_INLINE void EBI_TFTMaskBlendMode(EBI_TFTMaskBlend_TypeDef maskBlend)
\r
629 EBI->TFTCTRL = (EBI->TFTCTRL & (~_EBI_TFTCTRL_MASKBLEND_MASK))|maskBlend;
\r
633 /***************************************************************************//**
\r
634 * @brief Set TFT Alpha Blending Factor
\r
637 * 8-bit value indicating blending factor
\r
638 ******************************************************************************/
\r
639 __STATIC_INLINE void EBI_TFTAlphaBlendSet(uint8_t alpha)
\r
641 EBI->TFTALPHA = alpha;
\r
645 /***************************************************************************//**
\r
646 * @brief Set TFT mask value
\r
647 * Data accesses that matches this value are suppressed
\r
649 ******************************************************************************/
\r
650 __STATIC_INLINE void EBI_TFTMaskSet(uint32_t mask)
\r
652 EBI->TFTMASK = mask;
\r
656 /***************************************************************************//**
\r
657 * @brief Get current vertical position counter
\r
659 * Returns the current line position for the visible part of a frame
\r
660 ******************************************************************************/
\r
661 __STATIC_INLINE uint32_t EBI_TFTVCount(void)
\r
663 return((EBI->TFTSTATUS & _EBI_TFTSTATUS_VCNT_MASK) >> _EBI_TFTSTATUS_VCNT_SHIFT);
\r
667 /***************************************************************************//**
\r
668 * @brief Get current horizontal position counter
\r
670 * Returns the current horizontal pixel position within a visible line
\r
671 ******************************************************************************/
\r
672 __STATIC_INLINE uint32_t EBI_TFTHCount(void)
\r
674 return((EBI->TFTSTATUS & _EBI_TFTSTATUS_HCNT_MASK) >> _EBI_TFTSTATUS_HCNT_SHIFT);
\r
678 /***************************************************************************//**
\r
679 * @brief Set Frame Buffer Trigger
\r
682 * Frame buffer pointer will be updated either on each horizontal line (hsync)
\r
683 * or vertical update (vsync).
\r
686 * Trigger update of frame buffer pointer on vertical or horisontal sync.
\r
687 ******************************************************************************/
\r
688 __STATIC_INLINE void EBI_TFTFBTriggerSet(EBI_TFTFrameBufTrigger_TypeDef sync)
\r
690 EBI->TFTCTRL = ((EBI->TFTCTRL & ~_EBI_TFTCTRL_FBCTRIG_MASK)|sync);
\r
694 /***************************************************************************//**
\r
695 * @brief Set horizontal TFT stride value in number of bytes
\r
697 * @param[in] nbytes
\r
698 * Number of bytes to add to frame buffer pointer after each horizontal line
\r
700 ******************************************************************************/
\r
701 __STATIC_INLINE void EBI_TFTHStrideSet(uint32_t nbytes)
\r
703 EFM_ASSERT(nbytes < 0x1000);
\r
705 EBI->TFTSTRIDE = (EBI->TFTSTRIDE & ~(_EBI_TFTSTRIDE_HSTRIDE_MASK))|
\r
706 (nbytes<<_EBI_TFTSTRIDE_HSTRIDE_SHIFT);
\r
710 /***************************************************************************//**
\r
712 * Clear one or more pending EBI interrupts.
\r
714 * Pending EBI interrupt source to clear. Use a logical OR combination
\r
715 * of valid interrupt flags for the EBI module (EBI_IF_nnn).
\r
716 ******************************************************************************/
\r
717 __STATIC_INLINE void EBI_IntClear(uint32_t flags)
\r
723 /***************************************************************************//**
\r
725 * Set one or more pending EBI interrupts.
\r
728 * EBI interrupt sources to set to pending. Use a logical OR combination of
\r
729 * valid interrupt flags for the EBI module (EBI_IF_nnn).
\r
730 ******************************************************************************/
\r
731 __STATIC_INLINE void EBI_IntSet(uint32_t flags)
\r
737 /***************************************************************************//**
\r
739 * Disable one or more EBI interrupts.
\r
742 * EBI interrupt sources to disable. Use logical OR combination of valid
\r
743 * interrupt flags for the EBI module (EBI_IF_nnn)
\r
744 ******************************************************************************/
\r
745 __STATIC_INLINE void EBI_IntDisable(uint32_t flags)
\r
747 EBI->IEN &= ~(flags);
\r
751 /***************************************************************************//**
\r
753 * Enable one or more EBI interrupts.
\r
756 * EBI interrupt sources to enable. Use logical OR combination of valid
\r
757 * interrupt flags for the EBI module (EBI_IF_nnn)
\r
758 ******************************************************************************/
\r
759 __STATIC_INLINE void EBI_IntEnable(uint32_t flags)
\r
765 /***************************************************************************//**
\r
767 * Get pending EBI interrupt flags.
\r
770 * The event bits are not cleared by the use of this function
\r
773 * EBI interrupt sources pending, a logical combination of valid EBI
\r
774 * interrupt flags, EBI_IF_nnn
\r
775 ******************************************************************************/
\r
776 __STATIC_INLINE uint32_t EBI_IntGet(void)
\r
782 /***************************************************************************//**
\r
784 * Get enabled and pending EBI interrupt flags.
\r
785 * Useful for handling more interrupt sources in the same interrupt handler.
\r
788 * Interrupt flags are not cleared by the use of this function.
\r
791 * Pending and enabled EBI interrupt sources
\r
792 * The return value is the bitwise AND of
\r
793 * - the enabled interrupt sources in EBI_IEN and
\r
794 * - the pending interrupt flags EBI_IF
\r
795 ******************************************************************************/
\r
796 __STATIC_INLINE uint32_t EBI_IntGetEnabled(void)
\r
801 return EBI->IF & ien;
\r
805 /***************************************************************************//**
\r
807 * Start ECC generator on NAND flash transfers.
\r
808 ******************************************************************************/
\r
809 __STATIC_INLINE void EBI_StartNandEccGen(void)
\r
811 EBI->CMD = EBI_CMD_ECCSTART | EBI_CMD_ECCCLEAR;
\r
815 /***************************************************************************//**
\r
817 * Stop NAND flash ECC generator and return generated ECC.
\r
820 * The generated ECC.
\r
821 ******************************************************************************/
\r
822 __STATIC_INLINE uint32_t EBI_StopNandEccGen( void )
\r
824 EBI->CMD = EBI_CMD_ECCSTOP;
\r
825 return EBI->ECCPARITY;
\r
829 void EBI_ChipSelectEnable(uint32_t banks, bool enable);
\r
830 void EBI_ReadTimingSet(int setupCycles, int strobeCycles, int holdCycles);
\r
831 void EBI_WriteTimingSet(int setupCycles, int strobeCycles, int holdCycles);
\r
832 void EBI_AddressTimingSet(int setupCycles, int holdCycles);
\r
833 void EBI_PolaritySet(EBI_Line_TypeDef line, EBI_Polarity_TypeDef polarity);
\r
835 /** @} (end addtogroup EBI) */
\r
836 /** @} (end addtogroup EM_Library) */
\r
842 #endif /* defined(EBI_COUNT) && (EBI_COUNT > 0) */
\r
844 #endif /* __SILICON_LABS_EM_EBI_H__ */
\r