nguyen nam
/
BSP-DISCO_F746NG
Nam
Drivers/BSP/STM32746G-Discovery/stm32746g_discovery_sd.h@11:862f171dda3c, 2019-06-10 (annotated)
- Committer:
- nhancap98
- Date:
- Mon Jun 10 11:10:42 2019 +0000
- Revision:
- 11:862f171dda3c
- Parent:
- 8:56384bddaba5
SPKT
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 6:e1d9da7fe856 | 1 | /** |
bcostm | 6:e1d9da7fe856 | 2 | ****************************************************************************** |
bcostm | 6:e1d9da7fe856 | 3 | * @file stm32746g_discovery_sd.h |
bcostm | 6:e1d9da7fe856 | 4 | * @author MCD Application Team |
Jerome Coutant
8:56384bddaba5
|
5
|
* @version V2.0.0
|
|
Jerome Coutant
8:56384bddaba5
|
6
|
* @date 30-December-2016
|
|
bcostm | 6:e1d9da7fe856 | 7 | * @brief This file contains the common defines and functions prototypes for |
bcostm | 6:e1d9da7fe856 | 8 | * the stm32746g_discovery_sd.c driver. |
bcostm | 6:e1d9da7fe856 | 9 | ****************************************************************************** |
bcostm | 6:e1d9da7fe856 | 10 | * @attention |
bcostm | 6:e1d9da7fe856 | 11 | * |
bcostm | 6:e1d9da7fe856 | 12 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
bcostm | 6:e1d9da7fe856 | 13 | * |
bcostm | 6:e1d9da7fe856 | 14 | * Redistribution and use in source and binary forms, with or without modification, |
bcostm | 6:e1d9da7fe856 | 15 | * are permitted provided that the following conditions are met: |
bcostm | 6:e1d9da7fe856 | 16 | * 1. Redistributions of source code must retain the above copyright notice, |
bcostm | 6:e1d9da7fe856 | 17 | * this list of conditions and the following disclaimer. |
bcostm | 6:e1d9da7fe856 | 18 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
bcostm | 6:e1d9da7fe856 | 19 | * this list of conditions and the following disclaimer in the documentation |
bcostm | 6:e1d9da7fe856 | 20 | * and/or other materials provided with the distribution. |
bcostm | 6:e1d9da7fe856 | 21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
bcostm | 6:e1d9da7fe856 | 22 | * may be used to endorse or promote products derived from this software |
bcostm | 6:e1d9da7fe856 | 23 | * without specific prior written permission. |
bcostm | 6:e1d9da7fe856 | 24 | * |
bcostm | 6:e1d9da7fe856 | 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bcostm | 6:e1d9da7fe856 | 26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bcostm | 6:e1d9da7fe856 | 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bcostm | 6:e1d9da7fe856 | 28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
bcostm | 6:e1d9da7fe856 | 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
bcostm | 6:e1d9da7fe856 | 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
bcostm | 6:e1d9da7fe856 | 31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
bcostm | 6:e1d9da7fe856 | 32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
bcostm | 6:e1d9da7fe856 | 33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
bcostm | 6:e1d9da7fe856 | 34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bcostm | 6:e1d9da7fe856 | 35 | * |
bcostm | 6:e1d9da7fe856 | 36 | ****************************************************************************** |
bcostm | 6:e1d9da7fe856 | 37 | */ |
bcostm | 6:e1d9da7fe856 | 38 | |
bcostm | 6:e1d9da7fe856 | 39 | /* Define to prevent recursive inclusion -------------------------------------*/ |
bcostm | 6:e1d9da7fe856 | 40 | #ifndef __STM32746G_DISCOVERY_SD_H |
bcostm | 6:e1d9da7fe856 | 41 | #define __STM32746G_DISCOVERY_SD_H |
bcostm | 6:e1d9da7fe856 | 42 | |
bcostm | 6:e1d9da7fe856 | 43 | #ifdef __cplusplus |
bcostm | 6:e1d9da7fe856 | 44 | extern "C" { |
bcostm | 6:e1d9da7fe856 | 45 | #endif |
bcostm | 6:e1d9da7fe856 | 46 | |
bcostm | 6:e1d9da7fe856 | 47 | /* Includes ------------------------------------------------------------------*/ |
bcostm | 6:e1d9da7fe856 | 48 | #include "stm32746g_discovery.h" |
bcostm | 6:e1d9da7fe856 | 49 | |
bcostm | 6:e1d9da7fe856 | 50 | /** @addtogroup BSP |
bcostm | 6:e1d9da7fe856 | 51 | * @{ |
bcostm | 6:e1d9da7fe856 | 52 | */ |
bcostm | 6:e1d9da7fe856 | 53 | |
bcostm | 6:e1d9da7fe856 | 54 | /** @addtogroup STM32746G_DISCOVERY |
bcostm | 6:e1d9da7fe856 | 55 | * @{ |
bcostm | 6:e1d9da7fe856 | 56 | */ |
bcostm | 6:e1d9da7fe856 | 57 | |
bcostm | 6:e1d9da7fe856 | 58 | /** @addtogroup STM32746G_DISCOVERY_SD |
bcostm | 6:e1d9da7fe856 | 59 | * @{ |
bcostm | 6:e1d9da7fe856 | 60 | */ |
bcostm | 6:e1d9da7fe856 | 61 | |
bcostm | 6:e1d9da7fe856 | 62 | /** @defgroup STM32746G_DISCOVERY_SD_Exported_Types STM32746G_DISCOVERY_SD Exported Types |
bcostm | 6:e1d9da7fe856 | 63 | * @{ |
bcostm | 6:e1d9da7fe856 | 64 | */ |
bcostm | 6:e1d9da7fe856 | 65 | |
bcostm | 6:e1d9da7fe856 | 66 | /** |
bcostm | 6:e1d9da7fe856 | 67 | * @brief SD Card information structure |
bcostm | 6:e1d9da7fe856 | 68 | */ |
Jerome Coutant
8:56384bddaba5
|
69
|
#define BSP_SD_CardInfo HAL_SD_CardInfoTypeDef
|
|
bcostm | 6:e1d9da7fe856 | 70 | /** |
bcostm | 6:e1d9da7fe856 | 71 | * @} |
bcostm | 6:e1d9da7fe856 | 72 | */ |
bcostm | 6:e1d9da7fe856 | 73 | |
bcostm | 6:e1d9da7fe856 | 74 | /** |
bcostm | 6:e1d9da7fe856 | 75 | * @brief SD status structure definition |
bcostm | 6:e1d9da7fe856 | 76 | */ |
bcostm | 6:e1d9da7fe856 | 77 | #define MSD_OK ((uint8_t)0x00) |
bcostm | 6:e1d9da7fe856 | 78 | #define MSD_ERROR ((uint8_t)0x01) |
bcostm | 6:e1d9da7fe856 | 79 | #define MSD_ERROR_SD_NOT_PRESENT ((uint8_t)0x02) |
Jerome Coutant
8:56384bddaba5
|
80
|
|
|
Jerome Coutant
8:56384bddaba5
|
81
|
/**
|
|
Jerome Coutant
8:56384bddaba5
|
82
|
* @brief SD transfer state definition
|
|
Jerome Coutant
8:56384bddaba5
|
83
|
*/
|
|
Jerome Coutant
8:56384bddaba5
|
84
|
#define SD_TRANSFER_OK ((uint8_t)0x00)
|
|
Jerome Coutant
8:56384bddaba5
|
85
|
#define SD_TRANSFER_BUSY ((uint8_t)0x01)
|
|
bcostm | 6:e1d9da7fe856 | 86 | |
bcostm | 6:e1d9da7fe856 | 87 | /** @defgroup STM32746G_DISCOVERY_SD_Exported_Constants STM32746G_DISCOVERY_SD Exported Constants |
bcostm | 6:e1d9da7fe856 | 88 | * @{ |
bcostm | 6:e1d9da7fe856 | 89 | */ |
bcostm | 6:e1d9da7fe856 | 90 | #define SD_PRESENT ((uint8_t)0x01) |
bcostm | 6:e1d9da7fe856 | 91 | #define SD_NOT_PRESENT ((uint8_t)0x00) |
bcostm | 6:e1d9da7fe856 | 92 | |
bcostm | 6:e1d9da7fe856 | 93 | #define SD_DATATIMEOUT ((uint32_t)100000000) |
bcostm | 6:e1d9da7fe856 | 94 | |
bcostm | 6:e1d9da7fe856 | 95 | /* DMA definitions for SD DMA transfer */ |
bcostm | 6:e1d9da7fe856 | 96 | #define __DMAx_TxRx_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE |
bcostm | 6:e1d9da7fe856 | 97 | #define SD_DMAx_Tx_CHANNEL DMA_CHANNEL_4 |
bcostm | 6:e1d9da7fe856 | 98 | #define SD_DMAx_Rx_CHANNEL DMA_CHANNEL_4 |
bcostm | 6:e1d9da7fe856 | 99 | #define SD_DMAx_Tx_STREAM DMA2_Stream6 |
bcostm | 6:e1d9da7fe856 | 100 | #define SD_DMAx_Rx_STREAM DMA2_Stream3 |
bcostm | 6:e1d9da7fe856 | 101 | #define SD_DMAx_Tx_IRQn DMA2_Stream6_IRQn |
bcostm | 6:e1d9da7fe856 | 102 | #define SD_DMAx_Rx_IRQn DMA2_Stream3_IRQn |
bcostm | 6:e1d9da7fe856 | 103 | #define BSP_SDMMC_IRQHandler SDMMC1_IRQHandler |
bcostm | 6:e1d9da7fe856 | 104 | #define BSP_SDMMC_DMA_Tx_IRQHandler DMA2_Stream6_IRQHandler |
bcostm | 6:e1d9da7fe856 | 105 | #define BSP_SDMMC_DMA_Rx_IRQHandler DMA2_Stream3_IRQHandler |
bcostm | 6:e1d9da7fe856 | 106 | #define SD_DetectIRQHandler() HAL_GPIO_EXTI_IRQHandler(SD_DETECT_PIN) |
bcostm | 6:e1d9da7fe856 | 107 | /** |
bcostm | 6:e1d9da7fe856 | 108 | * @} |
bcostm | 6:e1d9da7fe856 | 109 | */ |
bcostm | 6:e1d9da7fe856 | 110 | |
bcostm | 6:e1d9da7fe856 | 111 | /** @defgroup STM32746G_DISCOVERY_SD_Exported_Macro STM32746G_DISCOVERY_SD Exported Macro |
bcostm | 6:e1d9da7fe856 | 112 | * @{ |
bcostm | 6:e1d9da7fe856 | 113 | */ |
bcostm | 6:e1d9da7fe856 | 114 | /** |
bcostm | 6:e1d9da7fe856 | 115 | * @} |
bcostm | 6:e1d9da7fe856 | 116 | */ |
bcostm | 6:e1d9da7fe856 | 117 | |
bcostm | 6:e1d9da7fe856 | 118 | /** @addtogroup STM32746G_DISCOVERY_SD_Exported_Functions |
bcostm | 6:e1d9da7fe856 | 119 | * @{ |
bcostm | 6:e1d9da7fe856 | 120 | */ |
bcostm | 6:e1d9da7fe856 | 121 | uint8_t BSP_SD_Init(void); |
bcostm | 6:e1d9da7fe856 | 122 | uint8_t BSP_SD_DeInit(void); |
bcostm | 6:e1d9da7fe856 | 123 | uint8_t BSP_SD_ITConfig(void); |
Jerome Coutant
8:56384bddaba5
|
124
|
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout);
|
|
Jerome Coutant
8:56384bddaba5
|
125
|
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout);
|
|
Jerome Coutant
8:56384bddaba5
|
126
|
uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks);
|
|
Jerome Coutant
8:56384bddaba5
|
127
|
uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks);
|
|
Jerome Coutant
8:56384bddaba5
|
128
|
uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr);
|
|
Jerome Coutant
8:56384bddaba5
|
129
|
uint8_t BSP_SD_GetCardState(void);
|
|
Jerome Coutant
8:56384bddaba5
|
130
|
void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo);
|
|
bcostm | 6:e1d9da7fe856 | 131 | uint8_t BSP_SD_IsDetected(void); |
bcostm | 6:e1d9da7fe856 | 132 | |
bcostm | 6:e1d9da7fe856 | 133 | /* These functions can be modified in case the current settings (e.g. DMA stream) |
bcostm | 6:e1d9da7fe856 | 134 | need to be changed for specific application needs */ |
bcostm | 6:e1d9da7fe856 | 135 | void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params); |
bcostm | 6:e1d9da7fe856 | 136 | void BSP_SD_Detect_MspInit(SD_HandleTypeDef *hsd, void *Params); |
bcostm | 6:e1d9da7fe856 | 137 | void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params); |
Jerome Coutant
8:56384bddaba5
|
138
|
void BSP_SD_AbortCallback(void);
|
|
Jerome Coutant
8:56384bddaba5
|
139
|
void BSP_SD_WriteCpltCallback(void);
|
|
Jerome Coutant
8:56384bddaba5
|
140
|
void BSP_SD_ReadCpltCallback(void);
|
|
bcostm | 6:e1d9da7fe856 | 141 | /** |
bcostm | 6:e1d9da7fe856 | 142 | * @} |
bcostm | 6:e1d9da7fe856 | 143 | */ |
bcostm | 6:e1d9da7fe856 | 144 | |
bcostm | 6:e1d9da7fe856 | 145 | /** |
bcostm | 6:e1d9da7fe856 | 146 | * @} |
bcostm | 6:e1d9da7fe856 | 147 | */ |
bcostm | 6:e1d9da7fe856 | 148 | |
bcostm | 6:e1d9da7fe856 | 149 | /** |
bcostm | 6:e1d9da7fe856 | 150 | * @} |
bcostm | 6:e1d9da7fe856 | 151 | */ |
bcostm | 6:e1d9da7fe856 | 152 | |
bcostm | 6:e1d9da7fe856 | 153 | /** |
bcostm | 6:e1d9da7fe856 | 154 | * @} |
bcostm | 6:e1d9da7fe856 | 155 | */ |
bcostm | 6:e1d9da7fe856 | 156 | |
bcostm | 6:e1d9da7fe856 | 157 | #ifdef __cplusplus |
bcostm | 6:e1d9da7fe856 | 158 | } |
bcostm | 6:e1d9da7fe856 | 159 | #endif |
bcostm | 6:e1d9da7fe856 | 160 | |
bcostm | 6:e1d9da7fe856 | 161 | #endif /* __STM32746G_DISCOVERY_SD_H */ |
bcostm | 6:e1d9da7fe856 | 162 | |
bcostm | 6:e1d9da7fe856 | 163 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |