complete async callback process for print received data
This commit is contained in:
@@ -27,8 +27,6 @@
|
||||
|
||||
static uint32_t g_devinuse = 0;
|
||||
|
||||
void usbh_cdc_acm_callback(void *arg, int nbytes);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: usbh_cdc_acm_devno_alloc
|
||||
*
|
||||
@@ -169,8 +167,22 @@ int usbh_cdc_acm_set_line_state(struct usbh_hubport *hport, uint8_t intf, bool d
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
USB_NOCACHE_RAM_SECTION uint8_t cdc_buffer[4096];
|
||||
|
||||
void usbh_cdc_acm_callback(void *arg, int nbytes)
|
||||
{
|
||||
struct usbh_hub *cdc_acm_class = (struct usbh_hub *)arg;
|
||||
|
||||
if (nbytes > 0) {
|
||||
for (size_t i = 0; i < nbytes; i++) {
|
||||
printf("0x%02x ", cdc_buffer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
printf("nbytes:%d\r\n", nbytes);
|
||||
}
|
||||
|
||||
int usbh_cdc_acm_connect(struct usbh_hubport *hport, uint8_t intf)
|
||||
{
|
||||
struct usbh_endpoint_cfg ep_cfg = { 0 };
|
||||
@@ -268,7 +280,7 @@ int usbh_cdc_acm_connect(struct usbh_hubport *hport, uint8_t intf)
|
||||
printf("send over:%d\r\n", ret);
|
||||
|
||||
#if 0
|
||||
usbh_ep_bulk_async_transfer(cdc_acm_class->bulkin, cdc_buffer, 512, usbh_cdc_acm_callback, NULL);
|
||||
usbh_ep_bulk_async_transfer(cdc_acm_class->bulkin, cdc_buffer, 512, usbh_cdc_acm_callback, cdc_acm_class);
|
||||
#else
|
||||
ret = usbh_ep_bulk_transfer(cdc_acm_class->bulkin, cdc_buffer, 512);
|
||||
if (ret < 0) {
|
||||
@@ -324,11 +336,6 @@ int usbh_cdc_acm_disconnect(struct usbh_hubport *hport, uint8_t intf)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void usbh_cdc_acm_callback(void *arg, int result)
|
||||
{
|
||||
printf("result:%d\r\n", result);
|
||||
}
|
||||
|
||||
const struct usbh_class_driver cdc_acm_class_driver = {
|
||||
.driver_name = "cdc_acm",
|
||||
.connect = usbh_cdc_acm_connect,
|
||||
|
||||
@@ -163,6 +163,14 @@ USB_NOCACHE_RAM_SECTION uint8_t report_buffer[128];
|
||||
|
||||
void usbh_hid_callback(void *arg, int nbytes)
|
||||
{
|
||||
struct usbh_hub *hid_class = (struct usbh_hub *)arg;
|
||||
|
||||
if (nbytes > 0) {
|
||||
for (size_t i = 0; i < nbytes; i++) {
|
||||
printf("0x%02x ", report_buffer[i]);
|
||||
}
|
||||
}
|
||||
|
||||
printf("nbytes:%d\r\n", nbytes);
|
||||
}
|
||||
|
||||
@@ -218,11 +226,12 @@ int usbh_hid_connect(struct usbh_hubport *hport, uint8_t intf)
|
||||
|
||||
USB_LOG_INFO("Register HID Class:%s\r\n", devname);
|
||||
|
||||
ret = usbh_ep_intr_async_transfer(hid_class->intin, report_buffer, 128, usbh_hid_callback, NULL);
|
||||
#if 1
|
||||
ret = usbh_ep_intr_async_transfer(hid_class->intin, report_buffer, 128, usbh_hid_callback, hid_class);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
#if 0
|
||||
#else
|
||||
ret = usbh_ep_intr_transfer(hid_class->intin, report_buffer, 128);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user