Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: DISCO_L496AG-LCD-prova_1 DISCO_L496AG-LCD-prova_2 DISCO_L496AG-LCD-demo DISCO_L496AG-SRAM-demo
Drivers/BSP/STM32L496G-Discovery/stm32l496g_discovery_sd.h@0:d83f1c8ca282, 2018-03-26 (annotated)
- Committer:
- bcostm
- Date:
- Mon Mar 26 10:28:18 2018 +0200
- Revision:
- 0:d83f1c8ca282
- Child:
- 2:106c7b82e064
Add BSP files coming from CubeL4 V1.11.0
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| bcostm | 0:d83f1c8ca282 | 1 | /** |
| bcostm | 0:d83f1c8ca282 | 2 | ****************************************************************************** |
| bcostm | 0:d83f1c8ca282 | 3 | * @file stm32l496g_discovery_sd.h |
| bcostm | 0:d83f1c8ca282 | 4 | * @author MCD Application Team |
| bcostm | 0:d83f1c8ca282 | 5 | * @brief This file includes the uSD card driver. |
| bcostm | 0:d83f1c8ca282 | 6 | ****************************************************************************** |
| bcostm | 0:d83f1c8ca282 | 7 | * @attention |
| bcostm | 0:d83f1c8ca282 | 8 | * |
| bcostm | 0:d83f1c8ca282 | 9 | * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
| bcostm | 0:d83f1c8ca282 | 10 | * |
| bcostm | 0:d83f1c8ca282 | 11 | * Redistribution and use in source and binary forms, with or without modification, |
| bcostm | 0:d83f1c8ca282 | 12 | * are permitted provided that the following conditions are met: |
| bcostm | 0:d83f1c8ca282 | 13 | * 1. Redistributions of source code must retain the above copyright notice, |
| bcostm | 0:d83f1c8ca282 | 14 | * this list of conditions and the following disclaimer. |
| bcostm | 0:d83f1c8ca282 | 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| bcostm | 0:d83f1c8ca282 | 16 | * this list of conditions and the following disclaimer in the documentation |
| bcostm | 0:d83f1c8ca282 | 17 | * and/or other materials provided with the distribution. |
| bcostm | 0:d83f1c8ca282 | 18 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| bcostm | 0:d83f1c8ca282 | 19 | * may be used to endorse or promote products derived from this software |
| bcostm | 0:d83f1c8ca282 | 20 | * without specific prior written permission. |
| bcostm | 0:d83f1c8ca282 | 21 | * |
| bcostm | 0:d83f1c8ca282 | 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| bcostm | 0:d83f1c8ca282 | 23 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| bcostm | 0:d83f1c8ca282 | 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| bcostm | 0:d83f1c8ca282 | 25 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| bcostm | 0:d83f1c8ca282 | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| bcostm | 0:d83f1c8ca282 | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| bcostm | 0:d83f1c8ca282 | 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| bcostm | 0:d83f1c8ca282 | 29 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| bcostm | 0:d83f1c8ca282 | 30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| bcostm | 0:d83f1c8ca282 | 31 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| bcostm | 0:d83f1c8ca282 | 32 | * |
| bcostm | 0:d83f1c8ca282 | 33 | ****************************************************************************** |
| bcostm | 0:d83f1c8ca282 | 34 | */ |
| bcostm | 0:d83f1c8ca282 | 35 | |
| bcostm | 0:d83f1c8ca282 | 36 | /* Define to prevent recursive inclusion -------------------------------------*/ |
| bcostm | 0:d83f1c8ca282 | 37 | #ifndef __STM32L496G_DISCOVERY_SD_H |
| bcostm | 0:d83f1c8ca282 | 38 | #define __STM32L496G_DISCOVERY_SD_H |
| bcostm | 0:d83f1c8ca282 | 39 | |
| bcostm | 0:d83f1c8ca282 | 40 | #ifdef __cplusplus |
| bcostm | 0:d83f1c8ca282 | 41 | extern "C" { |
| bcostm | 0:d83f1c8ca282 | 42 | #endif |
| bcostm | 0:d83f1c8ca282 | 43 | |
| bcostm | 0:d83f1c8ca282 | 44 | /* Includes ------------------------------------------------------------------*/ |
| bcostm | 0:d83f1c8ca282 | 45 | #include "stm32l4xx_hal.h" |
| bcostm | 0:d83f1c8ca282 | 46 | |
| bcostm | 0:d83f1c8ca282 | 47 | /** @addtogroup BSP |
| bcostm | 0:d83f1c8ca282 | 48 | * @{ |
| bcostm | 0:d83f1c8ca282 | 49 | */ |
| bcostm | 0:d83f1c8ca282 | 50 | |
| bcostm | 0:d83f1c8ca282 | 51 | /** @addtogroup STM32L496G_DISCOVERY |
| bcostm | 0:d83f1c8ca282 | 52 | * @{ |
| bcostm | 0:d83f1c8ca282 | 53 | */ |
| bcostm | 0:d83f1c8ca282 | 54 | |
| bcostm | 0:d83f1c8ca282 | 55 | /** @addtogroup STM32L496G_DISCOVERY_SD |
| bcostm | 0:d83f1c8ca282 | 56 | * @{ |
| bcostm | 0:d83f1c8ca282 | 57 | */ |
| bcostm | 0:d83f1c8ca282 | 58 | |
| bcostm | 0:d83f1c8ca282 | 59 | /* Exported types ------------------------------------------------------------*/ |
| bcostm | 0:d83f1c8ca282 | 60 | |
| bcostm | 0:d83f1c8ca282 | 61 | /** @defgroup STM32L496G_DISCOVERY_SD_Exported_Types Exported Types |
| bcostm | 0:d83f1c8ca282 | 62 | * @{ |
| bcostm | 0:d83f1c8ca282 | 63 | */ |
| bcostm | 0:d83f1c8ca282 | 64 | |
| bcostm | 0:d83f1c8ca282 | 65 | /** |
| bcostm | 0:d83f1c8ca282 | 66 | * @brief SD Card information structure |
| bcostm | 0:d83f1c8ca282 | 67 | */ |
| bcostm | 0:d83f1c8ca282 | 68 | #define BSP_SD_CardInfo HAL_SD_CardInfoTypeDef |
| bcostm | 0:d83f1c8ca282 | 69 | /** |
| bcostm | 0:d83f1c8ca282 | 70 | * @} |
| bcostm | 0:d83f1c8ca282 | 71 | */ |
| bcostm | 0:d83f1c8ca282 | 72 | |
| bcostm | 0:d83f1c8ca282 | 73 | /** |
| bcostm | 0:d83f1c8ca282 | 74 | * @brief SD status structure definition |
| bcostm | 0:d83f1c8ca282 | 75 | */ |
| bcostm | 0:d83f1c8ca282 | 76 | #define MSD_OK ((uint8_t)0x00) |
| bcostm | 0:d83f1c8ca282 | 77 | #define MSD_ERROR ((uint8_t)0x01) |
| bcostm | 0:d83f1c8ca282 | 78 | #define MSD_ERROR_SD_NOT_PRESENT ((uint8_t)0x02) |
| bcostm | 0:d83f1c8ca282 | 79 | |
| bcostm | 0:d83f1c8ca282 | 80 | /** |
| bcostm | 0:d83f1c8ca282 | 81 | * @brief SD transfer state definition |
| bcostm | 0:d83f1c8ca282 | 82 | */ |
| bcostm | 0:d83f1c8ca282 | 83 | #define SD_TRANSFER_OK ((uint8_t)0x00) |
| bcostm | 0:d83f1c8ca282 | 84 | #define SD_TRANSFER_BUSY ((uint8_t)0x01) |
| bcostm | 0:d83f1c8ca282 | 85 | #define SD_TRANSFER_ERROR ((uint8_t)0x02) |
| bcostm | 0:d83f1c8ca282 | 86 | |
| bcostm | 0:d83f1c8ca282 | 87 | /* Exported constants --------------------------------------------------------*/ |
| bcostm | 0:d83f1c8ca282 | 88 | |
| bcostm | 0:d83f1c8ca282 | 89 | /** @defgroup STM32L496G_DISCOVERY_SD_Exported_Constants Exported Constants |
| bcostm | 0:d83f1c8ca282 | 90 | * @{ |
| bcostm | 0:d83f1c8ca282 | 91 | */ |
| bcostm | 0:d83f1c8ca282 | 92 | #define SD_DETECT_PIN IO1_PIN_8 |
| bcostm | 0:d83f1c8ca282 | 93 | |
| bcostm | 0:d83f1c8ca282 | 94 | #define SD_DATATIMEOUT ((uint32_t)100000000) |
| bcostm | 0:d83f1c8ca282 | 95 | |
| bcostm | 0:d83f1c8ca282 | 96 | #define SD_PRESENT ((uint8_t)0x01) |
| bcostm | 0:d83f1c8ca282 | 97 | #define SD_NOT_PRESENT ((uint8_t)0x00) |
| bcostm | 0:d83f1c8ca282 | 98 | |
| bcostm | 0:d83f1c8ca282 | 99 | /* SD IRQ handler */ |
| bcostm | 0:d83f1c8ca282 | 100 | #define SDMMCx_IRQHandler SDMMC1_IRQHandler |
| bcostm | 0:d83f1c8ca282 | 101 | #define SDMMCx_IRQn SDMMC1_IRQn |
| bcostm | 0:d83f1c8ca282 | 102 | |
| bcostm | 0:d83f1c8ca282 | 103 | |
| bcostm | 0:d83f1c8ca282 | 104 | /* DMA definitions for SD DMA transfer */ |
| bcostm | 0:d83f1c8ca282 | 105 | #define SD_DMAx_CLK_ENABLE __HAL_RCC_DMA2_CLK_ENABLE |
| bcostm | 0:d83f1c8ca282 | 106 | #define SD_DMAx_CLK_DISABLE __HAL_RCC_DMA2_CLK_DISABLE |
| bcostm | 0:d83f1c8ca282 | 107 | #define SD_DMAx_STREAM DMA2_Channel5 |
| bcostm | 0:d83f1c8ca282 | 108 | #define SD_DMAx_IRQn DMA2_Channel5_IRQn |
| bcostm | 0:d83f1c8ca282 | 109 | #define SD_DMAx_IRQHandler DMA2_Channel5_IRQHandler |
| bcostm | 0:d83f1c8ca282 | 110 | |
| bcostm | 0:d83f1c8ca282 | 111 | /** |
| bcostm | 0:d83f1c8ca282 | 112 | * @} |
| bcostm | 0:d83f1c8ca282 | 113 | */ |
| bcostm | 0:d83f1c8ca282 | 114 | |
| bcostm | 0:d83f1c8ca282 | 115 | /* Exported functions --------------------------------------------------------*/ |
| bcostm | 0:d83f1c8ca282 | 116 | |
| bcostm | 0:d83f1c8ca282 | 117 | /** @defgroup STM32L496G_DISCOVERY_SD_Exported_Functions Exported Functions |
| bcostm | 0:d83f1c8ca282 | 118 | * @{ |
| bcostm | 0:d83f1c8ca282 | 119 | */ |
| bcostm | 0:d83f1c8ca282 | 120 | uint8_t BSP_SD_Init(void); |
| bcostm | 0:d83f1c8ca282 | 121 | uint8_t BSP_SD_DeInit(void); |
| bcostm | 0:d83f1c8ca282 | 122 | uint8_t BSP_SD_ITConfig(void); |
| bcostm | 0:d83f1c8ca282 | 123 | uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout); |
| bcostm | 0:d83f1c8ca282 | 124 | uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout); |
| bcostm | 0:d83f1c8ca282 | 125 | uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks); |
| bcostm | 0:d83f1c8ca282 | 126 | uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks); |
| bcostm | 0:d83f1c8ca282 | 127 | uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr); |
| bcostm | 0:d83f1c8ca282 | 128 | void BSP_SD_IRQHandler(void); |
| bcostm | 0:d83f1c8ca282 | 129 | void BSP_SD_DMA_Tx_IRQHandler(void); |
| bcostm | 0:d83f1c8ca282 | 130 | void BSP_SD_DMA_Rx_IRQHandler(void); |
| bcostm | 0:d83f1c8ca282 | 131 | uint8_t BSP_SD_GetCardState(void); |
| bcostm | 0:d83f1c8ca282 | 132 | void BSP_SD_GetCardInfo(BSP_SD_CardInfo *CardInfo); |
| bcostm | 0:d83f1c8ca282 | 133 | uint8_t BSP_SD_IsDetected(void); |
| bcostm | 0:d83f1c8ca282 | 134 | |
| bcostm | 0:d83f1c8ca282 | 135 | /* These __weak functions can be surcharged by application code in case the current settings |
| bcostm | 0:d83f1c8ca282 | 136 | (eg. interrupt priority, callbacks implementation) need to be changed for specific application needs */ |
| bcostm | 0:d83f1c8ca282 | 137 | void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params); |
| bcostm | 0:d83f1c8ca282 | 138 | void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params); |
| bcostm | 0:d83f1c8ca282 | 139 | void BSP_SD_AbortCallback(void); |
| bcostm | 0:d83f1c8ca282 | 140 | void BSP_SD_WriteCpltCallback(void); |
| bcostm | 0:d83f1c8ca282 | 141 | void BSP_SD_ReadCpltCallback(void); |
| bcostm | 0:d83f1c8ca282 | 142 | |
| bcostm | 0:d83f1c8ca282 | 143 | /** |
| bcostm | 0:d83f1c8ca282 | 144 | * @} |
| bcostm | 0:d83f1c8ca282 | 145 | */ |
| bcostm | 0:d83f1c8ca282 | 146 | |
| bcostm | 0:d83f1c8ca282 | 147 | /** |
| bcostm | 0:d83f1c8ca282 | 148 | * @} |
| bcostm | 0:d83f1c8ca282 | 149 | */ |
| bcostm | 0:d83f1c8ca282 | 150 | |
| bcostm | 0:d83f1c8ca282 | 151 | /** |
| bcostm | 0:d83f1c8ca282 | 152 | * @} |
| bcostm | 0:d83f1c8ca282 | 153 | */ |
| bcostm | 0:d83f1c8ca282 | 154 | |
| bcostm | 0:d83f1c8ca282 | 155 | /** |
| bcostm | 0:d83f1c8ca282 | 156 | * @} |
| bcostm | 0:d83f1c8ca282 | 157 | */ |
| bcostm | 0:d83f1c8ca282 | 158 | |
| bcostm | 0:d83f1c8ca282 | 159 | #ifdef __cplusplus |
| bcostm | 0:d83f1c8ca282 | 160 | } |
| bcostm | 0:d83f1c8ca282 | 161 | #endif |
| bcostm | 0:d83f1c8ca282 | 162 | |
| bcostm | 0:d83f1c8ca282 | 163 | #endif /* __STM32L496G_DISCOVERY_SD_H */ |
| bcostm | 0:d83f1c8ca282 | 164 | |
| bcostm | 0:d83f1c8ca282 | 165 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |