Move Dataflash operational checking code out from SCSI.c into the DataflashManager...
[pub/USBasp.git] / Demos / Device / ClassDriver / MassStorage / Lib / SCSI.c
index f400e20..771773b 100644 (file)
@@ -237,8 +237,6 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* MSInterface
  */\r
 static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)\r
 {\r
  */\r
 static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)\r
 {\r
-       uint8_t ReturnByte;\r
-\r
        /* Check to see if the SELF TEST bit is not set */\r
        if (!(MSInterfaceInfo->State.CommandBlock.SCSICommandData[1] & (1 << 2)))\r
        {\r
        /* Check to see if the SELF TEST bit is not set */\r
        if (!(MSInterfaceInfo->State.CommandBlock.SCSICommandData[1] & (1 << 2)))\r
        {\r
@@ -250,14 +248,8 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* MSInterfaceI
                return false;\r
        }\r
        \r
                return false;\r
        }\r
        \r
-       /* Test first Dataflash IC is present and responding to commands */\r
-       Dataflash_SelectChip(DATAFLASH_CHIP1);\r
-       Dataflash_SendByte(DF_CMD_READMANUFACTURERDEVICEINFO);\r
-       ReturnByte = Dataflash_ReceiveByte();\r
-       Dataflash_DeselectChip();\r
-\r
-       /* If returned data is invalid, fail the command */\r
-       if (ReturnByte != DF_MANUFACTURER_ATMEL)\r
+       /* Check to see if all attached Dataflash ICs are functional */\r
+       if (!(DataflashManager_CheckDataflashOperation()))\r
        {\r
                /* Update SENSE key with a hardware error condition and return command fail */\r
                SCSI_SET_SENSE(SCSI_SENSE_KEY_HARDWARE_ERROR,\r
        {\r
                /* Update SENSE key with a hardware error condition and return command fail */\r
                SCSI_SET_SENSE(SCSI_SENSE_KEY_HARDWARE_ERROR,\r
@@ -266,25 +258,6 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* MSInterfaceI
        \r
                return false;\r
        }\r
        \r
                return false;\r
        }\r
-\r
-       #if (DATAFLASH_TOTALCHIPS == 2)\r
-       /* Test second Dataflash IC is present and responding to commands */\r
-       Dataflash_SelectChip(DATAFLASH_CHIP2);\r
-       Dataflash_SendByte(DF_CMD_READMANUFACTURERDEVICEINFO);\r
-       ReturnByte = Dataflash_ReceiveByte();\r
-       Dataflash_DeselectChip();\r
-\r
-       /* If returned data is invalid, fail the command */\r
-       if (ReturnByte != DF_MANUFACTURER_ATMEL)\r
-       {\r
-               /* Update SENSE key with a hardware error condition and return command fail */\r
-               SCSI_SET_SENSE(SCSI_SENSE_KEY_HARDWARE_ERROR,\r
-                              SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,\r
-                              SCSI_ASENSEQ_NO_QUALIFIER);      \r
-       \r
-               return false;\r
-       }\r
-       #endif\r
        \r
        /* Succeed the command and update the bytes transferred counter */\r
        MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;\r
        \r
        /* Succeed the command and update the bytes transferred counter */\r
        MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;\r