aboutsummaryrefslogtreecommitdiffstats
path: root/Projects
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2011-01-30 14:14:04 +0000
committerDean Camera <dean@fourwalledcubicle.com>2011-01-30 14:14:04 +0000
commite6dc95163094692d11715711d5c1aaa19841dd77 (patch)
treef3935657b403333b3578581a2d76944cb9218b12 /Projects
parenta852ea8e43d6df9642df3524a974073d2229fa4c (diff)
downloadlufa-e6dc95163094692d11715711d5c1aaa19841dd77.tar.gz
lufa-e6dc95163094692d11715711d5c1aaa19841dd77.tar.bz2
lufa-e6dc95163094692d11715711d5c1aaa19841dd77.zip
Add new HID_DESCRIPTOR_VENDOR() macro, change over all projects and Device ClassDriver demos to use it.
Fix reversed byte ordering of multi-byte HID data. Added support to the HID parser for extended USAGE items that contain the usage page as well as the usage index. Removed the HID_IOF_NON_VOLATILE and HID_IOF_VOLATILE flags from HID INPUT items where the flag is invalid. Changed over HID OUTPUT items to use HID_IOF_NON_VOLATILE. Change over MagStripe project to use HID_DESCRIPTOR_KEYBOARD() for its HID report. Change over MouseHostDevice demo to use HID_DESCRIPTOR_MOUSE() for its HID report.
Diffstat (limited to 'Projects')
-rw-r--r--Projects/Benito/Benito.c37
-rw-r--r--Projects/Benito/makefile2
-rw-r--r--Projects/Magstripe/Descriptors.c36
-rw-r--r--Projects/Magstripe/Magstripe.c2
-rw-r--r--Projects/TempDataLogger/Descriptors.c24
-rw-r--r--Projects/USBtoSerial/USBtoSerial.c2
6 files changed, 34 insertions, 69 deletions
diff --git a/Projects/Benito/Benito.c b/Projects/Benito/Benito.c
index 4c964506c..26b5ad2b8 100644
--- a/Projects/Benito/Benito.c
+++ b/Projects/Benito/Benito.c
@@ -106,6 +106,9 @@ int main(void)
/* Check if the millisecond timer has elapsed */
if (TIFR0 & (1 << OCF0A))
{
+ /* Clear flush timer expiry flag */
+ TIFR0 |= (1 << TOV0);
+
/* Check if the reset pulse period has elapsed, if so tristate the target reset line */
if (PulseMSRemaining.ResetPulse && !(--PulseMSRemaining.ResetPulse))
{
@@ -132,31 +135,29 @@ int main(void)
uint16_t BufferCount = RingBuffer_GetCount(&USARTtoUSB_Buffer);
if (!(--FlushPeriodRemaining) || (BufferCount > 200))
{
- /* Echo bytes from the target to the host via the virtual serial port */
+ FlushPeriodRemaining = RECEIVE_BUFFER_FLUSH_MS;
+
+ /* Start RX LED indicator pulse */
if (BufferCount)
{
- while (BufferCount--)
- {
- /* Try to send the next byte of data to the host, abort if there is an error without dequeuing */
- if (CDC_Device_SendByte(&VirtualSerial_CDC_Interface,
- RingBuffer_Peek(&USARTtoUSB_Buffer)) != ENDPOINT_READYWAIT_NoError)
- {
- break;
- }
-
- /* Dequeue the already sent byte from the buffer now we have confirmed that no transmission error occurred */
- RingBuffer_Remove(&USARTtoUSB_Buffer);
- }
-
LEDs_TurnOnLEDs(LEDMASK_RX);
PulseMSRemaining.RxLEDPulse = TX_RX_LED_PULSE_MS;
}
- FlushPeriodRemaining = RECEIVE_BUFFER_FLUSH_MS;
+ /* Echo bytes from the target to the host via the virtual serial port */
+ while (BufferCount--)
+ {
+ /* Try to send the next byte of data to the host, abort if there is an error without dequeuing */
+ if (CDC_Device_SendByte(&VirtualSerial_CDC_Interface,
+ RingBuffer_Peek(&USARTtoUSB_Buffer)) != ENDPOINT_READYWAIT_NoError)
+ {
+ break;
+ }
+
+ /* Dequeue the already sent byte from the buffer now we have confirmed that no transmission error occurred */
+ RingBuffer_Remove(&USARTtoUSB_Buffer);
+ }
}
-
- /* Clear the millisecond timer CTC flag (cleared by writing logic one to the register) */
- TIFR0 |= (1 << OCF0A);
}
CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
diff --git a/Projects/Benito/makefile b/Projects/Benito/makefile
index 839b7d731..1d306803d 100644
--- a/Projects/Benito/makefile
+++ b/Projects/Benito/makefile
@@ -131,7 +131,7 @@ LUFA_OPTS += -D AVR_RESET_LINE_MASK="(1 << 4)"
LUFA_OPTS += -D AVR_RESET_PULSE_MS=10
LUFA_OPTS += -D TX_RX_LED_PULSE_MS=30
LUFA_OPTS += -D PING_PONG_LED_PULSE_MS=100
-LUFA_OPTS += -D RECEIVE_BUFFER_FLUSH_MS=20
+LUFA_OPTS += -D RECEIVE_BUFFER_FLUSH_MS=10
# Create the LUFA source path variables by including the LUFA root makefile
diff --git a/Projects/Magstripe/Descriptors.c b/Projects/Magstripe/Descriptors.c
index c7b21fdbf..420fe5e02 100644
--- a/Projects/Magstripe/Descriptors.c
+++ b/Projects/Magstripe/Descriptors.c
@@ -46,38 +46,10 @@
*/
USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
{
- HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
- HID_RI_USAGE(8, 0x06), /* Keyboard */
- HID_RI_COLLECTION(8, 0x01), /* Application */
- HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */
- HID_RI_USAGE_MINIMUM(8, 0xE0), /* Keyboard Left Control */
- HID_RI_USAGE_MAXIMUM(8, 0xE7), /* Keyboard Right GUI */
- HID_RI_LOGICAL_MINIMUM(8, 0x00),
- HID_RI_LOGICAL_MAXIMUM(8, 0x01),
- HID_RI_REPORT_SIZE(8, 0x01),
- HID_RI_REPORT_COUNT(8, 0x08),
- HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
- HID_RI_REPORT_COUNT(8, 0x01),
- HID_RI_REPORT_SIZE(8, 0x08),
- HID_RI_INPUT(8, HID_IOF_CONSTANT),
- HID_RI_USAGE_PAGE(8, 0x08), /* LEDs */
- HID_RI_USAGE_MINIMUM(8, 0x01), /* Num Lock */
- HID_RI_USAGE_MAXIMUM(8, 0x05), /* Kana */
- HID_RI_REPORT_COUNT(8, 0x05),
- HID_RI_REPORT_SIZE(8, 0x01),
- HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
- HID_RI_REPORT_COUNT(8, 0x01),
- HID_RI_REPORT_SIZE(8, 0x03),
- HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
- HID_RI_LOGICAL_MINIMUM(8, 0x00),
- HID_RI_LOGICAL_MAXIMUM(8, 0x65),
- HID_RI_USAGE_PAGE(8, 0x07), /* Keyboard */
- HID_RI_USAGE_MINIMUM(8, 0x00), /* Reserved (no event indicated) */
- HID_RI_USAGE_MAXIMUM(8, 0x65), /* Keyboard Application */
- HID_RI_REPORT_COUNT(8, 0x06),
- HID_RI_REPORT_SIZE(8, 0x08),
- HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
- HID_RI_END_COLLECTION(0),
+ /* Use the HID class driver's standard Keyboard report.
+ * Max simultaneous keys: 6
+ */
+ HID_DESCRIPTOR_KEYBOARD(6)
};
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
diff --git a/Projects/Magstripe/Magstripe.c b/Projects/Magstripe/Magstripe.c
index ebdee367b..2bb16145d 100644
--- a/Projects/Magstripe/Magstripe.c
+++ b/Projects/Magstripe/Magstripe.c
@@ -219,6 +219,6 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
const void* ReportData,
const uint16_t ReportSize)
{
- // Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
+ // Ignore keyboard LED reports from the host, but still need to declare the callback routine
}
diff --git a/Projects/TempDataLogger/Descriptors.c b/Projects/TempDataLogger/Descriptors.c
index 1e61df117..f9073422f 100644
--- a/Projects/TempDataLogger/Descriptors.c
+++ b/Projects/TempDataLogger/Descriptors.c
@@ -57,22 +57,14 @@
*/
USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] =
{
- HID_RI_USAGE_PAGE(16, 0x00FF), /* Vendor Page 1 */
- HID_RI_USAGE(8, 0x01), /* Vendor Usage 1 */
- HID_RI_COLLECTION(8, 0x01), /* Vendor Usage 1 */
- HID_RI_USAGE(8, 0x02), /* Vendor Usage 2 */
- HID_RI_LOGICAL_MINIMUM(8, 0x00),
- HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
- HID_RI_REPORT_SIZE(8, 0x08),
- HID_RI_REPORT_COUNT(8, GENERIC_REPORT_SIZE),
- HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
- HID_RI_USAGE(8, 0x03), /* Vendor Usage 3 */
- HID_RI_LOGICAL_MINIMUM(8, 0x00),
- HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
- HID_RI_REPORT_SIZE(8, 0x08),
- HID_RI_REPORT_COUNT(8, GENERIC_REPORT_SIZE),
- HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_VOLATILE),
- HID_RI_END_COLLECTION(0),
+ /* Use the HID class driver's standard Joystick report.
+ * Vendor Usage Page: 1
+ * Vendor Collection Usage: 1
+ * Vendor Report IN Usage: 2
+ * Vendor Report OUT Usage: 3
+ * Vendor Report Size: GENERIC_REPORT_SIZE
+ */
+ HID_DESCRIPTOR_VENDOR(0x00, 0x01, 0x02, 0x03, GENERIC_REPORT_SIZE)
};
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
diff --git a/Projects/USBtoSerial/USBtoSerial.c b/Projects/USBtoSerial/USBtoSerial.c
index 6afa41553..59f8edb69 100644
--- a/Projects/USBtoSerial/USBtoSerial.c
+++ b/Projects/USBtoSerial/USBtoSerial.c
@@ -46,7 +46,7 @@ uint8_t USBtoUSART_Buffer_Data[128];
RingBuffer_t USARTtoUSB_Buffer;
/** Underlying data buffer for \ref USARTtoUSB_Buffer, where the stored bytes are located. */
-uint8_t USARTtoUSB_Buffer_Data[128];
+uint8_t USARTtoUSB_Buffer_Data[128];
/** LUFA CDC Class driver interface configuration and state information. This structure is