Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions src/Sd2Card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ bool Sd2Card::init(uint32_t detectpin)
uint8_t Sd2Card::type(void) const
{
uint8_t cardType = SD_CARD_TYPE_UKN;
#ifndef STM32L1xx
switch (_SdCardInfo.CardType) {
case CARD_SDSC:
switch (_SdCardInfo.CardVersion) {
Expand All @@ -90,21 +89,6 @@ uint8_t Sd2Card::type(void) const
default:
cardType = SD_CARD_TYPE_UKN;
}
#else /* STM32L1xx */
switch (_SdCardInfo.CardType) {
case STD_CAPACITY_SD_CARD_V1_1:
cardType = SD_CARD_TYPE_SD1;
break;
case STD_CAPACITY_SD_CARD_V2_0:
cardType = SD_CARD_TYPE_SD2;
break;
case HIGH_CAPACITY_SD_CARD:
cardType = SD_CARD_TYPE_SDHC;
break;
default:
cardType = SD_CARD_TYPE_UKN;
}
#endif
return cardType;
}

73 changes: 6 additions & 67 deletions src/bsp_sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,8 @@ static GPIO_TypeDef *SD_detect_gpio_port = GPIOA;
static uint32_t SD_trans_sel_ll_gpio_pin = LL_GPIO_PIN_ALL;
static GPIO_TypeDef *SD_trans_sel_gpio_port = GPIOA;
#endif
#ifndef STM32L1xx
#define SD_OK HAL_OK
#define SD_TRANSFER_OK ((uint8_t)0x00)
#define SD_TRANSFER_BUSY ((uint8_t)0x01)
#else /* STM32L1xx */
static SD_CardInfo uSdCardInfo;
#endif
#define SD_TRANSFER_OK ((uint8_t)0x00)
#define SD_TRANSFER_BUSY ((uint8_t)0x01)


/**
Expand Down Expand Up @@ -165,19 +160,14 @@ uint8_t BSP_SD_Init(void)
BSP_SD_MspInit(&uSdHandle, NULL);

/* HAL SD initialization */
#ifndef STM32L1xx
if (HAL_SD_Init(&uSdHandle) != SD_OK)
#else /* STM32L1xx */
if (HAL_SD_Init(&uSdHandle, &uSdCardInfo) != SD_OK)
#endif
{
if (HAL_SD_Init(&uSdHandle) != HAL_OK) {
sd_state = MSD_ERROR;
}

/* Configure SD Bus width */
if (sd_state == MSD_OK) {
/* Enable wide operation */
if (HAL_SD_WideBusOperation_Config(&uSdHandle, SD_BUS_WIDE) != SD_OK) {
if (HAL_SD_ConfigWideBusOperation(&uSdHandle, SD_BUS_WIDE) != HAL_OK) {
sd_state = MSD_ERROR;
} else {
sd_state = MSD_OK;
Expand Down Expand Up @@ -328,7 +318,6 @@ uint8_t BSP_SD_IsDetected(void)
return status;
}

#ifndef STM32L1xx
/**
* @brief Reads block(s) from a specified address in an SD card, in polling mode.
* @param pData: Pointer to the buffer that will contain the data to transmit
Expand Down Expand Up @@ -362,41 +351,6 @@ uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBl
return MSD_OK;
}
}
#else /* STM32L1xx */
/**
* @brief Reads block(s) from a specified address in an SD card, in polling mode.
* @param pData: Pointer to the buffer that will contain the data to transmit
* @param ReadAddr: Address from where data is to be read
* @param BlockSize: SD card data block size, that should be 512
* @param NumOfBlocks: Number of SD blocks to read
* @retval SD status
*/
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
{
if (HAL_SD_ReadBlocks(&uSdHandle, (uint8_t *)pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK) {
return MSD_ERROR;
} else {
return MSD_OK;
}
}

/**
* @brief Writes block(s) to a specified address in an SD card, in polling mode.
* @param pData: Pointer to the buffer that will contain the data to transmit
* @param WriteAddr: Address from where data is to be written
* @param BlockSize: SD card data block size, that should be 512
* @param NumOfBlocks: Number of SD blocks to write
* @retval SD status
*/
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks)
{
if (HAL_SD_WriteBlocks(&uSdHandle, (uint8_t *)pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK) {
return MSD_ERROR;
} else {
return MSD_OK;
}
}
#endif /* !STM32L1xx */

/**
* @brief Erases the specified memory area of the given SD card.
Expand All @@ -406,7 +360,7 @@ uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSi
*/
uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr)
{
if (HAL_SD_Erase(&uSdHandle, StartAddr, EndAddr) != SD_OK) {
if (HAL_SD_Erase(&uSdHandle, StartAddr, EndAddr) != HAL_OK) {
return MSD_ERROR;
} else {
return MSD_OK;
Expand Down Expand Up @@ -532,7 +486,6 @@ __weak void BSP_SD_Transceiver_MspInit(SD_HandleTypeDef *hsd, void *Params)
}
#endif /* USE_SD_TRANSCEIVER && (USE_SD_TRANSCEIVER != 0U) */

#ifndef STM32L1xx
/**
* @brief Gets the current SD card data status.
* @retval Data transfer state.
Expand All @@ -544,20 +497,6 @@ uint8_t BSP_SD_GetCardState(void)
{
return ((HAL_SD_GetCardState(&uSdHandle) == HAL_SD_CARD_TRANSFER) ? SD_TRANSFER_OK : SD_TRANSFER_BUSY);
}
#else /* STM32L1xx */
/**
* @brief Gets the current SD card data status.
* @retval Data transfer state.
* This value can be one of the following values:
* @arg SD_TRANSFER_OK: No data transfer is acting
* @arg SD_TRANSFER_BUSY: Data transfer is acting
* @arg SD_TRANSFER_ERROR: Data transfer error
*/
HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void)
{
return (HAL_SD_GetStatus(&uSdHandle));
}
#endif

/**
* @brief Get SD information about specific SD card.
Expand All @@ -566,7 +505,7 @@ HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void)
void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo)
{
/* Get SD card Information */
HAL_SD_Get_CardInfo(&uSdHandle, CardInfo);
HAL_SD_GetCardInfo(&uSdHandle, CardInfo);
}

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
19 changes: 2 additions & 17 deletions src/bsp_sd.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,8 @@ Please update the core or install previous library version."
#endif

/*SD Card information structure */
#ifndef STM32L1xx
#define HAL_SD_CardInfoTypedef HAL_SD_CardInfoTypeDef
#define BSP_SD_CardInfo HAL_SD_CardInfoTypeDef
#define HAL_SD_WideBusOperation_Config HAL_SD_ConfigWideBusOperation
#define HAL_SD_Get_CardInfo HAL_SD_GetCardInfo
#endif

#define SD_CardInfo HAL_SD_CardInfoTypedef
#define SD_CardInfo HAL_SD_CardInfoTypeDef

/*SD status structure definition */
#define MSD_OK ((uint8_t)0x00)
Expand Down Expand Up @@ -105,20 +99,11 @@ uint8_t BSP_SD_TransceiverPin(GPIO_TypeDef *enport, uint32_t enpin, GPIO_TypeDef
#endif
uint8_t BSP_SD_DetectPin(GPIO_TypeDef *port, uint32_t pin);
uint8_t BSP_SD_DetectITConfig(void (*callback)(void));
#ifndef STM32L1xx
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout);
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout);
#else
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks);
#endif
uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr);
#ifndef STM32L1xx
uint8_t BSP_SD_GetCardState(void);
#else /* STM32L1xx */
HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void);
#endif
void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo);
void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo);
uint8_t BSP_SD_IsDetected(void);

/* These __weak function can be surcharged by application code in case the current settings (e.g. DMA stream)
Expand Down
2 changes: 1 addition & 1 deletion src/ffconf_default_32020.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
/ 1: Enable relative path. f_chdrive() and f_chdir() function are available.
/ 2: f_getcwd() function is available in addition to 1.
/
/ Note that output of the f_readdir() fnction is affected by this option. */
/ Note that output of the f_readdir() function is affected by this option. */


/*---------------------------------------------------------------------------/
Expand Down
2 changes: 1 addition & 1 deletion src/ffconf_default_68300.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
#define _NORTC_MON 1
#define _NORTC_MDAY 1
#define _NORTC_YEAR 2016
/* The option _FS_NORTC switches timestamp functiton. If the system does not have
/* The option _FS_NORTC switches timestamp function. If the system does not have
/ any RTC function or valid timestamp is not needed, set _FS_NORTC = 1 to disable
/ the timestamp function. All objects modified by FatFs will have a fixed timestamp
/ defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR in local time.
Expand Down