Skip to content

Commit 0ac53e7

Browse files
committed
fix: STM32L1xx support
is now aligned with other series Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 703f41d commit 0ac53e7

File tree

3 files changed

+6
-97
lines changed

3 files changed

+6
-97
lines changed

src/Sd2Card.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ bool Sd2Card::init(uint32_t detectpin)
6767
uint8_t Sd2Card::type(void) const
6868
{
6969
uint8_t cardType = SD_CARD_TYPE_UKN;
70-
#ifndef STM32L1xx
7170
switch (_SdCardInfo.CardType) {
7271
case CARD_SDSC:
7372
switch (_SdCardInfo.CardVersion) {
@@ -90,21 +89,6 @@ uint8_t Sd2Card::type(void) const
9089
default:
9190
cardType = SD_CARD_TYPE_UKN;
9291
}
93-
#else /* STM32L1xx */
94-
switch (_SdCardInfo.CardType) {
95-
case STD_CAPACITY_SD_CARD_V1_1:
96-
cardType = SD_CARD_TYPE_SD1;
97-
break;
98-
case STD_CAPACITY_SD_CARD_V2_0:
99-
cardType = SD_CARD_TYPE_SD2;
100-
break;
101-
case HIGH_CAPACITY_SD_CARD:
102-
cardType = SD_CARD_TYPE_SDHC;
103-
break;
104-
default:
105-
cardType = SD_CARD_TYPE_UKN;
106-
}
107-
#endif
10892
return cardType;
10993
}
11094

src/bsp_sd.c

Lines changed: 4 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,8 @@ static GPIO_TypeDef *SD_detect_gpio_port = GPIOA;
116116
static uint32_t SD_trans_sel_ll_gpio_pin = LL_GPIO_PIN_ALL;
117117
static GPIO_TypeDef *SD_trans_sel_gpio_port = GPIOA;
118118
#endif
119-
#ifndef STM32L1xx
120-
#define SD_OK HAL_OK
121119
#define SD_TRANSFER_OK ((uint8_t)0x00)
122120
#define SD_TRANSFER_BUSY ((uint8_t)0x01)
123-
#else /* STM32L1xx */
124-
static SD_CardInfo uSdCardInfo;
125-
#endif
126121

127122

128123
/**
@@ -165,19 +160,15 @@ uint8_t BSP_SD_Init(void)
165160
BSP_SD_MspInit(&uSdHandle, NULL);
166161

167162
/* HAL SD initialization */
168-
#ifndef STM32L1xx
169-
if (HAL_SD_Init(&uSdHandle) != SD_OK)
170-
#else /* STM32L1xx */
171-
if (HAL_SD_Init(&uSdHandle, &uSdCardInfo) != SD_OK)
172-
#endif
163+
if (HAL_SD_Init(&uSdHandle) != HAL_OK)
173164
{
174165
sd_state = MSD_ERROR;
175166
}
176167

177168
/* Configure SD Bus width */
178169
if (sd_state == MSD_OK) {
179170
/* Enable wide operation */
180-
if (HAL_SD_WideBusOperation_Config(&uSdHandle, SD_BUS_WIDE) != SD_OK) {
171+
if (HAL_SD_ConfigWideBusOperation(&uSdHandle, SD_BUS_WIDE) != HAL_OK) {
181172
sd_state = MSD_ERROR;
182173
} else {
183174
sd_state = MSD_OK;
@@ -328,7 +319,6 @@ uint8_t BSP_SD_IsDetected(void)
328319
return status;
329320
}
330321

331-
#ifndef STM32L1xx
332322
/**
333323
* @brief Reads block(s) from a specified address in an SD card, in polling mode.
334324
* @param pData: Pointer to the buffer that will contain the data to transmit
@@ -362,41 +352,6 @@ uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBl
362352
return MSD_OK;
363353
}
364354
}
365-
#else /* STM32L1xx */
366-
/**
367-
* @brief Reads block(s) from a specified address in an SD card, in polling mode.
368-
* @param pData: Pointer to the buffer that will contain the data to transmit
369-
* @param ReadAddr: Address from where data is to be read
370-
* @param BlockSize: SD card data block size, that should be 512
371-
* @param NumOfBlocks: Number of SD blocks to read
372-
* @retval SD status
373-
*/
374-
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
375-
{
376-
if (HAL_SD_ReadBlocks(&uSdHandle, (uint8_t *)pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK) {
377-
return MSD_ERROR;
378-
} else {
379-
return MSD_OK;
380-
}
381-
}
382-
383-
/**
384-
* @brief Writes block(s) to a specified address in an SD card, in polling mode.
385-
* @param pData: Pointer to the buffer that will contain the data to transmit
386-
* @param WriteAddr: Address from where data is to be written
387-
* @param BlockSize: SD card data block size, that should be 512
388-
* @param NumOfBlocks: Number of SD blocks to write
389-
* @retval SD status
390-
*/
391-
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
392-
{
393-
if (HAL_SD_WriteBlocks(&uSdHandle, (uint8_t *)pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK) {
394-
return MSD_ERROR;
395-
} else {
396-
return MSD_OK;
397-
}
398-
}
399-
#endif /* !STM32L1xx */
400355

401356
/**
402357
* @brief Erases the specified memory area of the given SD card.
@@ -406,7 +361,7 @@ uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSi
406361
*/
407362
uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr)
408363
{
409-
if (HAL_SD_Erase(&uSdHandle, StartAddr, EndAddr) != SD_OK) {
364+
if (HAL_SD_Erase(&uSdHandle, StartAddr, EndAddr) != HAL_OK) {
410365
return MSD_ERROR;
411366
} else {
412367
return MSD_OK;
@@ -532,7 +487,6 @@ __weak void BSP_SD_Transceiver_MspInit(SD_HandleTypeDef *hsd, void *Params)
532487
}
533488
#endif /* USE_SD_TRANSCEIVER && (USE_SD_TRANSCEIVER != 0U) */
534489

535-
#ifndef STM32L1xx
536490
/**
537491
* @brief Gets the current SD card data status.
538492
* @retval Data transfer state.
@@ -544,20 +498,6 @@ uint8_t BSP_SD_GetCardState(void)
544498
{
545499
return ((HAL_SD_GetCardState(&uSdHandle) == HAL_SD_CARD_TRANSFER) ? SD_TRANSFER_OK : SD_TRANSFER_BUSY);
546500
}
547-
#else /* STM32L1xx */
548-
/**
549-
* @brief Gets the current SD card data status.
550-
* @retval Data transfer state.
551-
* This value can be one of the following values:
552-
* @arg SD_TRANSFER_OK: No data transfer is acting
553-
* @arg SD_TRANSFER_BUSY: Data transfer is acting
554-
* @arg SD_TRANSFER_ERROR: Data transfer error
555-
*/
556-
HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void)
557-
{
558-
return (HAL_SD_GetStatus(&uSdHandle));
559-
}
560-
#endif
561501

562502
/**
563503
* @brief Get SD information about specific SD card.
@@ -566,7 +506,7 @@ HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void)
566506
void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo)
567507
{
568508
/* Get SD card Information */
569-
HAL_SD_Get_CardInfo(&uSdHandle, CardInfo);
509+
HAL_SD_GetCardInfo(&uSdHandle, CardInfo);
570510
}
571511

572512
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

src/bsp_sd.h

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,8 @@ Please update the core or install previous library version."
5959
#endif
6060

6161
/*SD Card information structure */
62-
#ifndef STM32L1xx
63-
#define HAL_SD_CardInfoTypedef HAL_SD_CardInfoTypeDef
64-
#define BSP_SD_CardInfo HAL_SD_CardInfoTypeDef
65-
#define HAL_SD_WideBusOperation_Config HAL_SD_ConfigWideBusOperation
66-
#define HAL_SD_Get_CardInfo HAL_SD_GetCardInfo
67-
#endif
6862

69-
#define SD_CardInfo HAL_SD_CardInfoTypedef
63+
#define SD_CardInfo HAL_SD_CardInfoTypeDef
7064

7165
/*SD status structure definition */
7266
#define MSD_OK ((uint8_t)0x00)
@@ -105,20 +99,11 @@ uint8_t BSP_SD_TransceiverPin(GPIO_TypeDef *enport, uint32_t enpin, GPIO_TypeDef
10599
#endif
106100
uint8_t BSP_SD_DetectPin(GPIO_TypeDef *port, uint32_t pin);
107101
uint8_t BSP_SD_DetectITConfig(void (*callback)(void));
108-
#ifndef STM32L1xx
109102
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout);
110103
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout);
111-
#else
112-
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
113-
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
114-
#endif
115104
uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr);
116-
#ifndef STM32L1xx
117105
uint8_t BSP_SD_GetCardState(void);
118-
#else /* STM32L1xx */
119-
HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void);
120-
#endif
121-
void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo);
106+
void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo);
122107
uint8_t BSP_SD_IsDetected(void);
123108

124109
/* These __weak function can be surcharged by application code in case the current settings (e.g. DMA stream)

0 commit comments

Comments
 (0)