forked from xcore/tool_axe
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPortNames.cpp
More file actions
80 lines (71 loc) · 1.98 KB
/
PortNames.cpp
File metadata and controls
80 lines (71 loc) · 1.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
#include "PortNames.h"
#include <map>
struct PortNames {
std::map<uint32_t, std::string> portNames;
std::map<std::string, uint32_t> portIds;
void addPort(const std::string &name, uint32_t id) {
portNames.insert(std::make_pair(id, name));
portIds.insert(std::make_pair(name, id));
}
PortNames();
bool getPortName(uint32_t id, std::string &name) {
std::map<uint32_t,std::string>::iterator it = portNames.find(id);
if (it == portNames.end()) {
return false;
}
name = it->second;
return true;
}
bool getPortId(const std::string &name, uint32_t &id) {
std::map<std::string,uint32_t>::iterator it = portIds.find(name);
if (it == portIds.end()) {
return false;
}
id = it->second;
return true;
}
};
PortNames::PortNames()
{
addPort("PORT_32A", 0x200000);
addPort("PORT_32B", 0x200100);
addPort("PORT_16A", 0x100000);
addPort("PORT_16B", 0x100100);
addPort("PORT_16C", 0x100200);
addPort("PORT_16D", 0x100300);
addPort("PORT_8A", 0x80000);
addPort("PORT_8B", 0x80100);
addPort("PORT_8C", 0x80200);
addPort("PORT_8D", 0x80300);
addPort("PORT_4A", 0x40000);
addPort("PORT_4B", 0x40100);
addPort("PORT_4C", 0x40200);
addPort("PORT_4D", 0x40300);
addPort("PORT_4E", 0x40400);
addPort("PORT_4F", 0x40500);
addPort("PORT_1A", 0x10200);
addPort("PORT_1B", 0x10000);
addPort("PORT_1C", 0x10100);
addPort("PORT_1D", 0x10300);
addPort("PORT_1E", 0x10600);
addPort("PORT_1F", 0x10400);
addPort("PORT_1G", 0x10500);
addPort("PORT_1H", 0x10700);
addPort("PORT_1I", 0x10a00);
addPort("PORT_1J", 0x10800);
addPort("PORT_1K", 0x10900);
addPort("PORT_1L", 0x10b00);
addPort("PORT_1M", 0x10c00);
addPort("PORT_1N", 0x10d00);
addPort("PORT_1O", 0x10e00);
addPort("PORT_1P", 0x10f00);
}
static PortNames portNames;
bool getPortName(uint32_t id, std::string &name)
{
return portNames.getPortName(id, name);
}
bool getPortId(const std::string &name, uint32_t &id)
{
return portNames.getPortId(name, id);
}