]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/SilLabs_Code/emlib/inc/em_ebi.h
84dc9a3da8f90ea37011f808d40589740c8ac7f1
[freertos] / FreeRTOS / Demo / CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio / Source / SilLabs_Code / emlib / inc / em_ebi.h
1 /***************************************************************************//**\r
2  * @file em_ebi.h\r
3  * @brief External Bus Iterface (EBI) peripheral API\r
4  * @version 4.2.1\r
5  *******************************************************************************\r
6  * @section License\r
7  * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>\r
8  *******************************************************************************\r
9  *\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
13  *\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
19  *\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
26  *\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
30  *\r
31  ******************************************************************************/\r
32 \r
33 #ifndef __SILICON_LABS_EM_EBI_H__\r
34 #define __SILICON_LABS_EM_EBI_H__\r
35 \r
36 #include "em_device.h"\r
37 #if defined(EBI_COUNT) && (EBI_COUNT > 0)\r
38 \r
39 #include <stdint.h>\r
40 #include <stdbool.h>\r
41 #include "em_assert.h"\r
42 \r
43 #ifdef __cplusplus\r
44 extern "C" {\r
45 #endif\r
46 \r
47 /***************************************************************************//**\r
48  * @addtogroup EM_Library\r
49  * @{\r
50  ******************************************************************************/\r
51 \r
52 /***************************************************************************//**\r
53  * @addtogroup EBI\r
54  * @{\r
55  ******************************************************************************/\r
56 \r
57 /***************************************************************************//**\r
58  * @verbatim\r
59  *\r
60  * ---------               ---------\r
61  * |       |  /|       |\  | Ext.  |\r
62  * |  EBI  | / --------- \ | Async |\r
63  * |       | \ --------- / | Device|\r
64  * |       |  \|       |/  |       |\r
65  * ---------               ---------\r
66  *         Parallel interface\r
67  *\r
68  * @endverbatim\r
69  ******************************************************************************/\r
70 \r
71 /*******************************************************************************\r
72  *******************************   DEFINES   ***********************************\r
73  ******************************************************************************/\r
74 \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
79 \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
84 \r
85 /*******************************************************************************\r
86  ********************************   ENUMS   ************************************\r
87  ******************************************************************************/\r
88 \r
89 /** EBI Mode of operation */\r
90 typedef enum\r
91 {\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
99   /** Mode D16 */\r
100   ebiModeD16       = EBI_CTRL_MODE_D16,\r
101 #endif\r
102 } EBI_Mode_TypeDef;\r
103 \r
104 /** EBI Polarity configuration */\r
105 typedef enum\r
106 {\r
107   /** Active Low */\r
108   ebiActiveLow  = 0,\r
109   /** Active High */\r
110   ebiActiveHigh = 1\r
111 } EBI_Polarity_TypeDef;\r
112 \r
113 /** EBI Pin Line types */\r
114 typedef enum\r
115 {\r
116   /** Address Ready line */\r
117   ebiLineARDY,\r
118   /** Address Latch Enable line */\r
119   ebiLineALE,\r
120   /** Write Enable line */\r
121   ebiLineWE,\r
122   /** Read Enable line */\r
123   ebiLineRE,\r
124   /** Chip Select line */\r
125   ebiLineCS,\r
126 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)\r
127   /** BL line */\r
128   ebiLineBL,\r
129 #endif\r
130 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)\r
131   /** TFT VSYNC line */\r
132   ebiLineTFTVSync,\r
133   /** TFT HSYNC line */\r
134   ebiLineTFTHSync,\r
135   /** TFT Data enable line */\r
136   ebiLineTFTDataEn,\r
137   /** TFT DCLK line */\r
138   ebiLineTFTDClk,\r
139   /** TFT Chip select line */\r
140   ebiLineTFTCS,\r
141 #endif\r
142 } EBI_Line_TypeDef;\r
143 \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
146 typedef enum\r
147 {\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
157 \r
158 /** Adress Pin Enable, high limit - higher limit of pins to enable */\r
159 typedef enum\r
160 {\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
212 \r
213 /** EBI I/O Alternate Pin Location */\r
214 typedef enum {\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
222 #endif\r
223 \r
224 /* TFT support */\r
225 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)\r
226 /** EBI TFT Graphics Bank Select */\r
227 typedef enum\r
228 {\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
238 \r
239 /** Masking and Alpha blending source color*/\r
240 typedef enum\r
241 {\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
247 \r
248 /** Bus Data Interleave Mode */\r
249 typedef enum\r
250 {\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
258 \r
259 /** Control frame base pointer copy */\r
260 typedef enum\r
261 {\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
267 \r
268 /** Control of mask and alpha blending mode */\r
269 typedef enum\r
270 {\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
286 \r
287 /** TFT Direct Drive mode */\r
288 typedef enum\r
289 {\r
290   /** Disabled */\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
297 \r
298 /** TFT Data Increment Width */\r
299 typedef enum\r
300 {\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
306 \r
307 #endif\r
308 \r
309 /*******************************************************************************\r
310  *******************************   STRUCTS   ***********************************\r
311  ******************************************************************************/\r
312 \r
313 /** EBI Initialization structure */\r
314 typedef struct\r
315 {\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
332   bool                 blEnable;\r
333   /** Flag to enable or disable idle state insertion between transfers */\r
334   bool                 noIdle;\r
335 #endif\r
336   /** Flag to enable or disable Address Ready support */\r
337   bool                 ardyEnable;\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
341   uint32_t             banks;\r
342   /** Mask of flags which selects chip select lines to configure EBI_CS<0-3> */\r
343   uint32_t             csLines;\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
350   bool                 addrHalfALE;\r
351 #endif\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
360   bool                 readPageMode;\r
361   /** Enables or disable prefetching from sequential addresses */\r
362   bool                 readPrefetch;\r
363   /** Enabled or disables half cycle duration of the REn signal in the last strobe cycle  */\r
364   bool                 readHalfRE;\r
365 #endif\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
376   bool                 writeHalfWE;\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
383 #endif\r
384   /** Flag, if EBI should be enabled after configuration */\r
385   bool                 enable;\r
386 } EBI_Init_TypeDef;\r
387 \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
391 {                                                             \\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
423 }\r
424 #else\r
425 #define EBI_INIT_DEFAULT                               \\r
426 {                                                      \\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
446 }\r
447 #endif\r
448 \r
449 #if defined(_EFM32_GIANT_FAMILY) || defined(_EFM32_WONDER_FAMILY)\r
450 \r
451 /** TFT Initialization structure */\r
452 typedef struct\r
453 {\r
454   /** External memory bank for driving display */\r
455   EBI_TFTBank_TypeDef            bank;\r
456   /** Width */\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
465   bool                           shiftDClk;\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
481   int                            hsize;\r
482   /** Horizontal Front Porch Size */\r
483   int                            hPorchFront;\r
484   /** Horizontal Back Porch Size */\r
485   int                            hPorchBack;\r
486   /** Horizontal Synchronization Pulse Width */\r
487   int                            hPulseWidth;\r
488   /** Vertical size in pixels */\r
489   int                            vsize;\r
490   /** Vertical Front Porch Size */\r
491   int                            vPorchFront;\r
492   /** Vertical Back Porch Size */\r
493   int                            vPorchBack;\r
494   /** Vertical Synchronization Pulse Width */\r
495   int                            vPulseWidth;\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
499   int                            dclkPeriod;\r
500   /** Starting position of External Direct Drive relative to DCLK inactive edge */\r
501   int                            startPosition;\r
502   /** Number of cycles RGB data is driven before active edge of DCLK */\r
503   int                            setupCycles;\r
504   /** Number of cycles RGB data is held after active edge of DCLK */\r
505   int                            holdCycles;\r
506 } EBI_TFTInit_TypeDef;\r
507 \r
508 /** Default configuration for EBI TFT init structure */\r
509 #define EBI_TFTINIT_DEFAULT                                                         \\r
510 {                                                                                   \\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
537 }\r
538 \r
539 #endif\r
540 /*******************************************************************************\r
541  *****************************   PROTOTYPES   **********************************\r
542  ******************************************************************************/\r
543 \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
548 \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
555 #endif\r
556 \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
561 \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
564 \r
565 void EBI_BankAddressTimingSet(uint32_t bank, int setupCycles, int holdCycles);\r
566 void EBI_BankAddressTimingConfig(uint32_t bank, bool halfALE);\r
567 \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
571 \r
572 /***************************************************************************//**\r
573  * @brief\r
574  *   Enable or disable TFT Direct Drive\r
575  *\r
576  * @param[in] mode\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
580 {\r
581   EBI->TFTCTRL = (EBI->TFTCTRL & ~(_EBI_TFTCTRL_DD_MASK)) | (uint32_t) mode;\r
582 }\r
583 \r
584 \r
585 /***************************************************************************//**\r
586  * @brief\r
587  *   Configure frame buffer pointer\r
588  *\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
593 {\r
594   EBI->TFTFRAMEBASE = (uint32_t) address;\r
595 }\r
596 \r
597 \r
598 /***************************************************************************//**\r
599  * @brief Set TFT Pixel Color 0 or 1\r
600  *\r
601  * @param[in] pixel\r
602  *   Which pixel instance to set\r
603  * @param[in] color\r
604  *   Color of pixel, 16-bit value\r
605  ******************************************************************************/\r
606 __STATIC_INLINE void EBI_TFTPixelSet(int pixel, uint32_t color)\r
607 {\r
608   EFM_ASSERT(pixel == 0 || pixel == 1);\r
609 \r
610   if (pixel == 0)\r
611   {\r
612     EBI->TFTPIXEL0 = color;\r
613   }\r
614   if (pixel == 1)\r
615   {\r
616     EBI->TFTPIXEL1 = color;\r
617   }\r
618 }\r
619 \r
620 \r
621 /***************************************************************************//**\r
622  * @brief Masking and Blending Mode Set\r
623  *\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
628 {\r
629   EBI->TFTCTRL = (EBI->TFTCTRL & (~_EBI_TFTCTRL_MASKBLEND_MASK))|maskBlend;\r
630 }\r
631 \r
632 \r
633 /***************************************************************************//**\r
634  * @brief Set TFT Alpha Blending Factor\r
635  *\r
636  * @param[in] alpha\r
637  *   8-bit value indicating blending factor\r
638  ******************************************************************************/\r
639 __STATIC_INLINE void EBI_TFTAlphaBlendSet(uint8_t alpha)\r
640 {\r
641   EBI->TFTALPHA = alpha;\r
642 }\r
643 \r
644 \r
645 /***************************************************************************//**\r
646  * @brief Set TFT mask value\r
647  *   Data accesses that matches this value are suppressed\r
648  * @param[in] mask\r
649  ******************************************************************************/\r
650 __STATIC_INLINE void EBI_TFTMaskSet(uint32_t mask)\r
651 {\r
652   EBI->TFTMASK = mask;\r
653 }\r
654 \r
655 \r
656 /***************************************************************************//**\r
657  * @brief Get current vertical position counter\r
658  * @return\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
662 {\r
663   return((EBI->TFTSTATUS & _EBI_TFTSTATUS_VCNT_MASK) >> _EBI_TFTSTATUS_VCNT_SHIFT);\r
664 }\r
665 \r
666 \r
667 /***************************************************************************//**\r
668  * @brief Get current horizontal position counter\r
669  * @return\r
670  *   Returns the current horizontal pixel position within a visible line\r
671  ******************************************************************************/\r
672 __STATIC_INLINE uint32_t EBI_TFTHCount(void)\r
673 {\r
674   return((EBI->TFTSTATUS & _EBI_TFTSTATUS_HCNT_MASK) >> _EBI_TFTSTATUS_HCNT_SHIFT);\r
675 }\r
676 \r
677 \r
678 /***************************************************************************//**\r
679  * @brief Set Frame Buffer Trigger\r
680  *\r
681  * @details\r
682  *   Frame buffer pointer will be updated either on each horizontal line (hsync)\r
683  *   or vertical update (vsync).\r
684  *\r
685  * @param[in] sync\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
689 {\r
690   EBI->TFTCTRL = ((EBI->TFTCTRL & ~_EBI_TFTCTRL_FBCTRIG_MASK)|sync);\r
691 }\r
692 \r
693 \r
694 /***************************************************************************//**\r
695  * @brief Set horizontal TFT stride value in number of bytes\r
696  *\r
697  * @param[in] nbytes\r
698  *    Number of bytes to add to frame buffer pointer after each horizontal line\r
699  *    update\r
700  ******************************************************************************/\r
701 __STATIC_INLINE void EBI_TFTHStrideSet(uint32_t nbytes)\r
702 {\r
703   EFM_ASSERT(nbytes < 0x1000);\r
704 \r
705   EBI->TFTSTRIDE = (EBI->TFTSTRIDE & ~(_EBI_TFTSTRIDE_HSTRIDE_MASK))|\r
706     (nbytes<<_EBI_TFTSTRIDE_HSTRIDE_SHIFT);\r
707 }\r
708 \r
709 \r
710 /***************************************************************************//**\r
711  * @brief\r
712  *   Clear one or more pending EBI interrupts.\r
713  * @param[in] flags\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
718 {\r
719   EBI->IFC = flags;\r
720 }\r
721 \r
722 \r
723 /***************************************************************************//**\r
724  * @brief\r
725  *   Set one or more pending EBI interrupts.\r
726  *\r
727  * @param[in] flags\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
732 {\r
733   EBI->IFS = flags;\r
734 }\r
735 \r
736 \r
737 /***************************************************************************//**\r
738  * @brief\r
739  *   Disable one or more EBI interrupts.\r
740  *\r
741  * @param[in] flags\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
746 {\r
747   EBI->IEN &= ~(flags);\r
748 }\r
749 \r
750 \r
751 /***************************************************************************//**\r
752  * @brief\r
753  *   Enable one or more EBI interrupts.\r
754  *\r
755  * @param[in] flags\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
760 {\r
761   EBI->IEN |= flags;\r
762 }\r
763 \r
764 \r
765 /***************************************************************************//**\r
766  * @brief\r
767  *   Get pending EBI interrupt flags.\r
768  *\r
769  * @note\r
770  *   The event bits are not cleared by the use of this function\r
771  *\r
772  * @return\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
777 {\r
778   return EBI->IF;\r
779 }\r
780 \r
781 \r
782 /***************************************************************************//**\r
783  * @brief\r
784  *   Get enabled and pending EBI interrupt flags.\r
785  *   Useful for handling more interrupt sources in the same interrupt handler.\r
786  *\r
787  * @note\r
788  *   Interrupt flags are not cleared by the use of this function.\r
789  *\r
790  * @return\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
797 {\r
798   uint32_t ien;\r
799 \r
800   ien = EBI->IEN;\r
801   return EBI->IF & ien;\r
802 }\r
803 \r
804 \r
805 /***************************************************************************//**\r
806  * @brief\r
807  *   Start ECC generator on NAND flash transfers.\r
808  ******************************************************************************/\r
809 __STATIC_INLINE void EBI_StartNandEccGen(void)\r
810 {\r
811   EBI->CMD = EBI_CMD_ECCSTART | EBI_CMD_ECCCLEAR;\r
812 }\r
813 \r
814 \r
815 /***************************************************************************//**\r
816  * @brief\r
817  *   Stop NAND flash ECC generator and return generated ECC.\r
818  *\r
819  * @return\r
820  *   The generated ECC.\r
821  ******************************************************************************/\r
822 __STATIC_INLINE uint32_t EBI_StopNandEccGen( void )\r
823 {\r
824   EBI->CMD = EBI_CMD_ECCSTOP;\r
825   return EBI->ECCPARITY;\r
826 }\r
827 #endif\r
828 \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
834 \r
835 /** @} (end addtogroup EBI) */\r
836 /** @} (end addtogroup EM_Library) */\r
837 \r
838 #ifdef __cplusplus\r
839 }\r
840 #endif\r
841 \r
842 #endif /* defined(EBI_COUNT) && (EBI_COUNT > 0) */\r
843 \r
844 #endif /* __SILICON_LABS_EM_EBI_H__ */\r