mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-24 16:20:49 +01:00
[usb] Microsoft OS String Descriptor v1
Change-Id: I7f77656b714f8c1bbe5f0b6d535d8df1cf3d36bb
This commit is contained in:
@@ -17,6 +17,7 @@ usb_objs += $(addprefix ion/src/device/usb/stack/, \
|
||||
dfu_functional_descriptor.o\
|
||||
interface_descriptor.o\
|
||||
language_id_string_descriptor.o \
|
||||
microsoft_os_string_descriptor.o\
|
||||
platform_device_capability_descriptor.o\
|
||||
streamable.o\
|
||||
string_descriptor.o\
|
||||
|
||||
@@ -25,6 +25,11 @@ void Calculator::Poll() {
|
||||
}
|
||||
|
||||
Descriptor * Calculator::descriptor(uint8_t type, uint8_t index) {
|
||||
/* Special case: Microsoft OS String Descriptor should be returned when
|
||||
* searching for string descriptor at index 0xEE. */
|
||||
if (type == m_microsoftOSStringDescriptor.type() && index == 0xEE) {
|
||||
return &m_microsoftOSStringDescriptor;
|
||||
}
|
||||
int typeCount = 0;
|
||||
for (size_t i=0; i<sizeof(m_descriptors)/sizeof(m_descriptors[0]); i++) {
|
||||
Descriptor * descriptor = m_descriptors[i];
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "stack/dfu_functional_descriptor.h"
|
||||
#include "stack/interface_descriptor.h"
|
||||
#include "stack/language_id_string_descriptor.h"
|
||||
#include "stack/microsoft_os_string_descriptor.h"
|
||||
#include "stack/string_descriptor.h"
|
||||
#include "stack/url_descriptor.h"
|
||||
#include "stack/webusb_platform_descriptor.h"
|
||||
@@ -88,6 +89,7 @@ public:
|
||||
m_serialNumberStringDescriptor("12345"),
|
||||
m_interfaceStringDescriptor("@Flash/0x08000000/04*016Kg,01*064Kg,07*128Kg"),
|
||||
//m_interfaceStringDescriptor("@SRAM/0x20000000/01*256Ke"), //TODO: Add this descriptor to use dfu-util to write in the SRAM
|
||||
m_microsoftOSStringDescriptor(k_microsoftOSVendorCode),
|
||||
m_workshopURLDescriptor(URLDescriptor::Scheme::HTTPS, "workshop.numworks.com"),
|
||||
m_descriptors{
|
||||
&m_deviceDescriptor, // Type = Device, Index = 0
|
||||
@@ -117,6 +119,7 @@ private:
|
||||
static constexpr uint8_t k_dfuInterfaceAlternateSetting = 0;
|
||||
static constexpr uint8_t k_webUSBVendorCode = 1;
|
||||
static constexpr uint8_t k_webUSBLandingPageIndex = 1;
|
||||
static constexpr uint8_t k_microsoftOSVendorCode = 2;
|
||||
bool getURLCommand(uint8_t * transferBuffer, uint16_t * transferBufferLength, uint16_t transferBufferMaxLength);
|
||||
DeviceDescriptor m_deviceDescriptor;
|
||||
DFUFunctionalDescriptor m_dfuFunctionalDescriptor;
|
||||
@@ -129,6 +132,7 @@ private:
|
||||
StringDescriptor m_productStringDescriptor;
|
||||
StringDescriptor m_serialNumberStringDescriptor;
|
||||
StringDescriptor m_interfaceStringDescriptor;
|
||||
MicrosoftOSStringDescriptor m_microsoftOSStringDescriptor;
|
||||
URLDescriptor m_workshopURLDescriptor;
|
||||
|
||||
Descriptor * m_descriptors[8];
|
||||
|
||||
19
ion/src/device/usb/stack/microsoft_os_string_descriptor.cpp
Normal file
19
ion/src/device/usb/stack/microsoft_os_string_descriptor.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "microsoft_os_string_descriptor.h"
|
||||
|
||||
namespace Ion {
|
||||
namespace USB {
|
||||
namespace Device {
|
||||
|
||||
void MicrosoftOSStringDescriptor::push(Channel * c) const {
|
||||
StringDescriptor::push(c);
|
||||
c->push(m_bMSVendorCode);
|
||||
c->push(m_bPad);
|
||||
}
|
||||
|
||||
uint8_t MicrosoftOSStringDescriptor::bLength() const {
|
||||
return StringDescriptor::bLength() + 2 * sizeof(uint8_t);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
30
ion/src/device/usb/stack/microsoft_os_string_descriptor.h
Normal file
30
ion/src/device/usb/stack/microsoft_os_string_descriptor.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef ION_DEVICE_USB_STACK_MICROSOFT_OS_STRING_DESCRIPTOR_H
|
||||
#define ION_DEVICE_USB_STACK_MICROSOFT_OS_STRING_DESCRIPTOR_H
|
||||
|
||||
#include "string_descriptor.h"
|
||||
|
||||
namespace Ion {
|
||||
namespace USB {
|
||||
namespace Device {
|
||||
|
||||
class MicrosoftOSStringDescriptor : public StringDescriptor {
|
||||
public:
|
||||
constexpr MicrosoftOSStringDescriptor(uint8_t bMSVendorCode) :
|
||||
StringDescriptor("MSFT100"),
|
||||
m_bMSVendorCode(bMSVendorCode),
|
||||
m_bPad(0)
|
||||
{
|
||||
}
|
||||
protected:
|
||||
void push(Channel * c) const override;
|
||||
virtual uint8_t bLength() const override;
|
||||
private:
|
||||
uint8_t m_bMSVendorCode;
|
||||
uint8_t m_bPad;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,16 +0,0 @@
|
||||
class OSStringDescriptor : public Descriptor {
|
||||
public:
|
||||
StringDescriptor(const char * string);
|
||||
void copy(void * target) override {
|
||||
memcpy(this, target, sizeof(Descriptor));
|
||||
// Ensuite, on veut pousser le compat ID et les extended properties
|
||||
;
|
||||
}
|
||||
private:
|
||||
uint8_t bLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t qwSignature[14];
|
||||
uint8_t bMS_VendorCode;
|
||||
uint8_t bPad;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user