aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-11-23 12:40:14 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-11-23 12:40:14 +0000
commitaaa0bed556d0fa424b831418a7ce2531653a8b03 (patch)
tree53cbc38a5510a8a769e8ad0078c1e1124290554d /Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs
parent6e867f7d9bc279a118fc774ab1ee05e99b4d8b7c (diff)
downloadlufa-aaa0bed556d0fa424b831418a7ce2531653a8b03.tar.gz
lufa-aaa0bed556d0fa424b831418a7ce2531653a8b03.tar.bz2
lufa-aaa0bed556d0fa424b831418a7ce2531653a8b03.zip
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.
Diffstat (limited to 'Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs')
-rw-r--r--Projects/Incomplete/StandaloneProgrammer/Lib/PetiteFATFs/diskio.c29
1 files changed, 23 insertions, 6 deletions
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 <string.h>
+#include <LUFA/Drivers/USB/Class/MassStorage.h>
#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;
}