Skip to content

Commit

Permalink
Merge branch 'feature/HID-transfer-increase' into feature/gd32f4
Browse files Browse the repository at this point in the history
  • Loading branch information
RockyZeroFour committed Feb 16, 2024
2 parents 239beb9 + 1513d53 commit af6db56
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/device/hid_boot_interface/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void tud_hid_set_protocol_cb(uint8_t instance, uint8_t protocol)
// Invoked when sent REPORT successfully to host
// Application can use this to send the next report
// Note: For composite reports, report[0] is report ID
void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint8_t len)
void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint16_t len)
{
(void) instance;
(void) report;
Expand Down
2 changes: 1 addition & 1 deletion examples/device/hid_composite/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void hid_task(void)
// Invoked when sent REPORT successfully to host
// Application can use this to send the next report
// Note: For composite reports, report[0] is report ID
void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint8_t len)
void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint16_t len)
{
(void) instance;
(void) len;
Expand Down
2 changes: 1 addition & 1 deletion examples/device/hid_composite_freertos/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ void hid_task(void* param)
// Invoked when sent REPORT successfully to host
// Application can use this to send the next report
// Note: For composite reports, report[0] is report ID
void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint8_t len)
void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint16_t len)
{
(void) instance;
(void) len;
Expand Down
10 changes: 5 additions & 5 deletions src/class/hid/hid_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ bool tud_hid_n_ready(uint8_t instance)
return tud_ready() && (ep_in != 0) && !usbd_edpt_busy(TUD_OPT_RHPORT, ep_in);
}

bool tud_hid_n_report(uint8_t instance, uint8_t report_id, void const* report, uint8_t len)
bool tud_hid_n_report(uint8_t instance, uint8_t report_id, void const* report, uint16_t len)
{
uint8_t const rhport = 0;
hidd_interface_t * p_hid = &_hidd_itf[instance];
Expand All @@ -91,15 +91,15 @@ bool tud_hid_n_report(uint8_t instance, uint8_t report_id, void const* report, u
// prepare data
if (report_id)
{
len = tu_min8(len, CFG_TUD_HID_EP_BUFSIZE-1);
len = tu_min16(len, CFG_TUD_HID_EP_BUFSIZE-1);

p_hid->epin_buf[0] = report_id;
memcpy(p_hid->epin_buf+1, report, len);
len++;
}else
{
// If report id = 0, skip ID field
len = tu_min8(len, CFG_TUD_HID_EP_BUFSIZE);
len = tu_min16(len, CFG_TUD_HID_EP_BUFSIZE);
memcpy(p_hid->epin_buf, report, len);
}

Expand Down Expand Up @@ -401,13 +401,13 @@ bool hidd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
{
if (tud_hid_report_complete_cb)
{
tud_hid_report_complete_cb(instance, p_hid->epin_buf, (uint8_t) xferred_bytes);
tud_hid_report_complete_cb(instance, p_hid->epin_buf, (uint16_t) xferred_bytes);
}
}
// Received report
else if (ep_addr == p_hid->ep_out)
{
tud_hid_set_report_cb(instance, 0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, xferred_bytes);
tud_hid_set_report_cb(instance, 0, HID_REPORT_TYPE_INVALID, p_hid->epout_buf, (uint16_t) xferred_bytes);
TU_ASSERT(usbd_edpt_xfer(rhport, p_hid->ep_out, p_hid->epout_buf, sizeof(p_hid->epout_buf)));
}

Expand Down
8 changes: 4 additions & 4 deletions src/class/hid/hid_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ uint8_t tud_hid_n_interface_protocol(uint8_t instance);
uint8_t tud_hid_n_get_protocol(uint8_t instance);

// Send report to host
bool tud_hid_n_report(uint8_t instance, uint8_t report_id, void const* report, uint8_t len);
bool tud_hid_n_report(uint8_t instance, uint8_t report_id, void const* report, uint16_t len);

// KEYBOARD: convenient helper to send keyboard report if application
// use template layout report as defined by hid_keyboard_report_t
Expand All @@ -82,7 +82,7 @@ bool tud_hid_n_gamepad_report(uint8_t instance, uint8_t report_id, int8_t x, int
static inline bool tud_hid_ready(void);
static inline uint8_t tud_hid_interface_protocol(void);
static inline uint8_t tud_hid_get_protocol(void);
static inline bool tud_hid_report(uint8_t report_id, void const* report, uint8_t len);
static inline bool tud_hid_report(uint8_t report_id, void const* report, uint16_t len);
static inline bool tud_hid_keyboard_report(uint8_t report_id, uint8_t modifier, uint8_t keycode[6]);
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);
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);
Expand Down Expand Up @@ -116,7 +116,7 @@ TU_ATTR_WEAK bool tud_hid_set_idle_cb(uint8_t instance, uint8_t idle_rate);
// Invoked when sent REPORT successfully to host
// Application can use this to send the next report
// Note: For composite reports, report[0] is report ID
TU_ATTR_WEAK void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint8_t len);
TU_ATTR_WEAK void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint16_t len);


//--------------------------------------------------------------------+
Expand All @@ -137,7 +137,7 @@ static inline uint8_t tud_hid_get_protocol(void)
return tud_hid_n_get_protocol(0);
}

static inline bool tud_hid_report(uint8_t report_id, void const* report, uint8_t len)
static inline bool tud_hid_report(uint8_t report_id, void const* report, uint16_t len)
{
return tud_hid_n_report(0, report_id, report, len);
}
Expand Down

0 comments on commit af6db56

Please sign in to comment.