X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/99d8a3936384d1e9286dfecfb6f7896294cd6c11..279e1b6ece7fbc90db6cb642f1c289b45648cf9c:/LUFA/Drivers/USB/HighLevel/Events.h diff --git a/LUFA/Drivers/USB/HighLevel/Events.h b/LUFA/Drivers/USB/HighLevel/Events.h index ab63c7bfe..53e31f6c1 100644 --- a/LUFA/Drivers/USB/HighLevel/Events.h +++ b/LUFA/Drivers/USB/HighLevel/Events.h @@ -1,21 +1,21 @@ /* LUFA Library - Copyright (C) Dean Camera, 2010. - + Copyright (C) Dean Camera, 2011. + dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com + www.lufa-lib.org */ /* - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -64,13 +64,13 @@ * * @{ */ - + #ifndef __USBEVENTS_H__ #define __USBEVENTS_H__ /* Includes: */ #include - + #include "../../../Common/Common.h" #include "USBMode.h" @@ -83,19 +83,10 @@ #if !defined(__INCLUDE_FROM_USB_DRIVER) #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead. #endif - - /* Public Interface - May be used in end-application: */ + + /* Public Interface - May be used in end-application: */ /* Pseudo-Functions for Doxygen: */ #if !defined(__INCLUDE_FROM_EVENTS_C) || defined(__DOXYGEN__) - /** Event for USB stack initialization failure. This event fires when the USB interface fails to - * initialize correctly due to a hardware or software fault. - * - * \note This event only exists on USB AVR models which support dual role modes. - * - * \param[in] ErrorCode Error code indicating the failure reason, a value in \ref USB_InitErrorCodes_t. - */ - void EVENT_USB_InitFailure(const uint8_t ErrorCode); - /** Event for USB mode pin level change. This event fires when the USB interface is set to dual role * mode, and the UID pin level has changed to indicate a new mode (device or host). This event fires * before the mode is switched to the newly indicated mode but after the \ref EVENT_USB_Device_Disconnect @@ -104,7 +95,7 @@ * \note This event only exists on USB AVR models which support dual role modes. * \n\n * - * \note This event does not exist if the USB_DEVICE_ONLY or USB_HOST_ONLY tokens have been supplied + * \note This event does not exist if the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY tokens have been supplied * to the compiler (see \ref Group_USBManagement documentation). */ void EVENT_USB_UIDChange(void); @@ -117,11 +108,11 @@ * \note This event only exists on USB AVR models which supports host mode. * \n\n * - * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see + * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see * \ref Group_USBManagement documentation). */ void EVENT_USB_Host_HostError(const uint8_t ErrorCode); - + /** Event for USB device attachment. This event fires when a the USB interface is in host mode, and * a USB device has been connected to the USB interface. This is interrupt driven, thus fires before * the standard \ref EVENT_USB_Device_Connect() event and so can be used to programmatically start the USB @@ -130,7 +121,7 @@ * \note This event only exists on USB AVR models which supports host mode. * \n\n * - * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see + * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see * \ref Group_USBManagement documentation). * * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage. @@ -144,17 +135,17 @@ * \note This event only exists on USB AVR models which supports host mode. * \n\n * - * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see + * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see * \ref Group_USBManagement documentation). * * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage. */ void EVENT_USB_Host_DeviceUnattached(void); - + /** Event for USB device enumeration failure. This event fires when a the USB interface is * in host mode, and an attached USB device has failed to enumerate completely. * - * \param[in] ErrorCode Error code indicating the failure reason, a value in + * \param[in] ErrorCode Error code indicating the failure reason, a value in * \ref USB_Host_EnumerationErrorCodes_t. * * \param[in] SubErrorCode Sub error code indicating the reason for failure - for example, if the @@ -164,10 +155,11 @@ * \note This event only exists on USB AVR models which supports host mode. * \n\n * - * \note This event does not exist if the USB_DEVICE_ONLY token is supplied to the compiler (see + * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see * \ref Group_USBManagement documentation). */ - void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); + void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, + const uint8_t SubErrorCode); /** Event for USB device enumeration completion. This event fires when a the USB interface is * in host mode and an attached USB device has been completely enumerated and is ready to be @@ -179,6 +171,23 @@ */ void EVENT_USB_Host_DeviceEnumerationComplete(void); + /** Event for USB Start Of Frame detection, when enabled. This event fires at the start of each USB + * frame, once per millisecond, and is synchronized to the USB bus. This can be used as an accurate + * millisecond timer source when the USB bus is not suspended while in host mode. + * + * This event is time-critical; it is run once per millisecond and thus long handlers will significantly + * degrade device performance. This event should only be enabled when needed to reduce device wake-ups. + * + * \note This event is not normally active - it must be manually enabled and disabled via the + * \ref USB_Host_EnableSOFEvents() and \ref USB_Host_DisableSOFEvents() commands after enumeration of + * a USB device. + * \n\n + * + * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see + * \ref Group_USBManagement documentation). + */ + void EVENT_USB_Host_StartOfFrame(void); + /** Event for USB device connection. This event fires when the AVR in device mode and the device is connected * to a host, beginning the enumeration process, measured by a rising level on the AVR's VBUS pin. * @@ -188,15 +197,15 @@ * \note For the smaller series 2 USB AVRs with limited USB controllers, VBUS is not available to the USB controller. * this means that the current connection state is derived from the bus suspension and wake up events by default, * which is not always accurate (host may suspend the bus while still connected). If the actual connection state - * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behavior turned off by - * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection + * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by + * passing the \c NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually. * \n\n * * \note This event may fire multiple times during device enumeration on the series 2 USB AVRs with limited USB controllers - * if NO_LIMITED_CONTROLLER_CONNECT is not defined. + * if \c NO_LIMITED_CONTROLLER_CONNECT is not defined. * - * \see USBTask.h for more information on the USB management task and reducing CPU usage. + * \see \ref Group_USBManagement for more information on the USB management task and reducing CPU usage. */ void EVENT_USB_Device_Connect(void); @@ -206,32 +215,34 @@ * \note For the smaller series 2 USB AVRs with limited USB controllers, VBUS is not available to the USB controller. * this means that the current connection state is derived from the bus suspension and wake up events by default, * which is not always accurate (host may suspend the bus while still connected). If the actual connection state - * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behavior turned off by - * passing the NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection + * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behaviour turned off by + * passing the \c NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually. * \n\n * * \note This event may fire multiple times during device enumeration on the series 2 USB AVRs with limited USB controllers - * if NO_LIMITED_CONTROLLER_CONNECT is not defined. + * if \c NO_LIMITED_CONTROLLER_CONNECT is not defined. * - * \see USBTask.h for more information on the USB management task and reducing CPU usage. + * \see \ref Group_USBManagement for more information on the USB management task and reducing CPU usage. */ void EVENT_USB_Device_Disconnect(void); - /** Event for unhandled control requests. This event fires when a the USB host issues a control - * request to the control endpoint (address 0) that the library does not handle. This may either - * be a standard request that the library has no handler code for, or a class specific request - * issued to the device which must be handled appropriately. + /** Event for control requests. This event fires when a the USB host issues a control request + * to the mandatory device control endpoint (of address 0). This may either be a standard + * request that the library may have a handler code for internally, or a class specific request + * issued to the device which must be handled appropriately. If a request is not processed in the + * user application via this event, it will be passed to the library for processing internally + * if a suitable handler exists. * * This event is time-critical; each packet within the request transaction must be acknowledged or * sent within 50ms or the host will abort the transfer. * * The library internally handles all standard control requests with the exceptions of SYNC FRAME, * SET DESCRIPTOR and SET INTERFACE. These and all other non-standard control requests will be left - * for the user to process via this event if desired. If not handled in the user application, requests - * are automatically STALLed. + * for the user to process via this event if desired. If not handled in the user application or by + * the library internally, unknown requests are automatically STALLed. * - * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see * \ref Group_USBManagement documentation). * \n\n * @@ -240,7 +251,7 @@ * request SETUP parameters into the \ref USB_ControlRequest structure which should then be used * by the application to determine how to handle the issued request. */ - void EVENT_USB_Device_UnhandledControlRequest(void); + void EVENT_USB_Device_ControlRequest(void); /** Event for USB configuration number changed. This event fires when a the USB host changes the * selected configuration number while in device mode. This event should be hooked in device @@ -251,7 +262,7 @@ * * This event fires after the value of \ref USB_ConfigurationNumber has been changed. * - * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see * \ref Group_USBManagement documentation). */ void EVENT_USB_Device_ConfigurationChanged(void); @@ -262,11 +273,11 @@ * enumerated with the \ref USB_OPT_AUTO_PLL option set, the library will automatically suspend the * USB PLL before the event is fired to save power. * - * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see * \ref Group_USBManagement documentation). * \n\n * - * \note This event does not exist on the series 2 USB AVRs when the NO_LIMITED_CONTROLLER_CONNECT + * \note This event does not exist on the series 2 USB AVRs when the \c NO_LIMITED_CONTROLLER_CONNECT * compile time token is not set - see \ref EVENT_USB_Device_Disconnect. * * \see \ref EVENT_USB_Device_WakeUp() event for accompanying Wake Up event. @@ -279,11 +290,11 @@ * mode. If the USB interface is enumerated with the \ref USB_OPT_AUTO_PLL option set, the library * will automatically restart the USB PLL before the event is fired. * - * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see * \ref Group_USBManagement documentation). * \n\n * - * \note This event does not exist on the series 2 USB AVRs when the NO_LIMITED_CONTROLLER_CONNECT + * \note This event does not exist on the series 2 USB AVRs when the \c NO_LIMITED_CONTROLLER_CONNECT * compile time token is not set - see \ref EVENT_USB_Device_Connect. * * \see \ref EVENT_USB_Device_Suspend() event for accompanying Suspend event. @@ -297,7 +308,7 @@ * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around * two seconds) will prevent the device from enumerating correctly. * - * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see * \ref Group_USBManagement documentation). */ void EVENT_USB_Device_Reset(void); @@ -309,40 +320,41 @@ * This event is time-critical; it is run once per millisecond and thus long handlers will significantly * degrade device performance. This event should only be enabled when needed to reduce device wake-ups. * - * \note This event is not normally active - it must be manually enabled and disabled via the - * \ref USB_Device_EnableSOFEvents() and \ref USB_Device_DisableSOFEvents() commands after enumeration. - * \n\n + * \pre This event is not normally active - it must be manually enabled and disabled via the + * \ref USB_Device_EnableSOFEvents() and \ref USB_Device_DisableSOFEvents() commands after enumeration. + * \n\n * - * \note This event does not exist if the USB_HOST_ONLY token is supplied to the compiler (see + * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see * \ref Group_USBManagement documentation). */ void EVENT_USB_Device_StartOfFrame(void); #endif - + /* Private Interface - For use in library only: */ #if !defined(__DOXYGEN__) /* Function Prototypes: */ #if defined(__INCLUDE_FROM_EVENTS_C) void USB_Event_Stub(void) ATTR_CONST; - + #if defined(USB_CAN_BE_BOTH) - void EVENT_USB_InitFailure(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); void EVENT_USB_UIDChange(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); #endif - + #if defined(USB_CAN_BE_HOST) void EVENT_USB_Host_HostError(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); void EVENT_USB_Host_DeviceAttached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); void EVENT_USB_Host_DeviceUnattached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); void EVENT_USB_Host_DeviceEnumerationComplete(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode) - ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, + const uint8_t SubErrorCode) + ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Host_StartOfFrame(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); #endif #if defined(USB_CAN_BE_DEVICE) void EVENT_USB_Device_Connect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); void EVENT_USB_Device_Disconnect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); - void EVENT_USB_Device_UnhandledControlRequest(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); + void EVENT_USB_Device_ControlRequest(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); void EVENT_USB_Device_ConfigurationChanged(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); void EVENT_USB_Device_Suspend(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); void EVENT_USB_Device_WakeUp(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub); @@ -356,7 +368,8 @@ #if defined(__cplusplus) } #endif - + #endif /** @} */ +