Bugfixes for Downstream, including one in the USB host stack!

Downstream now enumerates and accepts attached USB storage devices.
pull/7/head
Robert Fisk 9 years ago
parent 750c2f3a21
commit 48a6c2e2a4

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="ilg.gnuarmeclipse.debug.gdbjtag.openocd.launchConfigurationType"> <launchConfiguration type="ilg.gnuarmeclipse.debug.gdbjtag.openocd.launchConfigurationType">
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.PERIPHERALS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;peripherals/&gt;&#10;"/>
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doContinue" value="true"/> <booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doContinue" value="true"/>
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doDebugInRam" value="false"/> <booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doDebugInRam" value="false"/>
<booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doFirstReset" value="true"/> <booleanAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.doFirstReset" value="true"/>
@ -15,7 +16,7 @@
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerExecutable" value="${openocd_path}/${openocd_executable}"/> <stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerExecutable" value="${openocd_path}/${openocd_executable}"/>
<intAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerGdbPortNumber" value="3333"/> <intAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerGdbPortNumber" value="3333"/>
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerLog" value=""/> <stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerLog" value=""/>
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerOther" value="-f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f board/olimex_stm32_h405.cfg"/> <stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerOther" value="-f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f board/olimex_stm32_h407.cfg"/>
<intAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerTelnetPortNumber" value="4444"/> <intAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.gdbServerTelnetPortNumber" value="4444"/>
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.otherInitCommands" value=""/> <stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.otherInitCommands" value=""/>
<stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.otherRunCommands" value=""/> <stringAttribute key="ilg.gnuarmeclipse.debug.gdbjtag.openocd.otherRunCommands" value=""/>
@ -47,12 +48,12 @@
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/> <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/> <stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/> <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Release/Upstream.elf"/> <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/Downstream.elf"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="Upstream"/> <stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="Downstream"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/> <booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="ilg.gnuarmeclipse.managedbuild.cross.config.elf.release.441554085"/> <stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.110983800"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/Upstream"/> <listEntry value="/Downstream"/>
</listAttribute> </listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/> <listEntry value="4"/>
@ -60,6 +61,6 @@
<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> <listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> <listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
</listAttribute> </listAttribute>
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList context=&quot;Context string&quot;/&gt;&#10;"/> <stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList context=&quot;Context string&quot;&gt;&#10;&lt;memoryBlockExpression address=&quot;536874100&quot; label=&quot;0x20000c74&quot;/&gt;&#10;&lt;memoryBlockExpression address=&quot;536874078&quot; label=&quot;0x20000c5e&quot;/&gt;&#10;&lt;/memoryBlockExpressionList&gt;&#10;"/>
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/> <stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
</launchConfiguration> </launchConfiguration>

@ -28,6 +28,7 @@ typedef enum
do { \ do { \
LED_Fault_SetBlinkRate(LED_FAST_BLINK_RATE); \ LED_Fault_SetBlinkRate(LED_FAST_BLINK_RATE); \
DownstreamState = STATE_ERROR; \ DownstreamState = STATE_ERROR; \
while (1); \
} while (0); } while (0);

@ -142,6 +142,7 @@ typedef struct
uint8_t Reserved2[3]; uint8_t Reserved2[3];
uint8_t* pbuf; uint8_t* pbuf;
DownstreamPacketTypeDef* bot_packet; DownstreamPacketTypeDef* bot_packet;
uint8_t* bot_packet_pbuf;
uint16_t bot_packet_bytes_remaining; uint16_t bot_packet_bytes_remaining;
uint16_t this_URB_size; uint16_t this_URB_size;
} }

