Implemented read-only option (Downstream only)

USG_1.0
Robert Fisk 8 years ago
parent 53fea530aa
commit 7cf9b67d1f

@ -496,8 +496,10 @@ static USBH_StatusTypeDef USBH_MSC_Process(USBH_HandleTypeDef *phost)
error = USBH_OK;
break;
case MSC_READ:
#ifdef MASS_STORAGE_WRITES_PERMITTED
case MSC_WRITE:
#endif
case MSC_READ:
error = USBH_MSC_RdWrProcess(phost, MSC_Handle->rw_lun);
if(((int32_t)(phost->Timer - MSC_Handle->timeout) > 0) || (phost->device.is_connected == 0))
{
@ -572,6 +574,7 @@ static USBH_StatusTypeDef USBH_MSC_RdWrProcess(USBH_HandleTypeDef *phost, uint8_
#endif
break;
#ifdef MASS_STORAGE_WRITES_PERMITTED
case MSC_WRITE:
scsi_status = USBH_MSC_SCSI_Write(phost,lun, 0, 0) ;
@ -593,6 +596,7 @@ static USBH_StatusTypeDef USBH_MSC_RdWrProcess(USBH_HandleTypeDef *phost, uint8_
osMessagePut ( phost->os_event, USBH_CLASS_EVENT, 0);
#endif
break;
#endif //#ifdef MASS_STORAGE_WRITES_PERMITTED
case MSC_REQUEST_SENSE:
scsi_status = USBH_MSC_SCSI_RequestSense(phost, lun, &MSC_Handle->unit[lun].sense);
@ -758,6 +762,7 @@ USBH_StatusTypeDef USBH_MSC_Read(USBH_HandleTypeDef *phost,
* @param length: number of sector to write
* @retval USBH Status
*/
#ifdef MASS_STORAGE_WRITES_PERMITTED
USBH_StatusTypeDef USBH_MSC_Write(USBH_HandleTypeDef *phost,
uint8_t lun,
uint32_t address,
@ -786,6 +791,7 @@ USBH_StatusTypeDef USBH_MSC_Write(USBH_HandleTypeDef *phost,
length);
return USBH_OK;
}
#endif //#ifdef MASS_STORAGE_WRITES_PERMITTED
#endif //#ifdef ENABLE_MASS_STORAGE

@ -301,6 +301,7 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process (USBH_HandleTypeDef *phost, uint8_t lun)
MSC_Handle->OutPipe,
1);
}
#ifdef MASS_STORAGE_WRITES_PERMITTED
else
{
//Asynchronous multi-packet operation: get first packet
@ -311,6 +312,7 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process (USBH_HandleTypeDef *phost, uint8_t lun)
MSC_Handle->hbot.state = BOT_ERROR_OUT;
}
}
#endif
break;
case BOT_DATA_OUT_WAIT_RECEIVE_PACKET:
@ -328,6 +330,7 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process (USBH_HandleTypeDef *phost, uint8_t lun)
//Simple single-buffer operation: everything must fit in one URB
MSC_Handle->hbot.state = BOT_RECEIVE_CSW;
}
#ifdef MASS_STORAGE_WRITES_PERMITTED
else
{
//Asynchronous multi-packet operation
@ -359,6 +362,7 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process (USBH_HandleTypeDef *phost, uint8_t lun)
}
}
}
#endif
}
else if(URB_Status == USBH_URB_NOTREADY)
@ -368,6 +372,7 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process (USBH_HandleTypeDef *phost, uint8_t lun)
{
MSC_Handle->hbot.state = BOT_DATA_OUT;
}
#ifdef MASS_STORAGE_WRITES_PERMITTED
else
{
//Increment counters by the amount of data actually transferred during the NAK'd URB
@ -378,6 +383,7 @@ USBH_StatusTypeDef USBH_MSC_BOT_Process (USBH_HandleTypeDef *phost, uint8_t lun)
USBH_MSC_BOT_Write_Multipacket_PrepareURB(phost);
}
#endif
}
else if(URB_Status == USBH_URB_STALL)
@ -516,7 +522,7 @@ void USBH_MSC_BOT_Read_Multipacket_PrepareURB(USBH_HandleTypeDef *phost)
MSC_Handle->InPipe);
}
#ifdef MASS_STORAGE_WRITES_PERMITTED
void USBH_MSC_BOT_Write_Multipacket_ReceivePacketCallback(DownstreamPacketTypeDef* receivedPacket,
uint16_t dataLength)
{
@ -558,7 +564,7 @@ void USBH_MSC_BOT_Write_Multipacket_PrepareURB(USBH_HandleTypeDef *phost)
MSC_Handle->OutPipe,
1);
}
#endif
/**
* @brief USBH_MSC_BOT_Abort
@ -570,6 +576,7 @@ void USBH_MSC_BOT_Write_Multipacket_PrepareURB(USBH_HandleTypeDef *phost)
*/
static USBH_StatusTypeDef USBH_MSC_BOT_Abort(USBH_HandleTypeDef *phost, uint8_t lun, uint8_t dir)
{
UNUSED(lun);
USBH_StatusTypeDef status = USBH_FAIL;
MSC_HandleTypeDef *MSC_Handle = (MSC_HandleTypeDef *) phost->pActiveClass->pData;

@ -325,6 +325,7 @@ USBH_StatusTypeDef USBH_MSC_SCSI_RequestSense (USBH_HandleTypeDef *phost,
* @param length: number of sector to write
* @retval USBH Status
*/
#ifdef MASS_STORAGE_WRITES_PERMITTED
USBH_StatusTypeDef USBH_MSC_SCSI_Write(USBH_HandleTypeDef *phost,
uint8_t lun,
uint32_t address,
@ -372,6 +373,7 @@ USBH_StatusTypeDef USBH_MSC_SCSI_Write(USBH_HandleTypeDef *phost,
return error;
}
#endif
/**
* @brief USBH_MSC_SCSI_Read

@ -80,9 +80,11 @@ void Downstream_MSC_PacketProcessor(DownstreamPacketTypeDef* receivedPacket)
Downstream_MSC_PacketProcessor_BeginRead(receivedPacket);
break;
#ifdef MASS_STORAGE_WRITES_PERMITTED
case COMMAND_MSC_WRITE:
Downstream_MSC_PacketProcessor_BeginWrite(receivedPacket);
break;
#endif
default:
Downstream_PacketProcessor_FreakOut();
@ -170,7 +172,7 @@ void Downstream_MSC_PacketProcessor_RdWrCompleteCallback(USBH_StatusTypeDef resu
}
#ifdef MASS_STORAGE_WRITES_PERMITTED
void Downstream_MSC_PacketProcessor_BeginWrite(DownstreamPacketTypeDef* receivedPacket)
{
uint64_t writeBlockAddress;
@ -217,6 +219,7 @@ void Downstream_MSC_PacketProcessor_BeginWrite(DownstreamPacketTypeDef* received
}
Downstream_TransmitPacket(receivedPacket);
}
#endif
//Used by USB MSC host driver
@ -235,6 +238,7 @@ HAL_StatusTypeDef Downstream_MSC_PutStreamDataPacket(DownstreamPacketTypeDef* pa
}
#ifdef MASS_STORAGE_WRITES_PERMITTED
//Used by USB MSC host driver
HAL_StatusTypeDef Downstream_MSC_GetStreamDataPacket(DownstreamMSCCallbackPacketTypeDef callback)
{
@ -286,6 +290,7 @@ void Downstream_MSC_GetStreamDataPacketCallback(DownstreamPacketTypeDef* receive
}
}
#endif //#ifdef MASS_STORAGE_WRITES_PERMITTED
#endif //#ifdef ENABLE_MASS_STORAGE

Loading…
Cancel
Save