-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrwops.py
More file actions
41 lines (39 loc) · 1.27 KB
/
rwops.py
File metadata and controls
41 lines (39 loc) · 1.27 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
#!/usr/bin/env python3
# Note: See PPR Table "AccessType Definitions"
rwops = {"Read-write",
"Read-only",
#"Reset",
"Read,Write-1-to-clear",
"Volatile",
"Read-write,Volatile",
"Inaccessible",
"Write-only",
"Write-1-to-clear",
"Read-only,Volatile",
"Read-write,Read,Write-1-to-clear",
"Read,Write-1-to-clear,Volatile",
"Read-write,Reserved",
"Read,Error-on-write-1"}
def strip_off_rwops(item):
ops = {
}
item = item.strip()
for rwop in rwops:
if item.startswith(rwop + "."):
item = item[len(rwop + "."):].strip()
assert "access" not in ops, item
ops["access"] = rwop
#ops[rwop] = True
if item.startswith("Reset:"):
i = item.find(".")
assert i != -1
value = item[:i].strip()
if value.startswith("Reset:"):
value = value[len("Reset:"):].strip()
if value.startswith("Fixed,"):
value = value[len("Fixed,"):].strip()
if value.startswith("Cold,"):
value = value[len("Cold,"):].strip()
ops["Reset"] = value
item = item[i + len("."):].strip()
return ops, item