有个32G的eMMC,分成了4个盘。
连上usb只会显示其中的一个盘,用户可以去操作这个盘。
希望在未显示u盘或者显示了u盘但是未进行读写的情况下判断另外几个盘是否存在文件并上传到服务器。
目前已经实现了连上u盘只显示一个盘的功能,读写也正常。退出u盘后,上传文件也正常。
目前的问题是u盘显示出来的情况下,同时进行文件上传就会出现disk error。
我知道是SDIO操作冲突了,想问下这个有好的方案么?
裸机开发,未使用操作系统。
我想到的是弄2个标志位(u盘读写和fatfs上传),u盘读写优先级要高于fatfs上传。
想问下大佬,这个标志位的判断裸机应该怎么写,或者有没有其他更好的方案?
/** * @brief Reads Sector(s) * @param pdrv: Physical drive number (0..) * @param *buff: Data buffer to store read data * @param sector: Sector address (LBA) * @param count: Number of sectors to read (1..128) * @retval DRESULT: Opera
tion result */DRESULT USER_read( BYTE pdrv, /* Physical drive nmuber to identify the drive */ BYTE *buff, /* Data buffer to store read data */ DWORD sector, /* Sector address in LBA */ UINT count /* Number of sectors to read */){ /* USER CODE BEGIN READ */ if (usbd_inuse) { return RES_NOTRDY; } fatfs_inuse = 1; DRESULT res = FATFS_read(pdrv, buff, sector, count); fatfs_inuse = 0; return res; /* USER CODE END READ */}/** * @brief Writes Sector(s) * @param pdrv: Physical drive number (0..) * @param *buff: Data to be written * @param sector: Sector address (LBA) * @param count: Number of sectors to write (1..128) * @retval DRESULT: Operation result */#if _USE_WRITE == 1DRESULT USER_write( BYTE pdrv, /* Physical drive nmuber to identify the drive */ const BYTE *buff, /* Data to be written */ DWORD sector, /* Sector address in LBA */ UINT count /* Number of sectors to write */){ /* USER CODE BEGIN WRITE */ /* USER CODE HERE */ if (usbd_inuse) { return RES_NOTRDY; } fatfs_inuse = 1; DRESULT res = FATFS_write(pdrv, buff, sector, count); fatfs_inuse = 0; return res; /* USER CODE END WRITE */}#endif /* _USE_WRITE == 1 *//** * @brief Reads data from the medium. * @param lun: Logical unit number. * @param buf: data buffer. * @param blk_addr: Logical block address. * @param blk_len: Blocks number. * @retval USBD_OK if all operations are OK else USBD_FAIL */int8_t STORAGE_Read_HS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len){ /* USER CODE BEGIN 13 */ UNUSED(lun); usbd_inuse = 1; if (fatfs_inuse) { return USBD_BUSY; } DRESULT res = FATFS_read(lun, buf, blk_addr, blk_len); usbd_inuse = 0; return res == RES_OK ? USBD_OK : USBD_FAIL; /* USER CODE END 13 */}/** * @brief Writes data into the medium. * @param lun: Logical unit number. * @param buf: data buffer. * @param blk_addr: Logical block address. * @param blk_len: Blocks number. * @retval USBD_OK if all operations are OK else USBD_FAIL */int8_t STORAGE_Write_HS(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len){ /* USER CODE BEGIN 14 */ UNUSED(lun); usbd_inuse = 1; if (fatfs_inuse) { return USBD_BUSY; } DRESULT res = FATFS_write(lun, buf, blk_addr, blk_len); usbd_inuse = 0; return res == RES_OK ? USBD_OK : USBD_FAIL; /* USER CODE END 14 */}