Commit 3d1baa6f authored by Dean Camera's avatar Dean Camera
Browse files

Added multiple Report ID support to the HID class driver. Removed OUT endpoint...

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.
parent 7665bf32
...@@ -119,7 +119,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = ...@@ -119,7 +119,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.InterfaceNumber = 0x00, .InterfaceNumber = 0x00,
.AlternateSetting = 0x00, .AlternateSetting = 0x00,
.TotalEndpoints = 2, .TotalEndpoints = 1,
.Class = 0x03, .Class = 0x03,
.SubClass = 0x00, .SubClass = 0x00,
...@@ -148,16 +148,6 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = ...@@ -148,16 +148,6 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.EndpointSize = GENERIC_EPSIZE, .EndpointSize = GENERIC_EPSIZE,
.PollingIntervalMS = 0x02 .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 /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
......
...@@ -53,16 +53,12 @@ ...@@ -53,16 +53,12 @@
USB_Descriptor_Interface_t Interface; USB_Descriptor_Interface_t Interface;
USB_Descriptor_HID_t GenericHID; USB_Descriptor_HID_t GenericHID;
USB_Descriptor_Endpoint_t GenericINEndpoint; USB_Descriptor_Endpoint_t GenericINEndpoint;
USB_Descriptor_Endpoint_t GenericOUTEndpoint;
} USB_Descriptor_Configuration_t; } USB_Descriptor_Configuration_t;
/* Macros: */ /* Macros: */
/** Endpoint number of the Generic HID reporting IN endpoint. */ /** Endpoint number of the Generic HID reporting IN endpoint. */
#define GENERIC_IN_EPNUM 1 #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. */ /** Size in bytes of the Generic HID reporting endpoint. */
#define GENERIC_EPSIZE 8 #define GENERIC_EPSIZE 8
......
...@@ -47,9 +47,6 @@ USB_ClassInfo_HID_t Generic_HID_Interface = ...@@ -47,9 +47,6 @@ USB_ClassInfo_HID_t Generic_HID_Interface =
.ReportINEndpointNumber = GENERIC_IN_EPNUM, .ReportINEndpointNumber = GENERIC_IN_EPNUM,
.ReportINEndpointSize = GENERIC_EPSIZE, .ReportINEndpointSize = GENERIC_EPSIZE,
.ReportOUTEndpointNumber = GENERIC_OUT_EPNUM,
.ReportOUTEndpointSize = GENERIC_EPSIZE,
.ReportINBufferSize = GENERIC_REPORT_SIZE, .ReportINBufferSize = GENERIC_REPORT_SIZE,
.UsingReportProtocol = true, .UsingReportProtocol = true,
...@@ -133,7 +130,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK) ...@@ -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 * \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 // Create generic HID report here
...@@ -146,7 +143,8 @@ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceI ...@@ -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 ReportData Pointer to a buffer where the created report has been stored
* \param ReportSize Size in bytes of the received HID report * \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 // Process received generic HID report here
} }
...@@ -72,8 +72,8 @@ ...@@ -72,8 +72,8 @@
void EVENT_USB_ConfigurationChanged(void); void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void); void EVENT_USB_UnhandledControlPacket(void);
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);
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
void* ReportData, uint16_t ReportSize); void* ReportData, uint16_t ReportSize);
#endif #endif
...@@ -132,7 +132,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK) ...@@ -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 * \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; 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 ...@@ -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 ReportData Pointer to a buffer where the created report has been stored
* \param ReportSize Size in bytes of the received HID report * \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 // Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
} }
...@@ -83,8 +83,8 @@ ...@@ -83,8 +83,8 @@
void EVENT_USB_ConfigurationChanged(void); void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void); void EVENT_USB_UnhandledControlPacket(void);
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);
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
void* ReportData, uint16_t ReportSize); void* ReportData, uint16_t ReportSize);
#endif #endif
...@@ -136,7 +136,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = ...@@ -136,7 +136,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.InterfaceNumber = 0x00, .InterfaceNumber = 0x00,
.AlternateSetting = 0x00, .AlternateSetting = 0x00,
.TotalEndpoints = 2, .TotalEndpoints = 1,
.Class = 0x03, .Class = 0x03,
.SubClass = 0x01, .SubClass = 0x01,
...@@ -165,16 +165,6 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = ...@@ -165,16 +165,6 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.EndpointSize = KEYBOARD_EPSIZE, .EndpointSize = KEYBOARD_EPSIZE,
.PollingIntervalMS = 0x04 .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 /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
......
...@@ -54,15 +54,11 @@ ...@@ -54,15 +54,11 @@
USB_Descriptor_Interface_t Interface; USB_Descriptor_Interface_t Interface;
USB_Descriptor_HID_t KeyboardHID; USB_Descriptor_HID_t KeyboardHID;
USB_Descriptor_Endpoint_t KeyboardEndpoint; USB_Descriptor_Endpoint_t KeyboardEndpoint;
USB_Descriptor_Endpoint_t KeyboardLEDsEndpoint;
} USB_Descriptor_Configuration_t; } USB_Descriptor_Configuration_t;
/* Macros: */ /* Macros: */
/** Endpoint number of the Keyboard HID reporting IN endpoint. */ /** Endpoint number of the Keyboard HID reporting IN endpoint. */
#define KEYBOARD_EPNUM 1 #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. */ /** Size in bytes of the Keyboard HID reporting IN and OUT endpoints. */
#define KEYBOARD_EPSIZE 8 #define KEYBOARD_EPSIZE 8
......
...@@ -48,9 +48,6 @@ USB_ClassInfo_HID_t Keyboard_HID_Interface = ...@@ -48,9 +48,6 @@ USB_ClassInfo_HID_t Keyboard_HID_Interface =
.ReportINEndpointNumber = KEYBOARD_EPNUM, .ReportINEndpointNumber = KEYBOARD_EPNUM,
.ReportINEndpointSize = KEYBOARD_EPSIZE, .ReportINEndpointSize = KEYBOARD_EPSIZE,
.ReportOUTEndpointNumber = KEYBOARD_LEDS_EPNUM,
.ReportOUTEndpointSize = KEYBOARD_EPSIZE,
.ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t), .ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t),
.IdleCount = 500, .IdleCount = 500,
...@@ -136,7 +133,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK) ...@@ -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 * \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; 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 ...@@ -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 ReportData Pointer to a buffer where the created report has been stored
* \param ReportSize Size in bytes of the received HID report * \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 LEDMask = LEDS_NO_LEDS;
uint8_t* LEDReport = (uint8_t*)ReportData; uint8_t* LEDReport = (uint8_t*)ReportData;
......
...@@ -86,8 +86,8 @@ ...@@ -86,8 +86,8 @@
void EVENT_USB_ConfigurationChanged(void); void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void); void EVENT_USB_UnhandledControlPacket(void);
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);
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
void* ReportData, uint16_t ReportSize); void* ReportData, uint16_t ReportSize);
#endif #endif
...@@ -169,7 +169,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = ...@@ -169,7 +169,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.InterfaceNumber = 0x00, .InterfaceNumber = 0x00,
.AlternateSetting = 0x00, .AlternateSetting = 0x00,
.TotalEndpoints = 2, .TotalEndpoints = 1,
.Class = 0x03, .Class = 0x03,
.SubClass = 0x01, .SubClass = 0x01,
...@@ -199,16 +199,6 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = ...@@ -199,16 +199,6 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.PollingIntervalMS = 0x02 .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 = .MouseInterface =
{ {
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
......
...@@ -54,7 +54,6 @@ ...@@ -54,7 +54,6 @@
USB_Descriptor_Interface_t KeyboardInterface; USB_Descriptor_Interface_t KeyboardInterface;
USB_Descriptor_HID_t KeyboardHID; USB_Descriptor_HID_t KeyboardHID;
USB_Descriptor_Endpoint_t KeyboardInEndpoint; USB_Descriptor_Endpoint_t KeyboardInEndpoint;
USB_Descriptor_Endpoint_t KeyboardOutEndpoint;
USB_Descriptor_Interface_t MouseInterface; USB_Descriptor_Interface_t MouseInterface;
USB_Descriptor_HID_t MouseHID; USB_Descriptor_HID_t MouseHID;
USB_Descriptor_Endpoint_t MouseInEndpoint; USB_Descriptor_Endpoint_t MouseInEndpoint;
...@@ -64,9 +63,6 @@ ...@@ -64,9 +63,6 @@
/** Endpoint number of the Keyboard HID reporting IN endpoint. */ /** Endpoint number of the Keyboard HID reporting IN endpoint. */
#define KEYBOARD_IN_EPNUM 1 #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. */ /** Endpoint number of the Mouse HID reporting IN endpoint. */
#define MOUSE_IN_EPNUM 3 #define MOUSE_IN_EPNUM 3
......
...@@ -48,9 +48,6 @@ USB_ClassInfo_HID_t Keyboard_HID_Interface = ...@@ -48,9 +48,6 @@ USB_ClassInfo_HID_t Keyboard_HID_Interface =
.ReportINEndpointNumber = KEYBOARD_IN_EPNUM, .ReportINEndpointNumber = KEYBOARD_IN_EPNUM,
.ReportINEndpointSize = HID_EPSIZE, .ReportINEndpointSize = HID_EPSIZE,
.ReportOUTEndpointNumber = KEYBOARD_OUT_EPNUM,
.ReportOUTEndpointSize = HID_EPSIZE,
.ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t), .ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t),
...@@ -70,9 +67,6 @@ USB_ClassInfo_HID_t Mouse_HID_Interface = ...@@ -70,9 +67,6 @@ USB_ClassInfo_HID_t Mouse_HID_Interface =
.ReportINEndpointSize = HID_EPSIZE, .ReportINEndpointSize = HID_EPSIZE,
.ReportINBufferSize = sizeof(USB_MouseReport_Data_t), .ReportINBufferSize = sizeof(USB_MouseReport_Data_t),
.ReportOUTEndpointNumber = 0,
.ReportOUTEndpointSize = 0,
}; };
/** Main program entry point. This routine contains the overall program flow, including initial /** Main program entry point. This routine contains the overall program flow, including initial
...@@ -162,7 +156,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK) ...@@ -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 * \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 JoyStatus_LCL = Joystick_GetStatus();
uint8_t ButtonStatus_LCL = Buttons_GetStatus(); uint8_t ButtonStatus_LCL = Buttons_GetStatus();
...@@ -221,7 +215,8 @@ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceI ...@@ -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 ReportData Pointer to a buffer where the created report has been stored
* \param ReportSize Size in bytes of the received HID report * \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) if (HIDInterfaceInfo == &Keyboard_HID_Interface)
{ {
......
...@@ -90,8 +90,8 @@ ...@@ -90,8 +90,8 @@
void EVENT_USB_ConfigurationChanged(void); void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void); void EVENT_USB_UnhandledControlPacket(void);
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);
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
void* ReportData, uint16_t ReportSize); void* ReportData, uint16_t ReportSize);
#endif #endif
...@@ -130,7 +130,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK) ...@@ -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 * \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; 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 ...@@ -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 ReportData Pointer to a buffer where the created report has been stored
* \param ReportSize Size in bytes of the received HID report * \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 // Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
} }
...@@ -85,8 +85,8 @@ ...@@ -85,8 +85,8 @@
void EVENT_USB_ConfigurationChanged(void); void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void); void EVENT_USB_UnhandledControlPacket(void);
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);
void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,
void* ReportData, uint16_t ReportSize); void* ReportData, uint16_t ReportSize);
#endif #endif
...@@ -169,7 +169,7 @@ uint8_t USB_CDC_ReceiveByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo) ...@@ -169,7 +169,7 @@ uint8_t USB_CDC_ReceiveByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo)
return DataByte; return DataByte;
} }
void USB_CDC_SendSerialLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask) void USB_CDC_SendSerialLineStateChange(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask)
{ {
Endpoint_SelectEndpoint(CDCInterfaceInfo->NotificationEndpointNumber); Endpoint_SelectEndpoint(CDCInterfaceInfo->NotificationEndpointNumber);
......
...@@ -167,7 +167,7 @@ ...@@ -167,7 +167,7 @@
uint8_t NotificationEndpointNumber; /**< Endpoint number of the CDC interface's IN notification endpoint, if used */ uint8_t NotificationEndpointNumber; /**< Endpoint number of the CDC interface's IN notification endpoint, if used */
uint16_t NotificationEndpointSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used */ uint16_t NotificationEndpointSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used */
uint8_t ControlLineState; /**< Current control line state, as set by the host */ uint8_t ControlLineState; /**< Current control line states, as set by the host */
struct struct
{ {
...@@ -195,7 +195,7 @@ ...@@ -195,7 +195,7 @@
* \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the * \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the
* given CDC interface is selected. * given CDC interface is selected.
* *
* \param CDCInterfaceInfo Pointer to a structure containing an CDC Class configuration and state. * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
* *
* \return Boolean true if the endpoints were sucessfully configured, false otherwise * \return Boolean true if the endpoints were sucessfully configured, false otherwise
*/ */
...@@ -204,25 +204,41 @@ ...@@ -204,25 +204,41 @@
/** Processes incomming control requests from the host, that are directed to the given CDC class interface. This should be /** Processes incomming control requests from the host, that are directed to the given CDC class interface. This should be
* linked to the library \ref EVENT_USB_UnhandledControlPacket() event. * linked to the library \ref EVENT_USB_UnhandledControlPacket() event.
* *
* \param CDCInterfaceInfo Pointer to a structure containing an CDC Class configuration and state. * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
*/ */
void USB_CDC_ProcessControlPacket(USB_ClassInfo_CDC_t* CDCInterfaceInfo); void USB_CDC_ProcessControlPacket(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
/** General management task for a given CDC class interface, required for the correct operation of the interface. This should /** General management task for a given CDC class interface, required for the correct operation of the interface. This should
* be called frequently in the main program loop, before the master USB management task \ref USB_USBTask(). * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().
* *
* \param CDCInterfaceInfo Pointer to a structure containing an CDC Class configuration and state. * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
*/ */
void USB_CDC_USBTask(USB_ClassInfo_CDC_t* CDCInterfaceInfo); void USB_CDC_USBTask(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
void EVENT_USB_CDC_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo); /** CDC class driver event for a line encoding change on a CDC interface. This event fires each time the host requests a
void EVENT_USB_CDC_ControLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo); * line encoding change (containing the serial parity, baud and other configuration information) and may be hooked in the
* user program by declaring a handler function with the same name and parameters listed here. The new line encoding
* settings are available in the LineEncoding structure inside the CDC interface structure passed as a parameter.
*
* \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
*/
void EVENT_USB_CDC_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
/** CDC class driver event for a control line state change on a CDC interface. This event fires each time the host requests a
* control line state change (containing the virtual serial control line states, such as DTR) and may be hooked in the
* user program by declaring a handler function with the same name and parameters listed here. The new control line states
* are available in the ControlLineState value inside the CDC interface structure passed as a parameter, set as a mask of
* CDC_CONTROL_LINE_OUT_* masks.
*
* \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
*/
void EVENT_USB_CDC_ControLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
void USB_CDC_SendString(USB_ClassInfo_CDC_t* CDCInterfaceInfo, char* Data, uint16_t Length); void USB_CDC_SendString(USB_ClassInfo_CDC_t* CDCInterfaceInfo, char* Data, uint16_t Length);
void USB_CDC_SendByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint8_t Data); void USB_CDC_SendByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint8_t Data);
uint16_t USB_CDC_BytesReceived(USB_ClassInfo_CDC_t* CDCInterfaceInfo); uint16_t USB_CDC_BytesReceived(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
uint8_t USB_CDC_ReceiveByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo); uint8_t USB_CDC_ReceiveByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo);
void USB_CDC_SendSerialLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask); void USB_CDC_SendSerialLineStateChange(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask);
/* Disable C linkage for C++ Compilers: */ /* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus) #if defined(__cplusplus)
......
...@@ -47,10 +47,11 @@ void USB_HID_ProcessControlPacket(USB_ClassInfo_HID_t* HIDInterfaceInfo) ...@@ -47,10 +47,11 @@ void USB_HID_ProcessControlPacket(USB_ClassInfo_HID_t* HIDInterfaceInfo)
uint8_t ReportINData[HIDInterfaceInfo->ReportINBufferSize]; uint8_t ReportINData[HIDInterfaceInfo->ReportINBufferSize];
uint16_t ReportINSize; uint16_t ReportINSize;
uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF);
memset(ReportINData, 0, sizeof(ReportINData)); memset(ReportINData, 0, sizeof(ReportINData));
ReportINSize = CALLBACK_USB_HID_CreateNextHIDReport(HIDInterfaceInfo, ReportINData); ReportINSize = CALLBACK_USB_HID_CreateNextHIDReport(HIDInterfaceInfo, &ReportID, ReportINData);
Endpoint_Write_Control_Stream_LE(ReportINData, ReportINSize); Endpoint_Write_Control_Stream_LE(ReportINData, ReportINSize);
Endpoint_ClearOUT(); Endpoint_ClearOUT();
...@@ -64,11 +65,12 @@ void USB_HID_ProcessControlPacket(USB_ClassInfo_HID_t* HIDInterfaceInfo) ...@@ -64,11 +65,12 @@ void USB_HID_ProcessControlPacket(USB_ClassInfo_HID_t* HIDInterfaceInfo)
uint16_t ReportOUTSize = USB_ControlRequest.wLength; uint16_t ReportOUTSize = USB_ControlRequest.wLength;
uint8_t ReportOUTData[ReportOUTSize]; uint8_t ReportOUTData[ReportOUTSize];
uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF);
Endpoint_Read_Control_Stream_LE(ReportOUTData, ReportOUTSize); Endpoint_Read_Control_Stream_LE(ReportOUTData, ReportOUTSize);
Endpoint_ClearIN(); Endpoint_ClearIN();