Skip to content

Commit 556b5d5

Browse files
committed
change report len in hid API from uint8_t to uint16_t
since HS interrupt endpoint can be up to 1024, 8-bit is not enough. affected APIs are: - tud_hid_n_report() / tud_hid_report() - tud_hid_report_complete_cb()
1 parent 0b3503c commit 556b5d5

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

Diff for: examples/device/hid_boot_interface/src/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ void tud_hid_set_protocol_cb(uint8_t instance, uint8_t protocol)
181181
// Invoked when sent REPORT successfully to host
182182
// Application can use this to send the next report
183183
// Note: For composite reports, report[0] is report ID
184-
void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint8_t len)
184+
void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint16_t len)
185185
{
186186
(void) instance;
187187
(void) report;

Diff for: examples/device/hid_composite/src/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ void hid_task(void)
225225
// Invoked when sent REPORT successfully to host
226226
// Application can use this to send the next report
227227
// Note: For composite reports, report[0] is report ID
228-
void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint8_t len)
228+
void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint16_t len)
229229
{
230230
(void) instance;
231231
(void) len;

Diff for: examples/device/hid_composite_freertos/src/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ void hid_task(void* param)
294294
// Invoked when sent REPORT successfully to host
295295
// Application can use this to send the next report
296296
// Note: For composite reports, report[0] is report ID
297-
void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint8_t len)
297+
void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint16_t len)
298298
{
299299
(void) instance;
300300
(void) len;

Diff for: src/class/hid/hid_device.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ bool tud_hid_n_ready(uint8_t instance)
8181
return tud_ready() && (ep_in != 0) && !usbd_edpt_busy(rhport, ep_in);
8282
}
8383

84-
bool tud_hid_n_report(uint8_t instance, uint8_t report_id, void const* report, uint8_t len)
84+
bool tud_hid_n_report(uint8_t instance, uint8_t report_id, void const* report, uint16_t len)
8585
{
8686
uint8_t const rhport = 0;
8787
hidd_interface_t * p_hid = &_hidd_itf[instance];
@@ -92,15 +92,15 @@ bool tud_hid_n_report(uint8_t instance, uint8_t report_id, void const* report, u
9292
// prepare data
9393
if (report_id)
9494
{
95-
len = tu_min8(len, CFG_TUD_HID_EP_BUFSIZE-1);
95+
len = tu_min16(len, CFG_TUD_HID_EP_BUFSIZE-1);
9696

9797
p_hid->epin_buf[0] = report_id;
9898
memcpy(p_hid->epin_buf+1, report, len);
9999
len++;
100100
}else
101101
{
102102
// If report id = 0, skip ID field
103-
len = tu_min8(len, CFG_TUD_HID_EP_BUFSIZE);
103+
len = tu_min16(len, CFG_TUD_HID_EP_BUFSIZE);
104104
memcpy(p_hid->epin_buf, report, len);
105105
}
106106

@@ -402,7 +402,7 @@ bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
402402
{
403403
if (tud_hid_report_complete_cb)
404404
{
405-
tud_hid_report_complete_cb(instance, p_hid->epin_buf, (uint8_t) xferred_bytes);
405+
tud_hid_report_complete_cb(instance, p_hid->epin_buf, (uint16_t) xferred_bytes);
406406
}
407407
}
408408
// Received report

Diff for: src/class/hid/hid_device.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ uint8_t tud_hid_n_interface_protocol(uint8_t instance);
6262
uint8_t tud_hid_n_get_protocol(uint8_t instance);
6363

6464
// Send report to host
65-
bool tud_hid_n_report(uint8_t instance, uint8_t report_id, void const* report, uint8_t len);
65+
bool tud_hid_n_report(uint8_t instance, uint8_t report_id, void const* report, uint16_t len);
6666

6767
// KEYBOARD: convenient helper to send keyboard report if application
6868
// use template layout report as defined by hid_keyboard_report_t
@@ -82,7 +82,7 @@ bool tud_hid_n_gamepad_report(uint8_t instance, uint8_t report_id, int8_t x, int
8282
static inline bool tud_hid_ready(void);
8383
static inline uint8_t tud_hid_interface_protocol(void);
8484
static inline uint8_t tud_hid_get_protocol(void);
85-
static inline bool tud_hid_report(uint8_t report_id, void const* report, uint8_t len);
85+
static inline bool tud_hid_report(uint8_t report_id, void const* report, uint16_t len);
8686
static inline bool tud_hid_keyboard_report(uint8_t report_id, uint8_t modifier, uint8_t keycode[6]);
8787
static inline bool tud_hid_mouse_report(uint8_t report_id, uint8_t buttons, int8_t x, int8_t y, int8_t vertical, int8_t horizontal);
8888
static inline bool tud_hid_gamepad_report(uint8_t report_id, int8_t x, int8_t y, int8_t z, int8_t rz, int8_t rx, int8_t ry, uint8_t hat, uint32_t buttons);
@@ -116,7 +116,7 @@ TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t instance, uint8_t idle_rate);
116116
// Invoked when sent REPORT successfully to host
117117
// Application can use this to send the next report
118118
// Note: For composite reports, report[0] is report ID
119-
TU_ATTR_WEAK void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint8_t len);
119+
TU_ATTR_WEAK void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint16_t len);
120120

121121

122122
//--------------------------------------------------------------------+
@@ -137,7 +137,7 @@ static inline uint8_t tud_hid_get_protocol(void)
137137
return tud_hid_n_get_protocol(0);
138138
}
139139

140-
static inline bool tud_hid_report(uint8_t report_id, void const* report, uint8_t len)
140+
static inline bool tud_hid_report(uint8_t report_id, void const* report, uint16_t len)
141141
{
142142
return tud_hid_n_report(0, report_id, report, len);
143143
}

0 commit comments

Comments
 (0)