Media Transfer Protocol Porting Kit Instant
uint32_t mtp_get_num_storages(void); uint32_t mtp_get_storage_id(uint8_t idx); const char* mtp_get_storage_description(uint32_t storage_id); Implement object operations:
bool mtp_usb_send(const uint8_t* data, uint32_t len); bool mtp_usb_recv(uint8_t* buf, uint32_t timeout_ms); void mtp_usb_attach(void); // Notify host of device availability For USB interrupt endpoint (MTP events): Media Transfer Protocol Porting Kit
| RTOS Feature | Usage | |--------------|-------| | Mutex | Protect object list during concurrent host access | | Message queue | Deliver USB events to MTP task | | Semaphore | Block waiting for MTP response when acting as initiator | | | Property Provider | Maps standard MTP properties (e
| Layer | Description | |-------|-------------| | | Handles USB endpoint read/write, interrupt events, and session management. | | Command Processor | Parses MTP operation codes, validates parameters, invokes handlers. | | Object Manager | Interfaces with file system (FAT, exFAT, SPIFFS) to create/read/delete/rename objects. | | Property Provider | Maps standard MTP properties (e.g., StorageID , ObjectFormat ) to device metadata. | Integration with Real-Time Operating Systems (RTOS) MTP PK
void mtp_send_event(uint16_t event_code, uint32_t param1); Implement storage enumeration:
bool mtp_open_object(uint32_t handle, uint32_t* size); uint32_t mtp_read_object(uint32_t handle, uint8_t* buf, uint32_t offset, uint32_t len); void mtp_close_object(uint32_t handle); For each MTP property code (e.g., 0xDC03 = Object Size), provide a getter/setter. 5. Integration with Real-Time Operating Systems (RTOS) MTP PK is designed for single-threaded event loops but benefits from RTOS features: