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
|
@ -227,7 +227,7 @@ void CDC1_Task(void)
|
|||
Endpoint_SelectEndpoint(CDC1_TX_EPNUM);
|
||||
|
||||
/* Write the String to the Endpoint */
|
||||
Endpoint_Write_Stream_LE(ReportString, strlen(ReportString));
|
||||
Endpoint_Write_Stream_LE(ReportString, strlen(ReportString), NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
@ -269,7 +269,7 @@ void CDC2_Task(void)
|
|||
uint16_t DataLength = Endpoint_BytesInEndpoint();
|
||||
|
||||
/* Read in the incoming packet into the buffer */
|
||||
Endpoint_Read_Stream_LE(&Buffer, DataLength);
|
||||
Endpoint_Read_Stream_LE(&Buffer, DataLength, NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearOUT();
|
||||
|
@ -278,7 +278,7 @@ void CDC2_Task(void)
|
|||
Endpoint_SelectEndpoint(CDC2_TX_EPNUM);
|
||||
|
||||
/* Write the received data to the endpoint */
|
||||
Endpoint_Write_Stream_LE(&Buffer, DataLength);
|
||||
Endpoint_Write_Stream_LE(&Buffer, DataLength, NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
|
|
@ -121,7 +121,6 @@ LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
|
|||
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
|
||||
LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
|
||||
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | 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
|
||||
|
|
|
@ -198,7 +198,7 @@ void HID_Task(void)
|
|||
uint8_t GenericData[GENERIC_REPORT_SIZE];
|
||||
|
||||
/* Read Generic Report Data */
|
||||
Endpoint_Read_Stream_LE(&GenericData, sizeof(GenericData));
|
||||
Endpoint_Read_Stream_LE(&GenericData, sizeof(GenericData), NULL);
|
||||
|
||||
/* Process Generic Report Data */
|
||||
ProcessGenericHIDReport(GenericData);
|
||||
|
@ -220,7 +220,7 @@ void HID_Task(void)
|
|||
CreateGenericHIDReport(GenericData);
|
||||
|
||||
/* Write Generic Report Data */
|
||||
Endpoint_Write_Stream_LE(&GenericData, sizeof(GenericData));
|
||||
Endpoint_Write_Stream_LE(&GenericData, sizeof(GenericData), NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
|
|
@ -121,7 +121,6 @@ LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
|
|||
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
|
||||
LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
|
||||
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | 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
|
||||
|
|
|
@ -194,7 +194,7 @@ void HID_Task(void)
|
|||
GetNextReport(&JoystickReportData);
|
||||
|
||||
/* Write Joystick Report Data */
|
||||
Endpoint_Write_Stream_LE(&JoystickReportData, sizeof(JoystickReportData));
|
||||
Endpoint_Write_Stream_LE(&JoystickReportData, sizeof(JoystickReportData), NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
|
|
@ -121,7 +121,6 @@ LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
|
|||
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
|
||||
LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
|
||||
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | 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
|
||||
|
|
|
@ -324,7 +324,7 @@ void SendNextReport(void)
|
|||
PrevKeyboardReportData = KeyboardReportData;
|
||||
|
||||
/* Write Keyboard Report Data */
|
||||
Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData));
|
||||
Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData), NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
|
|
@ -121,7 +121,6 @@ LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
|
|||
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
|
||||
LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
|
||||
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | 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
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
USB_KeyboardReport_Data_t KeyboardReportData;
|
||||
|
||||
/** Global structure to hold the current mouse interface HID report, for transmission to the host */
|
||||
USB_MouseReport_Data_t MouseReportData;
|
||||
USB_MouseReport_Data_t MouseReportData;
|
||||
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
|
@ -242,7 +242,7 @@ void Keyboard_HID_Task(void)
|
|||
if (Endpoint_IsReadWriteAllowed())
|
||||
{
|
||||
/* Write Keyboard Report Data */
|
||||
Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData));
|
||||
Endpoint_Write_Stream_LE(&KeyboardReportData, sizeof(KeyboardReportData), NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
@ -300,7 +300,7 @@ void Mouse_HID_Task(void)
|
|||
if (Endpoint_IsReadWriteAllowed())
|
||||
{
|
||||
/* Write Mouse Report Data */
|
||||
Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData));
|
||||
Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData), NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
|
|
@ -121,7 +121,6 @@ LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
|
|||
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
|
||||
LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
|
||||
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | 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
|
||||
|
|
|
@ -171,7 +171,7 @@ void MIDI_Task(void)
|
|||
};
|
||||
|
||||
/* Write the MIDI event packet to the endpoint */
|
||||
Endpoint_Write_Stream_LE(&MIDIEvent, sizeof(MIDIEvent));
|
||||
Endpoint_Write_Stream_LE(&MIDIEvent, sizeof(MIDIEvent), NULL);
|
||||
|
||||
/* Send the data in the endpoint to the host */
|
||||
Endpoint_ClearIN();
|
||||
|
@ -190,7 +190,7 @@ void MIDI_Task(void)
|
|||
MIDI_EventPacket_t MIDIEvent;
|
||||
|
||||
/* Read the MIDI event packet from the endpoint */
|
||||
Endpoint_Read_Stream_LE(&MIDIEvent, sizeof(MIDIEvent));
|
||||
Endpoint_Read_Stream_LE(&MIDIEvent, sizeof(MIDIEvent), NULL);
|
||||
|
||||
/* Check to see if the sent command is a note on message with a non-zero velocity */
|
||||
if ((MIDIEvent.Command == (MIDI_COMMAND_NOTE_ON >> 4)) && (MIDIEvent.Data3 > 0))
|
||||
|
|
|
@ -121,7 +121,6 @@ LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
|
|||
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
|
||||
LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
|
||||
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | 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
|
||||
|
|
|
@ -166,12 +166,10 @@ static bool SCSI_Command_Inquiry(void)
|
|||
}
|
||||
|
||||
/* Write the INQUIRY data to the endpoint */
|
||||
Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, StreamCallback_AbortOnMassStoreReset);
|
||||
|
||||
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), StreamCallback_AbortOnMassStoreReset);
|
||||
Endpoint_Null_Stream((AllocationLength - BytesTransferred), NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
@ -193,12 +191,10 @@ static bool SCSI_Command_Request_Sense(void)
|
|||
uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData);
|
||||
|
||||
/* Send the SENSE data - this indicates to the host the status of the last command */
|
||||
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, StreamCallback_AbortOnMassStoreReset);
|
||||
|
||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NULL);
|
||||
|
||||
/* Pad out remaining bytes with 0x00 */
|
||||
Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), StreamCallback_AbortOnMassStoreReset);
|
||||
Endpoint_Null_Stream((AllocationLength - BytesTransferred), NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
|
|
@ -221,6 +221,8 @@ void MassStorage_Task(void)
|
|||
*/
|
||||
static bool ReadInCommandBlock(void)
|
||||
{
|
||||
uint16_t BytesTransferred;
|
||||
|
||||
/* Select the Data Out endpoint */
|
||||
Endpoint_SelectEndpoint(MASS_STORAGE_OUT_EPNUM);
|
||||
|
||||
|
@ -229,12 +231,14 @@ static bool ReadInCommandBlock(void)
|
|||
return false;
|
||||
|
||||
/* Read in command block header */
|
||||
Endpoint_Read_Stream_LE(&CommandBlock, (sizeof(CommandBlock) - sizeof(CommandBlock.SCSICommandData)),
|
||||
StreamCallback_AbortOnMassStoreReset);
|
||||
|
||||
/* Check if the current command is being aborted by the host */
|
||||
if (IsMassStoreReset)
|
||||
return false;
|
||||
BytesTransferred = 0;
|
||||
while (Endpoint_Read_Stream_LE(&CommandBlock, (sizeof(CommandBlock) - sizeof(CommandBlock.SCSICommandData)),
|
||||
&BytesTransferred) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
||||
{
|
||||
/* Check if the current command is being aborted by the host */
|
||||
if (IsMassStoreReset)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Verify the command block - abort if invalid */
|
||||
if ((CommandBlock.Signature != MS_CBW_SIGNATURE) ||
|
||||
|
@ -252,13 +256,14 @@ static bool ReadInCommandBlock(void)
|
|||
}
|
||||
|
||||
/* Read in command block command data */
|
||||
Endpoint_Read_Stream_LE(&CommandBlock.SCSICommandData,
|
||||
CommandBlock.SCSICommandLength,
|
||||
StreamCallback_AbortOnMassStoreReset);
|
||||
|
||||
/* Check if the current command is being aborted by the host */
|
||||
if (IsMassStoreReset)
|
||||
return false;
|
||||
BytesTransferred = 0;
|
||||
while (Endpoint_Read_Stream_LE(&CommandBlock.SCSICommandData, CommandBlock.SCSICommandLength,
|
||||
&BytesTransferred) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
||||
{
|
||||
/* Check if the current command is being aborted by the host */
|
||||
if (IsMassStoreReset)
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearOUT();
|
||||
|
@ -271,6 +276,8 @@ static bool ReadInCommandBlock(void)
|
|||
*/
|
||||
static void ReturnCommandStatus(void)
|
||||
{
|
||||
uint16_t BytesTransferred;
|
||||
|
||||
/* Select the Data Out endpoint */
|
||||
Endpoint_SelectEndpoint(MASS_STORAGE_OUT_EPNUM);
|
||||
|
||||
|
@ -294,27 +301,15 @@ static void ReturnCommandStatus(void)
|
|||
}
|
||||
|
||||
/* Write the CSW to the endpoint */
|
||||
Endpoint_Write_Stream_LE(&CommandStatus, sizeof(CommandStatus),
|
||||
StreamCallback_AbortOnMassStoreReset);
|
||||
|
||||
/* Check if the current command is being aborted by the host */
|
||||
if (IsMassStoreReset)
|
||||
return;
|
||||
|
||||
BytesTransferred = 0;
|
||||
while (Endpoint_Write_Stream_LE(&CommandStatus, sizeof(CommandStatus),
|
||||
&BytesTransferred) == ENDPOINT_RWSTREAM_IncompleteTransfer)
|
||||
{
|
||||
/* Check if the current command is being aborted by the host */
|
||||
if (IsMassStoreReset)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
/** Stream callback function for the Endpoint stream read and write functions. This callback will abort the current stream transfer
|
||||
* if a Mass Storage Reset request has been issued to the control endpoint.
|
||||
*/
|
||||
uint8_t StreamCallback_AbortOnMassStoreReset(void)
|
||||
{
|
||||
/* Abort if a Mass Storage reset command was received */
|
||||
if (IsMassStoreReset)
|
||||
return STREAMCALLBACK_Abort;
|
||||
|
||||
/* Continue with the current stream operation */
|
||||
return STREAMCALLBACK_Continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -280,7 +280,7 @@ void SendNextReport(void)
|
|||
PrevMouseReportData = MouseReportData;
|
||||
|
||||
/* Write Mouse Report Data */
|
||||
Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData));
|
||||
Endpoint_Write_Stream_LE(&MouseReportData, sizeof(MouseReportData), NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
|
|
@ -121,7 +121,6 @@ LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
|
|||
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
|
||||
LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
|
||||
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | 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
|
||||
|
|
|
@ -182,7 +182,7 @@ void RNDIS_Task(void)
|
|||
};
|
||||
|
||||
/* Indicate that a message response is ready for the host */
|
||||
Endpoint_Write_Stream_LE(&Notification, sizeof(Notification));
|
||||
Endpoint_Write_Stream_LE(&Notification, sizeof(Notification), NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
@ -204,7 +204,7 @@ void RNDIS_Task(void)
|
|||
if (Endpoint_IsOUTReceived() && !(FrameIN.FrameInBuffer))
|
||||
{
|
||||
/* Read in the packet message header */
|
||||
Endpoint_Read_Stream_LE(&RNDISPacketHeader, sizeof(RNDIS_Packet_Message_t));
|
||||
Endpoint_Read_Stream_LE(&RNDISPacketHeader, sizeof(RNDIS_Packet_Message_t), NULL);
|
||||
|
||||
/* Stall the request if the data is too large */
|
||||
if (RNDISPacketHeader.DataLength > ETHERNET_FRAME_SIZE_MAX)
|
||||
|
@ -214,7 +214,7 @@ void RNDIS_Task(void)
|
|||
}
|
||||
|
||||
/* Read in the Ethernet frame into the buffer */
|
||||
Endpoint_Read_Stream_LE(FrameIN.FrameData, RNDISPacketHeader.DataLength);
|
||||
Endpoint_Read_Stream_LE(FrameIN.FrameData, RNDISPacketHeader.DataLength, NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearOUT();
|
||||
|
@ -242,10 +242,10 @@ void RNDIS_Task(void)
|
|||
RNDISPacketHeader.DataLength = FrameOUT.FrameLength;
|
||||
|
||||
/* Send the packet header to the host */
|
||||
Endpoint_Write_Stream_LE(&RNDISPacketHeader, sizeof(RNDIS_Packet_Message_t));
|
||||
Endpoint_Write_Stream_LE(&RNDISPacketHeader, sizeof(RNDIS_Packet_Message_t), NULL);
|
||||
|
||||
/* Send the Ethernet frame data to the host */
|
||||
Endpoint_Write_Stream_LE(FrameOUT.FrameData, RNDISPacketHeader.DataLength);
|
||||
Endpoint_Write_Stream_LE(FrameOUT.FrameData, RNDISPacketHeader.DataLength, NULL);
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
|
|
|
@ -121,7 +121,6 @@ LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
|
|||
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
|
||||
LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
|
||||
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
|
||||
LUFA_OPTS += -D NO_STREAM_CALLBACKS
|
||||
|
||||
LUFA_OPTS += -D NO_DECODE_ETHERNET
|
||||
LUFA_OPTS += -D NO_DECODE_ARP
|
||||
|
|
|
@ -203,7 +203,7 @@ void CDC_Task(void)
|
|||
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
|
||||
|
||||
/* Write the String to the Endpoint */
|
||||
Endpoint_Write_Stream_LE(ReportString, strlen(ReportString));
|
||||
Endpoint_Write_Stream_LE(ReportString, strlen(ReportString), NULL);
|
||||
|
||||
/* Remember if the packet to send completely fills the endpoint */
|
||||
bool IsFull = (Endpoint_BytesInEndpoint() == CDC_TXRX_EPSIZE);
|
||||
|
|
|
@ -121,7 +121,6 @@ LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
|
|||
LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
|
||||
LUFA_OPTS += -D USE_FLASH_DESCRIPTORS
|
||||
LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue