diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-04-01 07:21:45 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-04-01 07:21:45 +0000 |
commit | 6198289b388e4122afe4913f899b37a8e7cd8af4 (patch) | |
tree | 178377f080f369a8b0bee80f1520f7ac087d0b84 /Demos/Host/KeyboardHost/KeyboardHost.c | |
parent | 74496a947eef42b416a8a0cb11b7415ac6fa103b (diff) | |
download | lufa-6198289b388e4122afe4913f899b37a8e7cd8af4.tar.gz lufa-6198289b388e4122afe4913f899b37a8e7cd8af4.tar.bz2 lufa-6198289b388e4122afe4913f899b37a8e7cd8af4.zip |
Added new GenericHIDHost demo.
Corrections to the KeyboardHost and MouseHost demos' pipe handling to freeze and unfreeze the data pipes at the point of use.
Diffstat (limited to 'Demos/Host/KeyboardHost/KeyboardHost.c')
-rw-r--r-- | Demos/Host/KeyboardHost/KeyboardHost.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/Demos/Host/KeyboardHost/KeyboardHost.c b/Demos/Host/KeyboardHost/KeyboardHost.c index 6249e5291..fe95c3493 100644 --- a/Demos/Host/KeyboardHost/KeyboardHost.c +++ b/Demos/Host/KeyboardHost/KeyboardHost.c @@ -183,13 +183,25 @@ void ReadNextReport(void) {
USB_KeyboardReport_Data_t KeyboardReport;
- /* Select the keyboard report data in pipe */
+ /* Select keyboard data pipe */
Pipe_SelectPipe(KEYBOARD_DATAPIPE);
+ #if !defined(INTERRUPT_DATA_PIPE)
+ /* Unfreeze keyboard data pipe */
+ Pipe_Unfreeze();
+ #endif
+
/* Ensure pipe contains data and is ready to be read before continuing */
if (!(Pipe_ReadWriteAllowed()))
- return;
+ {
+ #if !defined(INTERRUPT_DATA_PIPE)
+ /* Refreeze keyboard data pipe */
+ Pipe_Freeze();
+ #endif
+ return;
+ }
+
/* Read in keyboard report data */
Pipe_Read_Stream_LE(&KeyboardReport, sizeof(KeyboardReport));
@@ -224,6 +236,11 @@ void ReadNextReport(void) if (PressedKey)
putchar(PressedKey);
}
+
+ #if !defined(INTERRUPT_DATA_PIPE)
+ /* Refreeze keyboard data pipe */
+ Pipe_Freeze();
+ #endif
}
/** Task to set the configuration of the attached device after it has been enumerated, and to read and process
@@ -307,22 +324,21 @@ TASK(USB_Keyboard_Host) break;
}
+ #if defined(INTERRUPT_DATA_PIPE)
+ /* Select and unfreeze keyboard data pipe */
+ Pipe_SelectPipe(KEYBOARD_DATAPIPE);
+ Pipe_Unfreeze();
+ #endif
+
puts_P(PSTR("Keyboard Enumerated.\r\n"));
-
+
USB_HostState = HOST_STATE_Ready;
break;
#if !defined(INTERRUPT_DATA_PIPE)
case HOST_STATE_Ready:
- /* Select and unfreeze keyboard data pipe */
- Pipe_SelectPipe(KEYBOARD_DATAPIPE);
- Pipe_Unfreeze();
-
/* If a report has been received, read and process it */
- if (Pipe_ReadWriteAllowed())
- ReadNextReport();
+ ReadNextReport();
- /* Freeze keyboard data pipe */
- Pipe_Freeze();
break;
#endif
}
|