Skip to content

Commit 1ded8cf

Browse files
committed
Fix HAL_SD_ReadBlocks() definition to avoid confusion
Fix #9 Signed-off-by: Frederic Pillon <[email protected]>
1 parent 4ce0d15 commit 1ded8cf

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

src/bsp_sd.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,47 @@ uint8_t BSP_SD_IsDetected(void)
321321
return status;
322322
}
323323

324+
#ifndef STM32L1xx
325+
/**
326+
* @brief Reads block(s) from a specified address in an SD card, in polling mode.
327+
* @param pData: Pointer to the buffer that will contain the data to transmit
328+
* @param ReadAddr: Address from where data is to be read
329+
* @param NumOfBlocks: Number of SD blocks to read
330+
* @param Timeout: Timeout for read operation
331+
* @retval SD status
332+
*/
333+
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout)
334+
{
335+
if(HAL_SD_ReadBlocks(&uSdHandle, (uint8_t *)pData, ReadAddr, NumOfBlocks, Timeout) != HAL_OK)
336+
{
337+
return MSD_ERROR;
338+
}
339+
else
340+
{
341+
return MSD_OK;
342+
}
343+
}
344+
345+
/**
346+
* @brief Writes block(s) to a specified address in an SD card, in polling mode.
347+
* @param pData: Pointer to the buffer that will contain the data to transmit
348+
* @param WriteAddr: Address from where data is to be written
349+
* @param NumOfBlocks: Number of SD blocks to write
350+
* @param Timeout: Timeout for write operation
351+
* @retval SD status
352+
*/
353+
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout)
354+
{
355+
if(HAL_SD_WriteBlocks(&uSdHandle, (uint8_t *)pData, WriteAddr, NumOfBlocks, Timeout) != HAL_OK)
356+
{
357+
return MSD_ERROR;
358+
}
359+
else
360+
{
361+
return MSD_OK;
362+
}
363+
}
364+
#else /* STM32L1xx */
324365
/**
325366
* @brief Reads block(s) from a specified address in an SD card, in polling mode.
326367
* @param pData: Pointer to the buffer that will contain the data to transmit
@@ -360,6 +401,7 @@ uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSi
360401
return MSD_OK;
361402
}
362403
}
404+
#endif /* !STM32L1xx */
363405

364406
/**
365407
* @brief Erases the specified memory area of the given SD card.

src/bsp_sd.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ uint8_t BSP_SD_Init(void);
7575
uint8_t BSP_SD_CSSet(GPIO_TypeDef *csport, uint32_t cspin);
7676
uint8_t BSP_SD_DeInit(void);
7777
uint8_t BSP_SD_ITConfig(void);
78-
78+
#ifndef STM32L1xx
79+
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout);
80+
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout);
81+
#else
7982
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
8083
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
84+
#endif
8185
uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr);
8286
#ifndef STM32L1xx
8387
uint8_t BSP_SD_GetCardState(void);

0 commit comments

Comments
 (0)