/* SPDX-License-Identifier: MIT Copyright (c) 2023 Casey Reeves and the LuminaSensum contributors */ #include "MyUSBMSD.h" #include "ButtonThread.h" #include "mbed.h" // create a custom usb mass storage subclass to override // the product description MyUSBMSD::MyUSBMSD(mbed::BlockDevice *bd, bool connect_blocking, uint16_t vendor_id, uint16_t product_id, uint16_t product_release) : USBMSD(bd, connect_blocking, vendor_id, product_id, product_release) {} const uint8_t *MyUSBMSD::string_iproduct_desc() { static const uint8_t string_iproduct_descriptor[] = { 0x28, // bLength STRING_DESCRIPTOR, // bDescriptorType 'L', 0, 'u', 0, 'm', 0, 'i', 0, 'n', 0, 'a', 0, 'S', 0, 'e', 0, 'n', 0, 's', 0, 'u', 0, 'm', 0, ' ', 0, 'T', 0, 'a', 0, 'r', 0, 'd', 0, 'i', 0, 's', 0 // bString iProduct - usb mass storage }; return string_iproduct_descriptor; } void doUSBMSD(mbed::BlockDevice &bd) { printf("Switching to the usb mass storage mode...\n"); MyUSBMSD usb(&bd, true, 0x1209, 0x10); while (true) { int presses = waitForPresses(0s); usb.process(); if (presses == 1) { printf("Disconnecting the usb mass storage " "device...\n"); usb.disconnect(); printf("Switched usb mass storage mode off.\n"); break; } } }