中级会员
 
- 积分
- 242
- 金钱
- 242
- 注册时间
- 2016-11-19
- 在线时间
- 31 小时
|

楼主 |
发表于 2022-10-18 10:23:46
|
显示全部楼层
- void Get_SDCard_Capacity(void)
- {
- FRESULT result;
- FATFS FS;
- FATFS *fs;
- DWORD fre_clust,AvailableSize,UsedSize;
- uint16_t TotalSpace;
- uint8_t res;
-
- res = SD_init(); //SD卡初始化
- printf ("SD_TYPE:%d \n",SD_TYPE);
- if(res == 1)
- {
- printf("SD卡初始化失败! \r\n");
- }
- else
- {
- printf("SD卡初始化成功! \r\n");
- }
-
- /* 挂载 */
- res=f_mount(&FS,"0:",1); //挂载
- if (res != FR_OK)
- {
- printf("FileSystem Mounted Failed (%d)\r\n", result);
- }
- res = f_getfree("0:", &fre_clust, &fs); /* 根目录 */
- if ( res == FR_OK )
- {
- TotalSpace=(uint16_t)(((fs->n_fatent - 2) * fs->csize ) / 2 /1024);
- AvailableSize=(uint16_t)((fre_clust * fs->csize) / 2 /1024);
- UsedSize=TotalSpace-AvailableSize;
- /* Print free space in unit of MB (assuming 512 bytes/sector) */
- printf("\r\n%d MB total drive space.\r\n""%d MB available.\r\n""%d MB used.\r\n",TotalSpace, AvailableSize,UsedSize);
- }
- else
- {
- printf("Get SDCard Capacity Failed (%d)\r\n", result);
- }
- }
- 初始化输出成功,SD_TYPE:4
- res=f_mount(&FS,"0:",1); //挂载 出不来
复制代码 |
|