efm32_ebi.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /***************************************************************************//**
  2. * @file
  3. * @brief External Bus Iterface (EBI) peripheral API for EFM32
  4. * @author Energy Micro AS
  5. * @version 1.3.0
  6. *******************************************************************************
  7. * @section License
  8. * <b>(C) Copyright 2010 Energy Micro AS, http://www.energymicro.com</b>
  9. *******************************************************************************
  10. *
  11. * This source code is the property of Energy Micro AS. The source and compiled
  12. * code may only be used on Energy Micro "EFM32" microcontrollers.
  13. *
  14. * This copyright notice may not be removed from the source code nor changed.
  15. *
  16. * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
  17. * obligation to support this Software. Energy Micro AS is providing the
  18. * Software "AS IS", with no express or implied warranties of any kind,
  19. * including, but not limited to, any implied warranties of merchantability
  20. * or fitness for any particular purpose or warranties against infringement
  21. * of any proprietary rights of a third party.
  22. *
  23. * Energy Micro AS will not be liable for any consequential, incidental, or
  24. * special damages, or any other relief, or for any claim by any third party,
  25. * arising from your use of this Software.
  26. *
  27. ******************************************************************************/
  28. #ifndef __EFM32_EBI_H
  29. #define __EFM32_EBI_H
  30. #include "efm32.h"
  31. #if defined(EBI_COUNT) && (EBI_COUNT > 0)
  32. #include "efm32_bitband.h"
  33. #include <stdint.h>
  34. #include <stdbool.h>
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /***************************************************************************//**
  39. * @addtogroup EFM32_Library
  40. * @{
  41. ******************************************************************************/
  42. /***************************************************************************//**
  43. * @addtogroup EBI
  44. * @{
  45. ******************************************************************************/
  46. /***************************************************************************//**
  47. * @verbatim
  48. *
  49. * --------- ---------
  50. * | EBI | /| |\ | Ext. |
  51. * | | / --------- \ | Async |
  52. * |(EFM32)| \ --------- / | Device|
  53. * | | \| |/ | |
  54. * --------- ---------
  55. * Parallel interface
  56. *
  57. * @endverbatim
  58. ******************************************************************************/
  59. /*******************************************************************************
  60. ******************************* DEFINES ***********************************
  61. ******************************************************************************/
  62. #define EBI_BANK0 (1 << 1) /**< EBI address bank 0 */
  63. #define EBI_BANK1 (1 << 2) /**< EBI address bank 1 */
  64. #define EBI_BANK2 (1 << 3) /**< EBI address bank 2 */
  65. #define EBI_BANK3 (1 << 4) /**< EBI address bank 3 */
  66. #define EBI_CS0 (1 << 1) /**< EBI chip select line 0 */
  67. #define EBI_CS1 (1 << 2) /**< EBI chip select line 1 */
  68. #define EBI_CS2 (1 << 3) /**< EBI chip select line 2 */
  69. #define EBI_CS3 (1 << 4) /**< EBI chip select line 3 */
  70. /*******************************************************************************
  71. ******************************** ENUMS ************************************
  72. ******************************************************************************/
  73. /** EBI Mode of operation */
  74. typedef enum
  75. {
  76. /** 8 data bits, 8 address bits */
  77. ebiModeD8A8 = EBI_CTRL_MODE_D8A8,
  78. /** 16 data bits, 16 address bits, using address latch enable */
  79. ebiModeD16A16ALE = EBI_CTRL_MODE_D16A16ALE,
  80. /** 8 data bits, 24 address bits, using address latch enable */
  81. ebiModeD8A24ALE = EBI_CTRL_MODE_D8A24ALE
  82. } EBI_Mode_TypeDef;
  83. /** EBI Polarity configuration */
  84. typedef enum
  85. {
  86. /** Active Low */
  87. ebiActiveLow = 0,
  88. /** Active High */
  89. ebiActiveHigh = 1
  90. } EBI_Polarity_TypeDef;
  91. /** EBI Pin Line types */
  92. typedef enum
  93. {
  94. /** Address Ready polarity */
  95. ebiLineARDY,
  96. /** Address Latch Enable polarity */
  97. ebiLineALE,
  98. /** Write Enable polarity */
  99. ebiLineWE,
  100. /** Read Enable polarity */
  101. ebiLineRE,
  102. /** Chip Select polarity */
  103. ebiLineCS
  104. } EBI_Line_TypeDef;
  105. /*******************************************************************************
  106. ******************************* STRUCTS ***********************************
  107. ******************************************************************************/
  108. /** EBI Initialization structure */
  109. typedef struct
  110. {
  111. /** EBI operation mode, data and address limits */
  112. EBI_Mode_TypeDef mode;
  113. /** Address Ready pin polarity, active high or low */
  114. EBI_Polarity_TypeDef ardyPolarity;
  115. /** Address Latch Enable pin polarity, active high or low */
  116. EBI_Polarity_TypeDef alePolarity;
  117. /** Write Enable pin polarity, active high or low */
  118. EBI_Polarity_TypeDef wePolarity;
  119. /** Read Enable pin polarity, active high or low */
  120. EBI_Polarity_TypeDef rePolarity;
  121. /** Chip Select pin polarity, active high or low */
  122. EBI_Polarity_TypeDef csPolarity;
  123. /** Flag to enable or disable Address Ready support */
  124. bool ardyEnable;
  125. /** Set to turn off 32 cycle timeout ability */
  126. bool ardyDisableTimeout;
  127. /** Mask of flags which selects address banks to configure EBI_BANK<0-3> */
  128. uint32_t banks;
  129. /** Mask of flags which selects chip select lines t configure EBI_CS<0-3> */
  130. uint32_t csLines;
  131. /** Number of cycles address is held after Adress Latch Enable is asserted */
  132. int addrSetupCycles;
  133. /** Number of cycles address is driven onto the ADDRDAT bus before ALE is asserted */
  134. int addrHoldCycles;
  135. /** Number of cycles for address setup before REn is asserted */
  136. int readSetupCycles;
  137. /** Number of cycles REn is held active */
  138. int readStrobeCycles;
  139. /** Number of cycles CSn is held active after REn is deasserted */
  140. int readHoldCycles;
  141. /** Number of cycles for address setup before WEn is asserted */
  142. int writeSetupCycles;
  143. /** Number of cycles WEn is held active */
  144. int writeStrobeCycles;
  145. /** Number of cycles CSn is held active after WEn is deasserted */
  146. int writeHoldCycles;
  147. /** Flag, if EBI should be enabled after configuration */
  148. bool enable;
  149. } EBI_Init_TypeDef;
  150. /** Default config for EBI init structures */
  151. #define EBI_INIT_DEFAULT \
  152. { ebiModeD8A8, /* 8 bit address, 8 bit data */ \
  153. ebiActiveLow, /* ARDY polarity */ \
  154. ebiActiveLow, /* ALE polarity */ \
  155. ebiActiveLow, /* WE polarity */ \
  156. ebiActiveLow, /* RE polarity */ \
  157. ebiActiveLow, /* CS polarity */ \
  158. false, /* enable ARDY */ \
  159. false, /* don't disable ARDY timeout */ \
  160. EBI_BANK0, /* enable bank 0 */ \
  161. EBI_CS0, /* enable chip select 0 */ \
  162. 0, /* addr setup cycles */ \
  163. 1, /* addr hold cycles */ \
  164. 0, /* read setup cycles */ \
  165. 0, /* read strobe cycles */ \
  166. 0, /* read hold cycles */ \
  167. 0, /* write setup cycles */ \
  168. 0, /* write strobe cycles */ \
  169. 1, /* write hold cycles */ \
  170. true, /* enable EBI */ \
  171. }
  172. /*******************************************************************************
  173. ***************************** PROTOTYPES **********************************
  174. ******************************************************************************/
  175. void EBI_Init(const EBI_Init_TypeDef *ebiInit);
  176. void EBI_Disable(void);
  177. uint32_t EBI_BankAddress(uint32_t bank);
  178. void EBI_BankEnable(uint32_t banks, bool enable);
  179. void EBI_ChipSelectEnable(uint32_t banks, bool enable);
  180. void EBI_ReadTimingSet(int setupCycles, int strobeCycles, int holdCycles);
  181. void EBI_WriteTimingSet(int setupCycles, int strobeCycles, int holdCycles);
  182. void EBI_AddressTimingSet(int setupCycles, int holdCycles);
  183. void EBI_PolaritySet(EBI_Line_TypeDef line, EBI_Polarity_TypeDef polarity);
  184. /** @} (end addtogroup EBI) */
  185. /** @} (end addtogroup EFM32_Library) */
  186. #ifdef __cplusplus
  187. }
  188. #endif
  189. #endif /* defined(EBI_COUNT) && (EBI_COUNT > 0) */
  190. #endif /* __EFM32_EBI_H */