-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathme56ps2.h
131 lines (117 loc) · 4.87 KB
/
me56ps2.h
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "usb_struct.h"
constexpr auto ME56PS2_BCD_USB = 0x0110U; // USB 1.1
constexpr auto ME56PS2_BCD_DEVICE = 0x0101U;
constexpr auto ME56PS2_USB_VENDOR_ID = 0x0590U; // Omron Corp.
constexpr auto ME56PS2_USB_PRODUCT_ID = 0x001aU; // ME56PS2
constexpr auto ME56PS2_COM_EP_ADDR = 2U;
constexpr auto ME56PS2_COM_EP_ADDR_IN = ME56PS2_COM_EP_ADDR | USB_DIR_IN;
constexpr auto ME56PS2_COM_EP_ADDR_OUT = ME56PS2_COM_EP_ADDR | USB_DIR_OUT;
constexpr auto MAX_PACKET_SIZE_CONTROL = 64U; // 8 in original ME56PS2
constexpr auto MAX_PACKET_SIZE_BULK = 64U;
enum ME56PS2_STRING_ID {
ME56PS2_STRING_ID_MANUFACTURER = 1,
ME56PS2_STRING_ID_PRODUCT = 2,
ME56PS2_STRING_ID_SERIAL = 3,
};
// W5500-EVB-PICO pinout
enum PINOUT {
PINOUT_USER_LED = 25,
PINOUT_ETHERNET_RESET = 20,
PINOUT_ETHERNET_SS = 17,
};
enum class modem_state : int {
NotInitialized,
Offline,
Ringing,
Calling,
Online,
Disconnected,
};
const struct usb_device_descriptor me56ps2_device_descriptor = {
.bLength = sizeof(struct usb_device_descriptor),
.bDescriptorType = USB_DESCRIPTOR_TYPE_DEVICE,
.bcdUSB = ME56PS2_BCD_USB,
.bDeviceClass = 0,
.bDeviceSubClass = 0,
.bDeviceProtocol = 0,
.bMaxPacketSize0 = MAX_PACKET_SIZE_CONTROL,
.idVendor = ME56PS2_USB_VENDOR_ID,
.idProduct = ME56PS2_USB_PRODUCT_ID,
.bcdDevice = ME56PS2_BCD_DEVICE,
.iManufacturer = ME56PS2_STRING_ID_MANUFACTURER,
.iProduct = ME56PS2_STRING_ID_PRODUCT,
.iSerialNumber = ME56PS2_STRING_ID_SERIAL,
.bNumConfigurations = 1,
};
struct usb_config_descriptors {
struct usb_configuration_descriptor config;
struct usb_interface_descriptor interface;
struct usb_endpoint_descriptor endpoint_bulk_in;
struct usb_endpoint_descriptor endpoint_bulk_out;
};
const struct usb_config_descriptors me56ps2_config_descriptors = {
.config = {
.bLength = sizeof(usb_configuration_descriptor),
.bDescriptorType = USB_DESCRIPTOR_TYPE_CONFIGURATION,
.wTotalLength = sizeof(me56ps2_config_descriptors),
.bNumInterfaces = 1,
.bConfigurationValue = 1,
.iConfiguration = 2,
.bmAttributes = USB_CONFIG_ATTR_REMOTE_WAKEUP,
.bMaxPower = 0x1e, // 60mA
},
.interface = {
.bLength = sizeof(usb_interface_descriptor),
.bDescriptorType = USB_DESCRIPTOR_TYPE_INTERFACE,
.bInterfaceNumber = 0,
.bAlternateSetting = 0,
.bNumEndpoints = 2,
.bInterfaceClass = 0xff, // Vendor specific
.bInterfaceSubClass = 0xff, // Vendor specific
.bInterfaceProtocol = 0xff, // Vendor specific
.iInterface = ME56PS2_STRING_ID_PRODUCT,
},
.endpoint_bulk_in = {
.bLength = sizeof(struct usb_endpoint_descriptor),
.bDescriptorType = USB_DESCRIPTOR_TYPE_ENDPOINT,
.bEndpointAddress = ME56PS2_COM_EP_ADDR_IN,
.bmAttributes = USB_ENDPOINT_TRANSFER_TYPE_BULK,
.wMaxPacketSize = MAX_PACKET_SIZE_BULK,
.bInterval = 0,
},
.endpoint_bulk_out = {
.bLength = sizeof(struct usb_endpoint_descriptor),
.bDescriptorType = USB_DESCRIPTOR_TYPE_ENDPOINT,
.bEndpointAddress = ME56PS2_COM_EP_ADDR_OUT,
.bmAttributes = USB_ENDPOINT_TRANSFER_TYPE_BULK,
.wMaxPacketSize = MAX_PACKET_SIZE_BULK,
.bInterval = 0,
}
};
const struct usb_string_descriptor<1> me56ps2_string_descriptor_0 = {
.bLength = sizeof(me56ps2_string_descriptor_0),
.bDescriptorType = USB_DESCRIPTOR_TYPE_STRING,
.wData = {0x0409},
};
const struct usb_string_descriptor<3> me56ps2_string_descriptor_1 = { // Manufacturer
.bLength = sizeof(me56ps2_string_descriptor_1),
.bDescriptorType = USB_DESCRIPTOR_TYPE_STRING,
.wData = {u'N', u'/', u'A'},
};
const struct usb_string_descriptor<14> me56ps2_string_descriptor_2 = { // Product
.bLength = sizeof(me56ps2_string_descriptor_2),
.bDescriptorType = USB_DESCRIPTOR_TYPE_STRING,
.wData = {u'M', u'o', u'd', u'e', u'm', u' ', u'e', u'm', u'u', u'l', u'a', u't', u'o', u'r'},
};
const struct usb_string_descriptor<3> me56ps2_string_descriptor_3 = { // Serial
.bLength = sizeof(me56ps2_string_descriptor_3),
.bDescriptorType = USB_DESCRIPTOR_TYPE_STRING,
.wData = {u'N', u'/', u'A'},
};
constexpr auto ME56PS2_STRING_DESCRIPTORS_NUM = 4;
const void *me56ps2_string_descriptors[ME56PS2_STRING_DESCRIPTORS_NUM] = {
&me56ps2_string_descriptor_0,
&me56ps2_string_descriptor_1,
&me56ps2_string_descriptor_2,
&me56ps2_string_descriptor_3,
};