Add autoreset feature via DTR control line

This is inspired by Arduino.  Directly before connect, DTR is asserted
for 0.5 seconds and then deasserted again.  With a small external
circuit, the MCU can be power-cycled with this control signal.
In case the MCU draws very little power, it may even be possible to
supply power directly from the DTR pin.
This commit is contained in:
Grigori Goronzy
2016-04-02 23:00:07 +02:00
parent 41cabb587b
commit 372f854c77
2 changed files with 15 additions and 4 deletions

View File

@ -117,7 +117,7 @@ class StcGal:
self.protocol.disconnect()
def run(self):
try: self.protocol.connect()
try: self.protocol.connect(autoreset=self.opts.autoreset)
except KeyboardInterrupt:
sys.stdout.flush();
print("interrupted")
@ -174,6 +174,7 @@ def cli():
description="stcgal %s - an STC MCU ISP flash tool\n(C) 2014-2015 Grigori Goronzy\nhttps://github.com/grigorig/stcgal" %stcgal.__version__)
parser.add_argument("code_image", help="code segment file to flash (BIN/HEX)", type=argparse.FileType("rb"), nargs='?')
parser.add_argument("eeprom_image", help="eeprom segment file to flash (BIN/HEX)", type=argparse.FileType("rb"), nargs='?')
parser.add_argument("-a", "--autoreset", help="cycle power automatically by asserting DTR", action="store_true")
parser.add_argument("-P", "--protocol", help="protocol version", choices=["stc89", "stc12a", "stc12", "stc15a", "stc15"], default="stc12")
parser.add_argument("-p", "--port", help="serial port device", default="/dev/ttyUSB0")
parser.add_argument("-b", "--baud", help="transfer baud rate (default: 19200)", type=BaudType(), default=19200)