Skip to content

Commit

Permalink
Adapt to v1.3.0 version
Browse files Browse the repository at this point in the history
  • Loading branch information
udoudou committed Jun 10, 2024
1 parent 0066115 commit 4940a2e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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;

Expand Down
20 changes: 10 additions & 10 deletions examples/device/cherryusb_device_mtp/main/device_mtp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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:
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 4940a2e

Please sign in to comment.