8 #ifndef META_OCEAN_SYSTEM_USB_DESCRIPTOR_H
9 #define META_OCEAN_SYSTEM_USB_DESCRIPTOR_H
41 template <u
int32_t tValue0, u
int16_t tValue1, u
int16_t tValue2, u
int16_t tValue3, u
int64_t tValue4>
42 static constexpr std::array<uint8_t, 16u> createGUID();
53 static constexpr std::array<uint8_t, 16u> createGUID(
const uint32_t value0,
const uint16_t value1,
const uint16_t value2,
const uint16_t value3,
const uint64_t value4);
86 static void value(
const size_t offset, T& value,
const void* buffer);
93 template <
typename TDescriptor>
94 static void invalidate(TDescriptor& descriptor);
102 template <
typename T>
103 static constexpr uint8_t shift(
const T& value,
const unsigned int bytes);
106 template <u
int32_t tValue0, u
int16_t tValue1, u
int16_t tValue2, u
int16_t tValue3, u
int64_t tValue4>
109 static_assert(tValue4 <= 0xFFFFFFFFFFFFull);
115 shift(tValue4, 5),
shift(tValue4, 4),
shift(tValue4, 3),
shift(tValue4, 2),
shift(tValue4, 1),
shift(tValue4, 0)};
118 constexpr std::array<uint8_t, 16u>
Descriptor::createGUID(
const uint32_t value0,
const uint16_t value1,
const uint16_t value2,
const uint16_t value3,
const uint64_t value4)
120 ocean_assert(value4 <= 0xFFFFFFFFFFFFull);
126 shift(value4, 5),
shift(value4, 4),
shift(value4, 3),
shift(value4, 2),
shift(value4, 1),
shift(value4, 0)};
129 template <
typename T>
132 memcpy(&
value, (
const uint8_t*)(buffer) + offset,
sizeof(T));
135 template <
typename TDescriptor>
138 descriptor.bLength_ = 0u;
139 descriptor.bDescriptorType_ = 0u;
140 descriptor.bDescriptorSubtype_ = 0u;
142 ocean_assert(!descriptor.isValid());
145 template <
typename T>
148 return uint8_t((
value >> T(bytes * 8)) & T(0xFF));
This class implements the base class for all interface descriptors.
Definition: system/usb/Descriptor.h:29
static std::string guid2string(const uint8_t *guid)
Returns a string representation of the given GUID.
static constexpr uint8_t shift(const T &value, const unsigned int bytes)
Returns 8 bits from a given value which can be shifted right.
Definition: system/usb/Descriptor.h:146
static double interval2frequency(const uint32_t timeInterval)
Converts a time interval (in 100ns) to frequency in Hz.
static constexpr std::array< uint8_t, 16u > createGUID()
Returns a custom globally unique identifier (GUID).
Definition: system/usb/Descriptor.h:107
static void value(const size_t offset, T &value, const void *buffer)
Copies the value from a given buffer.
Definition: system/usb/Descriptor.h:130
static void invalidate(TDescriptor &descriptor)
Invalidates a descriptor.
Definition: system/usb/Descriptor.h:136
static uint32_t frequency2interval(const double frequency)
Converts a frequency in Hz to time interval in 100ns.
constexpr uint8_t CS_INTERFACE
Definition: system/usb/Descriptor.h:22
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15