rename tuh_device_is_configured() to tuh_device_configured()
- remove tuh_device_get_state() - more hid mouse clean up
This commit is contained in:
		| @@ -104,7 +104,7 @@ tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_int | ||||
| { | ||||
|   //------------- parameters validation -------------// | ||||
|   // TODO change to use is configured function | ||||
|   TU_ASSERT(TUSB_DEVICE_STATE_CONFIGURED == tuh_device_get_state(dev_addr), TUSB_ERROR_DEVICE_NOT_READY); | ||||
|   TU_ASSERT(tuh_device_configured(dev_addr), TUSB_ERROR_DEVICE_NOT_READY); | ||||
|   TU_VERIFY(report, TUSB_ERROR_INVALID_PARA); | ||||
|   TU_VERIFY(!hcd_edpt_busy(dev_addr, p_hid->ep_in), TUSB_ERROR_INTERFACE_IS_BUSY); | ||||
|  | ||||
| @@ -113,32 +113,45 @@ tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_int | ||||
|   return TUSB_ERROR_NONE; | ||||
| } | ||||
|  | ||||
| //bool tuh_n_hid_n_mounted(uint8_t daddr, uint8_t instance) | ||||
| //{ | ||||
| // | ||||
| //} | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // KEYBOARD | ||||
| //--------------------------------------------------------------------+ | ||||
|  | ||||
| bool tuh_n_hid_n_keyboard_mounted(uint8_t dev_addr, uint8_t instance) | ||||
| bool tuh_n_hid_n_mounted(uint8_t daddr, uint8_t instance) | ||||
| { | ||||
|   hidh_interface_t* hid_itf = get_instance(dev_addr, instance); | ||||
|   hidh_interface_t* hid_itf = get_instance(daddr, instance); | ||||
|  | ||||
|   // TODO check rid_keyboard | ||||
|   return tuh_device_is_configured(dev_addr) && (hid_itf->ep_in != 0); | ||||
|   return tuh_device_configured(daddr) && (hid_itf->ep_in != 0); | ||||
| } | ||||
|  | ||||
| bool tuh_n_hid_n_keyboard_mounted(uint8_t daddr, uint8_t instance) | ||||
| { | ||||
|   hidh_interface_t* hid_itf = get_instance(daddr, instance); | ||||
|  | ||||
|   // TODO check rid_keyboard | ||||
|   return tuh_device_configured(daddr) && (hid_itf->ep_in != 0); | ||||
| } | ||||
|  | ||||
| tusb_error_t tuh_hid_keyboard_get_report(uint8_t dev_addr, void* buffer) | ||||
| { | ||||
|   uint8_t itf = 0; | ||||
|   hidh_interface_t* hid_itf = get_instance(dev_addr, itf); | ||||
|   uint8_t inst = 0; | ||||
|   hidh_interface_t* hid_itf = get_instance(dev_addr, inst); | ||||
|  | ||||
|   return hidh_interface_get_report(dev_addr, buffer, hid_itf); | ||||
| } | ||||
|  | ||||
| bool tuh_hid_keyboard_is_busy(uint8_t dev_addr) | ||||
| { | ||||
|   uint8_t instance = 0; | ||||
|   hidh_interface_t* hid_itf = get_instance(dev_addr, instance); | ||||
|   uint8_t inst = 0; | ||||
|   hidh_interface_t* hid_itf = get_instance(dev_addr, inst); | ||||
|  | ||||
|   return tuh_n_hid_n_keyboard_mounted(dev_addr, instance) && hcd_edpt_busy(dev_addr, hid_itf->ep_in); | ||||
|   return tuh_n_hid_n_keyboard_mounted(dev_addr, inst) && hcd_edpt_busy(dev_addr, hid_itf->ep_in); | ||||
| } | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| @@ -149,14 +162,15 @@ bool tuh_hid_keyboard_is_busy(uint8_t dev_addr) | ||||
| static hidh_interface_t mouseh_data[CFG_TUSB_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1 | ||||
|  | ||||
| //------------- Public API -------------// | ||||
| bool tuh_hid_mouse_mounted(uint8_t dev_addr) | ||||
| bool tuh_n_hid_n_mouse_mounted(uint8_t dev_addr, uint8_t instance) | ||||
| { | ||||
|   return tuh_device_is_configured(dev_addr) && (mouseh_data[dev_addr-1].ep_in != 0); | ||||
| //  hidh_interface_t* hid_itf = get_instance(dev_addr, instance); | ||||
|   return tuh_device_configured(dev_addr) && (mouseh_data[dev_addr-1].ep_in != 0); | ||||
| } | ||||
|  | ||||
| bool tuh_hid_mouse_is_busy(uint8_t dev_addr) | ||||
| { | ||||
|   return  tuh_hid_mouse_mounted(dev_addr) && hcd_edpt_busy(dev_addr, mouseh_data[dev_addr-1].ep_in); | ||||
|   return  tuh_n_hid_n_mouse_mounted(dev_addr, 0) && hcd_edpt_busy(dev_addr, mouseh_data[dev_addr-1].ep_in); | ||||
| } | ||||
|  | ||||
| tusb_error_t tuh_hid_mouse_get_report(uint8_t dev_addr, void * report) | ||||
|   | ||||
| @@ -60,10 +60,14 @@ | ||||
| // Get the number of HID instances | ||||
| uint8_t tuh_n_hid_instance_count(uint8_t daddr); | ||||
|  | ||||
| // Check if HID instance has keyboard | ||||
| // Check if HID instance is mounted | ||||
| //bool tuh_n_hid_n_mounted(uint8_t daddr, uint8_t instance); | ||||
|  | ||||
| // Check if HID instance with Keyboard is mounted | ||||
| bool tuh_n_hid_n_keyboard_mounted(uint8_t daddr, uint8_t instance); | ||||
|  | ||||
|  | ||||
| // Check if HID instance with Mouse is mounted | ||||
| bool tuh_n_hid_n_mouse_mounted(uint8_t dev_addr, uint8_t instance); | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
| // Application API (Single device) | ||||
| @@ -101,10 +105,6 @@ TU_ATTR_WEAK void tuh_hid_unmounted_cb(uint8_t dev_addr, uint8_t instance); | ||||
|  *  The interface API includes status checking function, data transferring function and callback functions | ||||
|  *  @{ */ | ||||
|  | ||||
| // TODO used weak attr if build failed without KEYBOARD enabled | ||||
| // TODO remove | ||||
| extern uint8_t const hid_keycode_to_ascii_tbl[2][128]; | ||||
|  | ||||
| /** \brief      Check if device supports Keyboard interface or not | ||||
|  * \param[in]   dev_addr    device address | ||||
|  * \retval      true if device supports Keyboard interface | ||||
| @@ -170,13 +170,6 @@ void tuh_hid_keyboard_unmounted_cb(uint8_t dev_addr); | ||||
|  *  The interface API includes status checking function, data transferring function and callback functions | ||||
|  *  @{ */ | ||||
|  | ||||
| /** \brief      Check if device supports Mouse interface or not | ||||
|  * \param[in]   dev_addr    device address | ||||
|  * \retval      true if device supports Mouse interface | ||||
|  * \retval      false if device does not support Mouse interface or is not mounted | ||||
|  */ | ||||
| bool          tuh_hid_mouse_mounted(uint8_t dev_addr); | ||||
|  | ||||
| /** \brief      Check if the interface is currently busy or not | ||||
|  * \param[in]   dev_addr device address | ||||
|  * \retval      true if the interface is busy meaning the stack is still transferring/waiting data from/to device | ||||
|   | ||||
| @@ -152,10 +152,9 @@ uint8_t* usbh_get_enum_buf(void) | ||||
| //--------------------------------------------------------------------+ | ||||
| // PUBLIC API (Parameter Verification is required) | ||||
| //--------------------------------------------------------------------+ | ||||
| tusb_device_state_t tuh_device_get_state (uint8_t const dev_addr) | ||||
| bool tuh_device_configured(uint8_t dev_addr) | ||||
| { | ||||
|   TU_ASSERT( dev_addr <= CFG_TUSB_HOST_DEVICE_MAX, TUSB_DEVICE_STATE_UNPLUG); | ||||
|   return (tusb_device_state_t) _usbh_devices[dev_addr].state; | ||||
|   return _usbh_devices[dev_addr].configured; | ||||
| } | ||||
|  | ||||
| tusb_speed_t tuh_device_get_speed (uint8_t const dev_addr) | ||||
|   | ||||
| @@ -88,13 +88,9 @@ void tuh_task(void); | ||||
| extern void hcd_int_handler(uint8_t rhport); | ||||
| #define tuh_int_handler   hcd_int_handler | ||||
|  | ||||
| tusb_device_state_t tuh_device_get_state (uint8_t dev_addr); | ||||
| tusb_speed_t tuh_device_get_speed (uint8_t dev_addr); | ||||
| static inline bool tuh_device_is_configured(uint8_t dev_addr) | ||||
| { | ||||
|   return tuh_device_get_state(dev_addr) == TUSB_DEVICE_STATE_CONFIGURED; | ||||
| } | ||||
|  | ||||
| bool tuh_device_configured(uint8_t dev_addr); | ||||
| bool tuh_control_xfer (uint8_t dev_addr, tusb_control_request_t const* request, void* buffer, tuh_control_complete_cb_t complete_cb); | ||||
|  | ||||
| //--------------------------------------------------------------------+ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 hathach
					hathach