Rewritten event system to remove all macros, to make user code clearer.

Fixed incorrect ENDPOINT_EPNUM_MASK mask preventing endpoints above EP3 from being selected (thanks to Jonathan Oakley).

Removed STREAM_CALLBACK() macro - callbacks now use regular function definitions to clarify user code.

Removed DESCRIPTOR_COMPARATOR() macro - comparators should now use regular function definitions to clarify user code.
This commit is contained in:
Dean Camera 2009-05-18 10:05:21 +00:00
parent 72c2922e38
commit 2ee9fc7077
116 changed files with 596 additions and 1124 deletions

View file

@ -106,7 +106,7 @@ void USB_Device_ProcessControlPacket(void)
}
if (!(RequestHandled))
RAISE_EVENT(USB_UnhandledControlPacket);
EVENT_USB_UnhandledControlPacket();
if (Endpoint_IsSETUPReceived())
{
@ -157,9 +157,9 @@ static void USB_Device_SetConfiguration(void)
Endpoint_ClearIN();
if (!(AlreadyConfigured) && USB_ConfigurationNumber)
RAISE_EVENT(USB_DeviceEnumerationComplete);
EVENT_USB_DeviceEnumerationComplete();
RAISE_EVENT(USB_ConfigurationChanged);
EVENT_USB_ConfigurationChanged();
}
void USB_Device_GetConfiguration(void)

View file

@ -81,29 +81,6 @@
* \ingroup Group_Device
*/
extern bool USB_CurrentlySelfPowered;
/* Throwable Events: */
/** This module raises the \ref USB_UnhandledControlPacket event when a request to the default control
* endpoint has been received, but the library does not implement an internal handler for it.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_UnhandledControlPacket);
/** This module raises the \ref USB_ConfigurationChanged event when the host issues a \ref REQ_SetConfiguration
* device request, to change the currently selected configuration number.
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_ConfigurationChanged);
/** This module raises the \ref USB_DeviceEnumerationComplete event when the host has completed its
* enumeration of the device (i.e. when a \ref REQ_SetConfiguration request changes the current configuration
* number from 0 to a non-zero value).
*
* \see \ref Group_Events for more information on this event.
*/
RAISES_EVENT(USB_DeviceEnumerationComplete);
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)

View file

@ -115,7 +115,7 @@
#endif
/* Enums: */
/** Enum for the ErrorCode parameter of the \ref USB_DeviceError event.
/** Enum for the ErrorCode parameter of the \ref EVENT_USB_DeviceError() event.
*
* \see Events.h for more information on this event.
*/

View file

