From b71ff7c8cd68209a74c8690f4d190cc634ef8fb3 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 16 Aug 2009 08:51:54 +0000 Subject: 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. --- Demos/Device/LowLevel/Keyboard/Keyboard.c | 14 ++++---------- Demos/Device/LowLevel/Keyboard/Keyboard.h | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) (limited to 'Demos/Device/LowLevel/Keyboard') diff --git a/Demos/Device/LowLevel/Keyboard/Keyboard.c b/Demos/Device/LowLevel/Keyboard/Keyboard.c index f8310abb4..02f61a528 100644 --- a/Demos/Device/LowLevel/Keyboard/Keyboard.c +++ b/Demos/Device/LowLevel/Keyboard/Keyboard.c @@ -85,12 +85,6 @@ void SetupHardware(void) Joystick_Init(); LEDs_Init(); USB_Init(); - - /* Millisecond timer initialization, with output compare interrupt enabled for the idle timing */ - OCR0A = 0x7D; - TCCR0A = (1 << WGM01); - TCCR0B = ((1 << CS01) | (1 << CS00)); - TIMSK0 = (1 << OCIE0A); } /** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and @@ -137,6 +131,8 @@ void EVENT_USB_Device_ConfigurationChanged(void) { LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } + + USB_Device_EnableSOFEvents(); } /** Event handler for the USB_UnhandledControlRequest event. This is used to catch standard and class specific @@ -248,10 +244,8 @@ void EVENT_USB_Device_UnhandledControlRequest(void) } } -/** ISR for the timer 0 compare vector. This ISR fires once each millisecond, and increments the - * scheduler elapsed idle period counter when the host has set an idle period. - */ -ISR(TIMER0_COMPA_vect, ISR_BLOCK) +/** Event handler for the USB device Start Of Frame event. */ +void EVENT_USB_Device_StartOfFrame(void) { /* One millisecond has elapsed, decrement the idle time remaining counter if it has not already elapsed */ if (IdleMSRemaining) diff --git a/Demos/Device/LowLevel/Keyboard/Keyboard.h b/Demos/Device/LowLevel/Keyboard/Keyboard.h index bc478f317..f319ab73b 100644 --- a/Demos/Device/LowLevel/Keyboard/Keyboard.h +++ b/Demos/Device/LowLevel/Keyboard/Keyboard.h @@ -40,7 +40,6 @@ /* Includes: */ #include #include - #include #include #include #include @@ -105,6 +104,7 @@ void EVENT_USB_Device_Disconnect(void); void EVENT_USB_Device_ConfigurationChanged(void); void EVENT_USB_Device_UnhandledControlRequest(void); + void EVENT_USB_Device_StartOfFrame(void); void CreateKeyboardReport(USB_KeyboardReport_Data_t* ReportData); void ProcessLEDReport(uint8_t LEDReport); -- cgit v1.2.3