Removed specialized Endpoint_ClearControl* and Pipe_ClearControl* macros in favour of the standard Endpoint_Clear* and Pipe_Clear* macros (Atmel have confirmed no effect from setting FIFOCON on control endpoints).

This commit is contained in:
Dean Camera 2009-04-21 06:05:50 +00:00
parent ba7cd3f22e
commit e5e7eaee7a
23 changed files with 169 additions and 228 deletions

View file

@ -108,7 +108,7 @@ void USB_Device_ProcessControlPacket(void)
if (Endpoint_IsSETUPReceived())
{
Endpoint_StallTransaction();
Endpoint_ClearControlSETUP();
Endpoint_ClearSETUP();
}
}
@ -116,11 +116,11 @@ static void USB_Device_SetAddress(void)
{
uint8_t wValue_LSB = Endpoint_Read_Byte();
Endpoint_ClearControlSETUP();
Endpoint_ClearSETUP();
while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN();
Endpoint_ClearIN();
while (!(Endpoint_IsINReady()));
@ -152,11 +152,11 @@ static void USB_Device_SetConfiguration(void)
return;
}
Endpoint_ClearControlSETUP();
Endpoint_ClearSETUP();
USB_ConfigurationNumber = wValue_LSB;
Endpoint_ClearControlIN();
Endpoint_ClearIN();
if (!(AlreadyConfigured) && USB_ConfigurationNumber)
RAISE_EVENT(USB_DeviceEnumerationComplete);
@ -166,14 +166,14 @@ static void USB_Device_SetConfiguration(void)
void USB_Device_GetConfiguration(void)
{
Endpoint_ClearControlSETUP();
Endpoint_ClearSETUP();
Endpoint_Write_Byte(USB_ConfigurationNumber);
Endpoint_ClearControlIN();
Endpoint_ClearIN();
while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT();
Endpoint_ClearOUT();
}
static void USB_Device_GetDescriptor(void)
@ -190,7 +190,7 @@ static void USB_Device_GetDescriptor(void)
if ((DescriptorSize = USB_GetDescriptor(wValue, wIndex, &DescriptorPointer)) == NO_DESCRIPTOR)
return;
Endpoint_ClearControlSETUP();
Endpoint_ClearSETUP();
if (wLength > DescriptorSize)
wLength = DescriptorSize;
@ -201,7 +201,7 @@ static void USB_Device_GetDescriptor(void)
{
if (Endpoint_IsOUTReceived())
{
Endpoint_ClearControlOUT();
Endpoint_ClearOUT();
return;
}
}
@ -220,17 +220,17 @@ static void USB_Device_GetDescriptor(void)
}
SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
Endpoint_ClearControlIN();
Endpoint_ClearIN();
}
if (SendZLP)
{
while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN();
Endpoint_ClearIN();
}
while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT();
Endpoint_ClearOUT();
}
static void USB_Device_GetStatus(const uint8_t bmRequestType)
@ -264,14 +264,14 @@ static void USB_Device_GetStatus(const uint8_t bmRequestType)
}
Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
Endpoint_ClearControlSETUP();
Endpoint_ClearSETUP();
Endpoint_Write_Word_LE(CurrentStatus);
Endpoint_ClearControlIN();
Endpoint_ClearIN();
while (!(Endpoint_IsOUTReceived()));
Endpoint_ClearControlOUT();
Endpoint_ClearOUT();
}
#if !defined(FEATURELESS_CONTROL_ONLY_DEVICE)
@ -306,8 +306,8 @@ static void USB_Device_ClearSetFeature(const uint8_t bRequest, const uint8_t bmR
}
Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
Endpoint_ClearControlSETUP();
Endpoint_ClearControlIN();
Endpoint_ClearSETUP();
Endpoint_ClearIN();
}
}

View file

