USB Mass Storage Class API. This class makes the device accessible as a mass storage device and allows you to transfer data between the host and the device.
One of the examples for this mode is to flash the device by dropping the firmware binary like a flash memory device when connecting the ESP32 to the host computer.
This function is used to start the peripheral using the default MSC configuration.
bool begin(uint32_t block_count, uint16_t block_size);
Where:
block_count
set the disk sector count.block_size
set the disk sector size.
This function will return true
if the configuration was successful.
This function will finish the peripheral as MSC and release all the allocated resources. After calling end
you need to use begin
again in order to initialize the USB MSC driver again.
void end();
This function is used to define the vendor ID.
void vendorID(const char * vid);//max 8 chars
This function is used to define the product ID.
void productID(const char * pid);//max 16 chars
This function is used to define the product revision.
void productRevision(const char * ver);//max 4 chars
Set the mediaPresent
configuration.
void mediaPresent(bool media_present);
Set the onStartStop
callback function.
void onStartStop(msc_start_stop_cb cb);
Set the onRead
callback function.
void onRead(msc_read_cb cb);
Set the onWrite
callback function.
void onWrite(msc_write_cb cb);
Here is an example of how to use the USB MSC.
.. literalinclude:: ../../../libraries/USB/examples/FirmwareMSC/FirmwareMSC.ino :language: arduino