Move Dataflash operational checking code out from SCSI.c into the DataflashManager...
[pub/USBasp.git] / Demos / Device / LowLevel / MassStorage / Lib / SCSI.c
index 53d773f..d0840d3 100644 (file)
@@ -239,12 +239,12 @@ static bool SCSI_Command_Read_Capacity_10(void)
  *  board, and indicates if they are present and functioning correctly. Only the Self-Test portion of the diagnostic command is\r
  *  supported.\r
  *\r
+ *  \param[in] MSInterfaceInfo  Pointer to the Mass Storage class interface structure that the command is associated with\r
+ *\r
  *  \return Boolean true if the command completed successfully, false otherwise.\r
  */\r
 static bool SCSI_Command_Send_Diagnostic(void)\r
 {\r
-       uint8_t ReturnByte;\r
-\r
        /* Check to see if the SELF TEST bit is not set */\r
        if (!(CommandBlock.SCSICommandData[1] & (1 << 2)))\r
        {\r
@@ -256,14 +256,8 @@ static bool SCSI_Command_Send_Diagnostic(void)
                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
@@ -272,25 +266,6 @@ static bool SCSI_Command_Send_Diagnostic(void)
        \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
        CommandBlock.DataTransferLength = 0;\r