USB: added MSC Host Driver with VFS support
Closes https://github.com/espressif/esp-idf/issues/6401
This commit is contained in:
@@ -11,6 +11,8 @@ Warning: The USB Host Library API is still a beta version and may be subject to
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "usb/usb_types_stack.h"
|
||||
#include "usb/usb_types_ch9.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -129,6 +131,25 @@ static inline int usb_round_up_to_mps(int num_bytes, int mps)
|
||||
return ((num_bytes + mps - 1) / mps) * mps;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Print class specific descriptor callback
|
||||
*
|
||||
* Optional callback to be provided to usb_print_descriptors() function.
|
||||
* The callback is called when when a non-standard descriptor is encountered.
|
||||
* The callback should decode the descriptor as print it.
|
||||
*/
|
||||
|
||||
typedef void (*print_class_descriptor_cb)(const usb_standard_desc_t *);
|
||||
|
||||
/**
|
||||
* @brief Prints usb descriptors
|
||||
*
|
||||
* @param[in] device Handle to device
|
||||
* @param[in] class_specific_cb Optional callback to print class specific descriptors
|
||||
* @return esp_err_t
|
||||
*/
|
||||
esp_err_t usb_print_descriptors(usb_device_handle_t device, print_class_descriptor_cb class_specific_cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -214,6 +214,17 @@ _Static_assert(sizeof(usb_setup_packet_t) == USB_SETUP_PACKET_SIZE, "Size of usb
|
||||
(setup_pkt_ptr)->wLength = 0; \
|
||||
})
|
||||
|
||||
/**
|
||||
* @brief Initializer for a request to get an string descriptor
|
||||
*/
|
||||
#define USB_SETUP_PACKET_INIT_GET_STR_DESC(setup_pkt_ptr, string_index, desc_len) ({ \
|
||||
(setup_pkt_ptr)->bmRequestType = USB_BM_REQUEST_TYPE_DIR_IN | USB_BM_REQUEST_TYPE_TYPE_STANDARD | USB_BM_REQUEST_TYPE_RECIP_DEVICE; \
|
||||
(setup_pkt_ptr)->bRequest = USB_B_REQUEST_GET_DESCRIPTOR; \
|
||||
(setup_pkt_ptr)->wValue = (USB_W_VALUE_DT_STRING << 8) | ((string_index) & 0xFF); \
|
||||
(setup_pkt_ptr)->wIndex = 0; \
|
||||
(setup_pkt_ptr)->wLength = (desc_len); \
|
||||
})
|
||||
|
||||
// ---------------- Standard Descriptor --------------------
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user