SD card access through MSC
Hello,
I am trying to make a MSC USB device to access SD card files.
The computer recognizes the mass storage device, but cannot open the folder. After a while, it says the device was unrecognized.
My code from usbd_storage_if.c is like this:
int8_t STORAGE_Init_FS (uint8_t lun)
{ /* USER CODE BEGIN 2 */ return (USBD_OK); /* USER CODE END 2 */ }/*******************************************************************************
* Function Name : STORAGE_GetCapacity_FS* Description : * Input : None.* Output : None.* Return : None.*******************************************************************************/int8_t STORAGE_GetCapacity_FS (uint8_t lun, uint32_t *block_num, uint16_t *block_size){ /* USER CODE BEGIN 3 */ HAL_SD_GetCardInfo(&hsd, &SDCardInfo); *block_num = SDCardInfo.BlockNbr / BLOCK_SIZE; *block_size = BLOCK_SIZE; return (USBD_OK); /* USER CODE END 3 */ }/*******************************************************************************
* Function Name : STORAGE_IsReady_FS* Description : * Input : None.* Output : None.* Return : None.*******************************************************************************/int8_t STORAGE_IsReady_FS (uint8_t lun){ /* USER CODE BEGIN 4 */ return (USBD_OK); /* USER CODE END 4 */ }/*******************************************************************************
* Function Name : STORAGE_IsWriteProtected_FS* Description : * Input : None.* Output : None.* Return : None.*******************************************************************************/int8_t STORAGE_IsWriteProtected_FS (uint8_t lun){ /* USER CODE BEGIN 5 */ return (USBD_OK); /* USER CODE END 5 */ }/*******************************************************************************
* Function Name : STORAGE_Read_FS* Description : * Input : None.* Output : None.* Return : None.*******************************************************************************/int8_t STORAGE_Read_FS (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len){ /* USER CODE BEGIN 6 */ HAL_SD_ReadBlocks(&hsd, buf, (blk_addr * BLOCK_SIZE), BLOCK_SIZE, blk_len);return (USBD_OK);
/* USER CODE END 6 */ }/*******************************************************************************
* Function Name : STORAGE_Write_FS* Description :* Input : None.* Output : None.* Return : None.*******************************************************************************/int8_t STORAGE_Write_FS (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len){ /* USER CODE BEGIN 7 */ HAL_SD_WriteBlocks(&hsd, buf, (blk_addr * BLOCK_SIZE), BLOCK_SIZE, blk_len); return (USBD_OK); /* USER CODE END 7 */ }Does someone could help me? Maybe I am missing a step..
Thank you!!
