add check device API for stack usage
bool usbh_device_is_plugged(tusb_handle_device_t const device_hdl);
This commit is contained in:
@@ -61,8 +61,8 @@ tusb_error_t tusbh_hid_keyboard_get(tusb_handle_device_t const device_hdl, uint8
|
||||
{
|
||||
keyboard_interface_t *p_kbd;
|
||||
|
||||
ASSERT(usbh_device_is_plugged(device_hdl), TUSB_ERROR_INVALID_PARA);
|
||||
ASSERT_PTR(report, TUSB_ERROR_INVALID_PARA);
|
||||
ASSERT(device_hdl < TUSB_CFG_HOST_DEVICE_MAX, TUSB_ERROR_INVALID_PARA);
|
||||
ASSERT(instance_num < TUSB_CFG_HOST_HID_KEYBOARD_NO_INSTANCES_PER_DEVICE, TUSB_ERROR_INVALID_PARA);
|
||||
|
||||
p_kbd = &keyboard_info_pool[device_hdl].instance[instance_num];
|
||||
@@ -78,13 +78,14 @@ tusb_error_t tusbh_hid_keyboard_get(tusb_handle_device_t const device_hdl, uint8
|
||||
|
||||
uint8_t tusbh_hid_keyboard_no_instances(tusb_handle_device_t const device_hdl)
|
||||
{
|
||||
return 0;
|
||||
ASSERT(usbh_device_is_plugged(device_hdl), 0);
|
||||
|
||||
return keyboard_info_pool[device_hdl].instance_count;
|
||||
}
|
||||
|
||||
tusb_error_t class_hid_keyboard_install(uint8_t const dev_addr, uint8_t const *descriptor)
|
||||
{
|
||||
ASSERT(dev_addr < TUSB_CFG_HOST_DEVICE_MAX, TUSB_ERROR_INVALID_PARA);
|
||||
ASSERT_PTR(descriptor, TUSB_ERROR_INVALID_PARA);
|
||||
keyboard_info_pool[0].instance_count++;
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
+10
-11
@@ -94,22 +94,21 @@ enum {
|
||||
|
||||
typedef uint32_t tusbh_flag_class_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t interface_count;
|
||||
uint8_t attributes;
|
||||
} usbh_configure_info_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t core_id;
|
||||
pipe_handle_t pipe_control;
|
||||
uint8_t configure_count;
|
||||
|
||||
#if 0 // TODO allow configure for vendor/product
|
||||
uint16_t vendor_id;
|
||||
uint16_t product_id;
|
||||
|
||||
uint8_t configure_count;
|
||||
struct {
|
||||
uint8_t interface_count;
|
||||
uint8_t attributes;
|
||||
} configuration;
|
||||
#endif
|
||||
|
||||
usbh_configure_info_t configuration;
|
||||
} usbh_device_info_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -125,8 +124,8 @@ typedef uint32_t tusb_handle_device_t;
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION API
|
||||
//--------------------------------------------------------------------+
|
||||
void tusbh_device_mounting_cb (tusb_error_t error, tusb_handle_device_t device_hdl, uint32_t *configure_flags, uint8_t number_of_configure);
|
||||
void tusbh_device_mounted_cb (tusb_error_t error, tusb_handle_device_t device_hdl, uint32_t *configure_flags, uint8_t number_of_configure);
|
||||
void tusbh_device_mounting_cb (tusb_error_t const error, tusb_handle_device_t const device_hdl);
|
||||
void tusbh_device_mounted_cb (tusb_error_t const error, tusb_handle_device_t const device_hdl);
|
||||
tusb_error_t tusbh_configuration_set (tusb_handle_device_t const device_hdl, uint8_t const configure_number);
|
||||
|
||||
|
||||
@@ -134,8 +133,8 @@ tusb_error_t tusbh_configuration_set (tusb_handle_device_t const device_hdl,
|
||||
//--------------------------------------------------------------------+
|
||||
// CLASS API
|
||||
//--------------------------------------------------------------------+
|
||||
usbh_device_info_t* usbh_device_info_get(tusb_handle_device_t device_hdl);
|
||||
pipe_status_t usbh_pipe_status_get(pipe_handle_t pipe_hdl);
|
||||
bool usbh_device_is_plugged(tusb_handle_device_t const device_hdl);
|
||||
pipe_status_t usbh_pipe_status_get(pipe_handle_t pipe_hdl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user