|
|
@ -446,13 +446,14 @@ class Stc15AOption(BaseOption):
|
|
|
|
|
|
|
|
|
|
|
|
class Stc15Option(BaseOption):
|
|
|
|
class Stc15Option(BaseOption):
|
|
|
|
def __init__(self, msr):
|
|
|
|
def __init__(self, msr):
|
|
|
|
assert len(msr) >= 4
|
|
|
|
assert len(msr) == 5
|
|
|
|
self.msr = bytearray(msr)
|
|
|
|
self.msr = bytearray(msr)
|
|
|
|
|
|
|
|
|
|
|
|
self.options = (
|
|
|
|
self.options = (
|
|
|
|
("reset_pin_enabled", self.get_reset_pin_enabled, self.set_reset_pin_enabled),
|
|
|
|
("reset_pin_enabled", self.get_reset_pin_enabled, self.set_reset_pin_enabled),
|
|
|
|
("clock_source", self.get_clock_source, self.set_clock_source),
|
|
|
|
("clock_source", self.get_clock_source, self.set_clock_source),
|
|
|
|
("clock_gain", self.get_clock_gain, self.set_clock_gain),
|
|
|
|
("clock_gain", self.get_clock_gain, self.set_clock_gain),
|
|
|
|
|
|
|
|
("cpu_core_voltage", self.get_core_voltage, self.set_core_voltage),
|
|
|
|
("watchdog_por_enabled", self.get_watchdog, self.set_watchdog),
|
|
|
|
("watchdog_por_enabled", self.get_watchdog, self.set_watchdog),
|
|
|
|
("watchdog_stop_idle", self.get_watchdog_idle, self.set_watchdog_idle),
|
|
|
|
("watchdog_stop_idle", self.get_watchdog_idle, self.set_watchdog_idle),
|
|
|
|
("watchdog_prescale", self.get_watchdog_prescale, self.set_watchdog_prescale),
|
|
|
|
("watchdog_prescale", self.get_watchdog_prescale, self.set_watchdog_prescale),
|
|
|
@ -467,9 +468,6 @@ class Stc15Option(BaseOption):
|
|
|
|
("uart2_pin_mode", self.get_uart_pin_mode, self.set_uart_pin_mode),
|
|
|
|
("uart2_pin_mode", self.get_uart_pin_mode, self.set_uart_pin_mode),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if len(msr) > 4:
|
|
|
|
|
|
|
|
self.options += ("cpu_core_voltage", self.get_core_voltage, self.set_core_voltage),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_reset_pin_enabled(self):
|
|
|
|
def get_reset_pin_enabled(self):
|
|
|
|
return not bool(self.msr[2] & 16)
|
|
|
|
return not bool(self.msr[2] & 16)
|
|
|
|
|
|
|
|
|
|
|
@ -734,9 +732,10 @@ class StcBaseProtocol:
|
|
|
|
Set up serial port, send sync sequence and get part info.
|
|
|
|
Set up serial port, send sync sequence and get part info.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
self.ser = serial.Serial(port=self.port, parity=self.PARITY)
|
|
|
|
self.ser = serial.Serial(port=self.port,
|
|
|
|
# set baudrate separately to work around a bug with the CH340 driver
|
|
|
|
parity=self.PARITY)
|
|
|
|
# on older Linux kernels
|
|
|
|
# set baudrate separately to workaround a bug with the CH340 driver
|
|
|
|
|
|
|
|
# in older Linux kernels
|
|
|
|
self.ser.baudrate = self.baud_handshake
|
|
|
|
self.ser.baudrate = self.baud_handshake
|
|
|
|
|
|
|
|
|
|
|
|
# fast timeout values to deal with detection errors
|
|
|
|
# fast timeout values to deal with detection errors
|
|
|
@ -1927,10 +1926,7 @@ class Stc15Protocol(Stc15AProtocol):
|
|
|
|
0xff])
|
|
|
|
0xff])
|
|
|
|
packet += bytes([msr[3]])
|
|
|
|
packet += bytes([msr[3]])
|
|
|
|
packet += bytes([0xff] * 23)
|
|
|
|
packet += bytes([0xff] * 23)
|
|
|
|
if len(msr) > 4:
|
|
|
|
packet += bytes([msr[4]])
|
|
|
|
packet += bytes([msr[4]])
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
packet += bytes([0xff])
|
|
|
|
|
|
|
|
packet += bytes([0xff] * 3)
|
|
|
|
packet += bytes([0xff] * 3)
|
|
|
|
packet += bytes([self.trim_value[0], self.trim_value[1] + 0x3f])
|
|
|
|
packet += bytes([self.trim_value[0], self.trim_value[1] + 0x3f])
|
|
|
|
packet += msr[0:3]
|
|
|
|
packet += msr[0:3]
|
|
|
|