ebi.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /**************************************************************************//**
  2. * @file ebi.h
  3. * @version V3.00
  4. * $Revision: 4 $
  5. * $Date: 14/01/28 10:49a $
  6. * @brief M051 series EBI driver header file
  7. *
  8. * @note
  9. * Copyright (C) 2013 Nuvoton Technology Corp. All rights reserved.
  10. *****************************************************************************/
  11. #ifndef __EBI_H__
  12. #define __EBI_H__
  13. #ifdef __cplusplus
  14. extern "C"
  15. {
  16. #endif
  17. /** @addtogroup M051_Device_Driver M051 Device Driver
  18. @{
  19. */
  20. /** @addtogroup M051_EBI_Driver EBI Driver
  21. @{
  22. */
  23. /** @addtogroup M051_EBI_EXPORTED_CONSTANTS EBI Exported Constants
  24. @{
  25. */
  26. /*---------------------------------------------------------------------------------------------------------*/
  27. /* Miscellaneous Constant Definitions */
  28. /*---------------------------------------------------------------------------------------------------------*/
  29. #define EBI_BASE_ADDR 0x60000000UL /*!< EBI base address */
  30. #define EBI_MAX_SIZE 0x00020000UL /*!< Maximum EBI size */
  31. /*---------------------------------------------------------------------------------------------------------*/
  32. /* Constants for EBI data bus width */
  33. /*---------------------------------------------------------------------------------------------------------*/
  34. #define EBI_BUSWIDTH_8BIT 8 /*!< EBI bus width is 8-bit */
  35. #define EBI_BUSWIDTH_16BIT 16 /*!< EBI bus width is 16-bit */
  36. /*---------------------------------------------------------------------------------------------------------*/
  37. /* Constants for EBI MCLK divider and Timing */
  38. /*---------------------------------------------------------------------------------------------------------*/
  39. #define EBI_MCLKDIV_1 0x0UL /*!< EBI output clock(MCLK) is HCLK/1 */
  40. #define EBI_MCLKDIV_2 0x1UL /*!< EBI output clock(MCLK) is HCLK/2 */
  41. #define EBI_MCLKDIV_4 0x2UL /*!< EBI output clock(MCLK) is HCLK/4 */
  42. #define EBI_MCLKDIV_8 0x3UL /*!< EBI output clock(MCLK) is HCLK/8 */
  43. #define EBI_MCLKDIV_16 0x4UL /*!< EBI output clock(MCLK) is HCLK/16 */
  44. #define EBI_MCLKDIV_32 0x5UL /*!< EBI output clock(MCLK) is HCLK/32 */
  45. #define EBI_TIMING_FASTEST 0x0UL /*!< EBI timing is the fastest */
  46. #define EBI_TIMING_VERYFAST 0x1UL /*!< EBI timing is very fast */
  47. #define EBI_TIMING_FAST 0x2UL /*!< EBI timing is fast */
  48. #define EBI_TIMING_NORMAL 0x3UL /*!< EBI timing is normal */
  49. #define EBI_TIMING_SLOW 0x4UL /*!< EBI timing is slow */
  50. #define EBI_TIMING_VERYSLOW 0x5UL /*!< EBI timing is very slow */
  51. #define EBI_TIMING_SLOWEST 0x6UL /*!< EBI timing is the slowest */
  52. /*@}*/ /* end of group M051_EBI_EXPORTED_CONSTANTS */
  53. /** @addtogroup M051_EBI_EXPORTED_FUNCTIONS EBI Exported Functions
  54. @{
  55. */
  56. /**
  57. * @details This macro read 8-bit data from specify EBI address.
  58. */
  59. #define EBI_READ_DATA8(u32Addr) (*((volatile unsigned char *)(EBI_BASE_ADDR+u32Addr)))
  60. /**
  61. * @details This macro write 8-bit data to specify EBI address.
  62. */
  63. #define EBI_WRITE_DATA8(u32Addr, u32Data) (*((volatile unsigned char *)(EBI_BASE_ADDR+u32Addr)) = u32Data)
  64. /**
  65. * @details This macro read 16-bit data from specify EBI address.
  66. */
  67. #define EBI_READ_DATA16(u32Addr) (*((volatile unsigned short *)(EBI_BASE_ADDR+u32Addr)))
  68. /**
  69. * @details This macro write 16-bit data to specify EBI address.
  70. */
  71. #define EBI_WRITE_DATA16(u32Addr, u32Data) (*((volatile unsigned short *)(EBI_BASE_ADDR+u32Addr)) = u32Data)
  72. /**
  73. * @details This macro read 32-bit data from specify EBI address.
  74. */
  75. #define EBI_READ_DATA32(u32Addr) (*((volatile unsigned int *)(EBI_BASE_ADDR+u32Addr)))
  76. /**
  77. * @details This macro write 32-bit data to specify EBI address.
  78. */
  79. #define EBI_WRITE_DATA32(u32Addr, u32Data) (*((volatile unsigned int *)(EBI_BASE_ADDR+u32Addr)) = u32Data)Write 32-bit data to EBI bank 0
  80. void EBI_Open(uint32_t u32Bank, uint32_t u32DataWidth, uint32_t u32TimingClass, uint32_t u32BusMode, uint32_t u32CSActiveLevel);
  81. void EBI_Close(uint32_t u32Bank);
  82. void EBI_SetBusTiming(uint32_t u32Bank, uint32_t u32TimingConfig, uint32_t u32MclkDiv);
  83. /*@}*/ /* end of group M051_EBI_EXPORTED_FUNCTIONS */
  84. /*@}*/ /* end of group M051_EBI_Driver */
  85. /*@}*/ /* end of group M051_Device_Driver */
  86. #ifdef __cplusplus
  87. }
  88. #endif
  89. #endif //__EBI_H__
  90. /*** (C) COPYRIGHT 2013 Nuvoton Technology Corp. ***/