-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
533 lines (473 loc) · 22.1 KB
/
index.html
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mbed Target Viewer</title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/semantic.min.js"></script>
<script src="https://semantic-ui.com/javascript/library/tablesort.js"></script>
<style>
body {
margin-left: 30px;
margin-right: 30px;
margin-top: 30px;
}
select {
height: 300px;
padding-right: 10px;
}
div#filter-container {
overflow: auto;
padding-bottom: 20px;
}
div#filter-container>div {
float: left;
padding-left: 20px;
}
</style>
</head>
<body>
<h1> Mbed OS Target Viewer</h1>
<div id="filter-container">
<div id="featurefiltering"> </div>
<div>
<label for="manufacturers">Filter by Manufacturer: <br /> </label>
<select id="manufacturers" multiple>
</select>
</div>
</div>
<input type="submit" onclick="compileFilters(), renderTable()" value="Filter">
<input type="submit" onclick="clearFilters(), renderTable()" value="Clear Filters">
<p id="activefilters"> </p>
<h3> Matched <span id="targetnum">0</span> targets</h3>
<table id="datatable" class="ui sortable celled table"></table>
<script>
var targetList = [];
// Maps JSON name of feature to a human readable form
var humanReadableFeatureNames = {
"802_15_4_PHY": "802.15.4 Radio",
"ANALOGIN": "Analog Inputs",
"ANALOGOUT": "Analog Outputs",
"CAN": "CAN",
"CRC": "Hardware CRC",
"DEBUG_AWARENESS": "Semihost Detectable",
"EMAC": "Ethernet MAC",
"ERROR_RED": "Uses Red Error LED",
"ETHERNET": "Ethernet PHY", // TODO: ignore this one since it is not accurate
"FLASH": "Onboard Flash",
"I2C": "I²C",
"I2CSLAVE": "I²C Slave",
"I2C_ASYNCH": "Asynchronous I²C",
"INTERRUPTIN": "Interrupt Inputs",
"ITM": "ITM Data Transmission",
"LOCALFILESYSTEM": "Mbed Disk Access from App",
"LPTICKER": "Low-Power Ticker",
"MPU": "Memory Protection Unit",
"OSPI": "Octo SPI",
"PORTIN": "Full-Port Input",
"PORTINOUT": "Full-Port I/O",
"PORTOUT": "Full-Port Output",
"PWMOUT": "PWM Out",
"QSPI": "Quad SPI",
"RESET_REASON": "Reset Reason",
"RTC": "Real-Time Clock",
"SEMIHOST": "Semihost", // TODO: ignore this one since it is not accurate
"SERIAL": "Serial",
"SERIAL_ASYNCH": "Asynchronous Serial",
"SERIAL_FC": "Serial Flow Control",
"SLEEP": "Sleep",
"SPI": "SPI",
"SPISLAVE": "SPI Slave",
"SPI_ASYNCH": "Asynchronous SPI",
"STDIO_MESSAGES": "Provides C Stdout",
"TRNG": "Hardware RNG",
"USBDEVICE": "USB Device",
"USTICKER": "Microsecond Ticker",
"WATCHDOG": "Watchdog Timer",
}
// Map of manufacturer names in extra_labels to display name
var knownManufacturers = {
"Silicon_Labs": "Silicon Labs",
"NXP": "NXP",
"Freescale": "NXP/Freescale",
"Analog_Devices": "Analog Devices",
"STM": "STMicroelectronics",
"RENESAS": "Renesas",
"Maxim": "Maxim",
"NORDIC": "Nordic Semiconductor",
"NUVOTON": "Nuvoton",
"TOSHIBA": "Toshiba",
"Cypress": "Cypress",
"Samsung": "Samsung",
"Atmel": "Microchip/Atmel", // note: Mbed 6 doesn't currently support any Atmel MCUs, but some older versions do.
"GigaDevice": "GigaDevice",
}
// Categories that features are sorted into
var featureCategories = {
"Functionality": [
"Mbed Bare Metal",
"Mbed RTOS"
],
"Communications": [
"CAN",
"I²C",
"I²C Slave",
"Asynchronous I²C",
"Serial",
"Asynchronous Serial",
"Serial Flow Control",
"SPI",
"SPI Slave",
"Asynchronous SPI",
"Quad SPI",
"USB Device",
],
"Network": [
"Ethernet MAC",
"802.15.4 Radio",
],
"Pins": [
"Full-Port Input",
"Full-Port I/O",
"Full-Port Output",
"Analog Inputs",
"Analog Outputs",
"Interrupt Inputs",
"PWM Out",
],
"Processor": [
"Hardware CRC",
"Low-Power Ticker",
"Memory Protection Unit",
"Reset Reason",
"Real-Time Clock",
"Hardware RNG",
"Microsecond Ticker",
"Watchdog Timer",
],
"Miscellaneous": [ // Any other stuff (newly added features?) not in any of the other lists should go here
"Onboard Flash",
"ITM Data Transmission",
"Mbed Disk Access from App",
"Provides C Stdout",
],
"Disabled": [ // things that are known inaccurate and are not displayed at all
"Octo SPI", // exists on some STM32 processors but is not currently supported by Mbed OS
"Semihost Detectable", // only true for one processor? And does anyone really care?
"Uses Red Error LED", // Noone cares it it has one error LED or 4. Also seems to be deprecated?
"Ethernet PHY", // Not accurate at all, misses loads of STM32 boards
"Semihost", // Not accurate I think?
"SYSTICK_CLK_OFF_DURING_SLEEP", // Literally no idea what this does. Used nowhere in the code.
]
};
// cols of the table
table_cols = ["Target Name", "Manufacturer", "CPU Name"];
// automatically create new selection forms and add new table columns
var selectionCreator = "";
for (category in featureCategories) {
if (category == "Disabled") continue;
table_cols.push(category);
selectionCreator += "<div><label for= \"" + category +
"\">Filter by " + category + ": <br /> </label> <select id = \"" +
category + "\" multiple></select></div>";
}
selectionCreator += "<div><label for=\"manufacturers\">Filter by Manufacturer: <br /> </label><select id=\"manufacturers\" multiple></select></div>"
$("div#filter-container").html(selectionCreator);
// add last few table cols
table_cols = [].concat(table_cols, ["Board Components", "RAM Size (kiB)", "ROM Size (kiB)"]);
var filtFeatures = {};
var filtManufacturers = [];
var newFeatures = {};
// create data structures for filtering features
for (category in featureCategories) {
if (category == "Disabled") continue;
filtFeatures[category] = [];
newFeatures[category] = [];
}
for (manu in knownManufacturers) filtManufacturers.push(knownManufacturers[manu]);
var newManufacturers;
// live updater for highlighted features
function displayVals() {
for (category in featureCategories) {
if (category == "Disabled") continue;
newFeatures[category] = $("#" + category).val() || [];
}
newManufacturers = $("#manufacturers").val() || [];
}
$("select").change(displayVals);
function compileFilters() {
// compile list of filtered features and manufacturers
var filtText = "";
for (category in featureCategories) {
if (category == "Disabled") continue;
filtFeatures[category] = [].concat(filtFeatures[category], newFeatures[category]);
if (filtFeatures[category].length > 0)
{
if(filtText !== "")
{
filtText += ", ";
}
filtText += filtFeatures[category].join();
}
}
if (newManufacturers.length) filtManufacturers = filtManufacturers.filter(value => newManufacturers.includes(value));
$("p#activefilters").html(" <b>Features Filtered:</b> " + filtText + "<br>" +
" <b>Manufacturers Filtered:</b> " + filtManufacturers.join(", "));
}
function clearFilters() {
// reset all filters
for (category in featureCategories) {
if (category == "Disabled") continue;
filtFeatures[category] = [];
}
filtManufacturers = [];
for (manu in knownManufacturers) filtManufacturers.push(knownManufacturers[manu]);
$("p#activefilters").html("");
}
// Hexadecimal to Decimal Converter
function hexToDec(hex) {
var result = 0, digitValue;
hex = hex.toLowerCase();
for (var i = 2; i < hex.length; i++) {
digitValue = '0123456789abcdefgh'.indexOf(hex[i]);
result = result * 16 + digitValue;
}
return result;
}
// Copy a single aggregate property over to the definition.
// These properties can be defined at multiple levels and must be merged together.
function copyAggregateProperty(definition, definitionPropName, targetJson, targetName, propertyName) {
// Property name by itself replaces the current value
if (propertyName in targetJson[targetName]) {
definition[definitionPropName] = targetJson[targetName][propertyName];
}
// _add adds to the current value
if (propertyName + "_add" in targetJson[targetName]) {
definition[definitionPropName] = definition[definitionPropName].concat(targetJson[targetName][propertyName + "_add"]);
}
// _remove subtracts from the current value
if (propertyName + "_remove" in targetJson[targetName]) {
// from here: https://stackoverflow.com/questions/45342155/how-to-subtract-one-array-from-another-element-wise-in-javascript
definition[definitionPropName] = definition[definitionPropName].filter(
item => !targetJson[targetName][propertyName + "_remove"].includes(item));
}
}
// Copy the relevant data from the JSON definition into the given
// object.
function copyTargetProperties(definition, targetJson, targetName) {
// First handle superclasses of this target.
// Follows Mbed OS "high to low, left to right" parser order
if ("inherits" in targetJson[targetName]) {
for (superclassIdx in targetJson[targetName]["inherits"]) {
copyTargetProperties(definition, targetJson, targetJson[targetName]["inherits"][superclassIdx]);
}
}
if ("device_name" in targetJson[targetName]) {
definition["CPU Name"] = targetJson[targetName]["device_name"];
}
if ("mbed_ram_size" in targetJson[targetName]) {
definition["RAM Size (kiB)"] = parseInt(hexToDec(targetJson[targetName]["mbed_ram_size"]) / 1000);
}
if ("mbed_rom_size" in targetJson[targetName]) {
definition["ROM Size (kiB)"] = parseInt(hexToDec(targetJson[targetName]["mbed_rom_size"]) / 1000);
}
if("supported_application_profiles" in targetJson[targetName])
{
definition["Supported Application Profiles"] = targetJson[targetName]["supported_application_profiles"];
}
copyAggregateProperty(definition, "Supported Features", targetJson, targetName, "device_has");
copyAggregateProperty(definition, "Board Components", targetJson, targetName, "components");
copyAggregateProperty(definition, "Extra Labels", targetJson, targetName, "extra_labels");
for (category in featureCategories) definition[category] = [];
}
// Build the list of targets using the raw JSON file.
// Resolves inheritance declarations and flattens the tree
// into a list.
function buildTargetList(targetJson) {
for (targetName in targetJson) {
// If the target does not have the "device_name" or "supported_form_factors"
// properties then it is a super-type, not an actual target board
if (!("device_name" in targetJson[targetName] || "supported_form_factors" in targetJson[targetName])) {
continue;
}
if (targetName == "Target") {
// Skip default target
continue;
}
var targetDefinition = { "Target Name": targetName }
copyTargetProperties(targetDefinition, targetJson, targetName);
// convert JSON feature names to human readable
for (featureIdx in targetDefinition["Supported Features"]) {
if (targetDefinition["Supported Features"][featureIdx] in humanReadableFeatureNames) {
targetDefinition["Supported Features"][featureIdx] = humanReadableFeatureNames[targetDefinition["Supported Features"][featureIdx]];
}
var foundCategory = false;
// divide Supported Features into feature categories
for (category in featureCategories) {
for (i in featureCategories[category]) {
if (targetDefinition["Supported Features"][featureIdx] == featureCategories[category][i]) {
targetDefinition[category].push(targetDefinition["Supported Features"][featureIdx]);
foundCategory = true;
}
}
}
if (!foundCategory) targetDefinition["Miscellaneous"].push(targetDefinition["Supported Features"][featureIdx]);
}
// handle Bare Metal and RTOS, which are not defined as normal features for some reason
if("Supported Application Profiles" in targetDefinition)
{
targetDefinition["Functionality"] = []
if(targetDefinition["Supported Application Profiles"].includes("bare-metal"))
{
targetDefinition["Functionality"].push("Mbed Bare Metal");
}
if(targetDefinition["Supported Application Profiles"].includes("full"))
{
targetDefinition["Functionality"].push("Mbed RTOS");
}
}
// Try to figure out the manufacturer from the Extra Features
var foundManufacturer = false;
for (labelIdx in targetDefinition["Extra Labels"]) {
if (targetDefinition["Extra Labels"][labelIdx] in knownManufacturers) {
targetDefinition["Manufacturer"] = knownManufacturers[targetDefinition["Extra Labels"][labelIdx]];
foundManufacturer = true;
break;
}
}
if (!foundManufacturer) {
targetDefinition["Manufacturer"] = "";
}
targetList.push(targetDefinition);
}
}
// Redraw the table, taking the current filters into account
function renderTable() {
table = "<thead>"
// draw header row
table += "<tr>";
for (columnIdx in table_cols) {
table += "<th>";
table += table_cols[columnIdx];
table += "</th>";
}
table += "</tr>";
table += "</thead>";
table += "<tbody>";
var matchedTargets = 0;
var selectFeature = {};
for (category in featureCategories) {
if (category == "Disabled") continue;
selectFeature[category] = document.getElementById(category);
}
var optionsFeature = {};
for (category in featureCategories) {
if (category == "Disabled") continue;
optionsFeature[category] = [];
}
var selectManu = document.getElementById("manufacturers");
var optionsManu = [];
// draw element rows
for (targetIdx in targetList) {
// filter out targets that do not have the required features
var missingQuals = false;
for (category in featureCategories) {
if (category == "Disabled") continue;
for (feature in filtFeatures[category]) {
if (!targetList[targetIdx][category].includes(filtFeatures[category][feature])) {
missingQuals = true;
break;
}
}
}
if (!filtManufacturers.includes(targetList[targetIdx]["Manufacturer"]) && filtManufacturers.length) {
missingQuals = true;
}
if (missingQuals) {
continue;
}
// remake feature selection form based on the supported features within the selection
for (category in featureCategories) {
if (category == "Disabled") continue;
for (feature in targetList[targetIdx][category]) {
var option = document.createElement('option');
option.text = option.value = targetList[targetIdx][category][feature];
if (!optionsFeature[category].includes(option.outerHTML)) {
optionsFeature[category].push(option.outerHTML);
}
}
}
// remake manufacturer selection form based on the supported features within the selection
var option = document.createElement('option');
option.text = option.value = targetList[targetIdx]["Manufacturer"];
if (!optionsManu.includes(option.outerHTML)) {
optionsManu.push(option.outerHTML);
}
matchedTargets++;
table += "<tr>";
for (columnIdx in table_cols) {
if (columnIdx == 1) {
// by default, sort by the manufacturer in ascending order
table += "<td class=\"sorted ascending\">";
}
else {
table += "<td>";
}
var currCol = table_cols[columnIdx];
if (!(currCol in targetList[targetIdx])) {
// render undefined values as empty string
}
else if (columnIdx == 0) {
if (columnIdx == 0 && (targetList[targetIdx][table_cols[columnIdx]]).substr(0, 6) == "NUCLEO") {
var link = "https://os.mbed.com/platforms/ST-Nucleo-" + (targetList[targetIdx][currCol]).substr(7, 6) + "/";
table += "<a href=" + link + ">" + targetList[targetIdx][table_cols[columnIdx]] + "</a>";
}
else if (columnIdx == 0) {
var link = "https://os.mbed.com/platforms/" + (targetList[targetIdx][currCol]) + "/";
link = link.replace(/_/g, '-');
table += "<a href=" + link + ">" + targetList[targetIdx][table_cols[columnIdx]] + "</a>";
}
else {
table += targetList[targetIdx][currCol];
}
}
else if (Array.isArray(targetList[targetIdx][currCol])) {
// render arrays as bullet lists
table += "<ul>";
targetList[targetIdx][currCol].forEach(value => table += "<li>" + value + "</li>");
table += "</ul>";
}
else {
table += targetList[targetIdx][currCol];
}
table += "</td>";
}
table += "</tr>";
}
table += "</tbody>";
// replace current contents
document.getElementById("datatable").innerHTML = table;
$("#targetnum").html(matchedTargets)
// resort
$("#datatable").tablesort()
$("#datatable>thead>tr>th:nth-child(2)").trigger("click");
// clear and remake feature selection form
for (category in featureCategories) {
if (category == "Disabled") continue;
var i, L = selectFeature[category].options.length - 1;
for (i = L; i >= 0; i--) selectFeature[category].remove(i);
selectFeature[category].insertAdjacentHTML('beforeEnd', optionsFeature[category].join('\n'));
}
// clear and remake manufacturer selection form
var i, L = selectManu.options.length - 1;
for (i = L; i >= 0; i--) selectManu.remove(i);
selectManu.insertAdjacentHTML('beforeEnd', optionsManu.join('\n'));
}
$.getJSON('https://raw.githubusercontent.com/ARMmbed/mbed-os/master/targets/targets.json', function (data) {
buildTargetList(data);
renderTable();
});
</script>
</body>
</html>