From aaa0bed556d0fa424b831418a7ce2531653a8b03 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Mon, 23 Nov 2009 12:40:14 +0000 Subject: The incomplete StandaloneProgrammer project now uses Host and Device Mass storage classes, so that program data can either be loaded onto the device's Dataflash storage, or read off an attached USB memory stick. The USB target family and allowable USB mode tokens are now public and documented (USB_CAN_BE_*, USB_SERIES_*_AVR). The SCSI_Request_Sense_Response_t and SCSI_Inquiry_Response_t type defines are now part of the Mass Storage Class driver common defines, rather than being defined in the Host mode Class driver section only. The USB_MODE_HOST token is now defined even when host mode is not available. Added missing CDC_Host_CreateBlockingStream() function code to the CDC Host Class driver. --- .../StandaloneProgrammer/Lib/PetiteFATFs/diskio.c | 29 +++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs') diff --git a/Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs/diskio.c b/Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs/diskio.c index 0084fa514..013467c25 100644 --- a/Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs/diskio.c +++ b/Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs/diskio.c @@ -5,7 +5,9 @@ #include "diskio.h" #include +#include #include "../DataflashManager.h" +#include "../../DiskHost.h" /*-----------------------------------------------------------------------*/ /* Initialize Disk Drive */ @@ -33,14 +35,29 @@ DRESULT disk_readp ( WORD count /* Byte count (bit15:destination) */ ) { - DRESULT res; - + DRESULT ErrorCode = RES_OK; uint8_t BlockTemp[512]; - DataflashManager_ReadBlocks_RAM(sector, 1, BlockTemp); - memcpy(dest, &BlockTemp[sofs], count); - res = RES_OK; + if (USB_CurrentMode == USB_MODE_HOST) + { + #if defined(USB_CAN_BE_HOST) + if (USB_HostState != HOST_STATE_Configured) + ErrorCode = RES_NOTRDY; + else if (MS_Host_ReadDeviceBlocks(&DiskHost_MS_Interface, 0, sector, 1, 512, BlockTemp)) + ErrorCode = RES_ERROR; + + printf("BLOCK READ #%lu Ret %d\r\n", sector, MS_Host_ReadDeviceBlocks(&DiskHost_MS_Interface, 0, sector, 1, 512, BlockTemp)); + #endif + } + else + { + #if defined(USB_CAN_BE_DEVICE) + DataflashManager_ReadBlocks_RAM(sector, 1, BlockTemp); + #endif + } + + memcpy(dest, &BlockTemp[sofs], count); - return res; + return ErrorCode; } -- cgit v1.2.3