diff options
| author | Ha Thach <[email protected]> | 2025-10-02 19:58:12 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-10-02 19:58:12 +0700 |
| commit | c1bf19ed6cf1eaa791f221c1bc5ce4b3d069f76d (patch) | |
| tree | 60fe2447d25af0ab07b80f435d79a147cf717d8f /src/device | |
| parent | f655d210b17fad3d2e95c7ef07e114a2f0b6dac6 (diff) | |
| parent | 610f353d8d602c3192f9edc03669ab792056f7da (diff) | |
Merge pull request #3023 from ennebi/mtp
Add support for MTP device class
Diffstat (limited to 'src/device')
| -rw-r--r-- | src/device/usbd.c | 14 | ||||
| -rw-r--r-- | src/device/usbd.h | 19 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/device/usbd.c b/src/device/usbd.c index b1aef0b38..339ccf4b4 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -321,6 +321,20 @@ tu_static usbd_class_driver_t const _usbd_driver[] = { .sof = NULL }, #endif + + #if CFG_TUD_MTP + { + .name = DRIVER_NAME("MTP"), + .init = mtpd_init, + .deinit = mtpd_deinit, + .reset = mtpd_reset, + .open = mtpd_open, + .control_xfer_cb = mtpd_control_xfer_cb, + .xfer_cb = mtpd_xfer_cb, + .xfer_isr = NULL, + .sof = NULL + }, + #endif }; enum { BUILTIN_DRIVER_COUNT = TU_ARRAY_SIZE(_usbd_driver) }; diff --git a/src/device/usbd.h b/src/device/usbd.h index e5a848809..a4104e47d 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -270,6 +270,25 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ //--------------------------------------------------------------------+ +// MTP Descriptor Templates +//--------------------------------------------------------------------+ + +// Length of template descriptor: 30 bytes +#define TUD_MTP_DESC_LEN (9 + 7 + 7 + 7) + +// Interface number, string index, EP event, EP event size, EP event polling, EP Out & EP In address, EP size +#define TUD_MTP_DESCRIPTOR(_itfnum, _stridx, _ep_evt, _ep_evt_size, _ep_evt_polling_interval, _epout, _epin, _epsize) \ + /* Interface */\ + 9, TUSB_DESC_INTERFACE, _itfnum, 0, 3, TUSB_CLASS_IMAGE, MTP_SUBCLASS_STILL_IMAGE, MTP_PROTOCOL_PIMA_15470, _stridx,\ + /* Endpoint Interrupt */\ + 7, TUSB_DESC_ENDPOINT, _ep_evt, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_ep_evt_size), _ep_evt_polling_interval,\ + /* Endpoint Out */\ + 7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0,\ + /* Endpoint In */\ + 7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0 + + +//--------------------------------------------------------------------+ // HID Descriptor Templates //--------------------------------------------------------------------+ |
