forked from flipperdevices/flipperzero-catalog-sample-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: minimum work for at least get usb to work
- Loading branch information
Showing
6 changed files
with
131 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#include <furi.h> | ||
#include <furi_hal.h> | ||
#include <furi_hal_usb.h> | ||
#include "usb.h" | ||
#include "usb_desc.h" | ||
|
||
const struct usb_string_descriptor dev_manuf_desc = USB_STRING_DESC("Flipper Devices Inc."); | ||
const struct usb_string_descriptor dev_prod_desc = USB_STRING_DESC("MTP Device"); | ||
|
||
const struct usb_device_descriptor usb_mtp_dev_descr = { | ||
.bLength = sizeof(struct usb_device_descriptor), | ||
.bDescriptorType = USB_DTYPE_DEVICE, | ||
.bcdUSB = VERSION_BCD(2, 0, 0), | ||
.bDeviceClass = USB_CLASS_STILL_IMAGE, // MTP falls under Still Image class | ||
.bDeviceSubClass = 1, // Subclass for MTP | ||
.bDeviceProtocol = 1, // Protocol for MTP | ||
.bMaxPacketSize0 = USB_EP0_SIZE, | ||
.idVendor = 0x0483, // STMicroelectronics | ||
.idProduct = 0x5741, // Custom Product ID | ||
.bcdDevice = VERSION_BCD(1, 0, 0), | ||
.iManufacturer = UsbDevManuf, // UsbDevManuf | ||
.iProduct = UsbDevProduct, // UsbDevProduct | ||
.iSerialNumber = UsbDevSerial, // UsbDevSerial | ||
.bNumConfigurations = 1, | ||
}; | ||
|
||
const struct MtpDescriptor usb_mtp_cfg_descr = { | ||
.config = | ||
{ | ||
.bLength = sizeof(struct usb_config_descriptor), | ||
.bDescriptorType = USB_DTYPE_CONFIGURATION, | ||
.wTotalLength = sizeof(struct MtpDescriptor), | ||
.bNumInterfaces = 1, | ||
.bConfigurationValue = 1, | ||
.iConfiguration = NO_DESCRIPTOR, | ||
.bmAttributes = USB_CFG_ATTR_RESERVED | USB_CFG_ATTR_SELFPOWERED, | ||
.bMaxPower = USB_CFG_POWER_MA(100), | ||
}, | ||
.intf = | ||
{ | ||
.bLength = sizeof(struct usb_interface_descriptor), | ||
.bDescriptorType = USB_DTYPE_INTERFACE, | ||
.bInterfaceNumber = 0, | ||
.bAlternateSetting = 0, | ||
.bNumEndpoints = 2, | ||
.bInterfaceClass = USB_CLASS_STILL_IMAGE, | ||
.bInterfaceSubClass = 1, // Subclass for MTP | ||
.bInterfaceProtocol = 1, // Protocol for MTP | ||
.iInterface = NO_DESCRIPTOR, | ||
}, | ||
.ep_rx = | ||
{ | ||
.bLength = sizeof(struct usb_endpoint_descriptor), | ||
.bDescriptorType = USB_DTYPE_ENDPOINT, | ||
.bEndpointAddress = USB_MTP_RX_EP, | ||
.bmAttributes = USB_EPTYPE_BULK, | ||
.wMaxPacketSize = USB_MTP_RX_EP_SIZE, | ||
.bInterval = 0, | ||
}, | ||
.ep_tx = | ||
{ | ||
.bLength = sizeof(struct usb_endpoint_descriptor), | ||
.bDescriptorType = USB_DTYPE_ENDPOINT, | ||
.bEndpointAddress = USB_MTP_TX_EP, | ||
.bmAttributes = USB_EPTYPE_BULK, | ||
.wMaxPacketSize = USB_MTP_TX_EP_SIZE, | ||
.bInterval = 0, | ||
}, | ||
}; | ||
|
||
FuriHalUsbInterface usb_mtp_interface = { | ||
.init = usb_mtp_init, | ||
.deinit = usb_mtp_deinit, | ||
.wakeup = usb_mtp_wakeup, | ||
.suspend = usb_mtp_suspend, | ||
|
||
.dev_descr = (struct usb_device_descriptor*)&usb_mtp_dev_descr, | ||
|
||
.str_manuf_descr = (void*)&dev_manuf_desc, | ||
.str_prod_descr = (void*)&dev_prod_desc, | ||
.str_serial_descr = NULL, | ||
|
||
.cfg_descr = (void*)&usb_mtp_cfg_descr, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
#include <furi.h> | ||
#include <furi_hal.h> | ||
#include <furi_hal_usb.h> | ||
|
||
struct MtpDescriptor { | ||
struct usb_config_descriptor config; | ||
struct usb_interface_descriptor intf; | ||
struct usb_endpoint_descriptor ep_rx; | ||
struct usb_endpoint_descriptor ep_tx; | ||
} __attribute__((packed)); | ||
|
||
extern const struct usb_string_descriptor dev_manuf_desc; | ||
extern const struct usb_string_descriptor dev_prod_desc; | ||
extern const struct usb_device_descriptor usb_mtp_dev_descr; | ||
extern const struct MtpDescriptor usb_mtp_cfg_descr; | ||
extern FuriHalUsbInterface usb_mtp_interface; |