/Drivers/BSP/STM32H747I-DISCO/stm32h747i_discovery_sd.h

https://github.com/STMicroelectronics/STM32CubeH7 · C Header · 181 lines · 67 code · 30 blank · 84 comment · 2 complexity · 266d4002b1980599f0fd3c277c857329 MD5 · raw file

  1. /**
  2. ******************************************************************************
  3. * @file stm32h747i_discovery_sd.h
  4. * @author MCD Application Team
  5. * @brief This file contains the common defines and functions prototypes for
  6. * the stm32h747i_discovery_sd.c driver.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2018 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef STM32H747I_DISCO_SD_H
  22. #define STM32H747I_DISCO_SD_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "stm32h747i_discovery_conf.h"
  28. #include "stm32h747i_discovery_errno.h"
  29. /** @addtogroup BSP
  30. * @{
  31. */
  32. /** @addtogroup STM32H747I_DISCO
  33. * @{
  34. */
  35. /** @addtogroup STM32H747I_DISCO_SD
  36. * @{
  37. */
  38. /** @defgroup STM32H747I_DISCO_SD_Exported_Types Exported Types
  39. * @{
  40. */
  41. /**
  42. * @brief SD Card information structure
  43. */
  44. #define BSP_SD_CardInfo HAL_SD_CardInfoTypeDef
  45. #if (USE_HAL_SD_REGISTER_CALLBACKS == 1)
  46. typedef struct
  47. {
  48. void (* pMspInitCb)(SD_HandleTypeDef *);
  49. void (* pMspDeInitCb)(SD_HandleTypeDef *);
  50. }BSP_SD_Cb_t;
  51. #endif /* (USE_HAL_SD_REGISTER_CALLBACKS == 1) */
  52. /**
  53. * @}
  54. */
  55. /** @defgroup STM32H747I_DISCO_SD_Exported_Constants Exported Constants
  56. * @{
  57. */
  58. #define SD_INSTANCES_NBR 1UL
  59. #ifndef SD_WRITE_TIMEOUT
  60. #define SD_WRITE_TIMEOUT 100U
  61. #endif
  62. #ifndef SD_READ_TIMEOUT
  63. #define SD_READ_TIMEOUT 100U
  64. #endif
  65. /**
  66. * @brief SD interface bus width selection
  67. * 4-bit wide data bus can be disabled to avoid conflict with
  68. * camera pins (PC9 and PC11) on the Disco board.
  69. * 1-bit (SDMMC_D0) databus width will be used instead.
  70. */
  71. #ifndef USE_SD_BUS_WIDE_4B
  72. #define USE_SD_BUS_WIDE_4B 1U
  73. #endif
  74. /**
  75. * @brief SD transfer state definition
  76. */
  77. #define SD_TRANSFER_OK 0U
  78. #define SD_TRANSFER_BUSY 1U
  79. /**
  80. * @brief SD-detect signal
  81. */
  82. #define SD_PRESENT 1UL
  83. #define SD_NOT_PRESENT 0UL
  84. /**
  85. * @brief SD-detect signal
  86. */
  87. #define SD_DETECT_PIN GPIO_PIN_8
  88. #define SD_DETECT_GPIO_PORT GPIOI
  89. #define SD_DETECT_GPIO_CLK_ENABLE() __HAL_RCC_GPIOI_CLK_ENABLE()
  90. #define SD_DETECT_GPIO_CLK_DISABLE() __HAL_RCC_GPIOI_CLK_DISABLE()
  91. #define SD_DETECT_EXTI_IRQn EXTI9_5_IRQn
  92. #define SD_DETECT_EXTI_LINE EXTI_LINE_8
  93. #define SD_DetectIRQHandler() HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8)
  94. /**
  95. * @}
  96. */
  97. /** @addtogroup STM32H747I_DISCO_SD_Exported_Variables
  98. * @{
  99. */
  100. extern SD_HandleTypeDef hsd_sdmmc[];
  101. extern EXTI_HandleTypeDef hsd_exti[];
  102. /**
  103. * @}
  104. */
  105. /** @addtogroup STM32H747I_DISCO_SD_Exported_Functions
  106. * @{
  107. */
  108. int32_t BSP_SD_Init(uint32_t Instance);
  109. int32_t BSP_SD_DeInit(uint32_t Instance);
  110. #if (USE_HAL_SD_REGISTER_CALLBACKS == 1)
  111. int32_t BSP_SD_RegisterMspCallbacks(uint32_t Instance, BSP_SD_Cb_t *CallBacks);
  112. int32_t BSP_SD_RegisterDefaultMspCallbacks(uint32_t Instance);
  113. #endif /* (USE_HAL_SD_REGISTER_CALLBACKS == 1) */
  114. int32_t BSP_SD_DetectITConfig(uint32_t Instance);
  115. int32_t BSP_SD_ReadBlocks(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t BlocksNbr);
  116. int32_t BSP_SD_WriteBlocks(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t NbrOfBlocks);
  117. int32_t BSP_SD_ReadBlocks_DMA(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t NbrOfBlocks);
  118. int32_t BSP_SD_WriteBlocks_DMA(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t NbrOfBlocks);
  119. int32_t BSP_SD_ReadBlocks_IT(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t NbrOfBlocks);
  120. int32_t BSP_SD_WriteBlocks_IT(uint32_t Instance, uint32_t *pData, uint32_t BlockIdx, uint32_t NbrOfBlocks);
  121. int32_t BSP_SD_Erase(uint32_t Instance, uint32_t BlockIdx, uint32_t BlocksNbr);
  122. int32_t BSP_SD_GetCardState(uint32_t Instance);
  123. int32_t BSP_SD_GetCardInfo(uint32_t Instance, BSP_SD_CardInfo *CardInfo);
  124. int32_t BSP_SD_IsDetected(uint32_t Instance);
  125. void BSP_SD_DETECT_IRQHandler(uint32_t Instance);
  126. void BSP_SD_IRQHandler(uint32_t Instance);
  127. /* These functions can be modified in case the current settings (e.g. DMA stream or IT)
  128. need to be changed for specific application needs */
  129. void BSP_SD_AbortCallback(uint32_t Instance);
  130. void BSP_SD_WriteCpltCallback(uint32_t Instance);
  131. void BSP_SD_ReadCpltCallback(uint32_t Instance);
  132. void BSP_SD_DetectCallback(uint32_t Instance, uint32_t Status);
  133. void HAL_SD_DriveTransciver_1_8V_Callback(FlagStatus status);
  134. HAL_StatusTypeDef MX_SDMMC1_SD_Init(SD_HandleTypeDef *hsd);
  135. /**
  136. * @}
  137. */
  138. /**
  139. * @}
  140. */
  141. /**
  142. * @}
  143. */
  144. /**
  145. * @}
  146. */
  147. #ifdef __cplusplus
  148. }
  149. #endif
  150. #endif /* STM32H747I_DISCO_SD_H */
  151. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/