Add STC12B protocol variant

This is just like STC12, but with the STC12A option packet. Used by
STC12xx52 series, STC12xx56 series and possibly others.

Fixes grigorig/stcgal#14.
This commit is contained in:
Grigori Goronzy 2016-05-20 02:46:03 +02:00
parent d6ef028dc7
commit f90fe4152b
3 changed files with 11 additions and 1 deletions

View File

@ -117,6 +117,7 @@ protocols and MCU series is as follows:
* ```stc89``` STC 89/90 series
* ```stc12a``` STC12Cx052AD and possibly others
* ```stc12b``` STC12x52xx series, STC12x56xx series and possibly others
* ```stc12``` Most STC10/11/12 series (default)
* ```stc15a``` STC15x104E and STC15x204E(A) series
* ```stc15``` Most STC15 series

View File

@ -37,6 +37,8 @@ class StcGal:
self.protocol = Stc89Protocol(opts.port, opts.handshake, opts.baud)
elif opts.protocol == "stc12a":
self.protocol = Stc12AProtocol(opts.port, opts.handshake, opts.baud)
elif opts.protocol == "stc12b":
self.protocol = Stc12BProtocol(opts.port, opts.handshake, opts.baud)
elif opts.protocol == "stc12":
self.protocol = Stc12Protocol(opts.port, opts.handshake, opts.baud)
elif opts.protocol == "stc15a":
@ -194,7 +196,7 @@ def cli():
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", "usb15", "auto"], default="stc12")
parser.add_argument("-P", "--protocol", help="protocol version", choices=["stc89", "stc12a", "stc12b", "stc12", "stc15a", "stc15", "usb15", "auto"], 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)
parser.add_argument("-l", "--handshake", help="handshake baud rate (default: 2400)", type=BaudType(), default=2400)

View File

@ -194,6 +194,7 @@ class StcBaseProtocol:
protocol_database = [("stc89", "STC(89|90)(C|LE)\d"),
("stc12a", "STC12(C|LE)\d052"),
("stc12b", "STC12(C|LE)(52|56)"),
("stc12", "(STC|IAP)(10|11|12)\D"),
("stc15a", "(STC|IAP)15[FL][01]0\d(E|EA|)$"),
("stc15", "(STC|IAP|IRC)15\D")]
@ -914,6 +915,12 @@ class Stc12Protocol(Stc12OptionsMixIn, Stc12BaseProtocol):
Stc12BaseProtocol.__init__(self, port, handshake, baud)
class Stc12BProtocol(Stc12AOptionsMixIn, Stc12BaseProtocol):
"""STC 10/11/12 variant protocol handler"""
def __init__(self, port, handshake, baud):
Stc12BaseProtocol.__init__(self, port, handshake, baud)
class Stc15AProtocol(Stc12Protocol):
"""Protocol handler for STC 15 series"""