Minor tweaks to downstream interface

pull/7/head
Robert Fisk 9 years ago
parent d3da69eb07
commit aa72df1bbf

@ -104,6 +104,7 @@
</tool> </tool>
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.printsize.1355233875" name="Cross ARM GNU Print Size" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.printsize"> <tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.printsize.1355233875" name="Cross ARM GNU Print Size" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.printsize">
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.format.371297331" name="Size format" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.format" value="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.format.berkeley" valueType="enumerated"/> <option id="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.format.371297331" name="Size format" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.format" value="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.format.berkeley" valueType="enumerated"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.totals.306060728" name="Show totals" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.printsize.totals" value="false" valueType="boolean"/>
</tool> </tool>
</toolChain> </toolChain>
</folderInfo> </folderInfo>

@ -70,18 +70,6 @@
/** @defgroup USB_CORE_Exported_Types /** @defgroup USB_CORE_Exported_Types
* @{ * @{
*/ */
typedef struct _USBD_STORAGE
{
int8_t (* Init) (uint8_t lun);
int8_t (* GetCapacity) (uint8_t lun, uint32_t *block_num, uint16_t *block_size);
int8_t (* IsReady) (uint8_t lun);
int8_t (* IsWriteProtected) (uint8_t lun);
int8_t (* Read) (uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
int8_t (* Write)(uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len);
int8_t (* GetMaxLun)(void);
int8_t *pInquiry;
}USBD_StorageTypeDef;
typedef struct typedef struct
@ -113,8 +101,6 @@ USBD_MSC_BOT_HandleTypeDef;
extern USBD_ClassTypeDef USBD_MSC; extern USBD_ClassTypeDef USBD_MSC;
#define USBD_MSC_CLASS &USBD_MSC #define USBD_MSC_CLASS &USBD_MSC
uint8_t USBD_MSC_RegisterStorage (USBD_HandleTypeDef *pdev,
USBD_StorageTypeDef *fops);
/** /**
* @} * @}
*/ */

@ -20,6 +20,7 @@ uint64_t BlockStart;
uint32_t BlockCount; uint32_t BlockCount;
uint32_t ByteCount; uint32_t ByteCount;
DownstreamPacketTypeDef* ReadStreamPacket; DownstreamPacketTypeDef* ReadStreamPacket;
uint8_t ReadStreamBusy;
static void DownstreamInterface_TestReadyReplyCallback(DownstreamPacketTypeDef* replyPacket); static void DownstreamInterface_TestReadyReplyCallback(DownstreamPacketTypeDef* replyPacket);
@ -109,10 +110,9 @@ HAL_StatusTypeDef DownstreamInterface_BeginRead(DownstreamInterfaceMSCCallbackTy
{ {
DownstreamPacketTypeDef* freePacket; DownstreamPacketTypeDef* freePacket;
HAL_StatusTypeDef tempResult; HAL_StatusTypeDef tempResult;
uint64_t* workDammit;
uint32_t* prettyPlease;
ReadStreamPacket = NULL; //Prepare for GetStreamDataPacket's use ReadStreamPacket = NULL; //Prepare for GetStreamDataPacket's use
ReadStreamBusy = 0;
TestReadyCallback = callback; TestReadyCallback = callback;
BlockStart = readBlockStart; BlockStart = readBlockStart;
@ -123,10 +123,9 @@ HAL_StatusTypeDef DownstreamInterface_BeginRead(DownstreamInterfaceMSCCallbackTy
freePacket->Length = DOWNSTREAM_PACKET_HEADER_LEN + (4 * 3); freePacket->Length = DOWNSTREAM_PACKET_HEADER_LEN + (4 * 3);
freePacket->CommandClass = COMMAND_CLASS_MASS_STORAGE; freePacket->CommandClass = COMMAND_CLASS_MASS_STORAGE;
freePacket->Command = COMMAND_MSC_BEGIN_READ; freePacket->Command = COMMAND_MSC_BEGIN_READ;
workDammit = (uint64_t*)&(freePacket->Data[0]); *(uint64_t*)&(freePacket->Data[0]) = BlockStart;
*workDammit = BlockStart; *(uint32_t*)&(freePacket->Data[8]) = BlockCount;
prettyPlease = (uint32_t*)&(freePacket->Data[8]);
*prettyPlease = BlockCount;
tempResult = Downstream_SendPacket(freePacket); tempResult = Downstream_SendPacket(freePacket);
if (tempResult != HAL_OK) if (tempResult != HAL_OK)
{ {
@ -140,8 +139,13 @@ HAL_StatusTypeDef DownstreamInterface_GetStreamDataPacket(DownstreamInterfaceMSC
{ {
GetStreamDataCallback = callback; GetStreamDataCallback = callback;
//We have a callback address. Do we have a stored packet? if (ReadStreamBusy != 0)
if (ReadStreamPacket) {
return HAL_OK;
}
ReadStreamBusy = 1;
if (ReadStreamPacket && GetStreamDataCallback) //Do we have a stored packet and an address to send it?
{ {
DownstreamInterface_GetStreamDataPacketCallback(ReadStreamPacket); //Send it now! DownstreamInterface_GetStreamDataPacketCallback(ReadStreamPacket); //Send it now!
ReadStreamPacket = NULL; ReadStreamPacket = NULL;
@ -152,6 +156,7 @@ HAL_StatusTypeDef DownstreamInterface_GetStreamDataPacket(DownstreamInterfaceMSC
void DownstreamInterface_GetStreamDataPacketCallback(DownstreamPacketTypeDef* replyPacket) void DownstreamInterface_GetStreamDataPacketCallback(DownstreamPacketTypeDef* replyPacket)
{ {
ReadStreamBusy = 0;
if (GetStreamDataCallback == NULL) if (GetStreamDataCallback == NULL)
{ {
ReadStreamPacket = replyPacket; //We used up our callback already, so save this one for later. ReadStreamPacket = replyPacket; //We used up our callback already, so save this one for later.
@ -163,11 +168,14 @@ void DownstreamInterface_GetStreamDataPacketCallback(DownstreamPacketTypeDef* re
(replyPacket->Length > ByteCount)) (replyPacket->Length > ByteCount))
{ {
GetStreamDataCallback(HAL_ERROR, NULL); GetStreamDataCallback(HAL_ERROR, NULL);
return;
} }
else
ByteCount -= replyPacket->Length;
GetStreamDataCallback(HAL_OK, replyPacket); //usb_msc_scsi will use this packet, so don't release now
if (ByteCount > 0)
{ {
ByteCount -= replyPacket->Length; DownstreamInterface_GetStreamDataPacket(NULL); //Try to get the next packet now, before USB asks for it
GetStreamDataCallback(HAL_OK, replyPacket); //usb_msc_scsi will use this packet, so don't release now
} }
} }

Loading…
Cancel
Save