Skip to content

Commit 0be61e0

Browse files
committed
util: Update input format selection.
1 parent eaed336 commit 0be61e0

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

orbtrace_util.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ def parse_power(value):
1010

1111
return float(value)
1212

13+
input_formats = {
14+
'off': 0x00,
15+
'1': 0x01,
16+
'2': 0x02,
17+
'4': 0x03,
18+
'manchester': 0x10,
19+
'manchester_tpiu': 0x11,
20+
'nrz': 0x12,
21+
'nrz_tpiu': 0x13,
22+
}
23+
1324
parser = argparse.ArgumentParser()
1425

1526
parser_discovery = parser.add_argument_group('Device discovery')
@@ -18,7 +29,7 @@ def parse_power(value):
1829
parser_discovery.add_argument('--serial', help = 'Select serial number')
1930

2031
parser_actions = parser.add_argument_group('Actions')
21-
parser_actions.add_argument('--width', type = int, choices = [1, 2, 4], help = 'Set trace width')
32+
parser_actions.add_argument('--input-format', choices = input_formats, help = 'Set trace input format')
2233
parser_actions.add_argument('--vtref', type = parse_power, help = 'Set VTREF')
2334
parser_actions.add_argument('--vtpwr', type = parse_power, help = 'Set VTPWR')
2435

@@ -48,12 +59,10 @@ def read_config(self, device):
4859
if setting.getSubClass() == ord('P'):
4960
self.power_if = setting.getNumber()
5061

51-
def trace_set_width(self, width):
62+
def trace_set_input_format(self, format):
5263
assert self.trace_if is not None
5364

54-
type = {1: 1, 2: 2, 4: 3}[width]
55-
56-
self.handle.controlWrite(0x41, 0x01, type, self.trace_if, b'')
65+
self.handle.controlWrite(0x41, 0x01, input_formats[format], self.trace_if, b'')
5766

5867
def power_set_enable(self, channel, enable):
5968
assert self.power_if is not None
@@ -95,8 +104,8 @@ def power_set_voltage(self, channel, voltage):
95104

96105
orbtrace = Orbtrace(devices[0])
97106

98-
if args.width:
99-
orbtrace.trace_set_width(args.width)
107+
if args.input_format:
108+
orbtrace.trace_set_input_format(args.input_format)
100109

101110
if args.vtref:
102111
if args.vtref in ['off', 'on']:

0 commit comments

Comments
 (0)