-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
56 lines (44 loc) · 1.31 KB
/
main.cpp
File metadata and controls
56 lines (44 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <cstdio>
#include <cstdint>
#include "usbdescriptor.h"
constinit auto const usbConfiguration1Descriptor = usb::descriptor::MakeConfigurationDescriptor([]() {
using namespace usb::descriptor;
return Configuration{
1,
3,
false,
false,
100,
define_vendor_specific_interface(
1,
BulkEndpoint{EndpointDirection::Out, 1, 512},
InterruptEndpoint{EndpointDirection::In, 1, 512, 1}
),
define_vendor_specific_interface(
2,
BulkEndpoint{EndpointDirection::Out, 1, 512},
BulkEndpoint{EndpointDirection::In, 1, 512},
BulkEndpoint{EndpointDirection::In, 2, 512},
BulkEndpoint{EndpointDirection::In, 3, 512}
)
};
});
void DumpHexBlock(std::span<std::uint8_t const> buffer)
{
constexpr static auto hex = "0123456789ABCDEF";
for(auto i = 0; i < buffer.size(); ++i)
{
if(i % 8 == 0)
putchar('\n');
else
putchar(' ');
const auto b = buffer[i];
putchar(hex[(b >> 4)]);
putchar(hex[(b & 0x0F)]);
}
putchar('\n');
}
int main()
{
DumpHexBlock(usbConfiguration1Descriptor);
}