/
ch340.py
58 lines (40 loc) · 1.25 KB
/
ch340.py
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
from zorrom import mrom
# Unknown CH340, possibly CH340T
class CH340T(mrom.MaskROM):
def desc(self):
return 'CH340T'
def endian(self):
return "big"
def word_bits(self):
return 14
def nwords(self):
return ((16 * 14 * 64) // 14)
def txtwh(self):
# 14 groups (16 bits in each) of 224 bits across, 64 lines down.
return (16 * 14, 64)
def invert(self):
return True
'''Given binary (word offset, bit index) return image row/col'''
def calc_oi2cr(self, offset, maski):
row = offset // 16
col = (15 - (offset % 16)) + 16 * (13 - maski)
return (col, row)
class CH340G(mrom.MaskROM):
def desc(self):
return 'CH340G'
def endian(self):
return "big"
def word_bits(self):
return 14
def nwords(self):
return ((16 * 14 * 128) // 14)
def txtwh(self):
# 14 groups (16 bits in each) of 224 bits across, 128 lines down.
return (16 * 14, 128)
def invert(self):
return False
'''Given binary (word offset, bit index) return image row/col'''
def calc_oi2cr(self, offset, maski):
row = offset // 16
col = (15 - (offset % 16)) + 16 * (13 - maski)
return (col, row)