.InterfaceNumber = 0x00,\r
.AlternateSetting = 0x00,\r
\r
- .TotalEndpoints = 2,\r
+ .TotalEndpoints = 1,\r
\r
.Class = 0x03,\r
.SubClass = 0x00,\r
.EndpointSize = GENERIC_EPSIZE,\r
.PollingIntervalMS = 0x02\r
},\r
-\r
- .GenericOUTEndpoint = \r
- {\r
- .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
- \r
- .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | GENERIC_OUT_EPNUM),\r
- .Attributes = EP_TYPE_INTERRUPT,\r
- .EndpointSize = GENERIC_EPSIZE,\r
- .PollingIntervalMS = 0x02\r
- }\r
};\r
\r
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests\r
USB_Descriptor_Interface_t Interface;\r
USB_Descriptor_HID_t GenericHID;\r
USB_Descriptor_Endpoint_t GenericINEndpoint;\r
- USB_Descriptor_Endpoint_t GenericOUTEndpoint;\r
} USB_Descriptor_Configuration_t;\r
\r
/* Macros: */\r
/** Endpoint number of the Generic HID reporting IN endpoint. */\r
#define GENERIC_IN_EPNUM 1\r
\r
- /** Endpoint number of the Generic HID reporting OUT endpoint. */\r
- #define GENERIC_OUT_EPNUM 2\r
-\r
/** Size in bytes of the Generic HID reporting endpoint. */\r
#define GENERIC_EPSIZE 8\r
\r
.ReportINEndpointNumber = GENERIC_IN_EPNUM,\r
.ReportINEndpointSize = GENERIC_EPSIZE,\r
\r
- .ReportOUTEndpointNumber = GENERIC_OUT_EPNUM,\r
- .ReportOUTEndpointSize = GENERIC_EPSIZE,\r
- \r
.ReportINBufferSize = GENERIC_REPORT_SIZE,\r
\r
.UsingReportProtocol = true,\r
*\r
* \return Number of bytes written in the report (or zero if no report is to be sent\r
*/\r
-uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData)\r
+uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)\r
{\r
// Create generic HID report here\r
\r
* \param ReportData Pointer to a buffer where the created report has been stored\r
* \param ReportSize Size in bytes of the received HID report\r
*/\r
-void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize)\r
+void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,\r
+ void* ReportData, uint16_t ReportSize)\r
{\r
// Process received generic HID report here\r
}\r
void EVENT_USB_ConfigurationChanged(void);\r
void EVENT_USB_UnhandledControlPacket(void);\r
\r
- uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData);\r
- void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo,\r
+ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData);\r
+ void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, \r
void* ReportData, uint16_t ReportSize);\r
\r
#endif\r
*\r
* \return Number of bytes written in the report (or zero if no report is to be sent\r
*/\r
-uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData)\r
+uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)\r
{\r
USB_JoystickReport_Data_t* JoystickReport = (USB_JoystickReport_Data_t*)ReportData;\r
\r
* \param ReportData Pointer to a buffer where the created report has been stored\r
* \param ReportSize Size in bytes of the received HID report\r
*/\r
-void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize)\r
+void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,\r
+ void* ReportData, uint16_t ReportSize)\r
{\r
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports\r
}\r
void EVENT_USB_ConfigurationChanged(void);\r
void EVENT_USB_UnhandledControlPacket(void);\r
\r
- uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData);\r
- void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo,\r
+ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData);\r
+ void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, \r
void* ReportData, uint16_t ReportSize);\r
\r
#endif\r
.InterfaceNumber = 0x00,\r
.AlternateSetting = 0x00,\r
\r
- .TotalEndpoints = 2,\r
+ .TotalEndpoints = 1,\r
\r
.Class = 0x03,\r
.SubClass = 0x01,\r
.EndpointSize = KEYBOARD_EPSIZE,\r
.PollingIntervalMS = 0x04\r
},\r
-\r
- .KeyboardLEDsEndpoint = \r
- {\r
- .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
-\r
- .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | KEYBOARD_LEDS_EPNUM),\r
- .Attributes = EP_TYPE_INTERRUPT,\r
- .EndpointSize = KEYBOARD_EPSIZE,\r
- .PollingIntervalMS = 0x04\r
- }\r
};\r
\r
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests\r
USB_Descriptor_Interface_t Interface;\r
USB_Descriptor_HID_t KeyboardHID;\r
USB_Descriptor_Endpoint_t KeyboardEndpoint;\r
- USB_Descriptor_Endpoint_t KeyboardLEDsEndpoint;\r
} USB_Descriptor_Configuration_t;\r
\r
/* Macros: */\r
/** Endpoint number of the Keyboard HID reporting IN endpoint. */\r
#define KEYBOARD_EPNUM 1\r
-\r
- /** Endpoint number of the Keyboard HID reporting OUT endpoint. */\r
- #define KEYBOARD_LEDS_EPNUM 2\r
\r
/** Size in bytes of the Keyboard HID reporting IN and OUT endpoints. */ \r
#define KEYBOARD_EPSIZE 8\r
.ReportINEndpointNumber = KEYBOARD_EPNUM,\r
.ReportINEndpointSize = KEYBOARD_EPSIZE,\r
\r
- .ReportOUTEndpointNumber = KEYBOARD_LEDS_EPNUM,\r
- .ReportOUTEndpointSize = KEYBOARD_EPSIZE,\r
- \r
.ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t),\r
\r
.IdleCount = 500,\r
*\r
* \return Number of bytes written in the report (or zero if no report is to be sent\r
*/\r
-uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData)\r
+uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)\r
{\r
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;\r
\r
* \param ReportData Pointer to a buffer where the created report has been stored\r
* \param ReportSize Size in bytes of the received HID report\r
*/\r
-void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize)\r
+void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,\r
+ void* ReportData, uint16_t ReportSize)\r
{\r
uint8_t LEDMask = LEDS_NO_LEDS;\r
uint8_t* LEDReport = (uint8_t*)ReportData;\r
void EVENT_USB_ConfigurationChanged(void);\r
void EVENT_USB_UnhandledControlPacket(void);\r
\r
- uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData);\r
- void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo,\r
+ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData);\r
+ void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, \r
void* ReportData, uint16_t ReportSize);\r
\r
#endif\r
.InterfaceNumber = 0x00,\r
.AlternateSetting = 0x00,\r
\r
- .TotalEndpoints = 2,\r
+ .TotalEndpoints = 1,\r
\r
.Class = 0x03,\r
.SubClass = 0x01,\r
.PollingIntervalMS = 0x02\r
},\r
\r
- .KeyboardOutEndpoint = \r
- {\r
- .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},\r
-\r
- .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | KEYBOARD_OUT_EPNUM),\r
- .Attributes = EP_TYPE_INTERRUPT,\r
- .EndpointSize = HID_EPSIZE,\r
- .PollingIntervalMS = 0x02\r
- },\r
-\r
.MouseInterface = \r
{\r
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},\r
USB_Descriptor_Interface_t KeyboardInterface;\r
USB_Descriptor_HID_t KeyboardHID;\r
USB_Descriptor_Endpoint_t KeyboardInEndpoint;\r
- USB_Descriptor_Endpoint_t KeyboardOutEndpoint;\r
USB_Descriptor_Interface_t MouseInterface;\r
USB_Descriptor_HID_t MouseHID;\r
USB_Descriptor_Endpoint_t MouseInEndpoint;\r
/** Endpoint number of the Keyboard HID reporting IN endpoint. */\r
#define KEYBOARD_IN_EPNUM 1\r
\r
- /** Endpoint number of the Keyboard HID reporting OUT endpoint. */\r
- #define KEYBOARD_OUT_EPNUM 2\r
-\r
/** Endpoint number of the Mouse HID reporting IN endpoint. */\r
#define MOUSE_IN_EPNUM 3\r
\r
\r
.ReportINEndpointNumber = KEYBOARD_IN_EPNUM,\r
.ReportINEndpointSize = HID_EPSIZE,\r
-\r
- .ReportOUTEndpointNumber = KEYBOARD_OUT_EPNUM,\r
- .ReportOUTEndpointSize = HID_EPSIZE,\r
\r
.ReportINBufferSize = sizeof(USB_KeyboardReport_Data_t),\r
\r
.ReportINEndpointSize = HID_EPSIZE,\r
\r
.ReportINBufferSize = sizeof(USB_MouseReport_Data_t),\r
-\r
- .ReportOUTEndpointNumber = 0,\r
- .ReportOUTEndpointSize = 0,\r
};\r
\r
/** Main program entry point. This routine contains the overall program flow, including initial\r
*\r
* \return Number of bytes written in the report (or zero if no report is to be sent\r
*/\r
-uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData)\r
+uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)\r
{\r
uint8_t JoyStatus_LCL = Joystick_GetStatus();\r
uint8_t ButtonStatus_LCL = Buttons_GetStatus();\r
* \param ReportData Pointer to a buffer where the created report has been stored\r
* \param ReportSize Size in bytes of the received HID report\r
*/\r
-void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize)\r
+void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,\r
+ void* ReportData, uint16_t ReportSize)\r
{\r
if (HIDInterfaceInfo == &Keyboard_HID_Interface)\r
{\r
void EVENT_USB_ConfigurationChanged(void);\r
void EVENT_USB_UnhandledControlPacket(void);\r
\r
- uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData);\r
- void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo,\r
+ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData);\r
+ void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, \r
void* ReportData, uint16_t ReportSize);\r
\r
#endif\r
*\r
* \return Number of bytes written in the report (or zero if no report is to be sent\r
*/\r
-uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData)\r
+uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)\r
{\r
USB_MouseReport_Data_t* MouseReport = (USB_MouseReport_Data_t*)ReportData;\r
\r
* \param ReportData Pointer to a buffer where the created report has been stored\r
* \param ReportSize Size in bytes of the received HID report\r
*/\r
-void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize)\r
+void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,\r
+ void* ReportData, uint16_t ReportSize)\r
{\r
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports\r
}\r
void EVENT_USB_ConfigurationChanged(void);\r
void EVENT_USB_UnhandledControlPacket(void);\r
\r
- uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData);\r
- void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo,\r
+ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData);\r
+ void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, \r
void* ReportData, uint16_t ReportSize);\r
\r
#endif\r
return DataByte;\r
}\r
\r
-void USB_CDC_SendSerialLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask)\r
+void USB_CDC_SendSerialLineStateChange(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask)\r
{\r
Endpoint_SelectEndpoint(CDCInterfaceInfo->NotificationEndpointNumber);\r
\r
uint8_t NotificationEndpointNumber; /**< Endpoint number of the CDC interface's IN notification endpoint, if used */\r
uint16_t NotificationEndpointSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used */\r
\r
- uint8_t ControlLineState; /**< Current control line state, as set by the host */\r
+ uint8_t ControlLineState; /**< Current control line states, as set by the host */\r
\r
struct\r
{\r
* \ref EVENT_USB_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the\r
* given CDC interface is selected.\r
*\r
- * \param CDCInterfaceInfo Pointer to a structure containing an CDC Class configuration and state.\r
+ * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
*\r
* \return Boolean true if the endpoints were sucessfully configured, false otherwise\r
*/\r
/** Processes incomming control requests from the host, that are directed to the given CDC class interface. This should be\r
* linked to the library \ref EVENT_USB_UnhandledControlPacket() event.\r
*\r
- * \param CDCInterfaceInfo Pointer to a structure containing an CDC Class configuration and state.\r
+ * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
*/\r
void USB_CDC_ProcessControlPacket(USB_ClassInfo_CDC_t* CDCInterfaceInfo);\r
\r
/** General management task for a given CDC class interface, required for the correct operation of the interface. This should\r
* be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().\r
*\r
- * \param CDCInterfaceInfo Pointer to a structure containing an CDC Class configuration and state.\r
+ * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
*/\r
void USB_CDC_USBTask(USB_ClassInfo_CDC_t* CDCInterfaceInfo);\r
\r
- void EVENT_USB_CDC_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo);\r
- void EVENT_USB_CDC_ControLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo);\r
+ /** CDC class driver event for a line encoding change on a CDC interface. This event fires each time the host requests a\r
+ * line encoding change (containing the serial parity, baud and other configuration information) and may be hooked in the\r
+ * user program by declaring a handler function with the same name and parameters listed here. The new line encoding\r
+ * settings are available in the LineEncoding structure inside the CDC interface structure passed as a parameter.\r
+ *\r
+ * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ */\r
+ void EVENT_USB_CDC_LineEncodingChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo);\r
+ \r
+ /** CDC class driver event for a control line state change on a CDC interface. This event fires each time the host requests a\r
+ * control line state change (containing the virtual serial control line states, such as DTR) and may be hooked in the\r
+ * user program by declaring a handler function with the same name and parameters listed here. The new control line states\r
+ * are available in the ControlLineState value inside the CDC interface structure passed as a parameter, set as a mask of\r
+ * CDC_CONTROL_LINE_OUT_* masks.\r
+ *\r
+ * \param CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ */ \r
+ void EVENT_USB_CDC_ControLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo);\r
\r
void USB_CDC_SendString(USB_ClassInfo_CDC_t* CDCInterfaceInfo, char* Data, uint16_t Length);\r
void USB_CDC_SendByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint8_t Data);\r
uint16_t USB_CDC_BytesReceived(USB_ClassInfo_CDC_t* CDCInterfaceInfo);\r
uint8_t USB_CDC_ReceiveByte(USB_ClassInfo_CDC_t* CDCInterfaceInfo);\r
- void USB_CDC_SendSerialLineStateChanged(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask);\r
+ void USB_CDC_SendSerialLineStateChange(USB_ClassInfo_CDC_t* CDCInterfaceInfo, uint16_t LineStateMask);\r
\r
/* Disable C linkage for C++ Compilers: */\r
#if defined(__cplusplus)\r
\r
uint8_t ReportINData[HIDInterfaceInfo->ReportINBufferSize];\r
uint16_t ReportINSize;\r
+ uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF);\r
\r
memset(ReportINData, 0, sizeof(ReportINData));\r
-\r
- ReportINSize = CALLBACK_USB_HID_CreateNextHIDReport(HIDInterfaceInfo, ReportINData);\r
+ \r
+ ReportINSize = CALLBACK_USB_HID_CreateNextHIDReport(HIDInterfaceInfo, &ReportID, ReportINData);\r
\r
Endpoint_Write_Control_Stream_LE(ReportINData, ReportINSize);\r
Endpoint_ClearOUT();\r
\r
uint16_t ReportOUTSize = USB_ControlRequest.wLength;\r
uint8_t ReportOUTData[ReportOUTSize];\r
+ uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF);\r
\r
Endpoint_Read_Control_Stream_LE(ReportOUTData, ReportOUTSize);\r
Endpoint_ClearIN();\r
\r
- CALLBACK_USB_HID_ProcessReceivedHIDReport(HIDInterfaceInfo, ReportOUTData, ReportOUTSize);\r
+ CALLBACK_USB_HID_ProcessReceivedHIDReport(HIDInterfaceInfo, ReportID, ReportOUTData, ReportOUTSize);\r
}\r
\r
break;\r
return false;\r
}\r
\r
- if (HIDInterfaceInfo->ReportOUTEndpointNumber)\r
- {\r
- if (!(Endpoint_ConfigureEndpoint(HIDInterfaceInfo->ReportOUTEndpointNumber, EP_TYPE_INTERRUPT,\r
- ENDPOINT_DIR_OUT, HIDInterfaceInfo->ReportOUTEndpointSize, ENDPOINT_BANK_SINGLE)))\r
- {\r
- return false;\r
- }\r
- }\r
- \r
return true;\r
}\r
\r
\r
uint8_t ReportINData[HIDInterfaceInfo->ReportINBufferSize];\r
uint16_t ReportINSize;\r
+ uint8_t ReportID = 0;\r
\r
memset(ReportINData, 0, sizeof(ReportINData));\r
\r
- ReportINSize = CALLBACK_USB_HID_CreateNextHIDReport(HIDInterfaceInfo, ReportINData);\r
+ ReportINSize = CALLBACK_USB_HID_CreateNextHIDReport(HIDInterfaceInfo, &ReportID, ReportINData);\r
\r
if (ReportINSize)\r
- Endpoint_Write_Stream_LE(ReportINData, ReportINSize, NO_STREAM_CALLBACK);\r
- \r
- Endpoint_ClearIN();\r
- }\r
- \r
- if (HIDInterfaceInfo->ReportOUTEndpointNumber)\r
- {\r
- Endpoint_SelectEndpoint(HIDInterfaceInfo->ReportOUTEndpointNumber);\r
- \r
- if (Endpoint_IsOUTReceived())\r
{\r
- uint16_t ReportOUTSize = Endpoint_BytesInEndpoint();\r
- uint8_t ReportOUTData[ReportOUTSize];\r
- \r
- if (ReportOUTSize)\r
- Endpoint_Read_Stream_LE(ReportOUTData, ReportOUTSize, NO_STREAM_CALLBACK);\r
- \r
- CALLBACK_USB_HID_ProcessReceivedHIDReport(HIDInterfaceInfo, ReportOUTData, ReportOUTSize);\r
- \r
- Endpoint_ClearOUT();\r
+ if (ReportID)\r
+ Endpoint_Write_Stream_LE(&ReportID, sizeof(ReportID), NO_STREAM_CALLBACK);\r
+\r
+ Endpoint_Write_Stream_LE(ReportINData, ReportINSize, NO_STREAM_CALLBACK);\r
}\r
+ \r
+ Endpoint_ClearIN();\r
}\r
}\r
\r
uint8_t ReportINEndpointNumber; /**< Endpoint number of the HID interface's IN report endpoint */\r
uint16_t ReportINEndpointSize; /**< Size in bytes of the HID interface's IN report endpoint */\r
-\r
- uint8_t ReportOUTEndpointNumber; /**< Endpoint number of the HID interface's OUT report endpoint, if used */\r
- uint16_t ReportOUTEndpointSize; /**< Size in bytes of the HID interface's OUT report endpoint, if used */\r
\r
uint8_t ReportINBufferSize;\r
\r
void USB_HID_ProcessControlPacket(USB_ClassInfo_HID_t* HIDInterfaceInfo);\r
void USB_HID_USBTask(USB_ClassInfo_HID_t* HIDInterfaceInfo);\r
\r
- uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData);\r
- void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize);\r
+ /** HID class driver callback for the user creation of a HID input report. This callback may fire in response to either\r
+ * HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback the\r
+ * user is responsible for the creation of the next HID input report to be sent to the host.\r
+ *\r
+ * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.\r
+ * \param ReportID If preset to a non-zero value, this is the report ID being requested by the host. If zero, this should\r
+ * be set to the report ID of the generated HID input report. If multiple reports are not sent via the\r
+ * given HID interface, this parameter should be ignored.\r
+ * \param ReportData Pointer to a buffer where the generated HID report should be stored.\r
+ *\r
+ * \return Number of bytes in the generated input report, or zero if no report is to be sent\r
+ */\r
+ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData);\r
+\r
+ /** HID class driver callback for the user processing of a received HID input report. This callback may fire in response to\r
+ * either HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback\r
+ * the user is responsible for the processing of the received HID output report from the host.\r
+ *\r
+ * \param HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.\r
+ * \param ReportID Report ID of the received output report. If multiple reports are not received via the given HID\r
+ * interface, this parameter should be ignored.\r
+ * \param ReportData Pointer to a buffer where the received HID report is stored.\r
+ */\r
+ void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID, void* ReportData, uint16_t ReportSize);\r
\r
/* Disable C linkage for C++ Compilers: */\r
#if defined(__cplusplus)\r
/** MIDI command for a note off (deactivation) event */\r
#define MIDI_COMMAND_NOTE_OFF 0x08\r
\r
- /** Standard key press velocity value used for all note events, as no pressure sensor is mounted */\r
+ /** Standard key press velocity value used for all note events */\r
#define MIDI_STANDARD_VELOCITY 64\r
\r
/** Convenience macro. MIDI channels are numbered from 1-10 (natural numbers) however the logical channel\r
*\r
* \return Number of bytes in the created report\r
*/\r
-uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData)\r
+uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData)\r
{\r
static bool IsKeyReleaseReport;\r
static bool IsNewlineReport;\r
* \param ReportData Pointer to the report buffer where the received report is stored\r
* \param ReportSize Size in bytes of the report received from the host\r
*/\r
-void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize)\r
+void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,\r
+ void* ReportData, uint16_t ReportSize)\r
{\r
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports\r
}\r
void EVENT_USB_ConfigurationChanged(void);\r
void EVENT_USB_UnhandledControlPacket(void);\r
\r
- uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData);\r
- void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo,\r
- void* ReportData, uint16_t ReportSize);\r
+ uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t* ReportID, void* ReportData);\r
+ void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, uint8_t ReportID,\r
+ void* ReportData, uint16_t ReportSize);\r
\r
#endif\r