hathach 5 лет назад
Родитель
Сommit
13abcb953f

+ 2 - 2
examples/device/hid_multiple_interface/src/main.c

@@ -166,7 +166,7 @@ void hid_task(void)
 // Invoked when received GET_REPORT control request
 // Invoked when received GET_REPORT control request
 // Application must fill buffer report's content and return its length.
 // Application must fill buffer report's content and return its length.
 // Return zero will cause the stack to STALL request
 // Return zero will cause the stack to STALL request
-uint16_t tud_hid_n_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
+uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
 {
 {
   // TODO not Implemented
   // TODO not Implemented
   (void) itf;
   (void) itf;
@@ -180,7 +180,7 @@ uint16_t tud_hid_n_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type
 
 
 // Invoked when received SET_REPORT control request or
 // Invoked when received SET_REPORT control request or
 // received data on OUT endpoint ( Report ID = 0, Type = 0 )
 // received data on OUT endpoint ( Report ID = 0, Type = 0 )
-void tud_hid_n_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize)
+void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize)
 {
 {
   // TODO set LED based on CAPLOCK, NUMLOCK etc...
   // TODO set LED based on CAPLOCK, NUMLOCK etc...
   (void) itf;
   (void) itf;

+ 1 - 1
examples/device/hid_multiple_interface/src/usb_descriptors.c

@@ -83,7 +83,7 @@ uint8_t const desc_hid_report2[] =
 // Invoked when received GET HID REPORT DESCRIPTOR
 // Invoked when received GET HID REPORT DESCRIPTOR
 // Application return pointer to descriptor
 // Application return pointer to descriptor
 // Descriptor contents must exist long enough for transfer to complete
 // Descriptor contents must exist long enough for transfer to complete
-uint8_t const * tud_hid_n_descriptor_report_cb(uint8_t itf)
+uint8_t const * tud_hid_descriptor_report_cb(uint8_t itf)
 {
 {
   if (itf == 0)
   if (itf == 0)
   {
   {

+ 4 - 4
src/class/hid/hid_device.c

@@ -250,7 +250,7 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request
     else if (request->bRequest == TUSB_REQ_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT)
     else if (request->bRequest == TUSB_REQ_GET_DESCRIPTOR && desc_type == HID_DESC_TYPE_REPORT)
     {
     {
       #if CFG_TUD_HID>1
       #if CFG_TUD_HID>1
-      uint8_t const * desc_report = tud_hid_n_descriptor_report_cb(hid_itf);
+      uint8_t const * desc_report = tud_hid_descriptor_report_cb(hid_itf);
       #else
       #else
       uint8_t const * desc_report = tud_hid_descriptor_report_cb();
       uint8_t const * desc_report = tud_hid_descriptor_report_cb();
       #endif
       #endif
@@ -273,7 +273,7 @@ bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * request
         uint8_t const report_id   = tu_u16_low(request->wValue);
         uint8_t const report_id   = tu_u16_low(request->wValue);
 
 
         #if CFG_TUD_HID>1
         #if CFG_TUD_HID>1
-        uint16_t xferlen  = tud_hid_n_get_report_cb(hid_itf, report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength);
+        uint16_t xferlen  = tud_hid_get_report_cb(hid_itf, report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength);
         #else
         #else
         uint16_t xferlen  = tud_hid_get_report_cb(report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength);
         uint16_t xferlen  = tud_hid_get_report_cb(report_id, (hid_report_type_t) report_type, p_hid->epin_buf, request->wLength);
         #endif
         #endif
@@ -347,7 +347,7 @@ bool hidd_control_complete(uint8_t rhport, tusb_control_request_t const * p_requ
     #if CFG_TUD_HID>1
     #if CFG_TUD_HID>1
     uint8_t const hid_itf = get_hid_index_by_itfnum((uint8_t)p_request->wIndex);
     uint8_t const hid_itf = get_hid_index_by_itfnum((uint8_t)p_request->wIndex);
     TU_VERIFY(hid_itf<0xFF);
     TU_VERIFY(hid_itf<0xFF);
-    tud_hid_n_set_report_cb(hid_itf, report_id, (hid_report_type_t) report_type, p_hid->epout_buf, p_request->wLength);
+    tud_hid_set_report_cb(hid_itf, report_id, (hid_report_type_t) report_type, p_hid->epout_buf, p_request->wLength);
     #else
     #else
     tud_hid_set_report_cb(report_id, (hid_report_type_t) report_type, p_hid->epout_buf, p_request->wLength);
     tud_hid_set_report_cb(report_id, (hid_report_type_t) report_type, p_hid->epout_buf, p_request->wLength);
     #endif
     #endif
@@ -373,7 +373,7 @@ bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
   if (ep_addr == p_hid->ep_out)
   if (ep_addr == p_hid->ep_out)
   {
   {
     #if CFG_TUD_HID>1
     #if CFG_TUD_HID>1
-    tud_hid_n_set_report_cb(itf,  0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes);
+    tud_hid_set_report_cb(itf,  0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes);
     #else
     #else
     tud_hid_set_report_cb(0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes);
     tud_hid_set_report_cb(0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes);
     #endif
     #endif

+ 17 - 15
src/class/hid/hid_device.h

@@ -84,30 +84,20 @@ static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8
 // Callbacks (Weak is optional)
 // Callbacks (Weak is optional)
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+
 
 
+#if CFG_TUD_HID > 1
+
 // Invoked when received GET HID REPORT DESCRIPTOR request
 // Invoked when received GET HID REPORT DESCRIPTOR request
 // Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
 // Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
-#if CFG_TUD_HID>1
-uint8_t const * tud_hid_n_descriptor_report_cb(uint8_t itf);
-#else
-uint8_t const * tud_hid_descriptor_report_cb(void);
-#endif
+uint8_t const * tud_hid_descriptor_report_cb(uint8_t itf);
 
 
 // Invoked when received GET_REPORT control request
 // Invoked when received GET_REPORT control request
 // Application must fill buffer report's content and return its length.
 // Application must fill buffer report's content and return its length.
 // Return zero will cause the stack to STALL request
 // Return zero will cause the stack to STALL request
-#if CFG_TUD_HID>1
-uint16_t tud_hid_n_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
-#else
-uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
-#endif
+uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
 
 
 // Invoked when received SET_REPORT control request or
 // Invoked when received SET_REPORT control request or
 // received data on OUT endpoint ( Report ID = 0, Type = 0 )
 // received data on OUT endpoint ( Report ID = 0, Type = 0 )
-#if CFG_TUD_HID>1
-void tud_hid_n_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
-#else
-void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
-#endif
+void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
 
 
 // Invoked when received SET_PROTOCOL request ( mode switch Boot <-> Report )
 // Invoked when received SET_PROTOCOL request ( mode switch Boot <-> Report )
 TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode);
 TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode);
@@ -117,6 +107,18 @@ TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode);
 // - Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms).
 // - Idle Rate > 0 : skip duplication, but send at least 1 report every idle rate (in unit of 4 ms).
 TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate);
 TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate);
 
 
+#else
+
+uint8_t const * tud_hid_descriptor_report_cb(void);
+uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
+void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
+
+TU_ATTR_WEAK void tud_hid_boot_mode_cb(uint8_t boot_mode);
+TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t idle_rate);
+
+#endif
+
+
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+
 // Inline Functions
 // Inline Functions
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+