@ -59,7 +59,7 @@ bool Endpoint_ConfigureEndpointStatic(const uint8_t Number, const uint8_t UECFG0
Endpoint_SelectEndpoint(Number);
Endpoint_EnableEndpoint();
UECFG1X = 0;
UECFG1X = 0;
UECFG0X = UECFG0XData;
UECFG1X = UECFG1XData;
@ -307,7 +307,7 @@ uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length)
}
SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
Endpoint_ClearControlIN();
Endpoint_ClearIN();
}
if (Endpoint_IsOUTReceived())
@ -316,7 +316,7 @@ uint8_t Endpoint_Write_Control_Stream_LE(const void* Buffer, uint16_t Length)
if (SendZLP)
{
while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN();
Endpoint_ClearIN();
}
while (!(Endpoint_IsOUTReceived()));
@ -341,7 +341,7 @@ uint8_t Endpoint_Write_Control_Stream_BE(const void* Buffer, uint16_t Length)
}
SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
Endpoint_ClearControlIN();
Endpoint_ClearIN();
}
if (Endpoint_IsOUTReceived())
@ -350,7 +350,7 @@ uint8_t Endpoint_Write_Control_Stream_BE(const void* Buffer, uint16_t Length)
if (SendZLP)
{
while (!(Endpoint_IsINReady()));
Endpoint_ClearControlIN();
Endpoint_ClearIN();
}
while (!(Endpoint_IsOUTReceived()));
@ -373,7 +373,7 @@ uint8_t Endpoint_Read_Control_Stream_LE(void* Buffer, uint16_t Length)
Length--;
}
Endpoint_ClearControlOUT();
Endpoint_ClearOUT();
}
while (!(Endpoint_IsINReady()));
@ -396,7 +396,7 @@ uint8_t Endpoint_Read_Control_Stream_BE(void* Buffer, uint16_t Length)
Length--;
}
Endpoint_ClearControlOUT();
Endpoint_ClearOUT();
}
while (!(Endpoint_IsINReady()));

View file

@ -309,41 +309,19 @@
*
* \note This is not applicable for non CONTROL type endpoints.
*/
static inline void Endpoint_ClearControlSETUP(void);
static inline void Endpoint_ClearSETUP(void);
/** Sends an IN packet to the host on the currently selected CONTROL type endpoint, freeing up the
* endpoint for the next packet.
/** Sends an IN packet to the host on the currently selected endpoint, freeing up the endpoint for the
* next packet and switching to the alternative endpoint bank if double banked.
*
* \ingroup Group_EndpointPacketManagement
*
* \note For non CONTROL type endpoints, use Endpoint_ClearIN() instead.
*/
static inline void Endpoint_ClearControlIN(void);
/** Acknowledges an OUT packet to the host on the currently selected CONTROL type endpoint, freeing
* up the endpoint for the next packet.
*
* \ingroup Group_EndpointPacketManagement
*
* \note For non CONTROL type endpoints, use Endpoint_ClearOUT() instead.
*/
static inline void Endpoint_ClearControlOUT(void);
/** Sends an IN packet to the host on the currently selected non CONTROL type endpoint, freeing
* up the endpoint for the next packet and switching to the alternative endpoint bank if double banked.
*
* \ingroup Group_EndpointPacketManagement
*
* \note For CONTROL type endpoints, use Endpoint_ClearControlIN() instead.
*/
static inline void Endpoint_ClearIN(void);
/** Acknowledges an OUT packet to the host on the currently selected non CONTROL type endpoint, freeing
* up the endpoint for the next packet and switching to the alternative endpoint bank if double banked.
/** Acknowledges an OUT packet to the host on the currently selected endpoint, freeing up the endpoint
* for the next packet and switching to the alternative endpoint bank if double banked.
*
* \ingroup Group_EndpointPacketManagement
*
* \note For CONTROL type endpoints, use Endpoint_ClearControlOUT() instead.
*/
static inline void Endpoint_ClearOUT(void);
@ -417,11 +395,7 @@
#define Endpoint_IsSETUPReceived() ((UEINTX & (1 << RXSTPI)) ? true : false)
#define Endpoint_ClearControlSETUP() MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE
#define Endpoint_ClearControlIN() MACROS{ UEINTX &= ~(1 << TXINI); }MACROE
#define Endpoint_ClearControlOUT() MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE
#define Endpoint_ClearSETUP() MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE
#define Endpoint_ClearIN() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << TXINI)); \
UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE
@ -900,7 +874,7 @@
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
* in both failure and success states; the user is responsible for manually clearing the setup OUT to
* finalize the transfer via the Endpoint_ClearControlOUT() macro.
* finalize the transfer via the Endpoint_ClearOUT() macro.
*
* \note This routine should only be used on CONTROL type endpoints.
*
@ -919,7 +893,7 @@
/** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,
* sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
* in both failure and success states; the user is responsible for manually clearing the setup OUT to
* finalize the transfer via the Endpoint_ClearControlOUT() macro.
* finalize the transfer via the Endpoint_ClearOUT() macro.
*
* \note This routine should only be used on CONTROL type endpoints.
*
@ -938,7 +912,7 @@
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,
* discarding fully read packets from the host as needed. The device IN acknowledgement is not
* automatically sent after success or failure states; the user is responsible for manually sending the
* setup IN to finalize the transfer via the Endpoint_ClearControlIN() macro.
* setup IN to finalize the transfer via the Endpoint_ClearIN() macro.
*
* \note This routine should only be used on CONTROL type endpoints.
*
@ -952,12 +926,12 @@
*
* \return A value from the Endpoint_ControlStream_RW_ErrorCodes_t enum.
*/
uint8_t Endpoint_Read_Control_Stream_LE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
uint8_t Endpoint_Read_Control_Stream_LE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
/** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,
* discarding fully read packets from the host as needed. The device IN acknowledgement is not
* automatically sent after success or failure states; the user is responsible for manually sending the
* setup IN to finalize the transfer via the Endpoint_ClearControlIN() macro.
* setup IN to finalize the transfer via the Endpoint_ClearIN() macro.
*
* \note This routine should only be used on CONTROL type endpoints.
*
@ -971,7 +945,7 @@
*
* \return A value from the Endpoint_ControlStream_RW_ErrorCodes_t enum.
*/
uint8_t Endpoint_Read_Control_Stream_BE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
uint8_t Endpoint_Read_Control_Stream_BE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)

