X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/f896c00c48f04fb9273555ab8d9b1af99f865d25..baa1b22654830d78c1edb6ab35f35ceee089f6e5:/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c diff --git a/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c b/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c index 4e6c05013..771773bb7 100644 --- a/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c +++ b/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c @@ -84,7 +84,7 @@ SCSI_Request_Sense_Response_t SenseData = * to the appropriate SCSI command handling routine if the issued command is supported by the device, else it returns * a command failure due to a ILLEGAL REQUEST. * - * \param MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with + * \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with */ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* MSInterfaceInfo) { @@ -142,7 +142,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* MSInterfaceInfo) /** Command processing for an issued SCSI INQUIRY command. This command returns information about the device's features * and capabilities to the host. * - * \param MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with + * \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with * * \return Boolean true if the command completed successfully, false otherwise. */ @@ -184,7 +184,7 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* MSInterfaceInfo) /** Command processing for an issued SCSI REQUEST SENSE command. This command returns information about the last issued command, * including the error code and additional error information so that the host can determine why a command failed to complete. * - * \param MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with + * \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with * * \return Boolean true if the command completed successfully, false otherwise. */ @@ -208,16 +208,16 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* MSInterfaceInf /** Command processing for an issued SCSI READ CAPACITY (10) command. This command returns information about the device's capacity * on the selected Logical Unit (drive), as a number of OS-sized blocks. * - * \param MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with + * \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with * * \return Boolean true if the command completed successfully, false otherwise. */ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* MSInterfaceInfo) { - uint32_t TotalLUNs = (LUN_MEDIA_BLOCKS - 1); - uint32_t MediaBlockSize = VIRTUAL_MEMORY_BLOCK_SIZE; + uint32_t LastBlockAddressInLUN = (LUN_MEDIA_BLOCKS - 1); + uint32_t MediaBlockSize = VIRTUAL_MEMORY_BLOCK_SIZE; - Endpoint_Write_Stream_BE(&TotalLUNs, sizeof(TotalLUNs), NO_STREAM_CALLBACK); + Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NO_STREAM_CALLBACK); Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NO_STREAM_CALLBACK); Endpoint_ClearIN(); @@ -231,14 +231,12 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* MSInterface * board, and indicates if they are present and functioning correctly. Only the Self-Test portion of the diagnostic command is * supported. * - * \param MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with + * \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with * * \return Boolean true if the command completed successfully, false otherwise. */ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* MSInterfaceInfo) { - uint8_t ReturnByte; - /* Check to see if the SELF TEST bit is not set */ if (!(MSInterfaceInfo->State.CommandBlock.SCSICommandData[1] & (1 << 2))) { @@ -250,14 +248,8 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* MSInterfaceI return false; } - /* Test first Dataflash IC is present and responding to commands */ - Dataflash_SelectChip(DATAFLASH_CHIP1); - Dataflash_SendByte(DF_CMD_READMANUFACTURERDEVICEINFO); - ReturnByte = Dataflash_ReceiveByte(); - Dataflash_DeselectChip(); - - /* If returned data is invalid, fail the command */ - if (ReturnByte != DF_MANUFACTURER_ATMEL) + /* Check to see if all attached Dataflash ICs are functional */ + if (!(DataflashManager_CheckDataflashOperation())) { /* Update SENSE key with a hardware error condition and return command fail */ SCSI_SET_SENSE(SCSI_SENSE_KEY_HARDWARE_ERROR, @@ -266,25 +258,6 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* MSInterfaceI return false; } - - #if (DATAFLASH_TOTALCHIPS == 2) - /* Test second Dataflash IC is present and responding to commands */ - Dataflash_SelectChip(DATAFLASH_CHIP2); - Dataflash_SendByte(DF_CMD_READMANUFACTURERDEVICEINFO); - ReturnByte = Dataflash_ReceiveByte(); - Dataflash_DeselectChip(); - - /* If returned data is invalid, fail the command */ - if (ReturnByte != DF_MANUFACTURER_ATMEL) - { - /* Update SENSE key with a hardware error condition and return command fail */ - SCSI_SET_SENSE(SCSI_SENSE_KEY_HARDWARE_ERROR, - SCSI_ASENSE_NO_ADDITIONAL_INFORMATION, - SCSI_ASENSEQ_NO_QUALIFIER); - - return false; - } - #endif /* Succeed the command and update the bytes transferred counter */ MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0; @@ -296,8 +269,8 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* MSInterfaceI * and total number of blocks to process, then calls the appropriate low-level dataflash routine to handle the actual * reading and writing of the data. * - * \param MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with - * \param IsDataRead Indicates if the command is a READ (10) command or WRITE (10) command (DATA_READ or DATA_WRITE) + * \param[in] MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with + * \param[in] IsDataRead Indicates if the command is a READ (10) command or WRITE (10) command (DATA_READ or DATA_WRITE) * * \return Boolean true if the command completed successfully, false otherwise. */