bugfixes and reduced version for disco board only

Dependents:   Scope DISCO-F746NG_Sinewave DISCO-F746NG_Sweep DISCO-F746NG_Oscilloscope ... more

Fork of BSP_DISCO_F746NG_patch by Nirvana Jay

Committer:
the_sz
Date:
Sun Jan 31 17:45:21 2016 +0000
Revision:
7:a4e658110084
Parent:
1:e8fac4061a5b
remove debug line

Who changed what in which revision?

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