aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-09-22 07:53:57 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-09-22 07:53:57 +0000
commit576f40f5aec3d7e48ed949fd24494b6cfb3ec93f (patch)
treeb177b7ca2be074037ba8bf68ac7b3ee6b3b01a82 /Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.c
parent242303c1607fca405d9407b9fab6fb78cae676e2 (diff)
downloadlufa-576f40f5aec3d7e48ed949fd24494b6cfb3ec93f.tar.gz
lufa-576f40f5aec3d7e48ed949fd24494b6cfb3ec93f.tar.bz2
lufa-576f40f5aec3d7e48ed949fd24494b6cfb3ec93f.zip
Move Dataflash operational checking code out from SCSI.c into the DataflashManager.c in the Device mode Mass Storage demos.
Diffstat (limited to 'Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.c')
-rw-r--r--Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.c b/Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.c
index 9cd0279d6..7d070f37c 100644
--- a/Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.c
+++ b/Demos/Device/LowLevel/MassStorage/Lib/DataflashManager.c
@@ -488,3 +488,36 @@ void DataflashManager_ResetDataflashProtections(void)
/* Deselect current dataflash chip */
Dataflash_DeselectChip();
}
+
+/** Performs a simple test on the attached Dataflash IC(s) to ensure that they are working.
+ *
+ * \return Boolean true if all media chips are working, false otherwise
+ */
+bool DataflashManager_CheckDataflashOperation(void)
+{
+ uint8_t ReturnByte;
+
+ /* 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)
+ 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)
+ return false;
+ #endif
+
+ return true;
+}