wm_sdio_host.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef __WM_SDIO_HOST_H_
  2. #define __WM_SDIO_HOST_H_
  3. #include <core_804.h>
  4. #include "wm_regs.h"
  5. typedef struct {
  6. __IOM uint32_t MMC_CTL;
  7. __IOM uint32_t MMC_IO;
  8. __IOM uint32_t MMC_BYTECNTL;
  9. __IM uint32_t MMC_TR_BLOCKCNT;
  10. __IOM uint32_t MMC_CRCCTL; /*!< Offset: 0x010 */
  11. __IM uint32_t CMD_CRC;
  12. __IM uint32_t DAT_CRCL;
  13. __IM uint32_t DAT_CRCH;
  14. __IOM uint32_t MMC_PORT; /*!< Offset: 0x020 */
  15. __IOM uint32_t MMC_INT_MASK;
  16. __IOM uint32_t MMC_INT_SRC;
  17. __IOM uint32_t MMC_CARDSEL;
  18. __IM uint32_t MMC_SIG; /*!< Offset: 0x030 */
  19. __IOM uint32_t MMC_IO_MBCTL;
  20. __IOM uint32_t MMC_BLOCKCNT;
  21. __IOM uint32_t MMC_TIMEOUTCNT;
  22. __IOM uint32_t CMD_BUF[16]; /*!< Offset: 0x040 */
  23. __IOM uint32_t BUF_CTL; /*!< Offset: 0x080 */
  24. uint32_t RESERVED3[31U];
  25. __IOM uint32_t DATA_BUF[128]; /*!< Offset: 0x100 */
  26. }SDIO_HOST_Type;
  27. #define SDIO_HOST ((SDIO_HOST_Type *)HR_SDIO_HOST_BASE_ADDR)
  28. typedef struct
  29. {
  30. long long CardCapacity;
  31. u32 CardBlockSize;
  32. u16 RCA;
  33. u8 CSDVer;
  34. } SD_CardInfo_t;
  35. extern SD_CardInfo_t SDCardInfo;
  36. /**
  37. * @defgroup Driver_APIs Driver APIs
  38. * @brief Driver APIs
  39. */
  40. /**
  41. * @addtogroup Driver_APIs
  42. * @{
  43. */
  44. /**
  45. * @defgroup SDIOH_Driver_APIs SDIO HOST Driver APIs
  46. * @brief SDIO HOST driver APIs
  47. */
  48. /**
  49. * @addtogroup SDIOH_Driver_APIs
  50. * @{
  51. */
  52. /**
  53. * @brief This function is used to initial the sd host module .
  54. *
  55. * @param[out] rca_ref Pointer to the rca reference
  56. *
  57. * @retval status 0 if succeed, otherwise fail
  58. *
  59. * @note None
  60. */
  61. int sdh_card_init(uint32_t *rca_ref);
  62. /**
  63. * @brief This function is used to set the width of bus .
  64. *
  65. * @param[in] rca the rca reference
  66. * @param[in] bus_width: 0:1bit; 2:4bits
  67. *
  68. * @retval status 0 if succeed, otherwise fail
  69. *
  70. * @note None
  71. */
  72. int wm_sd_card_set_bus_width(uint32_t rca, uint8_t bus_width);
  73. /**
  74. * @brief This function is used to read one block data from the sd card with irq mode .
  75. *
  76. * @param[in] sd_addr address that to be read from
  77. * @param[in] buf Pointer to the buffer that the data shall be read into
  78. *
  79. * @retval status 0 if succeed, otherwise fail
  80. *
  81. * @note None
  82. */
  83. int wm_sd_card_block_read(uint32_t rca, uint32_t sd_addr, char *buf);
  84. /**
  85. * @brief This function is used to write one block data into the sd card with irq mode .
  86. *
  87. * @param[in] sd_addr address that to be written to
  88. * @param[in] buf Pointer to the buffer that holding the data to be written
  89. *
  90. * @retval status 0 if succeed, otherwise fail
  91. *
  92. * @note None
  93. */
  94. int wm_sd_card_block_write(uint32_t rca, uint32_t sd_addr, char *buf);
  95. /**
  96. * @brief This function is used to read blocks of data from the sd card with dma mode .
  97. *
  98. * @param[in] sd_addr address that to be read from
  99. * @param[in] buf Pointer to the buffer that the data shall be read into
  100. * @param[in] buflen buffer size, should be integer multiple of 512
  101. *
  102. * @retval status 0 if succeed, otherwise fail
  103. *
  104. * @note None
  105. */
  106. int wm_sd_card_blocks_read(uint32_t rca, uint32_t sd_addr, char *buf, uint32_t buflen);
  107. /**
  108. * @brief This function is used to write blocks of data into the sd card with dma mode .
  109. *
  110. * @param[in] sd_addr address that to be written to
  111. * @param[in] buf Pointer to the buffer that holding the data to be written
  112. * @param[in] buflen buffer size, should be integer multiple of 512
  113. *
  114. * @retval status 0 if succeed, otherwise fail
  115. *
  116. * @note None
  117. */
  118. int wm_sd_card_blocks_write(uint32_t rca, uint32_t sd_addr, char *buf, uint32_t buflen);
  119. /**
  120. * @}
  121. */
  122. /**
  123. * @}
  124. */
  125. #endif //__WM_SDIO_HOST_H_