bsp_driver_sd.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /**
  2. ******************************************************************************
  3. * @file bsp_driver_sd.h (based on stm324x9i_eval_sd.h)
  4. * @brief This file contains the common defines and functions prototypes for
  5. * the bsp_driver_sd.c driver.
  6. ******************************************************************************
  7. *
  8. * COPYRIGHT(c) 2016 STMicroelectronics
  9. *
  10. * Redistribution and use in source and binary forms, with or without modification,
  11. * are permitted provided that the following conditions are met:
  12. * 1. Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. * 2. Redistributions in binary form must reproduce the above copyright notice,
  15. * this list of conditions and the following disclaimer in the documentation
  16. * and/or other materials provided with the distribution.
  17. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  18. * may be used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  24. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  25. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  27. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  28. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  29. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. ******************************************************************************
  33. */
  34. /* Define to prevent recursive inclusion -------------------------------------*/
  35. #ifndef __STM32F2XX_SD_H
  36. #define __STM32F2XX_SD_H
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. /* Includes ------------------------------------------------------------------*/
  41. #include "stm32f2xx_hal.h"
  42. /* Exported constants --------------------------------------------------------*/
  43. /**
  44. * @brief SD status structure definition
  45. */
  46. #define MSD_OK 0x00
  47. #define MSD_ERROR 0x01
  48. #ifndef SD_CardInfo
  49. #define SD_CardInfo HAL_SD_CardInfoTypedef
  50. #endif
  51. /** @defgroup STM324x9I_EVAL_SD_Exported_Constants
  52. * @{
  53. */
  54. #define SD_DATATIMEOUT ((uint32_t)0xFFFFFFFF)
  55. #define SD_PRESENT ((uint8_t)0x01)
  56. #define SD_NOT_PRESENT ((uint8_t)0x00)
  57. /* USER CODE BEGIN 0 */
  58. /* DMA definitions for SD DMA transfer */
  59. /*
  60. #define __DMAx_TxRx_CLK_ENABLE __DMA2_CLK_ENABLE
  61. #define SD_DMAx_Tx_CHANNEL DMA_CHANNEL_4
  62. #define SD_DMAx_Rx_CHANNEL DMA_CHANNEL_4
  63. #define SD_DMAx_Tx_STREAM DMA2_Stream6
  64. #define SD_DMAx_Rx_STREAM DMA2_Stream3
  65. #define SD_DMAx_Tx_IRQn DMA2_Stream6_IRQn
  66. #define SD_DMAx_Rx_IRQn DMA2_Stream3_IRQn
  67. #define SD_DMAx_Tx_IRQHandler DMA2_Stream6_IRQHandler
  68. #define SD_DMAx_Rx_IRQHandler DMA2_Stream3_IRQHandler
  69. */
  70. /* Exported functions --------------------------------------------------------*/
  71. uint8_t BSP_SD_Init(void);
  72. uint8_t BSP_SD_ITConfig(void);
  73. void BSP_SD_DetectIT(void);
  74. __weak void BSP_SD_DetectCallback(void);
  75. uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
  76. uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
  77. uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
  78. uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
  79. uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr);
  80. void BSP_SD_IRQHandler(void);
  81. void BSP_SD_DMA_Tx_IRQHandler(void);
  82. void BSP_SD_DMA_Rx_IRQHandler(void);
  83. HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void);
  84. void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo);
  85. uint8_t BSP_SD_IsDetected(void);
  86. /* USER CODE END 0 */
  87. #ifdef __cplusplus
  88. }
  89. #endif
  90. #endif /* __STM32F2XX_SD_H */
  91. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/