diff options
| author | hathach <[email protected]> | 2013-03-26 02:02:54 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-03-26 02:02:54 +0700 |
| commit | 086a8e4a2dbd78dc42a6359c40e1920c9b93a701 (patch) | |
| tree | 8f84a2563c448f02c57165ed486cab5c5615fbbf /tinyusb | |
| parent | ff03b452d9097c8fc40bebe115f6d5979aa6ed08 (diff) | |
add flag_supported_class to usbh_devices
remove all ATTR_WEAK in init,open,isr,close driver functions of USBH-CLASS API
- prefer testing
Diffstat (limited to 'tinyusb')
| -rw-r--r-- | tinyusb/class/hid_host.c | 10 | ||||
| -rw-r--r-- | tinyusb/class/hid_host.h | 10 | ||||
| -rw-r--r-- | tinyusb/host/usbh.c | 14 | ||||
| -rw-r--r-- | tinyusb/host/usbh_hcd.h | 8 |
4 files changed, 32 insertions, 10 deletions
diff --git a/tinyusb/class/hid_host.c b/tinyusb/class/hid_host.c index 944339344..a01c57963 100644 --- a/tinyusb/class/hid_host.c +++ b/tinyusb/class/hid_host.c @@ -111,7 +111,17 @@ void hidh_isr(pipe_handle_t pipe_hdl, tusb_bus_event_t event) void hidh_close(uint8_t dev_addr) { +#if TUSB_CFG_HOST_HID_KEYBOARD + hidh_keyboard_close(dev_addr); +#endif +#if TUSB_CFG_HOST_HID_MOUSE + hidh_mouse_close(dev_addr); +#endif + +#if TUSB_CFG_HOST_HID_GENERIC + hidh_generic_close(dev_addr); +#endif } #endif diff --git a/tinyusb/class/hid_host.h b/tinyusb/class/hid_host.h index f4f1cbb9b..b06d74eed 100644 --- a/tinyusb/class/hid_host.h +++ b/tinyusb/class/hid_host.h @@ -72,14 +72,14 @@ //--------------------------------------------------------------------+ //--------------------------------------------------------------------+ -// CLASS DRIVER FUNCTION (all declared with WEAK) +// CLASS DRIVER FUNCTION //--------------------------------------------------------------------+ #ifdef _TINY_USB_SOURCE_FILE_ -void hidh_init(void) ATTR_WEAK; -tusb_error_t hidh_open_subtask(uint8_t dev_addr, uint8_t const *descriptor, uint16_t *p_length) ATTR_WEAK ATTR_WARN_UNUSED_RESULT; -void hidh_isr(pipe_handle_t pipe_hdl, tusb_bus_event_t event) ATTR_WEAK; -void hidh_close(uint8_t dev_addr) ATTR_WEAK; +void hidh_init(void); +tusb_error_t hidh_open_subtask(uint8_t dev_addr, uint8_t const *descriptor, uint16_t *p_length) ATTR_WARN_UNUSED_RESULT; +void hidh_isr(pipe_handle_t pipe_hdl, tusb_bus_event_t event); +void hidh_close(uint8_t dev_addr); #endif diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index c6fc411fa..587e8a840 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -63,19 +63,24 @@ void tusb_tick_tock(void) // TODO fix/compress number of class driver static host_class_driver_t const usbh_class_drivers[TUSB_CLASS_MAX_CONSEC_NUMBER] = { +#if HOST_CLASS_HID [TUSB_CLASS_HID] = { .init = hidh_init, .open_subtask = hidh_open_subtask, .isr = hidh_isr, .close = hidh_close }, +#endif +#if TUSB_CFG_HOST_CLASS_MSC [TUSB_CLASS_MSC] = { .init = msch_init, .open_subtask = msch_open_subtask, .isr = msch_isr, .close = msch_close } +#endif + }; //--------------------------------------------------------------------+ @@ -237,6 +242,7 @@ void usbh_device_unplugged_isr(uint8_t hostid) // set to REMOVING to allow HCD to clean up its cached data for this device // HCD must set this device's state to TUSB_DEVICE_STATE_UNPLUG when done usbh_devices[dev_addr].state = TUSB_DEVICE_STATE_REMOVING; + usbh_devices[dev_addr].flag_supported_class = 0; } //--------------------------------------------------------------------+ @@ -384,12 +390,16 @@ OSAL_TASK_DECLARE(usbh_enumeration_task) { TASK_ASSERT( false ); // corrupted data, abort enumeration } - // supported class - else if ( class_code < TUSB_CLASS_MAX_CONSEC_NUMBER && usbh_class_drivers[class_code].open_subtask) // TODO custom class + // supported class TODO custom class + else if ( class_code < TUSB_CLASS_MAX_CONSEC_NUMBER && usbh_class_drivers[class_code].open_subtask) { uint16_t length=0; OSAL_SUBTASK_INVOKED_AND_WAIT ( // parameters in task/sub_task must be static storage (static or global) usbh_class_drivers[ ((tusb_descriptor_interface_t*) p_desc)->bInterfaceClass ].open_subtask(new_addr, p_desc, &length) ); + + // TODO check class_open_subtask status + usbh_devices[new_addr].flag_supported_class |= BIT_(((tusb_descriptor_interface_t*) p_desc)->bInterfaceClass); + p_desc += length; } else // unsupported class (not enable or yet implemented) { diff --git a/tinyusb/host/usbh_hcd.h b/tinyusb/host/usbh_hcd.h index fd3430042..815d35b32 100644 --- a/tinyusb/host/usbh_hcd.h +++ b/tinyusb/host/usbh_hcd.h @@ -76,21 +76,23 @@ typedef struct ATTR_ALIGNED(4){ } usbh_enumerate_t; typedef struct { // TODO internal structure, re-order members - //------------- port info -------------// + //------------- port -------------// uint8_t core_id; uint8_t hub_addr; uint8_t hub_port; uint8_t speed; - //------------- device descriptor info -------------// + //------------- device descriptor -------------// uint16_t vendor_id; uint16_t product_id; uint8_t configure_count; // bNumConfigurations alias - //------------- configuration descriptor info -------------// + //------------- configuration descriptor -------------// uint8_t interface_count; // bNumInterfaces alias + //------------- device -------------// volatile uint8_t state; // device state, value from enum tusbh_device_state_t + uint32_t flag_supported_class; // a bitmap of supported class //------------- control pipe -------------// struct { |
