1
1
/**
2
2
******************************************************************************
3
3
* @file bsp_sd.c
4
- * @author MCD Application Team
5
- * @version V1.0.0
6
- * @date 10-June-2016
7
4
* @brief This file includes the uSD card driver mounted on stm32
8
5
* board.
9
6
******************************************************************************
36
33
******************************************************************************
37
34
*/
38
35
39
- /* File Info : -----------------------------------------------------------------
40
- User NOTES
41
- 1. How To use this driver:
42
- --------------------------
43
- - This driver is used to drive the micro SD external card mounted on a board.
44
- - This driver does not need a specific component driver for the micro SD device
45
- to be included with.
46
-
47
- 2. Driver description:
48
- ---------------------
49
- + Initialization steps:
50
- o Initialize the micro SD card using the BSP_SD_Init() function. This
51
- function includes the MSP layer hardware resources initialization and the
52
- SDIO interface configuration to interface with the external micro SD. It
53
- also includes the micro SD initialization sequence.
54
- o To check the SD card presence you can use the function BSP_SD_IsDetected() which
55
- returns the detection status
56
- o If SD presence detection interrupt mode is desired, you must configure the
57
- SD detection interrupt mode by calling the function BSP_SD_ITConfig(). The interrupt
58
- is generated as an external interrupt whenever the micro SD card is
59
- plugged/unplugged in/from the board. The SD detection interrupt
60
- is handled by calling the function BSP_SD_DetectIT() which is called in the IRQ
61
- handler file, the user callback is implemented in the function BSP_SD_DetectCallback().
62
- o The function BSP_SD_GetCardInfo() is used to get the micro SD card information
63
- which is stored in the structure "HAL_SD_CardInfoTypedef".
64
-
65
- + Micro SD card operations
66
- o The micro SD card can be accessed with read/write block(s) operations once
67
- it is reay for access. The access cand be performed whether using the polling
68
- mode by calling the functions BSP_SD_ReadBlocks()/BSP_SD_WriteBlocks(), or by DMA
69
- transfer using the functions BSP_SD_ReadBlocks_DMA()/BSP_SD_WriteBlocks_DMA()
70
- o The DMA transfer complete is used with interrupt mode. Once the SD transfer
71
- is complete, the SD interrupt is handeled using the function BSP_SD_IRQHandler(),
72
- the DMA Tx/Rx transfer complete are handeled using the functions
73
- BSP_SD_DMA_Tx_IRQHandler()/BSP_SD_DMA_Rx_IRQHandler(). The corresponding user callbacks
74
- are implemented by the user at application level.
75
- o The SD erase block(s) is performed using the function BSP_SD_Erase() with specifying
76
- the number of blocks to erase.
77
- o The SD runtime status is returned when calling the function BSP_SD_GetStatus().
78
-
79
- ------------------------------------------------------------------------------*/
80
-
81
36
/* Includes ------------------------------------------------------------------*/
82
37
#include "bsp_sd.h"
83
38
#include "PeripheralPins.h"
@@ -139,8 +94,6 @@ uint8_t BSP_SD_Init(void)
139
94
{
140
95
uint8_t sd_state = MSD_OK ;
141
96
142
- /* PLLSAI is dedicated to LCD periph. Do not use it to get 48MHz*/
143
-
144
97
/* uSD device interface configuration */
145
98
uSdHandle .Instance = SD_INSTANCE ;
146
99
@@ -186,22 +139,6 @@ uint8_t BSP_SD_Init(void)
186
139
return sd_state ;
187
140
}
188
141
189
- /**
190
- * @brief Set the SD card device detect pin and port.
191
- * @param csport one of the gpio port
192
- * @param cspin one of the gpio pin
193
- * @retval SD status
194
- */
195
- uint8_t BSP_SD_CSSet (GPIO_TypeDef * csport , uint32_t cspin )
196
- {
197
- if (csport != 0 ) {
198
- SD_detect_gpio_pin = cspin ;
199
- SD_detect_gpio_port = csport ;
200
- return MSD_OK ;
201
- }
202
- return MSD_ERROR ;
203
- }
204
-
205
142
/**
206
143
* @brief DeInitializes the SD card device.
207
144
* @retval SD status
@@ -224,11 +161,27 @@ uint8_t BSP_SD_DeInit(void)
224
161
return sd_state ;
225
162
}
226
163
164
+ /**
165
+ * @brief Set the SD card device detect pin and port.
166
+ * @param port one of the gpio port
167
+ * @param pin one of the gpio pin
168
+ * @retval SD status
169
+ */
170
+ uint8_t BSP_SD_DetectPin (GPIO_TypeDef * port , uint32_t pin )
171
+ {
172
+ if (port != 0 ) {
173
+ SD_detect_gpio_pin = pin ;
174
+ SD_detect_gpio_port = port ;
175
+ return MSD_OK ;
176
+ }
177
+ return MSD_ERROR ;
178
+ }
179
+
227
180
/**
228
181
* @brief Configures Interrupt mode for SD detection pin.
229
- * @retval Returns 0
182
+ * @retval Status
230
183
*/
231
- uint8_t BSP_SD_ITConfig (void )
184
+ uint8_t BSP_SD_DetectITConfig (void )
232
185
{
233
186
uint8_t sd_state = MSD_OK ;
234
187
GPIO_InitTypeDef gpio_init_structure ;
@@ -443,9 +396,6 @@ __weak void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params)
443
396
444
397
/* Disable SDIO clock */
445
398
SD_CLK_DISABLE ();
446
-
447
- /* GPOI pins clock and DMA cloks can be shut down in the applic
448
- by surcgarging this __weak function */
449
399
}
450
400
451
401
#ifndef STM32L1xx
@@ -485,20 +435,4 @@ void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo)
485
435
HAL_SD_Get_CardInfo (& uSdHandle , CardInfo );
486
436
}
487
437
488
- /**
489
- * @}
490
- */
491
-
492
- /**
493
- * @}
494
- */
495
-
496
- /**
497
- * @}
498
- */
499
-
500
- /**
501
- * @}
502
- */
503
-
504
438
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
0 commit comments