From 46d3c24fc0a97ffeca5e33c19843a10870d7c9fc Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Mon, 14 Oct 2013 20:44:57 +0200 Subject: Revert "Remove makeSip6.py helperscript" This reverts commit 9d8499af2c05a7a71adb75113a1c7d7a3d9bd8d0. --- libtoprammer/chips/microchip8/makeSip6.py | 74 +++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 libtoprammer/chips/microchip8/makeSip6.py (limited to 'libtoprammer/chips') diff --git a/libtoprammer/chips/microchip8/makeSip6.py b/libtoprammer/chips/microchip8/makeSip6.py new file mode 100644 index 0000000..8a72d0c --- /dev/null +++ b/libtoprammer/chips/microchip8/makeSip6.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python + +""" +# TOP2049 Open Source programming suite +# +# Commandline utility +# +# Copyright (c) 2013 Pavel Stemberk +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + +import re +import sys +import os + +def substitute(input, oldSocket, newSocket): + input = re.sub('(^\s*packages).*', lambda m:'{} = (("DIP10", ""), ),'.format(m.group(1)), input) + input = re.sub('(^\s*chipPackage).*', lambda m:'{} = "DIP10",'.format(m.group(1)), input) + input = re.sub('(^\s*chipPinVCC).*', lambda m:'{} = 9,'.format(m.group(1)), input) + input = re.sub('(^\s*chipPinsVPP).*', lambda m:'{} = 10,'.format(m.group(1)), input) + input = re.sub('(^\s*chipPinGND).*', lambda m:'{} = 8,'.format(m.group(1)), input) + input = re.sub('(^\s*runtimeID).*', lambda m:'{} = (0xDE05, 0x01),'.format(m.group(1)), input) + input = re.sub('(^\s*description).+"(.*)".*', lambda m:'{} = "{} - ICD",'.format(m.group(1), m.group(2)), input) + input = re.sub('(^\s*bitfile).*', lambda m:'{} = "microchip01sip6",'.format(m.group(1)), input) + input = re.sub("{}".format(oldSocket), "{}".format(newSocket), input) + return input + + +def makeSip(): + inputFileName = '__init__.py' + fin = open(inputFileName) + # from pic16f1824dip14 import * + dMCU = {} + for line in fin: + matchObj = re.match('#do not edit the text below this line.*', line) + if matchObj: + break + matchObj = re.match('.*(pic[0-9]+l?f\w+)(dip[0-9a]+).*', line) + if not matchObj: + print("{} did not match".format(line)) + continue + print('matched {} - {}'.format(matchObj.group(1), matchObj.group(2))) + dMCU.setdefault(matchObj.group(1), matchObj.group(2)) + fin.close() + finit = open("init", "a") + for item in dMCU.items(): + fin = open("{}{}.py".format(item[0], item[1])) + fout = open("{}sip6.py".format(item[0]), 'w') + for line in fin: + fout.write(substitute(line, "{}".format(item[1]), "sip6")) + fout.close() + fin.close() + finit.write("from {}sip6 import *\n".format(item[0])) + finit.close() + print ('{} - {}'.format(item[0], item[1])) + +def main(argv): + makeSip() + +if __name__ == "__main__": + exit(main(sys.argv)) -- cgit v1.2.3