###  解决fatfs   msc 冲突

sd_diskio.c增加两个函数,  msc usb中断时关闭消息
```C
void SD_Delet_Queue(void) {
	osMessageDelete(SDQueueID);
}

void SD_Create_Queue(void) {
    SDQueueID = osMessageQueueNew(QUEUE_SIZE, 2, NULL);
}
```

启用或禁用  SD FatFS 0禁止
```C
static void Set_SD_WriteOrRead(uint8_t en) {
	if (en == 1) {
		SD_Create_Queue();
		SDCard_EN = 1;
	} else {
		SD_Delet_Queue();
		SDCard_EN = 0;
	}
}

```


USB回调
```C
void OTG_FS_IRQHandler(void)
{
 
  HAL_PCD_IRQHandler(&hpcd_USB_OTG_FS);
 
  FILE_MGT_USB_CHECK(); // 自定义的函数
 
}
```


两个任务，一个是FatFs 读写任务，一个是 USB 状态连接任务
FatFS  读写放到任务里面取， 等待信号量执行读写
两个任务互斥信号量     		osMutexWait(sdFreeMutexHandle, osWaitForever);
```C
static void FILE_MGT_SD_TEST_TASK(const void *arg) {
	osDelay(500);
	for (;;) {
		osDelay(500);
		osMutexWait(sdFreeMutexHandle, osWaitForever);
		if (SDCard_EN) {
			FatFs_FileTest();
		} else {
			printf("禁止使用SD卡\n");
		}
		osMutexRelease(sdFreeMutexHandle);

	}
}

```

USB 状态连接检测任务， 检测到USB 关闭 SD  FATFS
需要提供 信号量   usbStateQueueHandle

```C
static void FILE_MGT_USB_CHECK_TASK(const void *arg) {
	uint8_t dev_state = 0;
	osEvent event;
	FatFs_Check();
	for (;;) {

		event = osMessageGet(usbStateQueueHandle, osWaitForever);  // 改osMessageQueueGet
		if (event.status == osEventMessage) {
			osMutexWait(sdFreeMutexHandle, osWaitForever);
			printf("hUsbDeviceFS:%d\n", (uint8_t) event.value.v);
			if ((uint8_t) event.value.v == USBD_STATE_ADDRESSED) {
				dev_state = USBD_STATE_ADDRESSED;
			} else if ((dev_state == USBD_STATE_ADDRESSED)
					&& ((uint8_t) event.value.v == USBD_STATE_CONFIGURED)) {
				Set_SD_WriteOrRead(0);
				printf("usb connect\n");
			} else {
				dev_state = 0;
				Set_SD_WriteOrRead(1);
				printf("usb disconnect\n");
			}
			osMutexRelease(sdFreeMutexHandle);
		}

	}
}
```