diff options
author | Dean Camera <[email protected]> | 2009-08-16 08:51:54 +0000 |
---|---|---|
committer | Dean Camera <[email protected]> | 2009-08-16 08:51:54 +0000 |
commit | b71ff7c8cd68209a74c8690f4d190cc634ef8fb3 (patch) | |
tree | 00dc93dadd1e8fc9841fec230be8dd7db006b6ba /LUFA/Drivers/USB/HighLevel | |
parent | 25ddbb9e3bcf184ebf1c17ea254b3c0c924327e2 (diff) | |
download | qmk_firmware-b71ff7c8cd68209a74c8690f4d190cc634ef8fb3.tar.gz qmk_firmware-b71ff7c8cd68209a74c8690f4d190cc634ef8fb3.zip |
Added new EVENT_USB_Device_StartOfFrame() event, controlled by the new USB_Device_EnableSOFEvents() and USB_Device_DisableSOFEvents() macros to give bus-synchronised millisecond interrupts when in USB device mode.
Diffstat (limited to 'LUFA/Drivers/USB/HighLevel')
-rw-r--r-- | LUFA/Drivers/USB/HighLevel/Events.h | 13 | ||||
-rw-r--r-- | LUFA/Drivers/USB/HighLevel/USBInterrupt.c | 7 |
2 files changed, 20 insertions, 0 deletions
diff --git a/LUFA/Drivers/USB/HighLevel/Events.h b/LUFA/Drivers/USB/HighLevel/Events.h index 1e638314cf..4ed6537b7b 100644 --- a/LUFA/Drivers/USB/HighLevel/Events.h +++ b/LUFA/Drivers/USB/HighLevel/Events.h @@ -234,6 +234,18 @@ * \ref Group_USBManagement documentation).
*/
void EVENT_USB_Device_Reset(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 synchronised to the USB bus. This can be used as an accurate
+ * millisecond timer source when the USB bus is enumerated in device mode to a USB host.
+ *
+ * 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.
+ *
+ * \note This event does not exist if the 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: */
@@ -264,6 +276,7 @@ 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);
void EVENT_USB_Device_Reset(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
+ void EVENT_USB_Device_StartOfFrame(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);
#endif
#endif
#endif
diff --git a/LUFA/Drivers/USB/HighLevel/USBInterrupt.c b/LUFA/Drivers/USB/HighLevel/USBInterrupt.c index 00fe7d1dcb..a8083c92ad 100644 --- a/LUFA/Drivers/USB/HighLevel/USBInterrupt.c +++ b/LUFA/Drivers/USB/HighLevel/USBInterrupt.c @@ -153,6 +153,13 @@ ISR(USB_GEN_vect, ISR_BLOCK) EVENT_USB_Device_Reset();
}
+
+ if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI))
+ {
+ USB_INT_Clear(USB_INT_SOFI);
+
+ EVENT_USB_Device_StartOfFrame();
+ }
#endif
#if defined(USB_CAN_BE_HOST)
|