bsp_driver_sd.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /**
  2. ******************************************************************************
  3. * @file bsp_driver_sd.h for F4 (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. * This notice applies to any and all portions of this file
  8. * that are not between comment pairs USER CODE BEGIN and
  9. * USER CODE END. Other portions of this file, whether
  10. * inserted by the user or by software development tools
  11. * are owned by their respective copyright owners.
  12. *
  13. * Copyright (c) 2018 STMicroelectronics International N.V.
  14. * All rights reserved.
  15. *
  16. * Redistribution and use in source and binary forms, with or without
  17. * modification, are permitted, provided that the following conditions are met:
  18. *
  19. * 1. Redistribution of source code must retain the above copyright notice,
  20. * this list of conditions and the following disclaimer.
  21. * 2. Redistributions in binary form must reproduce the above copyright notice,
  22. * this list of conditions and the following disclaimer in the documentation
  23. * and/or other materials provided with the distribution.
  24. * 3. Neither the name of STMicroelectronics nor the names of other
  25. * contributors to this software may be used to endorse or promote products
  26. * derived from this software without specific written permission.
  27. * 4. This software, including modifications and/or derivative works of this
  28. * software, must execute solely and exclusively on microcontroller or
  29. * microprocessor devices manufactured by or for STMicroelectronics.
  30. * 5. Redistribution and use of this software other than as permitted under
  31. * this license is void and will automatically terminate your rights under
  32. * this license.
  33. *
  34. * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
  35. * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
  36. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  37. * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
  38. * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
  39. * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  40. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  42. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  43. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  44. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  45. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  46. *
  47. ******************************************************************************
  48. */
  49. /* Define to prevent recursive inclusion -------------------------------------*/
  50. #ifndef __STM32F4_SD_H
  51. #define __STM32F4_SD_H
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. /* Includes ------------------------------------------------------------------*/
  56. #include "stm32f4xx_hal.h"
  57. /* Exported types --------------------------------------------------------*/
  58. /**
  59. * @brief SD Card information structure
  60. */
  61. #define BSP_SD_CardInfo HAL_SD_CardInfoTypeDef
  62. /* Exported constants --------------------------------------------------------*/
  63. /**
  64. * @brief SD status structure definition
  65. */
  66. #define MSD_OK ((uint8_t)0x00)
  67. #define MSD_ERROR ((uint8_t)0x01)
  68. /**
  69. * @brief SD transfer state definition
  70. */
  71. #define SD_TRANSFER_OK ((uint8_t)0x00)
  72. #define SD_TRANSFER_BUSY ((uint8_t)0x01)
  73. #define SD_PRESENT ((uint8_t)0x01)
  74. #define SD_NOT_PRESENT ((uint8_t)0x00)
  75. #define SD_DATATIMEOUT ((uint32_t)100000000)
  76. #ifdef OLD_API
  77. /* kept to avoid issue when migrating old projects. */
  78. /* USER CODE BEGIN 0 */
  79. /* USER CODE END 0 */
  80. #else
  81. /* USER CODE BEGIN BSP_H_CODE */
  82. /* Exported functions --------------------------------------------------------*/
  83. uint8_t BSP_SD_Init(void);
  84. uint8_t BSP_SD_ITConfig(void);
  85. void BSP_SD_DetectIT(void);
  86. void BSP_SD_DetectCallback(void);
  87. uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout);
  88. uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout);
  89. uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks);
  90. uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks);
  91. uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr);
  92. void BSP_SD_IRQHandler(void);
  93. void BSP_SD_DMA_Tx_IRQHandler(void);
  94. void BSP_SD_DMA_Rx_IRQHandler(void);
  95. uint8_t BSP_SD_GetCardState(void);
  96. void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo);
  97. uint8_t BSP_SD_IsDetected(void);
  98. /* These functions can be modified in case the current settings (e.g. DMA stream)
  99. need to be changed for specific application needs */
  100. void BSP_SD_AbortCallback(void);
  101. void BSP_SD_WriteCpltCallback(void);
  102. void BSP_SD_ReadCpltCallback(void);
  103. /* USER CODE END BSP_H_CODE */
  104. #endif
  105. #ifdef __cplusplus
  106. }
  107. #endif
  108. #endif /* __STM32F4_SD_H */
  109. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/