Altered all endpoint/pipe stream transfers so that the new BytesProcessed parameter now points to a location where the number of bytes in the transfer that have been completed can be stored (or NULL if entire transaction should be performed in one chunk).
Added new Endpoint_Null_Stream() and Pipe_Null_stream() functions. Removed the NO_STREAM_CALLBACKS compile time option due to the new partial stream transfer feature replacing it. Fixed errors in the incomplete Test and Measurement device demo preventing proper operation (thanks to Pavel Plotnikov).
This commit is contained in:
parent
477a2047f4
commit
f555ad7ced
107 changed files with 1257 additions and 943 deletions
|
@ -54,7 +54,7 @@ void ISPProtocol_EnterISPMode(void)
|
|||
uint8_t EnterProgBytes[4];
|
||||
} Enter_ISP_Params;
|
||||
|
||||
Endpoint_Read_Stream_LE(&Enter_ISP_Params, sizeof(Enter_ISP_Params), NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_LE(&Enter_ISP_Params, sizeof(Enter_ISP_Params), NULL);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
|
@ -109,7 +109,7 @@ void ISPProtocol_LeaveISPMode(void)
|
|||
uint8_t PostDelayMS;
|
||||
} Leave_ISP_Params;
|
||||
|
||||
Endpoint_Read_Stream_LE(&Leave_ISP_Params, sizeof(Leave_ISP_Params), NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_LE(&Leave_ISP_Params, sizeof(Leave_ISP_Params), NULL);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
|
@ -145,7 +145,7 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|||
} Write_Memory_Params; // whole page and ACK the packet as fast as possible to prevent it from aborting
|
||||
|
||||
Endpoint_Read_Stream_LE(&Write_Memory_Params, (sizeof(Write_Memory_Params) -
|
||||
sizeof(Write_Memory_Params.ProgData)), NO_STREAM_CALLBACK);
|
||||
sizeof(Write_Memory_Params.ProgData)), NULL);
|
||||
Write_Memory_Params.BytesToWrite = SwapEndian_16(Write_Memory_Params.BytesToWrite);
|
||||
|
||||
if (Write_Memory_Params.BytesToWrite > sizeof(Write_Memory_Params.ProgData))
|
||||
|
@ -160,7 +160,7 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|||
return;
|
||||
}
|
||||
|
||||
Endpoint_Read_Stream_LE(&Write_Memory_Params.ProgData, Write_Memory_Params.BytesToWrite, NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_LE(&Write_Memory_Params.ProgData, Write_Memory_Params.BytesToWrite, NULL);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
|
@ -279,7 +279,7 @@ void ISPProtocol_ReadMemory(uint8_t V2Command)
|
|||
uint8_t ReadMemoryCommand;
|
||||
} Read_Memory_Params;
|
||||
|
||||
Endpoint_Read_Stream_LE(&Read_Memory_Params, sizeof(Read_Memory_Params), NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_LE(&Read_Memory_Params, sizeof(Read_Memory_Params), NULL);
|
||||
Read_Memory_Params.BytesToRead = SwapEndian_16(Read_Memory_Params.BytesToRead);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
|
@ -353,7 +353,7 @@ void ISPProtocol_ChipErase(void)
|
|||
uint8_t EraseCommandBytes[4];
|
||||
} Erase_Chip_Params;
|
||||
|
||||
Endpoint_Read_Stream_LE(&Erase_Chip_Params, sizeof(Erase_Chip_Params), NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_LE(&Erase_Chip_Params, sizeof(Erase_Chip_Params), NULL);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
|
@ -389,7 +389,7 @@ void ISPProtocol_ReadFuseLockSigOSCCAL(uint8_t V2Command)
|
|||
uint8_t ReadCommandBytes[4];
|
||||
} Read_FuseLockSigOSCCAL_Params;
|
||||
|
||||
Endpoint_Read_Stream_LE(&Read_FuseLockSigOSCCAL_Params, sizeof(Read_FuseLockSigOSCCAL_Params), NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_LE(&Read_FuseLockSigOSCCAL_Params, sizeof(Read_FuseLockSigOSCCAL_Params), NULL);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
|
@ -420,7 +420,7 @@ void ISPProtocol_WriteFuseLock(uint8_t V2Command)
|
|||
uint8_t WriteCommandBytes[4];
|
||||
} Write_FuseLockSig_Params;
|
||||
|
||||
Endpoint_Read_Stream_LE(&Write_FuseLockSig_Params, sizeof(Write_FuseLockSig_Params), NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_LE(&Write_FuseLockSig_Params, sizeof(Write_FuseLockSig_Params), NULL);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
|
@ -447,8 +447,8 @@ void ISPProtocol_SPIMulti(void)
|
|||
uint8_t TxData[255];
|
||||
} SPI_Multi_Params;
|
||||
|
||||
Endpoint_Read_Stream_LE(&SPI_Multi_Params, (sizeof(SPI_Multi_Params) - sizeof(SPI_Multi_Params.TxData)), NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_LE(&SPI_Multi_Params.TxData, SPI_Multi_Params.TxBytes, NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_LE(&SPI_Multi_Params, (sizeof(SPI_Multi_Params) - sizeof(SPI_Multi_Params.TxData)), NULL);
|
||||
Endpoint_Read_Stream_LE(&SPI_Multi_Params.TxData, SPI_Multi_Params.TxBytes, NULL);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
|
|
|
@ -185,7 +185,7 @@ static void V2Protocol_SignOn(void)
|
|||
Endpoint_Write_Byte(CMD_SIGN_ON);
|
||||
Endpoint_Write_Byte(STATUS_CMD_OK);
|
||||
Endpoint_Write_Byte(sizeof(PROGRAMMER_ID) - 1);
|
||||
Endpoint_Write_Stream_LE(PROGRAMMER_ID, (sizeof(PROGRAMMER_ID) - 1), NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_LE(PROGRAMMER_ID, (sizeof(PROGRAMMER_ID) - 1), NULL);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,7 @@ static void V2Protocol_GetSetParam(const uint8_t V2Command)
|
|||
*/
|
||||
static void V2Protocol_LoadAddress(void)
|
||||
{
|
||||
Endpoint_Read_Stream_BE(&CurrentAddress, sizeof(CurrentAddress), NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_BE(&CurrentAddress, sizeof(CurrentAddress), NULL);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
|
|
|
@ -62,7 +62,7 @@ void XPROGProtocol_SetMode(void)
|
|||
uint8_t Protocol;
|
||||
} SetMode_XPROG_Params;
|
||||
|
||||
Endpoint_Read_Stream_LE(&SetMode_XPROG_Params, sizeof(SetMode_XPROG_Params), NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_LE(&SetMode_XPROG_Params, sizeof(SetMode_XPROG_Params), NULL);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
|
@ -163,7 +163,7 @@ static void XPROGProtocol_Erase(void)
|
|||
uint32_t Address;
|
||||
} Erase_XPROG_Params;
|
||||
|
||||
Endpoint_Read_Stream_LE(&Erase_XPROG_Params, sizeof(Erase_XPROG_Params), NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_LE(&Erase_XPROG_Params, sizeof(Erase_XPROG_Params), NULL);
|
||||
Erase_XPROG_Params.Address = SwapEndian_32(Erase_XPROG_Params.Address);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
|
@ -243,10 +243,10 @@ static void XPROGProtocol_WriteMemory(void)
|
|||
} WriteMemory_XPROG_Params;
|
||||
|
||||
Endpoint_Read_Stream_LE(&WriteMemory_XPROG_Params, (sizeof(WriteMemory_XPROG_Params) -
|
||||
sizeof(WriteMemory_XPROG_Params).ProgData), NO_STREAM_CALLBACK);
|
||||
sizeof(WriteMemory_XPROG_Params).ProgData), NULL);
|
||||
WriteMemory_XPROG_Params.Address = SwapEndian_32(WriteMemory_XPROG_Params.Address);
|
||||
WriteMemory_XPROG_Params.Length = SwapEndian_16(WriteMemory_XPROG_Params.Length);
|
||||
Endpoint_Read_Stream_LE(&WriteMemory_XPROG_Params.ProgData, WriteMemory_XPROG_Params.Length, NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_LE(&WriteMemory_XPROG_Params.ProgData, WriteMemory_XPROG_Params.Length, NULL);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
|
@ -326,7 +326,7 @@ static void XPROGProtocol_ReadMemory(void)
|
|||
uint16_t Length;
|
||||
} ReadMemory_XPROG_Params;
|
||||
|
||||
Endpoint_Read_Stream_LE(&ReadMemory_XPROG_Params, sizeof(ReadMemory_XPROG_Params), NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_LE(&ReadMemory_XPROG_Params, sizeof(ReadMemory_XPROG_Params), NULL);
|
||||
ReadMemory_XPROG_Params.Address = SwapEndian_32(ReadMemory_XPROG_Params.Address);
|
||||
ReadMemory_XPROG_Params.Length = SwapEndian_16(ReadMemory_XPROG_Params.Length);
|
||||
|
||||
|
@ -354,7 +354,7 @@ static void XPROGProtocol_ReadMemory(void)
|
|||
Endpoint_Write_Byte(ReturnStatus);
|
||||
|
||||
if (ReturnStatus == XPRG_ERR_OK)
|
||||
Endpoint_Write_Stream_LE(ReadBuffer, ReadMemory_XPROG_Params.Length, NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_LE(ReadBuffer, ReadMemory_XPROG_Params.Length, NULL);
|
||||
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
@ -371,7 +371,7 @@ static void XPROGProtocol_ReadCRC(void)
|
|||
uint8_t CRCType;
|
||||
} ReadCRC_XPROG_Params;
|
||||
|
||||
Endpoint_Read_Stream_LE(&ReadCRC_XPROG_Params, sizeof(ReadCRC_XPROG_Params), NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_LE(&ReadCRC_XPROG_Params, sizeof(ReadCRC_XPROG_Params), NULL);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
|
|
|
@ -170,12 +170,10 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
return false;
|
||||
}
|
||||
|
||||
Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||
|
||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||
Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, NULL);
|
||||
|
||||
/* Pad out remaining bytes with 0x00 */
|
||||
Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), NO_STREAM_CALLBACK);
|
||||
Endpoint_Null_Stream((AllocationLength - BytesTransferred), NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
@ -198,10 +196,8 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
|
|||
uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
|
||||
uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData);
|
||||
|
||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||
|
||||
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NULL);
|
||||
Endpoint_Null_Stream((AllocationLength - BytesTransferred), NULL);
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
|
@ -222,8 +218,8 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
|
|||
uint32_t LastBlockAddressInLUN = (VIRTUAL_MEMORY_BLOCKS - 1);
|
||||
uint32_t MediaBlockSize = VIRTUAL_MEMORY_BLOCK_SIZE;
|
||||
|
||||
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NULL);
|
||||
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NULL);
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
|
|
|
@ -269,7 +269,7 @@ void WriteNextReport(uint8_t* const ReportOUTData,
|
|||
}
|
||||
|
||||
/* Write out HID report data */
|
||||
Pipe_Write_Stream_LE(ReportOUTData, ReportLength);
|
||||
Pipe_Write_Stream_LE(ReportOUTData, ReportLength, NULL);
|
||||
|
||||
/* Clear the OUT endpoint, send last data packet */
|
||||
Pipe_ClearOUT();
|
||||
|
|
|
@ -120,7 +120,6 @@ LUFA_OPTS = -D USB_HOST_ONLY
|
|||
LUFA_OPTS += -D HOST_STATE_AS_GPIOR=0
|
||||
LUFA_OPTS += -D ORDERED_EP_CONFIG
|
||||
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
|
||||
LUFA_OPTS += -D NO_STREAM_CALLBACKS
|
||||
|
||||
|
||||
# Create the LUFA source path variables by including the LUFA root makefile
|
||||
|
|
|
@ -169,12 +169,10 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
return false;
|
||||
}
|
||||
|
||||
Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||
|
||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||
Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, NULL);
|
||||
|
||||
/* Pad out remaining bytes with 0x00 */
|
||||
Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), NO_STREAM_CALLBACK);
|
||||
Endpoint_Null_Stream((AllocationLength - BytesTransferred), NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
@ -197,10 +195,8 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
|
|||
uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
|
||||
uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData);
|
||||
|
||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||
|
||||
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NULL);
|
||||
Endpoint_Null_Stream((AllocationLength - BytesTransferred), NULL);
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
|
@ -221,8 +217,8 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
|
|||
uint32_t LastBlockAddressInLUN = (VIRTUAL_MEMORY_BLOCKS - 1);
|
||||
uint32_t MediaBlockSize = VIRTUAL_MEMORY_BLOCK_SIZE;
|
||||
|
||||
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NULL);
|
||||
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NULL);
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
|
|
|
@ -169,12 +169,10 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
return false;
|
||||
}
|
||||
|
||||
Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||
|
||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||
Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, NULL);
|
||||
|
||||
/* Pad out remaining bytes with 0x00 */
|
||||
Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), NO_STREAM_CALLBACK);
|
||||
Endpoint_Null_Stream((AllocationLength - BytesTransferred), NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
@ -197,10 +195,8 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
|
|||
uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
|
||||
uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData);
|
||||
|
||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||
|
||||
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NULL);
|
||||
Endpoint_Null_Stream((AllocationLength - BytesTransferred), NULL);
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
|
@ -221,8 +217,8 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
|
|||
uint32_t LastBlockAddressInLUN = (VIRTUAL_MEMORY_BLOCKS - 1);
|
||||
uint32_t MediaBlockSize = VIRTUAL_MEMORY_BLOCK_SIZE;
|
||||
|
||||
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NULL);
|
||||
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NULL);
|
||||
Endpoint_ClearIN();
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue