-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathdevice_spec.rs
More file actions
377 lines (320 loc) · 9.98 KB
/
Copy pathdevice_spec.rs
File metadata and controls
377 lines (320 loc) · 9.98 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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
use phf::{phf_map, Map};
use crate::platform_spec::{PlatformSpec, PLATFORM_SH68F881, PLATFORM_SH68F90};
const DEFAULT_ISP_IFACE_NUM: i32 = 1;
const DEFAULT_ISP_REPORT_ID: u32 = 5;
const DEFAULT_REBOOT: bool = true;
#[derive(Clone, Copy, PartialEq)]
pub struct DeviceSpec {
pub vendor_id: u16,
pub product_id: u16,
pub platform: PlatformSpec,
/// USB interface number with the ISP report
pub isp_iface_num: i32,
/// HID report ID
pub isp_report_id: u32,
pub reboot: bool,
}
pub const DEVICE_BASE_SH68F90: DeviceSpec = DeviceSpec {
vendor_id: 0x0000,
product_id: 0x0000,
platform: PLATFORM_SH68F90,
isp_iface_num: DEFAULT_ISP_IFACE_NUM,
isp_report_id: DEFAULT_ISP_REPORT_ID,
reboot: DEFAULT_REBOOT,
};
pub const DEVICE_BASE_SH68F881: DeviceSpec = DeviceSpec {
vendor_id: 0x0000,
product_id: 0x0000,
platform: PLATFORM_SH68F881,
isp_iface_num: DEFAULT_ISP_IFACE_NUM,
isp_report_id: DEFAULT_ISP_REPORT_ID,
reboot: DEFAULT_REBOOT,
};
pub const DEVICE_AULA_F75: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x010c,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_AULA_F87: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x010c,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_CIY_X77: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0016,
reboot: false,
..DEVICE_BASE_SH68F881
};
pub const DEVICE_DELTACO_WK95R: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0049,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_DIERYA_DK68SE: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x013b,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_DIGITALALLIANCE_MECA_WARRIOR_X: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0090,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_EWEADN_V20: DeviceSpec = DeviceSpec {
vendor_id: 0x05ac,
product_id: 0x024f,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_EYOOSO_Z11: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x002a,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_EYOOSO_Z82: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x010c,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_GENESIS_THOR_300: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x001f,
..DEVICE_BASE_SH68F881
};
pub const DEVICE_GENESIS_THOR_300_RGB: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0090,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_GLORIOUS_MODEL_O: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0036,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_KZZI_K68PRO: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0186,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_LEOBOG_HI75: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x010c,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_MACHENIKE_K500_B61: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0049,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_MAGEGEE_MKSTAR61: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x010c,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_NUPHY_AIR60: DeviceSpec = DeviceSpec {
vendor_id: 0x05ac,
product_id: 0x024f,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_PORTRONICS_HYDRA10: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0049,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_RE_K70_BYK800: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x001a,
..DEVICE_BASE_SH68F881
};
pub const DEVICE_REDRAGON_ANIVIA_K614: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0049,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_REDRAGON_FIZZ_K617: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0049,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_REDRAGON_K530_DRACONIC_PRO: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0049,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_REDRAGON_K618: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0049,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_REDRAGON_K630_NO_RGB: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x002a,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_REDRAGON_K633_RYZE: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0049,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_REDRAGON_K641_SHACO_PRO: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0049,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_REDRAGON_K652_PRO: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0049,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_REDRAGON_K658_PRO_SE: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0049,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_ROYALKLUDGE_RK100: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0056,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_ROYALKLUDGE_RK61: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x00c7,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_ROYALKLUDGE_RK68_BT_DUAL: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x008b,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_ROYALKLUDGE_RK68_ISO_RETURN: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x00a9,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_ROYALKLUDGE_RK71: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x00ea,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_ROYALKLUDGE_RK84_ISO_RETURN: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x00f4,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_ROYALKLUDGE_RKG68: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0049,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_SUPERFRAME_PHANTOM: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x019d,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_TERPORT_TR95: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0049,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_TRUST_GXT_960: DeviceSpec = DeviceSpec {
vendor_id: 0x145f,
product_id: 0x02b6,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_WEIKAV_SUGAR65: DeviceSpec = DeviceSpec {
vendor_id: 0x05ac,
product_id: 0x024f,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_XINMENG_K916: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x00a1,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_XINMENG_M71: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x010c,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_XINMENG_XM_RF68: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x002a,
..DEVICE_BASE_SH68F90
};
pub const DEVICE_YINREN_R108: DeviceSpec = DeviceSpec {
vendor_id: 0x258a,
product_id: 0x0049,
..DEVICE_BASE_SH68F90
};
pub static DEVICES: Map<&'static str, DeviceSpec> = phf_map! {
"aula-f75" => DEVICE_AULA_F75,
"aula-f87" => DEVICE_AULA_F87,
"ciy-x77" => DEVICE_CIY_X77,
"deltaco-wk95r" => DEVICE_DELTACO_WK95R,
"dierya-dk68se" => DEVICE_DIERYA_DK68SE,
"digitalalliance-meca-warrior-x" => DEVICE_DIGITALALLIANCE_MECA_WARRIOR_X,
"eweadn-v20" => DEVICE_EWEADN_V20,
"eyooso-z11" => DEVICE_EYOOSO_Z11,
"eyooso-z82" => DEVICE_EYOOSO_Z82,
"genesis-thor-300" => DEVICE_GENESIS_THOR_300,
"genesis-thor-300-rgb" => DEVICE_GENESIS_THOR_300_RGB,
"glorious-model-o" => DEVICE_GLORIOUS_MODEL_O,
"kzzi-k68pro" => DEVICE_KZZI_K68PRO,
"leobog-hi75" => DEVICE_LEOBOG_HI75,
"machenike-k500-b61" => DEVICE_MACHENIKE_K500_B61,
"magegee-mkstar61" => DEVICE_MAGEGEE_MKSTAR61,
"nuphy-air60" => DEVICE_NUPHY_AIR60,
"nuphy-air75" => DEVICE_NUPHY_AIR60, // same as nuphy-air60
"nuphy-air96" => DEVICE_NUPHY_AIR60, // same as nuphy-air60
"nuphy-halo65" => DEVICE_NUPHY_AIR60, // same as nuphy-air60
"portronics-hydra10" => DEVICE_PORTRONICS_HYDRA10,
"re-k70-byk800" => DEVICE_RE_K70_BYK800,
"redragon-k530-draconic-pro" => DEVICE_REDRAGON_K530_DRACONIC_PRO,
"redragon-k614-anivia" => DEVICE_REDRAGON_ANIVIA_K614,
"redragon-k617-fizz" => DEVICE_REDRAGON_FIZZ_K617,
"redragon-k618" => DEVICE_REDRAGON_K618,
"redragon-k630-norgb" => DEVICE_REDRAGON_K630_NO_RGB,
"redragon-k633-ryze" => DEVICE_REDRAGON_K633_RYZE,
"redragon-k641-shaco-pro" => DEVICE_REDRAGON_K641_SHACO_PRO,
"redragon-k652-pro" => DEVICE_REDRAGON_K652_PRO,
"redragon-k658-pro-se" => DEVICE_REDRAGON_K658_PRO_SE,
"royalkludge-rk100" => DEVICE_ROYALKLUDGE_RK100,
"royalkludge-rk61" => DEVICE_ROYALKLUDGE_RK61,
"royalkludge-rk68-bt-dual" => DEVICE_ROYALKLUDGE_RK68_BT_DUAL,
"royalkludge-rk68-iso-return" => DEVICE_ROYALKLUDGE_RK68_ISO_RETURN,
"royalkludge-rk71" => DEVICE_ROYALKLUDGE_RK71,
"royalkludge-rk84-iso-return" => DEVICE_ROYALKLUDGE_RK84_ISO_RETURN,
"royalkludge-rkg68" => DEVICE_ROYALKLUDGE_RKG68,
"superframe-phantom" => DEVICE_SUPERFRAME_PHANTOM,
"terport-tr95" => DEVICE_TERPORT_TR95,
"trust-gxt-960" => DEVICE_TRUST_GXT_960,
"weikav-sugar65" => DEVICE_WEIKAV_SUGAR65,
"xinmeng-k916" => DEVICE_XINMENG_K916,
"xinmeng-m66" => DEVICE_XINMENG_M71,
"xinmeng-m71" => DEVICE_XINMENG_M71,
"xinmeng-xm-rf68" => DEVICE_XINMENG_XM_RF68,
"yinren-r108" => DEVICE_YINREN_R108,
"yunzii-al66" => DEVICE_XINMENG_M71, // same as xinmeng-m71
"yunzii-al71" => DEVICE_XINMENG_M71, // same as xinmeng-m71
};
impl DeviceSpec {
pub fn available_devices() -> Vec<&'static str> {
let mut device_names = DEVICES.keys().copied().collect::<Vec<_>>();
device_names.sort();
device_names
}
pub fn num_pages(&self) -> usize {
self.platform.firmware_size / self.platform.page_size
}
pub fn total_flash_size(&self) -> usize {
self.platform.firmware_size + self.platform.bootloader_size
}
}
#[test]
fn test_device_num_pages() {
assert_eq!(DEVICE_NUPHY_AIR60.num_pages(), 30)
}
#[test]
fn test_device_total_flash_size() {
assert_eq!(DEVICE_NUPHY_AIR60.total_flash_size(), 65536)
}