ST / BSP_DISCO_F769NI

Dependents:   mbed-os-example-blinky-5 DISCO-F769NI_TOUCHSCREEN_demo_custom_1 Datarecorder2 DISCO-F769NI_TOUCHSCREEN_demo ... more

Committer:
Jerome Coutant
Date:
Thu Feb 23 14:14:08 2017 +0100
Revision:
1:3e58f8a39705
Parent:
0:c0f3bbab73d2
Child:
4:72a949940ad6
STM32Cube_FW_F7_V1.6.0 BSP_DISCO_F769NI

Who changed what in which revision?

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