mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-07 05:54:11 +08:00
update vendor open()
This commit is contained in:
parent
bec5b5f9da
commit
c1db36a15c
14
src/class/vendor/vendor_device.c
vendored
14
src/class/vendor/vendor_device.c
vendored
@ -166,9 +166,9 @@ void vendord_reset(uint8_t rhport)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool vendord_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_len)
|
uint16_t vendord_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len)
|
||||||
{
|
{
|
||||||
TU_VERIFY(TUSB_CLASS_VENDOR_SPECIFIC == itf_desc->bInterfaceClass);
|
TU_VERIFY(TUSB_CLASS_VENDOR_SPECIFIC == itf_desc->bInterfaceClass, 0);
|
||||||
|
|
||||||
// Find available interface
|
// Find available interface
|
||||||
vendord_interface_t* p_vendor = NULL;
|
vendord_interface_t* p_vendor = NULL;
|
||||||
@ -180,18 +180,18 @@ bool vendord_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TU_VERIFY(p_vendor);
|
TU_VERIFY(p_vendor, 0);
|
||||||
|
|
||||||
// Open endpoint pair with usbd helper
|
// Open endpoint pair with usbd helper
|
||||||
TU_ASSERT(usbd_open_edpt_pair(rhport, tu_desc_next(itf_desc), 2, TUSB_XFER_BULK, &p_vendor->ep_out, &p_vendor->ep_in));
|
TU_ASSERT(usbd_open_edpt_pair(rhport, tu_desc_next(itf_desc), 2, TUSB_XFER_BULK, &p_vendor->ep_out, &p_vendor->ep_in), 0);
|
||||||
|
|
||||||
p_vendor->itf_num = itf_desc->bInterfaceNumber;
|
p_vendor->itf_num = itf_desc->bInterfaceNumber;
|
||||||
(*p_len) = sizeof(tusb_desc_interface_t) + 2*sizeof(tusb_desc_endpoint_t);
|
uint16_t const drv_len = sizeof(tusb_desc_interface_t) + itf_desc->bNumEndpoints*sizeof(tusb_desc_endpoint_t);
|
||||||
|
|
||||||
// Prepare for incoming data
|
// Prepare for incoming data
|
||||||
TU_ASSERT(usbd_edpt_xfer(rhport, p_vendor->ep_out, p_vendor->epout_buf, sizeof(p_vendor->epout_buf)));
|
TU_ASSERT(usbd_edpt_xfer(rhport, p_vendor->ep_out, p_vendor->epout_buf, sizeof(p_vendor->epout_buf)), drv_len);
|
||||||
|
|
||||||
return true;
|
return drv_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool vendord_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)
|
bool vendord_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_t xferred_bytes)
|
||||||
|
2
src/class/vendor/vendor_device.h
vendored
2
src/class/vendor/vendor_device.h
vendored
@ -120,7 +120,7 @@ static inline uint32_t tud_vendor_write_available (void)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void vendord_init(void);
|
void vendord_init(void);
|
||||||
void vendord_reset(uint8_t rhport);
|
void vendord_reset(uint8_t rhport);
|
||||||
bool vendord_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t *p_length);
|
uint16_t vendord_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
||||||
bool vendord_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
bool vendord_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
Loading…
x
Reference in New Issue
Block a user