View file

@ -58,7 +58,7 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr)
for (uint8_t HeaderByte = 0; HeaderByte < sizeof(USB_Host_Request_Header_t); HeaderByte++)
Pipe_Write_Byte(*(HeaderStream++));
Pipe_ClearControlSETUP();
Pipe_ClearSETUP();
if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_SetupSent)))
goto End_Of_Control_Send;
@ -91,7 +91,7 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr)
}
Pipe_Freeze();
Pipe_ClearControlIN();
Pipe_ClearIN();
}
}
@ -101,7 +101,7 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr)
if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady)))
goto End_Of_Control_Send;
Pipe_ClearControlOUT();
Pipe_ClearOUT();
if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady)))
goto End_Of_Control_Send;
@ -124,7 +124,7 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr)
DataLen--;
}
Pipe_ClearControlOUT();
Pipe_ClearOUT();
}
if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_OutReady)))
@ -139,7 +139,7 @@ uint8_t USB_Host_SendControlRequest(void* BufferPtr)
if ((ReturnStatus = USB_Host_Wait_For_Setup_IOS(USB_HOST_WAITFOR_InReceived)))
goto End_Of_Control_Send;
Pipe_ClearControlIN();
Pipe_ClearIN();
}
End_Of_Control_Send:

View file

@ -420,38 +420,16 @@
*/
static inline bool Pipe_IsSETUPSent(void);
/** Acknowledges the reception of a setup IN request from the attached device on the currently selected
* CONTROL type pipe, freeing the bank ready for the next packet.
*
* \ingroup Group_PipePacketManagement
*
* \note For non CONTROL type pipes, use Pipe_ClearIN() instead.
*/
static inline void Pipe_ClearControlIN(void);
/** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing
* the bank ready for the next packet.
*
* \ingroup Group_PipePacketManagement
*
* \note For non CONTROL type pipes, use Pipe_ClearOUT() instead.
*/
static inline void Pipe_ClearControlOUT(void);
/** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet.
*
* \ingroup Group_PipePacketManagement
*
* \note This is not applicable for non CONTROL type pipes.
* \ingroup Group_PipePacketManagement
*/
static inline void Pipe_ClearControlSETUP(void);
static inline void Pipe_ClearSETUP(void);
/** Acknowledges the reception of a setup IN request from the attached device on the currently selected
* pipe, freeing the bank ready for the next packet.
*
* \ingroup Group_PipePacketManagement
*
* \note For CONTROL type pipes, use Pipe_ClearControlIN() instead.
*/
static inline void Pipe_ClearIN(void);
@ -459,8 +437,6 @@
* the bank ready for the next packet.
*
* \ingroup Group_PipePacketManagement
*
* \note For CONTROL type pipes, use Pipe_ClearControlOUT() instead.
*/
static inline void Pipe_ClearOUT(void);
@ -554,16 +530,10 @@
#define Pipe_ClearIN() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << RXINI)); \
UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE
#define Pipe_ClearControlIN() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << RXINI)); \
UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE
#define Pipe_ClearOUT() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << TXOUTI)); \
UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE
#define Pipe_ClearControlOUT() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << TXOUTI)); \
UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE
#define Pipe_ClearControlSETUP() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << TXSTPI)); \
#define Pipe_ClearSETUP() MACROS{ uint8_t Temp = UPINTX; UPINTX = (Temp & ~(1 << TXSTPI)); \
UPINTX = (Temp & ~(1 << FIFOCON)); }MACROE
#define Pipe_IsNAKReceived() ((UPINTX & (1 << NAKEDI)) ? true : false)