diff options
-rw-r--r-- | Demos/Host/LowLevel/CDCHost/CDCHost.c | 7 | ||||
-rw-r--r-- | Demos/Host/LowLevel/CDCHost/ConfigDescriptor.c | 3 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Pipe.c | 10 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Pipe.h | 19 | ||||
-rw-r--r-- | LUFA/ManPages/ChangeLog.txt | 1 | ||||
-rw-r--r-- | LUFA/ManPages/FutureChanges.txt | 1 |
6 files changed, 37 insertions, 4 deletions
diff --git a/Demos/Host/LowLevel/CDCHost/CDCHost.c b/Demos/Host/LowLevel/CDCHost/CDCHost.c index e00332f9f..b3e067418 100644 --- a/Demos/Host/LowLevel/CDCHost/CDCHost.c +++ b/Demos/Host/LowLevel/CDCHost/CDCHost.c @@ -176,10 +176,14 @@ void CDC_Host_Task(void) case HOST_STATE_Ready:
/* Select and the data IN pipe */
Pipe_SelectPipe(CDC_DATAPIPE_IN);
+ Pipe_Unfreeze();
/* Check to see if a packet has been received */
if (Pipe_IsINReceived())
{
+ /* Re-freeze IN pipe after the packet has been received */
+ Pipe_Freeze();
+
/* Check if data is in the pipe */
if (Pipe_IsReadWriteAllowed())
{
@@ -199,6 +203,9 @@ void CDC_Host_Task(void) Pipe_ClearIN();
}
+ /* Re-freeze IN pipe after use */
+ Pipe_Freeze();
+
/* Select and unfreeze the notification pipe */
Pipe_SelectPipe(CDC_NOTIFICATIONPIPE);
Pipe_Unfreeze();
diff --git a/Demos/Host/LowLevel/CDCHost/ConfigDescriptor.c b/Demos/Host/LowLevel/CDCHost/ConfigDescriptor.c index 57d7ec051..33234e4fd 100644 --- a/Demos/Host/LowLevel/CDCHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/CDCHost/ConfigDescriptor.c @@ -155,7 +155,6 @@ uint8_t ProcessConfigurationDescriptor(void) EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);
Pipe_SetInfiniteINRequests();
- Pipe_Unfreeze();
/* Set the flag indicating that the data IN pipe has been found */
FoundEndpoints |= (1 << CDC_DATAPIPE_IN);
@@ -166,8 +165,6 @@ uint8_t ProcessConfigurationDescriptor(void) Pipe_ConfigurePipe(CDC_DATAPIPE_OUT, EP_TYPE_BULK, PIPE_TOKEN_OUT,
EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);
- Pipe_Unfreeze();
-
/* Set the flag indicating that the data OUT pipe has been found */
FoundEndpoints |= (1 << CDC_DATAPIPE_OUT);
}
diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.c b/LUFA/Drivers/USB/LowLevel/Pipe.c index 189aaa63b..35ba480cd 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.c +++ b/LUFA/Drivers/USB/LowLevel/Pipe.c @@ -113,6 +113,8 @@ uint8_t Pipe_Write_Stream_LE(const void* Data, uint16_t Length uint8_t* DataStream = (uint8_t*)Data;
uint8_t ErrorCode;
+ Pipe_SetToken(PIPE_TOKEN_OUT);
+
if ((ErrorCode = Pipe_WaitUntilReady()))
return ErrorCode;
@@ -149,6 +151,8 @@ uint8_t Pipe_Write_Stream_BE(const void* Data, uint16_t Length uint8_t* DataStream = (uint8_t*)(Data + Length - 1);
uint8_t ErrorCode;
+ Pipe_SetToken(PIPE_TOKEN_OUT);
+
if ((ErrorCode = Pipe_WaitUntilReady()))
return ErrorCode;
@@ -184,6 +188,8 @@ uint8_t Pipe_Discard_Stream(uint16_t Length {
uint8_t ErrorCode;
+ Pipe_SetToken(PIPE_TOKEN_IN);
+
if ((ErrorCode = Pipe_WaitUntilReady()))
return ErrorCode;
@@ -220,6 +226,8 @@ uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length uint8_t* DataStream = (uint8_t*)Buffer;
uint8_t ErrorCode;
+ Pipe_SetToken(PIPE_TOKEN_IN);
+
if ((ErrorCode = Pipe_WaitUntilReady()))
return ErrorCode;
@@ -256,6 +264,8 @@ uint8_t Pipe_Read_Stream_BE(void* Buffer, uint16_t Length uint8_t* DataStream = (uint8_t*)(Buffer + Length - 1);
uint8_t ErrorCode;
+ Pipe_SetToken(PIPE_TOKEN_IN);
+
if ((ErrorCode = Pipe_WaitUntilReady()))
return ErrorCode;
diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.h b/LUFA/Drivers/USB/LowLevel/Pipe.h index 82d9b69d4..30f2d387c 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.h +++ b/LUFA/Drivers/USB/LowLevel/Pipe.h @@ -730,7 +730,9 @@ *
* The banking mode may be either \ref PIPE_BANK_SINGLE or \ref PIPE_BANK_DOUBLE.
*
- * A newly configured pipe is frozen by default, and must be unfrozen before use via the \ref Pipe_Unfreeze() macro.
+ * A newly configured pipe is frozen by default, and must be unfrozen before use via the \ref Pipe_Unfreeze()
+ * before being used. Pipes should be kept frozen unless waiting for data from a device while in IN mode, or
+ * sending data to the device in OUT mode.
*
* \note The default control pipe does not have to be manually configured, as it is automatically
* configured by the library internally.
@@ -762,6 +764,9 @@ * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are
* disabled and this function has the Callback parameter omitted.
*
+ * The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
+ *
* \ingroup Group_PipeRW
*
* \param Buffer Pointer to the source data buffer to read from.
@@ -786,6 +791,9 @@ * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are
* disabled and this function has the Callback parameter omitted.
*
+ * The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
+ *
* \ingroup Group_PipeRW
*
* \param Buffer Pointer to the source data buffer to read from.
@@ -810,6 +818,9 @@ * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are
* disabled and this function has the Callback parameter omitted.
*
+ * The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
+ *
* \ingroup Group_PipeRW
*
* \param Length Number of bytes to send via the currently selected pipe.
@@ -833,6 +844,9 @@ * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are
* disabled and this function has the Callback parameter omitted.
*
+ * The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
+ *
* \ingroup Group_PipeRW
*
* \param Buffer Pointer to the source data buffer to write to.
@@ -857,6 +871,9 @@ * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are
* disabled and this function has the Callback parameter omitted.
*
+ * The pipe token is set automatically, thus this can be used on bi-directional pipes directly without
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().
+ *
* \ingroup Group_PipeRW
*
* \param Buffer Pointer to the source data buffer to write to.
diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index 81fb51555..b80fa4d6f 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -31,6 +31,7 @@ * - Added new USE_INTERNAL_SERIAL define for using the unique serial numbers in some AVR models as the USB device's serial number,
* added NO_INTERNAL_SERIAL compile time option to turn off new serial number reading code
* - Fixed ADC driver for the ATMEGA32U4 and ATMEGA16U4 (thanks to Opendous Inc.)
+ * - Pipe stream functions now automatically set the correct pipe token, so that bidirectional pipes can be used
*
*
* \section Sec_ChangeLog090605 Version 090605
diff --git a/LUFA/ManPages/FutureChanges.txt b/LUFA/ManPages/FutureChanges.txt index 9704131b1..7c6e4ee32 100644 --- a/LUFA/ManPages/FutureChanges.txt +++ b/LUFA/ManPages/FutureChanges.txt @@ -25,4 +25,5 @@ * - Debug mode for pipe/endpoint calls
* - Add hub support to match Atmel's stack
* - Update Host mode Class Driver demo .txt files
+ * - Stream reads - return number of bytes not read?
*/
|