aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Host/KeyboardHost
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-04-01 07:21:45 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-04-01 07:21:45 +0000
commit6198289b388e4122afe4913f899b37a8e7cd8af4 (patch)
tree178377f080f369a8b0bee80f1520f7ac087d0b84 /Demos/Host/KeyboardHost
parent74496a947eef42b416a8a0cb11b7415ac6fa103b (diff)
downloadlufa-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')
-rw-r--r--Demos/Host/KeyboardHost/ConfigDescriptor.c2
-rw-r--r--Demos/Host/KeyboardHost/KeyboardHost.c38
-rw-r--r--Demos/Host/KeyboardHost/KeyboardHost.txt2
3 files changed, 28 insertions, 14 deletions
diff --git a/Demos/Host/KeyboardHost/ConfigDescriptor.c b/Demos/Host/KeyboardHost/ConfigDescriptor.c
index 9d1a630ad..14db19846 100644
--- a/Demos/Host/KeyboardHost/ConfigDescriptor.c
+++ b/Demos/Host/KeyboardHost/ConfigDescriptor.c
@@ -98,8 +98,6 @@ uint8_t ProcessConfigurationDescriptor(void)
/* Enable the pipe IN interrupt for the data pipe */
USB_INT_Enable(PIPE_INT_IN);
#endif
-
- Pipe_Unfreeze();
/* Valid data found, return success */
return SuccessfulConfigRead;
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
}
diff --git a/Demos/Host/KeyboardHost/KeyboardHost.txt b/Demos/Host/KeyboardHost/KeyboardHost.txt
index 6d536fb86..8abe99f23 100644
--- a/Demos/Host/KeyboardHost/KeyboardHost.txt
+++ b/Demos/Host/KeyboardHost/KeyboardHost.txt
@@ -36,7 +36,7 @@
* \section SSec_Description Project Description:
*
* Keyboard host demonstration application. This gives a simple reference
- * application for implementing a USB Mouse keyboard, for USB keyboards using
+ * application for implementing a USB keyboard, for USB keyboards using
* the standard keyboard HID profile.
*
* Pressed alpha-numeric, enter or space key is transmitted through the serial