From 31d8ebebc0796873f7c70db80a04acdcbb307ed8 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Wed, 26 Aug 2009 07:34:31 +0000 Subject: 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. --- .../ClassDriver/MassStorageHost/MassStorageHost.c | 54 +++++++++++++++++++++- .../ClassDriver/MassStorageHost/MassStorageHost.h | 1 + 2 files changed, 54 insertions(+), 1 deletion(-) (limited to 'Demos/Host/ClassDriver') 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 #include #include + #include #include #include -- cgit v1.2.3