@ -108,7 +108,7 @@
/** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's
* numerical address in the device.
*/
#define ENDPOINT_EPNUM_MASK 0x03
#define ENDPOINT_EPNUM_MASK 0x07
/** Endpoint bank size mask, for masking against endpoint addresses to retrieve the endpoint's
* bank size in the device.
@ -712,9 +712,9 @@
* each USB packet, the given stream callback function is executed repeatedly until the next
* packet is ready, allowing for early aborts of stream transfers.
*
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. 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 callback routine should be created according to the information in \ref Group_StreamCallbacks.
* 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.
*
* \note This routine should not be used on CONTROL type endpoints.
*
@ -738,9 +738,9 @@
* is executed repeatedly until the endpoint is ready to accept the next packet, allowing for early
* aborts of stream transfers.
*
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. 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 callback routine should be created according to the information in \ref Group_StreamCallbacks.
* 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.
*
* \note This routine should not be used on CONTROL type endpoints.
*
@ -765,9 +765,9 @@
* is executed repeatedly until the endpoint is ready to accept the next packet, allowing for early
* aborts of stream transfers.
*
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. 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 callback routine should be created according to the information in \ref Group_StreamCallbacks.
* 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.
*
* \note This routine should not be used on CONTROL type endpoints.
*
@ -792,9 +792,9 @@
* each USB packet, the given stream callback function is executed repeatedly until the endpoint
* is ready to accept the next packet, allowing for early aborts of stream transfers.
*
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. 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 callback routine should be created according to the information in \ref Group_StreamCallbacks.
* 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.
*
* \note This routine should not be used on CONTROL type endpoints.
*
@ -819,9 +819,9 @@
* each USB packet, the given stream callback function is executed repeatedly until the endpoint
* is ready to accept the next packet, allowing for early aborts of stream transfers.
*
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. 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 callback routine should be created according to the information in \ref Group_StreamCallbacks.
* 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.
*
* \note This routine should not be used on CONTROL type endpoints.
*

View file

@ -90,7 +90,7 @@ void USB_Host_ProcessNextHostState(void)
USB_INT_Enable(USB_INT_VBERRI);
USB_IsConnected = true;
RAISE_EVENT(USB_Connect);
EVENT_USB_Connect();
USB_Host_ResumeBus();
Pipe_ClearPipes();
@ -184,7 +184,7 @@ void USB_Host_ProcessNextHostState(void)
case HOST_STATE_Default_PostAddressSet:
USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS);
RAISE_EVENT(USB_DeviceEnumerationComplete);
EVENT_USB_DeviceEnumerationComplete();
USB_HostState = HOST_STATE_Addressed;
break;
@ -192,14 +192,14 @@ void USB_Host_ProcessNextHostState(void)
if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached))
{
RAISE_EVENT(USB_DeviceEnumerationFailed, ErrorCode, SubErrorCode);
EVENT_USB_DeviceEnumerationFailed(ErrorCode, SubErrorCode);
USB_Host_VBUS_Auto_Off();
RAISE_EVENT(USB_DeviceUnattached);
EVENT_USB_DeviceUnattached();
if (USB_IsConnected)
RAISE_EVENT(USB_Disconnect);
EVENT_USB_Disconnect();
USB_ResetInterface();
}

View file

@ -199,7 +199,7 @@
HOST_STATE_Suspended = 13, /**< May be implemented by the user project. */
};
/** Enum for the error codes for the \ref USB_HostError event.
/** Enum for the error codes for the \ref EVENT_USB_HostError() event.
*
* \see \ref Group_Events for more information on this event.
*/
@ -213,14 +213,14 @@
*/
};
/** Enum for the error codes for the \ref USB_DeviceEnumerationFailed event.
/** Enum for the error codes for the \ref EVENT_USB_DeviceEnumerationFailed() event.
*
* \see \ref Group_Events for more information on this event.
*/
enum USB_Host_EnumerationErrorCodes_t
{
HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid
* ErrorCode parameter value for the \ref USB_DeviceEnumerationFailed
* ErrorCode parameter value for the \ref EVENT_USB_DeviceEnumerationFailed()
* event.
*/
HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed

View file

@ -92,7 +92,7 @@ void USB_Init(
}
else
{
RAISE_EVENT(USB_InitFailure, USB_INITERROR_NoUSBModeSpecified);
EVENT_USB_InitFailure(USB_INITERROR_NoUSBModeSpecified);
return;
}
#endif
@ -111,7 +111,7 @@ void USB_Init(
void USB_ShutDown(void)
{
if (USB_IsConnected)
RAISE_EVENT(USB_Disconnect);
EVENT_USB_Disconnect();
USB_Detach();

View file

@ -283,7 +283,7 @@
/* Enums: */
/** Enum for error codes relating to the powering on of the USB interface. These error codes are
* used in the ErrorCode parameter value of the \ref USB_InitFailure event.
* used in the ErrorCode parameter value of the \ref EVENT_USB_InitFailure() event.
*/
enum USB_InitErrorCodes_t
{
@ -313,24 +313,6 @@
extern volatile uint8_t USB_Options;
#endif
/* Throwable Events: */
/** This module raises the \ref USB_Disconnect event if the USB interface is reset (such as during a mode
* change while in UID mode) while the USB interface is connected to a device when in host mode, or
* a host while in device mode.
*
* \see Events.h for more information on this event.
*/
RAISES_EVENT(USB_Disconnect);
#if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)
/** This module raises the Power On Failure event when an error occurs while initializing the USB
* interface.
*
* \see Events.h for more information on this event.
*/
RAISES_EVENT(USB_InitFailure);
#endif
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */

View file

@ -745,9 +745,9 @@
* \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
*
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. 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 callback routine should be created according to the information in \ref Group_StreamCallbacks.
* 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.
*
* \ingroup Group_PipeRW
*
@ -769,9 +769,9 @@
* \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
*
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. 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 callback routine should be created according to the information in \ref Group_StreamCallbacks.
* 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.
*
* \ingroup Group_PipeRW
*
@ -793,9 +793,9 @@
* Between each USB packet, the given stream callback function is executed repeatedly until the next packet is ready,
* allowing for early aborts of stream transfers.
*
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. 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 callback routine should be created according to the information in \ref Group_StreamCallbacks.
* 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.
*
* \ingroup Group_PipeRW
*
@ -816,9 +816,9 @@
* \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
*
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. 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 callback routine should be created according to the information in \ref Group_StreamCallbacks.
* 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.
*
* \ingroup Group_PipeRW
*
@ -840,9 +840,9 @@
* \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is
* executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.
*
* The callback routine should be created using the \ref STREAM_CALLBACK() macro. 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 callback routine should be created according to the information in \ref Group_StreamCallbacks.
* 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.
*
* \ingroup Group_PipeRW
*