aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Host/ClassDriver
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-08-26 07:34:31 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-08-26 07:34:31 +0000
commit31d8ebebc0796873f7c70db80a04acdcbb307ed8 (patch)
tree175e917bd85a7e5a449dfd80e8e8dfff55f1b334 /Demos/Host/ClassDriver
parentee744abb7efd5fef49782991d58895e10696809a (diff)
downloadlufa-31d8ebebc0796873f7c70db80a04acdcbb307ed8.tar.gz
lufa-31d8ebebc0796873f7c70db80a04acdcbb307ed8.tar.bz2
lufa-31d8ebebc0796873f7c70db80a04acdcbb307ed8.zip
Oops: Really disable building of Projects/Host/ClassDriver directory in the Projects/Host/ makefile.
Add more skeleton functions and definitions to the Mass Storage Host mode Class driver. Made Endpoint_Write_DWord_* functions echo the structure of the matching Endpoint routines for clarity.
Diffstat (limited to 'Demos/Host/ClassDriver')
-rw-r--r--Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c54
-rw-r--r--Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.h1
2 files changed, 54 insertions, 1 deletions
diff --git a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c
index 0f9134fea..27662db75 100644
--- a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c
+++ b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c
@@ -121,6 +121,23 @@ int main(void)
break;
}
+ SCSI_Request_Sense_Response_t SenseData;
+ if (MS_Host_RequestSense(&FlashDisk_MS_Interface, 0, &SenseData) != 0)
+ {
+ printf("Error retrieving device sense.\r\n");
+ LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
+ break;
+ }
+
+ if (MS_Host_PreventAllowMediumRemoval(&FlashDisk_MS_Interface, 0, true))
+ {
+ printf("Error setting Prevent Device Removal bit.\r\n");
+ LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
+ break;
+ }
+
SCSI_Inquiry_Response_t InquiryData;
if (MS_Host_GetInquiryData(&FlashDisk_MS_Interface, &InquiryData))
{
@@ -147,7 +164,7 @@ int main(void)
}
while (!(DeviceReady));
- puts_P(PSTR("Retrieving Capacity... "));
+ printf("Retrieving Capacity... ");
SCSI_Capacity_t DiskCapacity;
if (MS_Host_ReadDeviceCapacity(&FlashDisk_MS_Interface, 0, &DiskCapacity))
@@ -160,6 +177,41 @@ int main(void)
printf("%lu blocks of %lu bytes.\r\n", DiskCapacity.Blocks, DiskCapacity.BlockSize);
+ uint8_t BlockBuffer[DiskCapacity.BlockSize];
+
+ if (MS_Host_ReadDeviceBlocks(&FlashDisk_MS_Interface, 0, 0x00000000, 1, DiskCapacity.BlockSize, BlockBuffer))
+ {
+ printf("Error reading device block.\r\n");
+ LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
+ USB_HostState = HOST_STATE_WaitForDeviceRemoval;
+ break;
+ }
+
+ printf("\r\nContents of first block:\r\n");
+
+ for (uint16_t Chunk = 0; Chunk < (DiskCapacity.BlockSize >> 4); Chunk++)
+ {
+ uint8_t* ChunkPtr = &BlockBuffer[Chunk << 4];
+
+ /* Print out the 16 bytes of the chunk in HEX format */
+ for (uint8_t ByteOffset = 0; ByteOffset < (1 << 4); ByteOffset++)
+ {
+ char CurrByte = *(ChunkPtr + ByteOffset);
+ printf_P(PSTR("%.2X "), CurrByte);
+ }
+
+ printf(" ");
+
+ /* Print out the 16 bytes of the chunk in ASCII format */
+ for (uint8_t ByteOffset = 0; ByteOffset < (1 << 4); ByteOffset++)
+ {
+ char CurrByte = *(ChunkPtr + ByteOffset);
+ putchar(isprint(CurrByte) ? CurrByte : '.');
+ }
+
+ printf("\r\n");
+ }
+
LEDs_SetAllLEDs(LEDMASK_USB_READY);
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
break;
diff --git a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.h b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.h
index 02aabaf58..4c3539fd0 100644
--- a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.h
+++ b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.h
@@ -41,6 +41,7 @@
#include <avr/wdt.h>
#include <avr/pgmspace.h>
#include <avr/power.h>
+ #include <ctype.h>
#include <stdio.h>
#include <LUFA/Version.h>