BSP_DISCO_L4R9I
Dependents: DISCO_L4R9I-LCD-demo
Drivers/BSP/STM32L4R9I-Discovery/stm32l4r9i_discovery_sd.c@1:2105b8894450, 2019-11-26 (annotated)
- Committer:
- Jerome Coutant
- Date:
- Tue Nov 26 14:35:07 2019 +0100
- Revision:
- 1:2105b8894450
- Parent:
- 0:31ddfafdd3da
Update for MBED use
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jerome Coutant
0:31ddfafdd3da
|
1
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
2
|
******************************************************************************
|
|
Jerome Coutant
0:31ddfafdd3da
|
3
|
* @file stm32l4r9i_discovery_sd.c
|
|
Jerome Coutant
0:31ddfafdd3da
|
4
|
* @author MCD Application Team
|
|
Jerome Coutant
0:31ddfafdd3da
|
5
|
* @brief This file includes the uSD card driver.
|
|
Jerome Coutant
0:31ddfafdd3da
|
6
|
@verbatim
|
|
Jerome Coutant
0:31ddfafdd3da
|
7
|
==============================================================================
|
|
Jerome Coutant
0:31ddfafdd3da
|
8
|
##### How to use this driver #####
|
|
Jerome Coutant
0:31ddfafdd3da
|
9
|
==============================================================================
|
|
Jerome Coutant
0:31ddfafdd3da
|
10
|
(#) This driver is used to drive the micro SD external card mounted on STM32L4R9I_DISCOVERY
|
|
Jerome Coutant
0:31ddfafdd3da
|
11
|
evaluation board.
|
|
Jerome Coutant
0:31ddfafdd3da
|
12
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
13
|
(#) This driver does not need a specific component driver for the micro SD device
|
|
Jerome Coutant
0:31ddfafdd3da
|
14
|
to be included with.
|
|
Jerome Coutant
0:31ddfafdd3da
|
15
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
16
|
(#) Initialization steps:
|
|
Jerome Coutant
0:31ddfafdd3da
|
17
|
(++) Initialize the micro SD card using the BSP_SD_Init() function. This
|
|
Jerome Coutant
0:31ddfafdd3da
|
18
|
function includes the MSP layer hardware resources initialization (BSP_SD_MspInit())
|
|
Jerome Coutant
0:31ddfafdd3da
|
19
|
and the SDMMC1 interface configuration to interface with the external micro SD. It
|
|
Jerome Coutant
0:31ddfafdd3da
|
20
|
also includes the micro SD initialization sequence.
|
|
Jerome Coutant
0:31ddfafdd3da
|
21
|
(++) To check the SD card presence you can use the function BSP_SD_IsDetected() which
|
|
Jerome Coutant
0:31ddfafdd3da
|
22
|
returns the detection status.
|
|
Jerome Coutant
0:31ddfafdd3da
|
23
|
(++) If SD presence detection interrupt mode is desired, you must configure the
|
|
Jerome Coutant
0:31ddfafdd3da
|
24
|
SD detection interrupt mode by calling the functions BSP_SD_ITConfig().
|
|
Jerome Coutant
0:31ddfafdd3da
|
25
|
The interrupt is generated as an external interrupt whenever the
|
|
Jerome Coutant
0:31ddfafdd3da
|
26
|
micro SD card is plugged/unplugged in/from the evaluation board. The SD detection
|
|
Jerome Coutant
0:31ddfafdd3da
|
27
|
is managed by MFX, so the SD detection interrupt has to be treated by MFX_IRQOUT
|
|
Jerome Coutant
0:31ddfafdd3da
|
28
|
gpio pin IRQ handler.
|
|
Jerome Coutant
0:31ddfafdd3da
|
29
|
(++) The function BSP_SD_GetCardInfo() is used to get the micro SD card information
|
|
Jerome Coutant
0:31ddfafdd3da
|
30
|
which is stored in the structure "HAL_SD_CardInfoTypedef".
|
|
Jerome Coutant
0:31ddfafdd3da
|
31
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
32
|
(#) Micro SD card operations
|
|
Jerome Coutant
0:31ddfafdd3da
|
33
|
(++) The micro SD card can be accessed with read/write block(s) operations once
|
|
Jerome Coutant
0:31ddfafdd3da
|
34
|
it is reay for access. The access can be performed whether using the polling
|
|
Jerome Coutant
0:31ddfafdd3da
|
35
|
mode by calling the functions BSP_SD_ReadBlocks()/BSP_SD_WriteBlocks(),
|
|
Jerome Coutant
0:31ddfafdd3da
|
36
|
or by DMA transfer using the functions BSP_SD_ReadBlocks_DMA()/BSP_SD_WriteBlocks_DMA().
|
|
Jerome Coutant
0:31ddfafdd3da
|
37
|
(++) The DMA transfer complete is used with interrupt mode. Once the SD transfer
|
|
Jerome Coutant
0:31ddfafdd3da
|
38
|
is complete, the DMA Tx/Rx transfer complete are handled using the
|
|
Jerome Coutant
0:31ddfafdd3da
|
39
|
BSP_SD_WriteCpltCallback()/BSP_SD_ReadCpltCallback() user callback functions implemented
|
|
Jerome Coutant
0:31ddfafdd3da
|
40
|
by the user at application level.
|
|
Jerome Coutant
0:31ddfafdd3da
|
41
|
(++) The SD erase block(s) is performed using the function BSP_SD_Erase() with specifying
|
|
Jerome Coutant
0:31ddfafdd3da
|
42
|
the number of blocks to erase.
|
|
Jerome Coutant
0:31ddfafdd3da
|
43
|
(++) The SD runtime status is returned when calling the function BSP_SD_GetStatus().
|
|
Jerome Coutant
0:31ddfafdd3da
|
44
|
[..]
|
|
Jerome Coutant
0:31ddfafdd3da
|
45
|
@endverbatim
|
|
Jerome Coutant
0:31ddfafdd3da
|
46
|
******************************************************************************
|
|
Jerome Coutant
0:31ddfafdd3da
|
47
|
* @attention
|
|
Jerome Coutant
0:31ddfafdd3da
|
48
|
*
|
|
Jerome Coutant
0:31ddfafdd3da
|
49
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
|
Jerome Coutant
0:31ddfafdd3da
|
50
|
* All rights reserved.</center></h2>
|
|
Jerome Coutant
0:31ddfafdd3da
|
51
|
*
|
|
Jerome Coutant
0:31ddfafdd3da
|
52
|
* This software component is licensed by ST under BSD 3-Clause license,
|
|
Jerome Coutant
0:31ddfafdd3da
|
53
|
* the "License"; You may not use this file except in compliance with the
|
|
Jerome Coutant
0:31ddfafdd3da
|
54
|
* License. You may obtain a copy of the License at:
|
|
Jerome Coutant
0:31ddfafdd3da
|
55
|
* opensource.org/licenses/BSD-3-Clause
|
|
Jerome Coutant
0:31ddfafdd3da
|
56
|
*
|
|
Jerome Coutant
0:31ddfafdd3da
|
57
|
******************************************************************************
|
|
Jerome Coutant
0:31ddfafdd3da
|
58
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
59
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
60
|
/* Includes ------------------------------------------------------------------*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
61
|
#include "stm32l4r9i_discovery_io.h"
|
|
Jerome Coutant
0:31ddfafdd3da
|
62
|
#include "stm32l4r9i_discovery_sd.h"
|
|
Jerome Coutant
0:31ddfafdd3da
|
63
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
64
|
/** @addtogroup BSP
|
|
Jerome Coutant
0:31ddfafdd3da
|
65
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
66
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
67
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
68
|
/** @addtogroup STM32L4R9I_DISCOVERY
|
|
Jerome Coutant
0:31ddfafdd3da
|
69
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
70
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
71
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
72
|
/** @defgroup STM32L4R9I_DISCOVERY_SD STM32L4R9I_DISCOVERY SD
|
|
Jerome Coutant
0:31ddfafdd3da
|
73
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
74
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
75
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
76
|
/* Private variables ---------------------------------------------------------*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
77
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
78
|
/** @defgroup STM32L4R9I_DISCOVERY_SD_Private_Variables Private Variables
|
|
Jerome Coutant
0:31ddfafdd3da
|
79
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
80
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
81
|
SD_HandleTypeDef hsd_discovery;
|
|
Jerome Coutant
0:31ddfafdd3da
|
82
|
static uint8_t UseExtiModeDetection = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
83
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
84
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
85
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
86
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
87
|
/* Private function prototypes -----------------------------------------------*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
88
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
89
|
/* Exported functions ---------------------------------------------------------*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
90
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
91
|
/** @addtogroup STM32L4R9I_DISCOVERY_SD_Exported_Functions
|
|
Jerome Coutant
0:31ddfafdd3da
|
92
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
93
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
94
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
95
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
96
|
* @brief Initializes the SD card device.
|
|
Jerome Coutant
0:31ddfafdd3da
|
97
|
* @retval SD status
|
|
Jerome Coutant
0:31ddfafdd3da
|
98
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
99
|
uint8_t BSP_SD_Init(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
100
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
101
|
uint8_t sd_state = MSD_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
102
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
103
|
/* uSD device interface configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
104
|
hsd_discovery.Instance = SDMMC1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
105
|
hsd_discovery.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
|
|
Jerome Coutant
0:31ddfafdd3da
|
106
|
hsd_discovery.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
107
|
hsd_discovery.Init.BusWide = SDMMC_BUS_WIDE_4B;
|
|
Jerome Coutant
0:31ddfafdd3da
|
108
|
hsd_discovery.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_ENABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
109
|
hsd_discovery.Init.ClockDiv = 1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
110
|
hsd_discovery.Init.Transceiver = SDMMC_TRANSCEIVER_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
111
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
112
|
/* Initialize IO functionalities (MFX) used by SD detect pin */
|
|
Jerome Coutant
0:31ddfafdd3da
|
113
|
BSP_IO_Init();
|
|
Jerome Coutant
0:31ddfafdd3da
|
114
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
115
|
/* Check if the SD card is plugged in the slot */
|
|
Jerome Coutant
0:31ddfafdd3da
|
116
|
BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_INPUT_PU);
|
|
Jerome Coutant
0:31ddfafdd3da
|
117
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
118
|
/* Check if the SD card is plugged in the slot */
|
|
Jerome Coutant
0:31ddfafdd3da
|
119
|
if(BSP_SD_IsDetected() != SD_PRESENT)
|
|
Jerome Coutant
0:31ddfafdd3da
|
120
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
121
|
return MSD_ERROR_SD_NOT_PRESENT;
|
|
Jerome Coutant
0:31ddfafdd3da
|
122
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
123
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
124
|
/* Msp SD initialization */
|
|
Jerome Coutant
0:31ddfafdd3da
|
125
|
BSP_SD_MspInit(&hsd_discovery, NULL);
|
|
Jerome Coutant
0:31ddfafdd3da
|
126
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
127
|
/* HAL SD initialization */
|
|
Jerome Coutant
0:31ddfafdd3da
|
128
|
if(HAL_SD_Init(&hsd_discovery) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
129
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
130
|
sd_state = MSD_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
131
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
132
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
133
|
return sd_state;
|
|
Jerome Coutant
0:31ddfafdd3da
|
134
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
135
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
136
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
137
|
* @brief DeInitializes the SD card device.
|
|
Jerome Coutant
0:31ddfafdd3da
|
138
|
* @retval SD status
|
|
Jerome Coutant
0:31ddfafdd3da
|
139
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
140
|
uint8_t BSP_SD_DeInit(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
141
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
142
|
uint8_t sd_state = MSD_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
143
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
144
|
hsd_discovery.Instance = SDMMC1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
145
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
146
|
/* Set back Mfx pin to INPUT mode in case it was in exti */
|
|
Jerome Coutant
0:31ddfafdd3da
|
147
|
UseExtiModeDetection = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
148
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
149
|
/* HAL SD deinitialization */
|
|
Jerome Coutant
0:31ddfafdd3da
|
150
|
if(HAL_SD_DeInit(&hsd_discovery) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
151
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
152
|
sd_state = MSD_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
153
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
154
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
155
|
/* Msp SD deinitialization */
|
|
Jerome Coutant
0:31ddfafdd3da
|
156
|
BSP_SD_MspDeInit(&hsd_discovery, NULL);
|
|
Jerome Coutant
0:31ddfafdd3da
|
157
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
158
|
return sd_state;
|
|
Jerome Coutant
0:31ddfafdd3da
|
159
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
160
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
161
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
162
|
* @brief Configures Interrupt mode for SD detection pin.
|
|
Jerome Coutant
0:31ddfafdd3da
|
163
|
* @retval IO_OK: if all initializations are OK. Other value if error.
|
|
Jerome Coutant
0:31ddfafdd3da
|
164
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
165
|
uint8_t BSP_SD_ITConfig(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
166
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
167
|
/* Configure Interrupt mode for SD detection pin */
|
|
Jerome Coutant
0:31ddfafdd3da
|
168
|
/* Note: disabling exti mode can be done calling BSP_SD_DeInit() */
|
|
Jerome Coutant
0:31ddfafdd3da
|
169
|
UseExtiModeDetection = 1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
170
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
171
|
/* Check SD card detect pin */
|
|
Jerome Coutant
0:31ddfafdd3da
|
172
|
if(BSP_IO_ReadPin(SD_DETECT_PIN) == IO_PIN_RESET)
|
|
Jerome Coutant
0:31ddfafdd3da
|
173
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
174
|
/* Card present */
|
|
Jerome Coutant
0:31ddfafdd3da
|
175
|
return BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_IT_RISING_EDGE_PU);
|
|
Jerome Coutant
0:31ddfafdd3da
|
176
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
177
|
else
|
|
Jerome Coutant
0:31ddfafdd3da
|
178
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
179
|
/* Card not present */
|
|
Jerome Coutant
0:31ddfafdd3da
|
180
|
return BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_IT_FALLING_EDGE_PU);
|
|
Jerome Coutant
0:31ddfafdd3da
|
181
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
182
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
183
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
184
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
185
|
* @brief Detects if SD card is correctly plugged in the memory slot or not.
|
|
Jerome Coutant
0:31ddfafdd3da
|
186
|
* @retval Returns if SD is detected or not
|
|
Jerome Coutant
0:31ddfafdd3da
|
187
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
188
|
uint8_t BSP_SD_IsDetected(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
189
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
190
|
__IO uint8_t status = SD_PRESENT;
|
|
Jerome Coutant
0:31ddfafdd3da
|
191
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
192
|
/* Check SD card detect pin */
|
|
Jerome Coutant
0:31ddfafdd3da
|
193
|
if (BSP_IO_ReadPin(SD_DETECT_PIN) == IO_PIN_RESET)
|
|
Jerome Coutant
0:31ddfafdd3da
|
194
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
195
|
/* Card present */
|
|
Jerome Coutant
0:31ddfafdd3da
|
196
|
if (UseExtiModeDetection)
|
|
Jerome Coutant
0:31ddfafdd3da
|
197
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
198
|
BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_IT_RISING_EDGE_PU);
|
|
Jerome Coutant
0:31ddfafdd3da
|
199
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
200
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
201
|
else
|
|
Jerome Coutant
0:31ddfafdd3da
|
202
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
203
|
/* Card not present */
|
|
Jerome Coutant
0:31ddfafdd3da
|
204
|
status = SD_NOT_PRESENT;
|
|
Jerome Coutant
0:31ddfafdd3da
|
205
|
if (UseExtiModeDetection)
|
|
Jerome Coutant
0:31ddfafdd3da
|
206
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
207
|
BSP_IO_ConfigPin(SD_DETECT_PIN, IO_MODE_IT_FALLING_EDGE_PU);
|
|
Jerome Coutant
0:31ddfafdd3da
|
208
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
209
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
210
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
211
|
return status;
|
|
Jerome Coutant
0:31ddfafdd3da
|
212
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
213
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
214
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
215
|
* @brief Reads block(s) from a specified address in an SD card, in polling mode.
|
|
Jerome Coutant
0:31ddfafdd3da
|
216
|
* @param pData: Pointer to the buffer that will contain the data to transmit
|
|
Jerome Coutant
0:31ddfafdd3da
|
217
|
* @param ReadAddr: Address from where data is to be read
|
|
Jerome Coutant
0:31ddfafdd3da
|
218
|
* @param NumOfBlocks: Number of SD blocks to read
|
|
Jerome Coutant
0:31ddfafdd3da
|
219
|
* @param Timeout: Timeout for read operation
|
|
Jerome Coutant
0:31ddfafdd3da
|
220
|
* @retval SD status
|
|
Jerome Coutant
0:31ddfafdd3da
|
221
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
222
|
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout)
|
|
Jerome Coutant
0:31ddfafdd3da
|
223
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
224
|
HAL_StatusTypeDef sd_state = HAL_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
225
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
226
|
sd_state = HAL_SD_ReadBlocks(&hsd_discovery, (uint8_t *)pData, ReadAddr, NumOfBlocks, Timeout);
|
|
Jerome Coutant
0:31ddfafdd3da
|
227
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
228
|
if (sd_state == HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
229
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
230
|
return MSD_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
231
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
232
|
else
|
|
Jerome Coutant
0:31ddfafdd3da
|
233
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
234
|
return MSD_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
235
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
236
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
237
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
238
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
239
|
* @brief Writes block(s) to a specified address in an SD card, in polling mode.
|
|
Jerome Coutant
0:31ddfafdd3da
|
240
|
* @param pData: Pointer to the buffer that will contain the data to transmit
|
|
Jerome Coutant
0:31ddfafdd3da
|
241
|
* @param WriteAddr: Address from where data is to be written
|
|
Jerome Coutant
0:31ddfafdd3da
|
242
|
* @param NumOfBlocks: Number of SD blocks to write
|
|
Jerome Coutant
0:31ddfafdd3da
|
243
|
* @param Timeout: Timeout for write operation
|
|
Jerome Coutant
0:31ddfafdd3da
|
244
|
* @retval SD status
|
|
Jerome Coutant
0:31ddfafdd3da
|
245
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
246
|
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout)
|
|
Jerome Coutant
0:31ddfafdd3da
|
247
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
248
|
HAL_StatusTypeDef sd_state = HAL_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
249
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
250
|
sd_state = HAL_SD_WriteBlocks(&hsd_discovery, (uint8_t *)pData, WriteAddr, NumOfBlocks, Timeout);
|
|
Jerome Coutant
0:31ddfafdd3da
|
251
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
252
|
if( sd_state == HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
253
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
254
|
return MSD_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
255
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
256
|
else
|
|
Jerome Coutant
0:31ddfafdd3da
|
257
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
258
|
return MSD_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
259
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
260
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
261
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
262
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
263
|
* @brief Reads block(s) from a specified address in an SD card, in DMA mode.
|
|
Jerome Coutant
0:31ddfafdd3da
|
264
|
* @param pData: Pointer to the buffer that will contain the data to transmit
|
|
Jerome Coutant
0:31ddfafdd3da
|
265
|
* @param ReadAddr: Address from where data is to be read
|
|
Jerome Coutant
0:31ddfafdd3da
|
266
|
* @param NumOfBlocks: Number of SD blocks to read
|
|
Jerome Coutant
0:31ddfafdd3da
|
267
|
* @retval SD status
|
|
Jerome Coutant
0:31ddfafdd3da
|
268
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
269
|
uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks)
|
|
Jerome Coutant
0:31ddfafdd3da
|
270
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
271
|
HAL_StatusTypeDef sd_state = HAL_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
272
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
273
|
/* Read block(s) in DMA transfer mode */
|
|
Jerome Coutant
0:31ddfafdd3da
|
274
|
sd_state = HAL_SD_ReadBlocks_DMA(&hsd_discovery, (uint8_t *)pData, ReadAddr, NumOfBlocks);
|
|
Jerome Coutant
0:31ddfafdd3da
|
275
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
276
|
if( sd_state == HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
277
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
278
|
return MSD_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
279
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
280
|
else
|
|
Jerome Coutant
0:31ddfafdd3da
|
281
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
282
|
return MSD_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
283
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
284
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
285
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
286
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
287
|
* @brief Writes block(s) to a specified address in an SD card, in DMA mode.
|
|
Jerome Coutant
0:31ddfafdd3da
|
288
|
* @param pData: Pointer to the buffer that will contain the data to transmit
|
|
Jerome Coutant
0:31ddfafdd3da
|
289
|
* @param WriteAddr: Address from where data is to be written
|
|
Jerome Coutant
0:31ddfafdd3da
|
290
|
* @param NumOfBlocks: Number of SD blocks to write
|
|
Jerome Coutant
0:31ddfafdd3da
|
291
|
* @retval SD status
|
|
Jerome Coutant
0:31ddfafdd3da
|
292
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
293
|
uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks)
|
|
Jerome Coutant
0:31ddfafdd3da
|
294
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
295
|
HAL_StatusTypeDef sd_state = HAL_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
296
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
297
|
/* Write block(s) in DMA transfer mode */
|
|
Jerome Coutant
0:31ddfafdd3da
|
298
|
sd_state = HAL_SD_WriteBlocks_DMA(&hsd_discovery, (uint8_t *)pData, WriteAddr, NumOfBlocks);
|
|
Jerome Coutant
0:31ddfafdd3da
|
299
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
300
|
if( sd_state == HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
301
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
302
|
return MSD_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
303
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
304
|
else
|
|
Jerome Coutant
0:31ddfafdd3da
|
305
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
306
|
return MSD_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
307
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
308
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
309
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
310
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
311
|
* @brief Erases the specified memory area of the given SD card.
|
|
Jerome Coutant
0:31ddfafdd3da
|
312
|
* @param StartAddr: Start byte address
|
|
Jerome Coutant
0:31ddfafdd3da
|
313
|
* @param EndAddr: End byte address
|
|
Jerome Coutant
0:31ddfafdd3da
|
314
|
* @retval SD status
|
|
Jerome Coutant
0:31ddfafdd3da
|
315
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
316
|
uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr)
|
|
Jerome Coutant
0:31ddfafdd3da
|
317
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
318
|
HAL_StatusTypeDef sd_state = HAL_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
319
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
320
|
sd_state = HAL_SD_Erase(&hsd_discovery, StartAddr, EndAddr);
|
|
Jerome Coutant
0:31ddfafdd3da
|
321
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
322
|
if( sd_state == HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
323
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
324
|
return MSD_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
325
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
326
|
else
|
|
Jerome Coutant
0:31ddfafdd3da
|
327
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
328
|
return MSD_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
329
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
330
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
331
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
332
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
333
|
* @brief Gets the current SD card data status.
|
|
Jerome Coutant
0:31ddfafdd3da
|
334
|
* @retval Data transfer state.
|
|
Jerome Coutant
0:31ddfafdd3da
|
335
|
* This value can be one of the following values:
|
|
Jerome Coutant
0:31ddfafdd3da
|
336
|
* @arg SD_TRANSFER_OK: No data transfer is acting
|
|
Jerome Coutant
0:31ddfafdd3da
|
337
|
* @arg SD_TRANSFER_BUSY: Data transfer is acting
|
|
Jerome Coutant
0:31ddfafdd3da
|
338
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
339
|
uint8_t BSP_SD_GetCardState(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
340
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
341
|
return((HAL_SD_GetCardState(&hsd_discovery) == HAL_SD_CARD_TRANSFER ) ? SD_TRANSFER_OK : SD_TRANSFER_BUSY);
|
|
Jerome Coutant
0:31ddfafdd3da
|
342
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
343
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
344
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
345
|
* @brief Get SD information about specific SD card.
|
|
Jerome Coutant
0:31ddfafdd3da
|
346
|
* @param CardInfo: Pointer to HAL_SD_CardInfoTypedef structure
|
|
Jerome Coutant
0:31ddfafdd3da
|
347
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
348
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
349
|
void BSP_SD_GetCardInfo(BSP_SD_CardInfo *CardInfo)
|
|
Jerome Coutant
0:31ddfafdd3da
|
350
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
351
|
/* Get SD card Information */
|
|
Jerome Coutant
0:31ddfafdd3da
|
352
|
HAL_SD_GetCardInfo(&hsd_discovery, CardInfo);
|
|
Jerome Coutant
0:31ddfafdd3da
|
353
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
354
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
355
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
356
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
357
|
* @brief Initializes the SD MSP.
|
|
Jerome Coutant
0:31ddfafdd3da
|
358
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
359
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
360
|
__weak void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params)
|
|
Jerome Coutant
0:31ddfafdd3da
|
361
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
362
|
GPIO_InitTypeDef gpioinitstruct = {0};
|
|
Jerome Coutant
0:31ddfafdd3da
|
363
|
RCC_OscInitTypeDef RCC_OscInitStruct;
|
|
Jerome Coutant
0:31ddfafdd3da
|
364
|
RCC_PeriphCLKInitTypeDef RCC_PeriphClkInit;
|
|
Jerome Coutant
0:31ddfafdd3da
|
365
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
366
|
/* Check whether HSI48 is enabled or not */
|
|
Jerome Coutant
0:31ddfafdd3da
|
367
|
HAL_RCC_GetOscConfig(&RCC_OscInitStruct);
|
|
Jerome Coutant
0:31ddfafdd3da
|
368
|
if(RCC_OscInitStruct.HSI48State != RCC_HSI48_ON)
|
|
Jerome Coutant
0:31ddfafdd3da
|
369
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
370
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48;
|
|
Jerome Coutant
0:31ddfafdd3da
|
371
|
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
|
|
Jerome Coutant
0:31ddfafdd3da
|
372
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
373
|
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
374
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
375
|
while(1) {}
|
|
Jerome Coutant
0:31ddfafdd3da
|
376
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
377
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
378
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
379
|
/* Configure the SDMMC1 clock source. The clock is derived from the HSI48 */
|
|
Jerome Coutant
0:31ddfafdd3da
|
380
|
RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_SDMMC1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
381
|
RCC_PeriphClkInit.Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_HSI48;
|
|
Jerome Coutant
0:31ddfafdd3da
|
382
|
if(HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit) != HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
383
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
384
|
while(1) {}
|
|
Jerome Coutant
0:31ddfafdd3da
|
385
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
386
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
387
|
/* Enable SDMMC1 clock */
|
|
Jerome Coutant
0:31ddfafdd3da
|
388
|
__HAL_RCC_SDMMC1_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
389
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
390
|
/* Enable GPIOs clock */
|
|
Jerome Coutant
0:31ddfafdd3da
|
391
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
392
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
393
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
394
|
/* Common GPIO configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
395
|
gpioinitstruct.Mode = GPIO_MODE_AF_PP;
|
|
Jerome Coutant
0:31ddfafdd3da
|
396
|
gpioinitstruct.Pull = GPIO_PULLUP;
|
|
Jerome Coutant
0:31ddfafdd3da
|
397
|
gpioinitstruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
Jerome Coutant
0:31ddfafdd3da
|
398
|
gpioinitstruct.Alternate = GPIO_AF12_SDMMC1;
|
|
Jerome Coutant
0:31ddfafdd3da
|
399
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
400
|
/* GPIOC configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
401
|
gpioinitstruct.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;
|
|
Jerome Coutant
0:31ddfafdd3da
|
402
|
HAL_GPIO_Init(GPIOC, &gpioinitstruct);
|
|
Jerome Coutant
0:31ddfafdd3da
|
403
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
404
|
/* GPIOD configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
405
|
gpioinitstruct.Pin = GPIO_PIN_2;
|
|
Jerome Coutant
0:31ddfafdd3da
|
406
|
HAL_GPIO_Init(GPIOD, &gpioinitstruct);
|
|
Jerome Coutant
0:31ddfafdd3da
|
407
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
408
|
/* NVIC configuration for SDMMC1 interrupts */
|
|
Jerome Coutant
0:31ddfafdd3da
|
409
|
HAL_NVIC_SetPriority(SDMMCx_IRQn, 5, 0);
|
|
Jerome Coutant
0:31ddfafdd3da
|
410
|
HAL_NVIC_EnableIRQ(SDMMCx_IRQn);
|
|
Jerome Coutant
0:31ddfafdd3da
|
411
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
412
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
413
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
414
|
* @brief De-Initializes the SD MSP.
|
|
Jerome Coutant
0:31ddfafdd3da
|
415
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
416
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
417
|
__weak void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params)
|
|
Jerome Coutant
0:31ddfafdd3da
|
418
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
419
|
GPIO_InitTypeDef gpioinitstruct = {0};
|
|
Jerome Coutant
0:31ddfafdd3da
|
420
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
421
|
/* NVIC configuration for SDMMC1 interrupts */
|
|
Jerome Coutant
0:31ddfafdd3da
|
422
|
HAL_NVIC_DisableIRQ(SDMMCx_IRQn);
|
|
Jerome Coutant
0:31ddfafdd3da
|
423
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
424
|
/* Disable SDMMC1 clock */
|
|
Jerome Coutant
0:31ddfafdd3da
|
425
|
__HAL_RCC_SDMMC1_CLK_DISABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
426
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
427
|
/* Enable GPIOs clock */
|
|
Jerome Coutant
0:31ddfafdd3da
|
428
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
429
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
430
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
431
|
/* Common GPIO configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
432
|
gpioinitstruct.Mode = GPIO_MODE_ANALOG;
|
|
Jerome Coutant
0:31ddfafdd3da
|
433
|
gpioinitstruct.Pull = GPIO_NOPULL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
434
|
gpioinitstruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
Jerome Coutant
0:31ddfafdd3da
|
435
|
gpioinitstruct.Alternate = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
436
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
437
|
/* GPIOC configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
438
|
gpioinitstruct.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;
|
|
Jerome Coutant
0:31ddfafdd3da
|
439
|
HAL_GPIO_Init(GPIOC, &gpioinitstruct);
|
|
Jerome Coutant
0:31ddfafdd3da
|
440
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
441
|
/* GPIOD configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
442
|
gpioinitstruct.Pin = GPIO_PIN_2;
|
|
Jerome Coutant
0:31ddfafdd3da
|
443
|
HAL_GPIO_Init(GPIOD, &gpioinitstruct);
|
|
Jerome Coutant
0:31ddfafdd3da
|
444
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
445
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
446
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
447
|
* @brief BSP SD Abort callback
|
|
Jerome Coutant
0:31ddfafdd3da
|
448
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
449
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
450
|
__weak void BSP_SD_AbortCallback(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
451
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
452
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
453
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
454
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
455
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
456
|
* @brief BSP Tx Transfer completed callback
|
|
Jerome Coutant
0:31ddfafdd3da
|
457
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
458
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
459
|
__weak void BSP_SD_WriteCpltCallback(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
460
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
461
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
462
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
463
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
464
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
465
|
* @brief BSP Rx Transfer completed callback
|
|
Jerome Coutant
0:31ddfafdd3da
|
466
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
467
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
468
|
__weak void BSP_SD_ReadCpltCallback(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
469
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
470
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
471
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
472
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
473
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
474
|
* @brief SD Abort callbacks
|
|
Jerome Coutant
0:31ddfafdd3da
|
475
|
* @param hsd: SD handle
|
|
Jerome Coutant
0:31ddfafdd3da
|
476
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
477
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
478
|
void HAL_SD_AbortCallback(SD_HandleTypeDef *hsd)
|
|
Jerome Coutant
0:31ddfafdd3da
|
479
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
480
|
BSP_SD_AbortCallback();
|
|
Jerome Coutant
0:31ddfafdd3da
|
481
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
482
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
483
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
484
|
* @brief Tx Transfer completed callback
|
|
Jerome Coutant
0:31ddfafdd3da
|
485
|
* @param hsd: SD handle
|
|
Jerome Coutant
0:31ddfafdd3da
|
486
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
487
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
488
|
void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd)
|
|
Jerome Coutant
0:31ddfafdd3da
|
489
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
490
|
BSP_SD_WriteCpltCallback();
|
|
Jerome Coutant
0:31ddfafdd3da
|
491
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
492
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
493
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
494
|
* @brief Rx Transfer completed callback
|
|
Jerome Coutant
0:31ddfafdd3da
|
495
|
* @param hsd: SD handle
|
|
Jerome Coutant
0:31ddfafdd3da
|
496
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
497
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
498
|
void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd)
|
|
Jerome Coutant
0:31ddfafdd3da
|
499
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
500
|
BSP_SD_ReadCpltCallback();
|
|
Jerome Coutant
0:31ddfafdd3da
|
501
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
502
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
503
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
504
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
505
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
506
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
507
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
508
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
509
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
510
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
511
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
512
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
513
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
514
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
515
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
516
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
517
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
518
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
519
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|