/* Deselect current dataflash chip */\r
Dataflash_DeselectChip();\r
}\r
+\r
+/** Performs a simple test on the attached Dataflash IC(s) to ensure that they are working.\r
+ *\r
+ * \return Boolean true if all media chips are working, false otherwise\r
+ */\r
+bool DataflashManager_CheckDataflashOperation(void)\r
+{\r
+ uint8_t ReturnByte;\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
+ return false;\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
+ return false;\r
+ #endif\r
+ \r
+ return true;\r
+}\r
void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress, uint16_t TotalBlocks,\r
uint8_t* BufferPtr) ATTR_NON_NULL_PTR_ARG(3);\r
void DataflashManager_ResetDataflashProtections(void);\r
+ bool DataflashManager_CheckDataflashOperation(void);\r
\r
#endif\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
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
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
/* Deselect current dataflash chip */\r
Dataflash_DeselectChip();\r
}\r
+\r
+/** Performs a simple test on the attached Dataflash IC(s) to ensure that they are working.\r
+ *\r
+ * \return Boolean true if all media chips are working, false otherwise\r
+ */\r
+bool DataflashManager_CheckDataflashOperation(void)\r
+{\r
+ uint8_t ReturnByte;\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
+ return false;\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
+ return false;\r
+ #endif\r
+ \r
+ return true;\r
+}\r
void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress, uint16_t TotalBlocks,\r
uint8_t* BufferPtr) ATTR_NON_NULL_PTR_ARG(3);\r
void DataflashManager_ResetDataflashProtections(void);\r
+ bool DataflashManager_CheckDataflashOperation(void);\r
\r
#endif\r
* 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
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
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
* - Add detailed overviews of how each demo works\r
* - Master LUFA include file rather than per-module includes\r
* - Change makefiles to allow for absolute LUFA location to be used\r
+ * - Abstract out the physical media from the Mass Storage device demos\r
* - Make new demos\r
* -# Multiple-report HID device\r
* -# Dual Role Mouse Host/Keyboard Device\r