mirror of
https://github.com/jonathanhogg/scopething
synced 2025-07-14 03:02:09 +01:00
Compare commits
5 Commits
188db8bd76
...
main
Author | SHA1 | Date | |
---|---|---|---|
7e2b262429 | |||
58aaf4c74e | |||
759828c637 | |||
f3748a4c6a | |||
81eba8bc5c |
Binary file not shown.
24
scope.py
24
scope.py
@ -174,9 +174,11 @@ class Scope(vm.VirtualMachine):
|
||||
if capture_mode.analog_channels == len(analog_channels) and capture_mode.logic_channels == bool(logic_channels):
|
||||
Log.debug(f"Considering trace mode {capture_mode.trace_mode.name}...")
|
||||
if ticks > capture_mode.clock_high and capture_mode.clock_divide > 1:
|
||||
clock_scale = int(math.ceil(period / self.primary_clock_period / nsamples / capture_mode.clock_high))
|
||||
clock_scale = min(capture_mode.clock_divide, int(math.ceil(period / self.primary_clock_period / nsamples / capture_mode.clock_high)))
|
||||
ticks = int(round(period / self.primary_clock_period / nsamples / clock_scale))
|
||||
if ticks in range(capture_mode.clock_low, capture_mode.clock_high+1):
|
||||
if ticks > capture_mode.clock_low:
|
||||
if ticks > capture_mode.clock_high:
|
||||
ticks = capture_mode.clock_high
|
||||
Log.debug(f"- try with tick count {ticks} x {clock_scale}")
|
||||
else:
|
||||
continue
|
||||
@ -234,15 +236,7 @@ class Scope(vm.VirtualMachine):
|
||||
if trigger_level is None:
|
||||
trigger_level = (high + low) / 2
|
||||
analog_trigger_level = (trigger_level - analog_params.offset) / analog_params.scale if not raw else trigger_level
|
||||
if trigger in {'A', 'B'}:
|
||||
if trigger == 'A':
|
||||
spock_option |= vm.SpockOption.TriggerSourceA
|
||||
trigger_logic = 0x80
|
||||
elif trigger == 'B':
|
||||
spock_option |= vm.SpockOption.TriggerSourceB
|
||||
trigger_logic = 0x40
|
||||
trigger_mask = 0xff ^ trigger_logic
|
||||
elif isinstance(trigger, dict):
|
||||
if isinstance(trigger, dict):
|
||||
trigger_logic = 0
|
||||
trigger_mask = 0xff
|
||||
for channel, value in trigger.items():
|
||||
@ -257,6 +251,14 @@ class Scope(vm.VirtualMachine):
|
||||
trigger_mask &= ~mask
|
||||
if value:
|
||||
trigger_logic |= mask
|
||||
elif trigger in {'A', 'B'}:
|
||||
if trigger == 'A':
|
||||
spock_option |= vm.SpockOption.TriggerSourceA
|
||||
trigger_logic = 0x80
|
||||
elif trigger == 'B':
|
||||
spock_option |= vm.SpockOption.TriggerSourceB
|
||||
trigger_logic = 0x40
|
||||
trigger_mask = 0xff ^ trigger_logic
|
||||
else:
|
||||
raise ValueError("Unrecognised trigger value")
|
||||
trigger_type = trigger_type.lower()
|
||||
|
@ -24,7 +24,7 @@ class SerialStream:
|
||||
@classmethod
|
||||
def devices_matching(cls, vid=None, pid=None, serial_number=None):
|
||||
for port in comports():
|
||||
if (vid is None or vid == port.vid) and (pid is None or pid == port.pid) and (serial is None or serial_number == port.serial_number):
|
||||
if (vid is None or vid == port.vid) and (pid is None or pid == port.pid) and (serial_number is None or serial_number == port.serial_number):
|
||||
yield port.device
|
||||
|
||||
@classmethod
|
||||
|
10
vm.py
10
vm.py
@ -6,7 +6,7 @@ Package capturing BitScope VM specification, including registers, enumerations,
|
||||
commands and logic for encoding and decoding virtual machine instructions and data.
|
||||
|
||||
All names and descriptions copyright BitScope and taken from their [VM specification
|
||||
document][VM01B].
|
||||
document][VM01B] (with slight changes).
|
||||
|
||||
[VM01B]: https://docs.google.com/document/d/1cZNRpSPAMyIyAvIk_mqgEByaaHzbFTX8hWglAMTlnHY
|
||||
|
||||
@ -90,8 +90,8 @@ Registers = DotDict({
|
||||
"TriggerOutro": Register(0x34, 'U16', "Edge trigger outro filter counter (samples/2)"),
|
||||
"TriggerValue": Register(0x44, 'S0.16', "Digital (comparator) trigger (signed)"),
|
||||
"TriggerTime": Register(0x40, 'U32', "Stopwatch trigger time (ticks)"),
|
||||
"ClockTicks": Register(0x2e, 'U16', "Master Sample (clock) period (ticks)"),
|
||||
"ClockScale": Register(0x14, 'U16', "Clock divide by N (low byte)"),
|
||||
"ClockTicks": Register(0x2e, 'U16', "Sample period (ticks)"),
|
||||
"ClockScale": Register(0x14, 'U16', "Sample clock divider"),
|
||||
"TraceOption": Register(0x20, 'U8', "Trace Mode Option bits"),
|
||||
"TraceMode": Register(0x21, 'U8', "Trace Mode (see Trace Mode Table)"),
|
||||
"TraceIntro": Register(0x26, 'U16', "Pre-trigger capture count (samples)"),
|
||||
@ -151,8 +151,8 @@ Registers = DotDict({
|
||||
"Map5": Register(0x99, 'U8', "Peripheral Pin Select Channel 5"),
|
||||
"Map6": Register(0x9a, 'U8', "Peripheral Pin Select Channel 6"),
|
||||
"Map7": Register(0x9b, 'U8', "Peripheral Pin Select Channel 7"),
|
||||
"MasterClockN": Register(0xf7, 'U8', "PLL prescale (DIV N)"),
|
||||
"MasterClockM": Register(0xf8, 'U16', "PLL multiplier (MUL M)"),
|
||||
"PrimaryClockN": Register(0xf7, 'U8', "PLL prescale (DIV N)"),
|
||||
"PrimaryClockM": Register(0xf8, 'U16', "PLL multiplier (MUL M)"),
|
||||
})
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user