implement tuh_hid_receive_ready() and tuh_hid_send_ready()
This commit is contained in:
@@ -331,6 +331,15 @@ static bool _hidh_set_idle(uint8_t daddr, uint8_t itf_num, uint16_t idle_rate, t
|
|||||||
// Interrupt Endpoint API
|
// Interrupt Endpoint API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
|
// Check if HID interface is ready to receive report
|
||||||
|
bool tuh_hid_receive_ready(uint8_t dev_addr, uint8_t idx)
|
||||||
|
{
|
||||||
|
hidh_interface_t* p_hid = get_hid_itf(dev_addr, idx);
|
||||||
|
TU_VERIFY(p_hid);
|
||||||
|
|
||||||
|
return !usbh_edpt_busy(dev_addr, p_hid->ep_in);
|
||||||
|
}
|
||||||
|
|
||||||
bool tuh_hid_receive_report(uint8_t daddr, uint8_t idx)
|
bool tuh_hid_receive_report(uint8_t daddr, uint8_t idx)
|
||||||
{
|
{
|
||||||
hidh_interface_t* p_hid = get_hid_itf(daddr, idx);
|
hidh_interface_t* p_hid = get_hid_itf(daddr, idx);
|
||||||
@@ -348,13 +357,13 @@ bool tuh_hid_receive_report(uint8_t daddr, uint8_t idx)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//bool tuh_n_hid_n_ready(uint8_t dev_addr, uint8_t instance)
|
bool tuh_hid_send_ready(uint8_t dev_addr, uint8_t idx)
|
||||||
//{
|
{
|
||||||
// TU_VERIFY(tuh_n_hid_n_mounted(dev_addr, instance));
|
hidh_interface_t* p_hid = get_hid_itf(dev_addr, idx);
|
||||||
//
|
TU_VERIFY(p_hid);
|
||||||
// hidh_interface_t* hid_itf = get_instance(dev_addr, instance);
|
|
||||||
// return !usbh_edpt_busy(dev_addr, hid_itf->ep_in);
|
return !usbh_edpt_busy(dev_addr, p_hid->ep_out);
|
||||||
//}
|
}
|
||||||
|
|
||||||
bool tuh_hid_send_report(uint8_t daddr, uint8_t idx, uint8_t report_id, const void* report, uint16_t len)
|
bool tuh_hid_send_report(uint8_t daddr, uint8_t idx, uint8_t report_id, const void* report, uint16_t len)
|
||||||
{
|
{
|
||||||
|
@@ -62,7 +62,7 @@ typedef struct
|
|||||||
// Interface API
|
// Interface API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// Get the number of mounted HID interfaces of a device
|
// Get the total number of mounted HID interfaces of a device
|
||||||
uint8_t tuh_hid_itf_get_count(uint8_t dev_addr);
|
uint8_t tuh_hid_itf_get_count(uint8_t dev_addr);
|
||||||
|
|
||||||
// Get all mounted interfaces across devices
|
// Get all mounted interfaces across devices
|
||||||
@@ -109,14 +109,17 @@ bool tuh_hid_set_report(uint8_t dev_addr, uint8_t idx, uint8_t report_id, uint8_
|
|||||||
// Interrupt Endpoint API
|
// Interrupt Endpoint API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// Check if the interface is ready to use
|
// Check if HID interface is ready to receive report
|
||||||
//bool tuh_n_hid_n_ready(uint8_t dev_addr, uint8_t idx);
|
bool tuh_hid_receive_ready(uint8_t dev_addr, uint8_t idx);
|
||||||
|
|
||||||
// Try to receive next report on Interrupt Endpoint. Immediately return
|
// Try to receive next report on Interrupt Endpoint. Immediately return
|
||||||
// - true If succeeded, tuh_hid_report_received_cb() callback will be invoked when report is available
|
// - true If succeeded, tuh_hid_report_received_cb() callback will be invoked when report is available
|
||||||
// - false if failed to queue the transfer e.g endpoint is busy
|
// - false if failed to queue the transfer e.g endpoint is busy
|
||||||
bool tuh_hid_receive_report(uint8_t dev_addr, uint8_t idx);
|
bool tuh_hid_receive_report(uint8_t dev_addr, uint8_t idx);
|
||||||
|
|
||||||
|
// Check if HID interface is ready to send report
|
||||||
|
bool tuh_hid_send_ready(uint8_t dev_addr, uint8_t idx);
|
||||||
|
|
||||||
// Send report using interrupt endpoint
|
// Send report using interrupt endpoint
|
||||||
// If report_id > 0 (composite), it will be sent as 1st byte, then report contents. Otherwise only report content is sent.
|
// If report_id > 0 (composite), it will be sent as 1st byte, then report contents. Otherwise only report content is sent.
|
||||||
bool tuh_hid_send_report(uint8_t dev_addr, uint8_t idx, uint8_t report_id, const void* report, uint16_t len);
|
bool tuh_hid_send_report(uint8_t dev_addr, uint8_t idx, uint8_t report_id, const void* report, uint16_t len);
|
||||||
|
Reference in New Issue
Block a user