Skip to content

Commit

Permalink
New function to get itfnum from HID instance
Browse files Browse the repository at this point in the history
- Function to get the interface number for a given HID instance
  • Loading branch information
RockyZeroFour committed Sep 23, 2024
1 parent fb333bf commit 6c20137
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/class/hid/hid_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ static inline uint8_t get_index_by_itfnum(uint8_t itf_num)
//--------------------------------------------------------------------+
// APPLICATION API
//--------------------------------------------------------------------+
uint8_t tud_hid_get_itfnum_by_instance(uint8_t index)
{
// Only return the interface number when the instance is valid
if ( _hidd_itf[index].ep_in || _hidd_itf[index].ep_out ) return _hidd_itf[index].itf_num;

return 0xFF;
}

bool tud_hid_n_ready(uint8_t instance)
{
uint8_t const ep_in = _hidd_itf[instance].ep_in;
Expand Down
3 changes: 3 additions & 0 deletions src/class/hid/hid_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
// CFG_TUD_HID > 1
//--------------------------------------------------------------------+

// Get the interface number for the HID instance index
uint8_t tud_hid_get_itfnum_by_instance(uint8_t index);

// Check if the interface is ready to use
bool tud_hid_n_ready(uint8_t instance);

Expand Down

0 comments on commit 6c20137

Please sign in to comment.