complete async callback process for print received data

This commit is contained in:
sakumisu
2022-02-13 14:33:54 +08:00
parent 97f5b0e9af
commit 0ec3c5e4ef
2 changed files with 26 additions and 10 deletions

View File

@@ -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,