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