From 4940a2e21cddaa5648a709da65c836c7f51c63ab Mon Sep 17 00:00:00 2001 From: udoudou <949797067@qq.com> Date: Mon, 10 Jun 2024 23:58:31 +0800 Subject: [PATCH] Adapt to v1.3.0 version --- .../components/usb_mtp/usb_mtp.c | 18 ++++++++--------- .../main/device_mtp_main.c | 20 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/examples/device/cherryusb_device_mtp/components/usb_mtp/usb_mtp.c b/examples/device/cherryusb_device_mtp/components/usb_mtp/usb_mtp.c index fa3d388..bb38297 100644 --- a/examples/device/cherryusb_device_mtp/components/usb_mtp/usb_mtp.c +++ b/examples/device/cherryusb_device_mtp/components/usb_mtp/usb_mtp.c @@ -33,7 +33,7 @@ esp_mtp_handle_t s_handle; static usb_mtp_status_t s_mtp_status = USB_MTP_CLOSE; static portMUX_TYPE s_spinlock = portMUX_INITIALIZER_UNLOCKED; -static int mtp_class_interface_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len) +static int mtp_class_interface_request_handler(uint8_t busid, struct usb_setup_packet *setup, uint8_t **data, uint32_t *len) { USB_LOG_DBG("MTP Class request: " "bRequest 0x%02x\r\n", @@ -62,17 +62,17 @@ static int mtp_class_interface_request_handler(struct usb_setup_packet *setup, u return 0; } -static void usbd_mtp_bulk_out(uint8_t ep, uint32_t nbytes) +static void usbd_mtp_bulk_out(uint8_t busid, uint8_t ep, uint32_t nbytes) { esp_mtp_read_async_cb(s_handle, nbytes); } -static void usbd_mtp_bulk_in(uint8_t ep, uint32_t nbytes) +static void usbd_mtp_bulk_in(uint8_t busid, uint8_t ep, uint32_t nbytes) { esp_mtp_write_async_cb(s_handle, nbytes); } -static void mtp_notify_handler(uint8_t event, void *arg) +static void mtp_notify_handler(uint8_t busid, uint8_t event, void *arg) { BaseType_t high_task_wakeup = pdFALSE; switch (event) { @@ -125,7 +125,7 @@ static int usb_write(void *pipe_context, const uint8_t *data, int data_size) esp_mtp_write_async_cb(s_handle, data_size); return data_size; } - usbd_ep_start_write(mtp_ep_data[MTP_IN_EP_IDX].ep_addr, data, data_size); + usbd_ep_start_write(0, mtp_ep_data[MTP_IN_EP_IDX].ep_addr, data, data_size); return data_size; } @@ -136,7 +136,7 @@ static int usb_read(void *pipe_context, uint8_t *data, int data_size) esp_mtp_read_async_cb(s_handle, data_size); return data_size; } - usbd_ep_start_read(mtp_ep_data[MTP_OUT_EP_IDX].ep_addr, data, data_size); + usbd_ep_start_read(0, mtp_ep_data[MTP_OUT_EP_IDX].ep_addr, data, data_size); return data_size; } @@ -159,9 +159,9 @@ struct usbd_interface *usbd_mtp_init_intf(struct usbd_interface *intf, mtp_ep_data[MTP_INT_EP_IDX].ep_addr = int_ep; mtp_ep_data[MTP_INT_EP_IDX].ep_cb = NULL; - usbd_add_endpoint(&mtp_ep_data[MTP_OUT_EP_IDX]); - usbd_add_endpoint(&mtp_ep_data[MTP_IN_EP_IDX]); - usbd_add_endpoint(&mtp_ep_data[MTP_INT_EP_IDX]); + usbd_add_endpoint(0, &mtp_ep_data[MTP_OUT_EP_IDX]); + usbd_add_endpoint(0, &mtp_ep_data[MTP_IN_EP_IDX]); + usbd_add_endpoint(0, &mtp_ep_data[MTP_INT_EP_IDX]); s_mtp_status = USB_MTP_STOPPING; diff --git a/examples/device/cherryusb_device_mtp/main/device_mtp_main.c b/examples/device/cherryusb_device_mtp/main/device_mtp_main.c index 5e73e18..9ea5f2b 100644 --- a/examples/device/cherryusb_device_mtp/main/device_mtp_main.c +++ b/examples/device/cherryusb_device_mtp/main/device_mtp_main.c @@ -87,9 +87,9 @@ const uint8_t mtp_descriptor[] = { '2', 0x00, /* wcChar0 */ '0', 0x00, /* wcChar1 */ '2', 0x00, /* wcChar2 */ - '1', 0x00, /* wcChar3 */ + '4', 0x00, /* wcChar3 */ '0', 0x00, /* wcChar4 */ - '3', 0x00, /* wcChar5 */ + '6', 0x00, /* wcChar5 */ '1', 0x00, /* wcChar6 */ '0', 0x00, /* wcChar7 */ '0', 0x00, /* wcChar8 */ @@ -112,7 +112,7 @@ const uint8_t mtp_descriptor[] = { 0x00 }; -void usbd_event_handler(uint8_t event) +void usbd_event_handler(uint8_t busid, uint8_t event) { switch (event) { case USBD_EVENT_RESET: @@ -144,19 +144,19 @@ void app_main(void) void sd_main(void); sd_main(); uint32_t before = heap_caps_get_free_size(MALLOC_CAP_DEFAULT); - usbd_desc_register(mtp_descriptor); - usbd_add_interface(usbd_mtp_init_intf(&intf0, CDC_OUT_EP, CDC_IN_EP, CDC_INT_EP)); - usbd_initialize(); + usbd_desc_register(0, mtp_descriptor); + usbd_add_interface(0, usbd_mtp_init_intf(&intf0, CDC_OUT_EP, CDC_IN_EP, CDC_INT_EP)); + usbd_initialize(0, ESP_USBD_BASE, usbd_event_handler); while (1){ vTaskDelay(10000 / portTICK_PERIOD_MS); usbd_mtp_deinit(); - usbd_deinitialize(); + usbd_deinitialize(0); vTaskDelay(500 / portTICK_PERIOD_MS); uint32_t now; now = heap_caps_get_free_size(MALLOC_CAP_DEFAULT); ESP_LOGW(TAG, "use %"PRIu32, before - now); - usbd_desc_register(mtp_descriptor); - usbd_add_interface(usbd_mtp_init_intf(&intf0, CDC_OUT_EP, CDC_IN_EP, CDC_INT_EP)); - usbd_initialize(); + usbd_desc_register(0, mtp_descriptor); + usbd_add_interface(0, usbd_mtp_init_intf(&intf0, CDC_OUT_EP, CDC_IN_EP, CDC_INT_EP)); + usbd_initialize(0, ESP_USBD_BASE, usbd_event_handler); } } \ No newline at end of file