@ -445,7 +445,7 @@ static USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost)
(MSC_Handle->unit[MSC_Handle->current_lun].sense.key == SCSI_SENSE_KEY_NOT_READY) ) (MSC_Handle->unit[MSC_Handle->current_lun].sense.key == SCSI_SENSE_KEY_NOT_READY) )
{ {
if((phost->Timer - MSC_Handle->timeout) > 10000) if((phost->Timer - MSC_Handle->timeout) < 10000)
{ {
MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_TEST_UNIT_READY; MSC_Handle->unit[MSC_Handle->current_lun].state = MSC_TEST_UNIT_READY;
break; break;

@ -36,11 +36,12 @@
static USBH_StatusTypeDef USBH_MSC_BOT_Abort(USBH_HandleTypeDef *phost, uint8_t lun, uint8_t dir); static USBH_StatusTypeDef USBH_MSC_BOT_Abort(USBH_HandleTypeDef *phost, uint8_t lun, uint8_t dir);
static BOT_CSWStatusTypeDef USBH_MSC_DecodeCSW(USBH_HandleTypeDef *phost); static BOT_CSWStatusTypeDef USBH_MSC_DecodeCSW(USBH_HandleTypeDef *phost);
void USBH_MSC_BOT_Read_FreePacketCallback(DownstreamPacketTypeDef* freePacket); void USBH_MSC_BOT_Read_Multipacket_FreePacketCallback(DownstreamPacketTypeDef* freePacket);
void USBH_MSC_BOT_Read_PrepareURB(USBH_HandleTypeDef *phost); void USBH_MSC_BOT_Read_Multipacket_PrepareURB(USBH_HandleTypeDef *phost);
void USBH_MSC_BOT_Write_ReceivePacketCallback(DownstreamPacketTypeDef* receivedPacket, void USBH_MSC_BOT_Write_Multipacket_ReceivePacketCallback(DownstreamPacketTypeDef* receivedPacket,
uint16_t dataLength); uint16_t dataLength);
void USBH_MSC_BOT_Write_PrepareURB(USBH_HandleTypeDef *phost); void USBH_MSC_BOT_Write_Multipacket_PrepareURB(USBH_HandleTypeDef *phost);
USBH_HandleTypeDef *Callback_MSC_phost; USBH_HandleTypeDef *Callback_MSC_phost;
@ -175,13 +176,26 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process (USBH_HandleTypeDef *phost, uint8_t lun)
} }
break; break;
case BOT_DATA_IN: case BOT_DATA_IN:
/* Get first packet */
Callback_MSC_phost = phost;
MSC_Handle->hbot.state = BOT_DATA_IN_WAIT; MSC_Handle->hbot.state = BOT_DATA_IN_WAIT;
if (Downstream_GetFreePacket(USBH_MSC_BOT_Read_FreePacketCallback) != HAL_OK) if (MSC_Handle->hbot.pbuf != NULL)
{
//Simple single-buffer operation
MSC_Handle->hbot.this_URB_size = MIN(MSC_Handle->hbot.cbw.field.DataTransferLength,
MSC_Handle->InEpSize);
USBH_BulkReceiveData (phost,
MSC_Handle->hbot.pbuf,
MSC_Handle->hbot.this_URB_size,
MSC_Handle->InPipe);
}
else
{ {
MSC_Handle->hbot.state = BOT_ERROR_IN; //Asynchronous multi-packet operation: get first packet
Callback_MSC_phost = phost;
if (Downstream_GetFreePacket(USBH_MSC_BOT_Read_Multipacket_FreePacketCallback) != HAL_OK)
{
MSC_Handle->hbot.state = BOT_ERROR_IN;
}
} }
break; break;
@ -191,39 +205,49 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process (USBH_HandleTypeDef *phost, uint8_t lun)
if (URB_Status == USBH_URB_DONE) if (URB_Status == USBH_URB_DONE)
{ {
MSC_Handle->hbot.cbw.field.DataTransferLength -= MSC_Handle->hbot.this_URB_size; MSC_Handle->hbot.cbw.field.DataTransferLength -= MSC_Handle->hbot.this_URB_size;
MSC_Handle->hbot.bot_packet_bytes_remaining -= MSC_Handle->hbot.this_URB_size;
MSC_Handle->hbot.pbuf += MSC_Handle->hbot.this_URB_size;
if (MSC_Handle->hbot.cbw.field.DataTransferLength == 0) if (MSC_Handle->hbot.pbuf != NULL)
{ {
//End of reception: dispatch last packet //Simple single-buffer operation: everything must fit in one URB
MSC_Handle->hbot.state = BOT_RECEIVE_CSW; MSC_Handle->hbot.state = BOT_RECEIVE_CSW;
Downstream_MSC_PutStreamDataPacket(MSC_Handle->hbot.bot_packet,
(BOT_PAGE_LENGTH - MSC_Handle->hbot.bot_packet_bytes_remaining));
} }
else else
{ {
//Still more data to receive //Asynchronous multi-packet operation
if (MSC_Handle->hbot.bot_packet_bytes_remaining == 0) MSC_Handle->hbot.bot_packet_bytes_remaining -= MSC_Handle->hbot.this_URB_size;
{ MSC_Handle->hbot.bot_packet_pbuf += MSC_Handle->hbot.this_URB_size;
//Dispatch current bot_packet, then get a new one
if (Downstream_MSC_PutStreamDataPacket(MSC_Handle->hbot.bot_packet, if (MSC_Handle->hbot.cbw.field.DataTransferLength == 0)
(BOT_PAGE_LENGTH - MSC_Handle->hbot.bot_packet_bytes_remaining)) != HAL_OK) {
{ //End of reception: dispatch last packet
MSC_Handle->hbot.state = BOT_ERROR_IN; MSC_Handle->hbot.state = BOT_RECEIVE_CSW;
break; Downstream_MSC_PutStreamDataPacket(MSC_Handle->hbot.bot_packet,
} (BOT_PAGE_LENGTH - MSC_Handle->hbot.bot_packet_bytes_remaining));
if (Downstream_GetFreePacket(USBH_MSC_BOT_Read_FreePacketCallback) != HAL_OK) }
{ else
MSC_Handle->hbot.state = BOT_ERROR_IN; {
break; //Still more data to receive
} if (MSC_Handle->hbot.bot_packet_bytes_remaining == 0)
} {
else //Dispatch current bot_packet, then get a new one
{ if (Downstream_MSC_PutStreamDataPacket(MSC_Handle->hbot.bot_packet,
//Continue filling the current bot_packet (BOT_PAGE_LENGTH - MSC_Handle->hbot.bot_packet_bytes_remaining)) != HAL_OK)
USBH_MSC_BOT_Read_PrepareURB(phost); {
} MSC_Handle->hbot.state = BOT_ERROR_IN;
break;
}
if (Downstream_GetFreePacket(USBH_MSC_BOT_Read_Multipacket_FreePacketCallback) != HAL_OK)
{
MSC_Handle->hbot.state = BOT_ERROR_IN;
break;
}
}
else
{
//Continue filling the current bot_packet
USBH_MSC_BOT_Read_Multipacket_PrepareURB(phost);
}
}
} }
} }
@ -242,11 +266,26 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process (USBH_HandleTypeDef *phost, uint8_t lun)
break; break;
case BOT_DATA_OUT: case BOT_DATA_OUT:
Callback_MSC_phost = phost;
MSC_Handle->hbot.state = BOT_DATA_OUT_WAIT; MSC_Handle->hbot.state = BOT_DATA_OUT_WAIT;
if (Downstream_MSC_GetStreamDataPacket(USBH_MSC_BOT_Write_ReceivePacketCallback) != HAL_OK) if (MSC_Handle->hbot.pbuf != NULL)
{ {
MSC_Handle->hbot.state = BOT_ERROR_OUT; //Simple single-buffer operation
MSC_Handle->hbot.this_URB_size = MIN(MSC_Handle->hbot.cbw.field.DataTransferLength,
MSC_Handle->OutEpSize);
USBH_BulkSendData (phost,
MSC_Handle->hbot.pbuf,
MSC_Handle->hbot.this_URB_size,
MSC_Handle->OutPipe,
1);
}
else
{
//Asynchronous multi-packet operation: get first packet
Callback_MSC_phost = phost;
if (Downstream_MSC_GetStreamDataPacket(USBH_MSC_BOT_Write_Multipacket_ReceivePacketCallback) != HAL_OK)
{
MSC_Handle->hbot.state = BOT_ERROR_OUT;
}
} }
break; break;
@ -256,30 +295,39 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process (USBH_HandleTypeDef *phost, uint8_t lun)
if(URB_Status == USBH_URB_DONE) if(URB_Status == USBH_URB_DONE)
{ {
MSC_Handle->hbot.cbw.field.DataTransferLength -= MSC_Handle->hbot.this_URB_size; MSC_Handle->hbot.cbw.field.DataTransferLength -= MSC_Handle->hbot.this_URB_size;
MSC_Handle->hbot.bot_packet_bytes_remaining -= MSC_Handle->hbot.this_URB_size;
MSC_Handle->hbot.pbuf += MSC_Handle->hbot.this_URB_size;
if (MSC_Handle->hbot.cbw.field.DataTransferLength == 0) if (MSC_Handle->hbot.pbuf != NULL)
{ {
//End of reception //Simple single-buffer operation: everything must fit in one URB
MSC_Handle->hbot.state = BOT_RECEIVE_CSW; MSC_Handle->hbot.state = BOT_RECEIVE_CSW;
} }
else else
{ {
//Still more data to receive //Asynchronous multi-packet operation
if (MSC_Handle->hbot.bot_packet_bytes_remaining == 0) MSC_Handle->hbot.bot_packet_bytes_remaining -= MSC_Handle->hbot.this_URB_size;
{ MSC_Handle->hbot.bot_packet_pbuf += MSC_Handle->hbot.this_URB_size;
//Get next bot_packet if (MSC_Handle->hbot.cbw.field.DataTransferLength == 0)
if (Downstream_MSC_GetStreamDataPacket(USBH_MSC_BOT_Write_ReceivePacketCallback) != HAL_OK) {
{ //End of transmission
MSC_Handle->hbot.state = BOT_ERROR_OUT; MSC_Handle->hbot.state = BOT_RECEIVE_CSW;
} }
} else
else {
{ //Still more data to send
//Continue reading the current bot_packet if (MSC_Handle->hbot.bot_packet_bytes_remaining == 0)
USBH_MSC_BOT_Write_PrepareURB(phost); {
} //Get next bot_packet
if (Downstream_MSC_GetStreamDataPacket(USBH_MSC_BOT_Write_Multipacket_ReceivePacketCallback) != HAL_OK)
{
MSC_Handle->hbot.state = BOT_ERROR_OUT;
}
}
else
{
//Continue writing the current bot_packet
USBH_MSC_BOT_Write_Multipacket_PrepareURB(phost);
}
}
} }
} }
@ -385,7 +433,7 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process (USBH_HandleTypeDef *phost, uint8_t lun)
} }
void USBH_MSC_BOT_Read_FreePacketCallback(DownstreamPacketTypeDef* freePacket) void USBH_MSC_BOT_Read_Multipacket_FreePacketCallback(DownstreamPacketTypeDef* freePacket)
{ {
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) Callback_MSC_phost->pActiveClass->pData; MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) Callback_MSC_phost->pActiveClass->pData;
@ -396,13 +444,13 @@ void USBH_MSC_BOT_Read_FreePacketCallback(DownstreamPacketTypeDef* freePacket)
} }
MSC_Handle->hbot.bot_packet = freePacket; MSC_Handle->hbot.bot_packet = freePacket;
MSC_Handle->hbot.pbuf = freePacket->Data; MSC_Handle->hbot.bot_packet_pbuf = freePacket->Data;
MSC_Handle->hbot.bot_packet_bytes_remaining = BOT_PAGE_LENGTH; MSC_Handle->hbot.bot_packet_bytes_remaining = BOT_PAGE_LENGTH;
USBH_MSC_BOT_Read_PrepareURB(Callback_MSC_phost); USBH_MSC_BOT_Read_Multipacket_PrepareURB(Callback_MSC_phost);
} }
void USBH_MSC_BOT_Read_PrepareURB(USBH_HandleTypeDef *phost) void USBH_MSC_BOT_Read_Multipacket_PrepareURB(USBH_HandleTypeDef *phost)
{ {
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData; MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
@ -417,14 +465,14 @@ void USBH_MSC_BOT_Read_PrepareURB(USBH_HandleTypeDef *phost)
} }
USBH_BulkReceiveData(phost, USBH_BulkReceiveData(phost,
MSC_Handle->hbot.pbuf, MSC_Handle->hbot.bot_packet_pbuf,
MSC_Handle->hbot.this_URB_size, MSC_Handle->hbot.this_URB_size,
MSC_Handle->InPipe); MSC_Handle->InPipe);
} }
void USBH_MSC_BOT_Write_ReceivePacketCallback(DownstreamPacketTypeDef* receivedPacket, void USBH_MSC_BOT_Write_Multipacket_ReceivePacketCallback(DownstreamPacketTypeDef* receivedPacket,
uint16_t dataLength) uint16_t dataLength)
{ {
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) Callback_MSC_phost->pActiveClass->pData; MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) Callback_MSC_phost->pActiveClass->pData;
@ -435,13 +483,13 @@ void USBH_MSC_BOT_Write_ReceivePacketCallback(DownstreamPacketTypeDef* receivedP
} }
MSC_Handle->hbot.bot_packet = receivedPacket; MSC_Handle->hbot.bot_packet = receivedPacket;
MSC_Handle->hbot.pbuf = receivedPacket->Data; MSC_Handle->hbot.bot_packet_pbuf = receivedPacket->Data;
MSC_Handle->hbot.bot_packet_bytes_remaining = dataLength; MSC_Handle->hbot.bot_packet_bytes_remaining = dataLength;
USBH_MSC_BOT_Write_PrepareURB(Callback_MSC_phost); USBH_MSC_BOT_Write_Multipacket_PrepareURB(Callback_MSC_phost);
} }
void USBH_MSC_BOT_Write_PrepareURB(USBH_HandleTypeDef *phost) void USBH_MSC_BOT_Write_Multipacket_PrepareURB(USBH_HandleTypeDef *phost)
{ {
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData; MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;
@ -455,7 +503,7 @@ void USBH_MSC_BOT_Write_PrepareURB(USBH_HandleTypeDef *phost)
MSC_Handle->hbot.this_URB_size = MSC_Handle->OutEpSize; MSC_Handle->hbot.this_URB_size = MSC_Handle->OutEpSize;
} }
USBH_BulkSendData (phost, USBH_BulkSendData (phost,
MSC_Handle->hbot.pbuf, MSC_Handle->hbot.bot_packet_pbuf,
MSC_Handle->hbot.this_URB_size, MSC_Handle->hbot.this_URB_size,
MSC_Handle->OutPipe, MSC_Handle->OutPipe,
1); 1);

