| 在freertos的任务中读写tf卡是没问题的,在定时器中读写就不行了,报错代码FR_DISK_ERR。调试代码发现在加载分区时,fmt的值为4从而报错。 
 fatfs的可重入功能配置如下,超时时间配置为0是因为fatfs的同步机制使用的获取信号量函数为osSemaphoreAcquire,该函数超时时间值为0可在中断函数中调用。复制代码 /* Find an FAT partition on the drive. Supports only generic partitioning rules, FDISK and SFD. */
        bsect = 0;
        fmt = check_fs(fs, bsect);                        /* Load sector 0 and check if it is an FAT-VBR as SFD */
        if (fmt == 2 || (fmt < 2 && LD2PT(vol) != 0)) {        /* Not an FAT-VBR or forced partition number */
                for (i = 0; i < 4; i++) {                /* Get partition offset */
                        pt = fs->win + (MBR_Table + i * SZ_PTE);
                        br[i] = pt[PTE_System] ? ld_dword(pt + PTE_StLba) : 0;
                }
                i = LD2PT(vol);                                        /* Partition number: 0:auto, 1-4:forced */
                if (i) i--;
                do {                                                        /* Find an FAT volume */
                        bsect = br[i];
                        fmt = bsect ? check_fs(fs, bsect) : 3;        /* Check the partition */
                } while (LD2PT(vol) == 0 && fmt >= 2 && ++i < 4);
        }
        if (fmt == 4) return FR_DISK_ERR;                /* An error occured in the disk I/O layer */
        if (fmt >= 2) return FR_NO_FILESYSTEM;        /* No FAT volume is found */
 希望各位大佬不吝赐教,感谢!复制代码#define _FS_REENTRANT    1  /* 0:Disable or 1:Enable */
#define _USE_MUTEX       0 /* 0:Disable or 1:Enable */
#define _FS_TIMEOUT      0//1000 /* Timeout period in unit of time ticks */
#define _SYNC_t          osSemaphoreId_t
 |