From 3d1baa6f953c3c78c78c31466c4f551123e84415 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Fri, 5 Jun 2009 02:23:31 +0000 Subject: Added multiple Report ID support to the HID class driver. Removed OUT endpoint support from HID driver (all OUT reports are now processed through control requests) as a seperate endpoint had issues with determining the exact output report length. --- Demos/Device/GenericHID/Descriptors.c | 12 +----------- Demos/Device/GenericHID/Descriptors.h | 4 ---- Demos/Device/GenericHID/GenericHID.c | 8 +++----- Demos/Device/GenericHID/GenericHID.h | 4 ++-- Demos/Device/Joystick/Joystick.c | 5 +++-- Demos/Device/Joystick/Joystick.h | 4 ++-- Demos/Device/Keyboard/Descriptors.c | 12 +----------- Demos/Device/Keyboard/Descriptors.h | 4 ---- Demos/Device/Keyboard/Keyboard.c | 8 +++----- Demos/Device/Keyboard/Keyboard.h | 4 ++-- Demos/Device/KeyboardMouse/Descriptors.c | 12 +----------- Demos/Device/KeyboardMouse/Descriptors.h | 4 ---- Demos/Device/KeyboardMouse/KeyboardMouse.c | 11 +++-------- Demos/Device/KeyboardMouse/KeyboardMouse.h | 4 ++-- Demos/Device/Mouse/Mouse.c | 5 +++-- Demos/Device/Mouse/Mouse.h | 4 ++-- 16 files changed, 28 insertions(+), 77 deletions(-) (limited to 'Demos/Device') diff --git a/Demos/Device/GenericHID/Descriptors.c b/Demos/Device/GenericHID/Descriptors.c index ca1a110e7..6988166b3 100644 --- a/Demos/Device/GenericHID/Descriptors.c +++ b/Demos/Device/GenericHID/Descriptors.c @@ -119,7 +119,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .InterfaceNumber = 0x00, .AlternateSetting = 0x00, - .TotalEndpoints = 2, + .TotalEndpoints = 1, .Class = 0x03, .SubClass = 0x00, @@ -148,16 +148,6 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .EndpointSize = GENERIC_EPSIZE, .PollingIntervalMS = 0x02 }, - - .GenericOUTEndpoint = - { - .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - - .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | GENERIC_OUT_EPNUM), - .Attributes = EP_TYPE_INTERRUPT, - .EndpointSize = GENERIC_EPSIZE, - .PollingIntervalMS = 0x02 - } }; /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests diff --git a/Demos/Device/GenericHID/Descriptors.h b/Demos/Device/GenericHID/Descriptors.h index bc4c68ae6..01db53e41 100644 --- a/Demos/Device/GenericHID/Descriptors.h +++ b/Demos/Device/GenericHID/Descriptors.h @@ -53,16 +53,12 @@ USB_Descriptor_Interface_t Interface; USB_Descriptor_HID_t GenericHID; USB_Descriptor_Endpoint_t GenericINEndpoint; - USB_Descriptor_Endpoint_t GenericOUTEndpoint; } USB_Descriptor_Configuration_t; /* Macros: */ /** Endpoint number of the Generic HID reporting IN endpoint. */ #define GENERIC_IN_EPNUM 1 - /** Endpoint number of the Generic HID reporting OUT endpoint. */ - #define GENERIC_OUT_EPNUM 2 - /** Size in bytes of the Generic HID reporting endpoint. */ #define GENERIC_EPSIZE 8 diff --git a/Demos/Device/GenericHID/GenericHID.c b/Demos/Device/GenericHID/GenericHID.c index b933e4506..172df7fa7 100644 --- a/Demos/Device/GenericHID/GenericHID.c +++ b/Demos/Device/GenericHID/GenericHID.c @@ -47,9 +47,6 @@ USB_ClassInfo_HID_t Generic_HID_Interface = .ReportINEndpointNumber = GENERIC_IN_EPNUM, .ReportINEndpointSize = GENERIC_EPSIZE, - .ReportOUTEndpointNumber = GENERIC_OUT_EPNUM, - .ReportOUTEndpointSize = GENERIC_EPSIZE, - .ReportINBufferSize = GENERIC_REPORT_SIZE, .UsingReportProtocol = true, @@ -133,7 +130,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK) * * \return Number of bytes written in the report (or zero if no report is to be sent */ -uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData) +uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData) { // Create generic HID report here @@ -146,7 +143,8 @@ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceI * \param ReportData Pointer to a buffer where the created report has been stored * \param ReportSize Size in bytes of the received HID report */ -void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize) +void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, + void* ReportData, uint16_t ReportSize) { // Process received generic HID report here } diff --git a/Demos/Device/GenericHID/GenericHID.h b/Demos/Device/GenericHID/GenericHID.h index b68dc4c24..5ea084c7e 100644 --- a/Demos/Device/GenericHID/GenericHID.h +++ b/Demos/Device/GenericHID/GenericHID.h @@ -72,8 +72,8 @@ void EVENT_USB_ConfigurationChanged(void); void EVENT_USB_UnhandledControlPacket(void); - uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData); - void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, + uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData); + void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, void* ReportData, uint16_t ReportSize); #endif diff --git a/Demos/Device/Joystick/Joystick.c b/Demos/Device/Joystick/Joystick.c index 66cb808d0..1cf59bbfd 100644 --- a/Demos/Device/Joystick/Joystick.c +++ b/Demos/Device/Joystick/Joystick.c @@ -132,7 +132,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK) * * \return Number of bytes written in the report (or zero if no report is to be sent */ -uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData) +uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData) { USB_JoystickReport_Data_t* JoystickReport = (USB_JoystickReport_Data_t*)ReportData; @@ -164,7 +164,8 @@ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceI * \param ReportData Pointer to a buffer where the created report has been stored * \param ReportSize Size in bytes of the received HID report */ -void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize) +void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, + void* ReportData, uint16_t ReportSize) { // Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports } diff --git a/Demos/Device/Joystick/Joystick.h b/Demos/Device/Joystick/Joystick.h index 9db357b40..4209f4d7e 100644 --- a/Demos/Device/Joystick/Joystick.h +++ b/Demos/Device/Joystick/Joystick.h @@ -83,8 +83,8 @@ void EVENT_USB_ConfigurationChanged(void); void EVENT_USB_UnhandledControlPacket(void); - uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData); - void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, + uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData); + void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, void* ReportData, uint16_t ReportSize); #endif diff --git a/Demos/Device/Keyboard/Descriptors.c b/Demos/Device/Keyboard/Descriptors.c index ddd19fc8c..8914909d7 100644 --- a/Demos/Device/Keyboard/Descriptors.c +++ b/Demos/Device/Keyboard/Descriptors.c @@ -136,7 +136,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .InterfaceNumber = 0x00, .AlternateSetting = 0x00, - .TotalEndpoints = 2, + .TotalEndpoints = 1, .Class = 0x03, .SubClass = 0x01, @@ -165,16 +165,6 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .EndpointSize = KEYBOARD_EPSIZE, .PollingIntervalMS = 0x04 }, - - .KeyboardLEDsEndpoint = - { - .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - - .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | KEYBOARD_LEDS_EPNUM), - .Attributes = EP_TYPE_INTERRUPT, - .EndpointSize = KEYBOARD_EPSIZE, - .PollingIntervalMS = 0x04 - } }; /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests diff --git a/Demos/Device/Keyboard/Descriptors.h b/Demos/Device/Keyboard/Descriptors.h index 0a95ca06e..40b358caa 100644 --- a/Demos/Device/Keyboard/Descriptors.h +++ b/Demos/Device/Keyboard/Descriptors.h @@ -54,15 +54,11 @@ USB_Descriptor_Interface_t Interface; USB_Descriptor_HID_t KeyboardHID; USB_Descriptor_Endpoint_t KeyboardEndpoint; - USB_Descriptor_Endpoint_t KeyboardLEDsEndpoint; } USB_Descriptor_Configuration_t; /* Macros: */ /** Endpoint number of the Keyboard HID reporting IN endpoint. */ #define KEYBOARD_EPNUM 1 - - /** Endpoint number of the Keyboard HID reporting OUT endpoint. */ - #define KEYBOARD_LEDS_EPNUM 2 /** Size in bytes of the Keyboard HID reporting IN and OUT endpoints. */ #define KEYBOARD_EPSIZE 8 diff --git a/Demos/Device/Keyboard/Keyboard.c b/Demos/Device/Keyboard/Keyboard.c index 923dd7176..bebad12e0 100644 --- a/Demos/Device/Keyboard/Keyboard.c +++ b/Demos/Device/Keyboard/Keyboard.c @@ -48,9 +48,6 @@ USB_ClassInfo_HID_t Keyboard_HID_Interface = .ReportINEndpointNumber = KEYBOARD_EPNUM, .ReportINEndpointSize = KEYBOARD_EPSIZE, - .ReportOUTEndpointNumber = KEYBOARD_LEDS_EPNUM, - .ReportOUTEndpointSize = KEYBOARD_EPSIZE, - .ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t), .IdleCount = 500, @@ -136,7 +133,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK) * * \return Number of bytes written in the report (or zero if no report is to be sent */ -uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData) +uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData) { USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData; @@ -168,7 +165,8 @@ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceI * \param ReportData Pointer to a buffer where the created report has been stored * \param ReportSize Size in bytes of the received HID report */ -void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize) +void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, + void* ReportData, uint16_t ReportSize) { uint8_t LEDMask = LEDS_NO_LEDS; uint8_t* LEDReport = (uint8_t*)ReportData; diff --git a/Demos/Device/Keyboard/Keyboard.h b/Demos/Device/Keyboard/Keyboard.h index e04ae9e34..1b4bb7092 100644 --- a/Demos/Device/Keyboard/Keyboard.h +++ b/Demos/Device/Keyboard/Keyboard.h @@ -86,8 +86,8 @@ void EVENT_USB_ConfigurationChanged(void); void EVENT_USB_UnhandledControlPacket(void); - uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData); - void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, + uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData); + void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, void* ReportData, uint16_t ReportSize); #endif diff --git a/Demos/Device/KeyboardMouse/Descriptors.c b/Demos/Device/KeyboardMouse/Descriptors.c index 145708db9..c9a778feb 100644 --- a/Demos/Device/KeyboardMouse/Descriptors.c +++ b/Demos/Device/KeyboardMouse/Descriptors.c @@ -169,7 +169,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .InterfaceNumber = 0x00, .AlternateSetting = 0x00, - .TotalEndpoints = 2, + .TotalEndpoints = 1, .Class = 0x03, .SubClass = 0x01, @@ -199,16 +199,6 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .PollingIntervalMS = 0x02 }, - .KeyboardOutEndpoint = - { - .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, - - .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | KEYBOARD_OUT_EPNUM), - .Attributes = EP_TYPE_INTERRUPT, - .EndpointSize = HID_EPSIZE, - .PollingIntervalMS = 0x02 - }, - .MouseInterface = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, diff --git a/Demos/Device/KeyboardMouse/Descriptors.h b/Demos/Device/KeyboardMouse/Descriptors.h index 152e5111a..1dcad086e 100644 --- a/Demos/Device/KeyboardMouse/Descriptors.h +++ b/Demos/Device/KeyboardMouse/Descriptors.h @@ -54,7 +54,6 @@ USB_Descriptor_Interface_t KeyboardInterface; USB_Descriptor_HID_t KeyboardHID; USB_Descriptor_Endpoint_t KeyboardInEndpoint; - USB_Descriptor_Endpoint_t KeyboardOutEndpoint; USB_Descriptor_Interface_t MouseInterface; USB_Descriptor_HID_t MouseHID; USB_Descriptor_Endpoint_t MouseInEndpoint; @@ -64,9 +63,6 @@ /** Endpoint number of the Keyboard HID reporting IN endpoint. */ #define KEYBOARD_IN_EPNUM 1 - /** Endpoint number of the Keyboard HID reporting OUT endpoint. */ - #define KEYBOARD_OUT_EPNUM 2 - /** Endpoint number of the Mouse HID reporting IN endpoint. */ #define MOUSE_IN_EPNUM 3 diff --git a/Demos/Device/KeyboardMouse/KeyboardMouse.c b/Demos/Device/KeyboardMouse/KeyboardMouse.c index e68a24793..5cea55580 100644 --- a/Demos/Device/KeyboardMouse/KeyboardMouse.c +++ b/Demos/Device/KeyboardMouse/KeyboardMouse.c @@ -48,9 +48,6 @@ USB_ClassInfo_HID_t Keyboard_HID_Interface = .ReportINEndpointNumber = KEYBOARD_IN_EPNUM, .ReportINEndpointSize = HID_EPSIZE, - - .ReportOUTEndpointNumber = KEYBOARD_OUT_EPNUM, - .ReportOUTEndpointSize = HID_EPSIZE, .ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t), @@ -70,9 +67,6 @@ USB_ClassInfo_HID_t Mouse_HID_Interface = .ReportINEndpointSize = HID_EPSIZE, .ReportINBufferSize = sizeof(USB_MouseReport_Data_t), - - .ReportOUTEndpointNumber = 0, - .ReportOUTEndpointSize = 0, }; /** Main program entry point. This routine contains the overall program flow, including initial @@ -162,7 +156,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK) * * \return Number of bytes written in the report (or zero if no report is to be sent */ -uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData) +uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData) { uint8_t JoyStatus_LCL = Joystick_GetStatus(); uint8_t ButtonStatus_LCL = Buttons_GetStatus(); @@ -221,7 +215,8 @@ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceI * \param ReportData Pointer to a buffer where the created report has been stored * \param ReportSize Size in bytes of the received HID report */ -void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize) +void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, + void* ReportData, uint16_t ReportSize) { if (HIDInterfaceInfo == &Keyboard_HID_Interface) { diff --git a/Demos/Device/KeyboardMouse/KeyboardMouse.h b/Demos/Device/KeyboardMouse/KeyboardMouse.h index 9afe7646b..74b1c9e5f 100644 --- a/Demos/Device/KeyboardMouse/KeyboardMouse.h +++ b/Demos/Device/KeyboardMouse/KeyboardMouse.h @@ -90,8 +90,8 @@ void EVENT_USB_ConfigurationChanged(void); void EVENT_USB_UnhandledControlPacket(void); - uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData); - void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, + uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData); + void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, void* ReportData, uint16_t ReportSize); #endif diff --git a/Demos/Device/Mouse/Mouse.c b/Demos/Device/Mouse/Mouse.c index 1bc62dac6..f5bd931d1 100644 --- a/Demos/Device/Mouse/Mouse.c +++ b/Demos/Device/Mouse/Mouse.c @@ -130,7 +130,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK) * * \return Number of bytes written in the report (or zero if no report is to be sent */ -uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData) +uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData) { USB_MouseReport_Data_t* MouseReport = (USB_MouseReport_Data_t*)ReportData; @@ -162,7 +162,8 @@ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceI * \param ReportData Pointer to a buffer where the created report has been stored * \param ReportSize Size in bytes of the received HID report */ -void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize) +void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, + void* ReportData, uint16_t ReportSize) { // Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports } diff --git a/Demos/Device/Mouse/Mouse.h b/Demos/Device/Mouse/Mouse.h index 62d6d8323..6de20ee79 100644 --- a/Demos/Device/Mouse/Mouse.h +++ b/Demos/Device/Mouse/Mouse.h @@ -85,8 +85,8 @@ void EVENT_USB_ConfigurationChanged(void); void EVENT_USB_UnhandledControlPacket(void); - uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData); - void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, + uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData); + void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, void* ReportData, uint16_t ReportSize); #endif -- cgit v1.2.3