@ -352,6 +352,7 @@ USBH_StatusTypeDef USBH_MSC_SCSI_Write(USBH_HandleTypeDef *phost,
MSC_Handle->hbot.state = BOT_SEND_CBW; MSC_Handle->hbot.state = BOT_SEND_CBW;
MSC_Handle->hbot.cmd_state = BOT_CMD_WAIT; MSC_Handle->hbot.cmd_state = BOT_CMD_WAIT;
MSC_Handle->hbot.pbuf = NULL;
error = USBH_BUSY; error = USBH_BUSY;
break; break;
@ -408,6 +409,7 @@ USBH_StatusTypeDef USBH_MSC_SCSI_Read(USBH_HandleTypeDef *phost,
MSC_Handle->hbot.state = BOT_SEND_CBW; MSC_Handle->hbot.state = BOT_SEND_CBW;
MSC_Handle->hbot.cmd_state = BOT_CMD_WAIT; MSC_Handle->hbot.cmd_state = BOT_CMD_WAIT;
MSC_Handle->hbot.pbuf = NULL;
error = USBH_BUSY; error = USBH_BUSY;
break; break;

@ -94,6 +94,9 @@
#define LE32S(addr) (int32_t)(LE32((addr))) #define LE32S(addr) (int32_t)(LE32((addr)))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define USB_LEN_DESC_HDR 0x02 #define USB_LEN_DESC_HDR 0x02
#define USB_LEN_DEV_DESC 0x12 #define USB_LEN_DEV_DESC 0x12

@ -37,6 +37,11 @@ HAL_StatusTypeDef Downstream_MSC_ApproveConnectedDevice(void)
{ {
MSC_HandleTypeDef* MSC_Handle = (MSC_HandleTypeDef*)hUsbHostFS.pActiveClass->pData; MSC_HandleTypeDef* MSC_Handle = (MSC_HandleTypeDef*)hUsbHostFS.pActiveClass->pData;
if (MSC_Handle->unit[MSC_FIXED_LUN].error != MSC_OK)
{
return HAL_ERROR;
}
if ((MSC_Handle->unit[MSC_FIXED_LUN].capacity.block_nbr == 0) || if ((MSC_Handle->unit[MSC_FIXED_LUN].capacity.block_nbr == 0) ||
(MSC_Handle->unit[MSC_FIXED_LUN].capacity.block_nbr == UINT32_MAX)) (MSC_Handle->unit[MSC_FIXED_LUN].capacity.block_nbr == UINT32_MAX))
{ {

Loading…
Cancel
Save