diff options
author | kc8apf <kc8apf@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-12-19 04:25:22 +0000 |
---|---|---|
committer | kc8apf <kc8apf@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-12-19 04:25:22 +0000 |
commit | 063f4c182cbb77a9d1807a97d67c81f1afd656ee (patch) | |
tree | e62ffe2089e90de1a70893d407a3fd904c91dab5 /tools/rlink_make_speed_table | |
parent | e873a6d27cc1b0323b5687f6aecb1ee3c513688c (diff) | |
download | openocd_libswd-063f4c182cbb77a9d1807a97d67c81f1afd656ee.tar.gz openocd_libswd-063f4c182cbb77a9d1807a97d67c81f1afd656ee.tar.bz2 openocd_libswd-063f4c182cbb77a9d1807a97d67c81f1afd656ee.tar.xz openocd_libswd-063f4c182cbb77a9d1807a97d67c81f1afd656ee.zip |
- rlink interface support from Lou Deluxe <lou.openocd012@fixit.nospammail.net>
git-svn-id: svn://svn.berlios.de/openocd/trunk@1258 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'tools/rlink_make_speed_table')
-rwxr-xr-x | tools/rlink_make_speed_table/rlink_make_speed_table | 2 | ||||
-rw-r--r-- | tools/rlink_make_speed_table/rlink_make_speed_table.pl | 68 |
2 files changed, 70 insertions, 0 deletions
diff --git a/tools/rlink_make_speed_table/rlink_make_speed_table b/tools/rlink_make_speed_table/rlink_make_speed_table new file mode 100755 index 00000000..62f7a480 --- /dev/null +++ b/tools/rlink_make_speed_table/rlink_make_speed_table @@ -0,0 +1,2 @@ +#!/bin/sh +exec perl "$0.pl" $* diff --git a/tools/rlink_make_speed_table/rlink_make_speed_table.pl b/tools/rlink_make_speed_table/rlink_make_speed_table.pl new file mode 100644 index 00000000..f35c9edb --- /dev/null +++ b/tools/rlink_make_speed_table/rlink_make_speed_table.pl @@ -0,0 +1,68 @@ +#!/bin/perl +#*************************************************************************** +#* Copyright (C) 2008 Lou Deluxe * +#* lou.openocd012@fixit.nospammail.net * +#* * +#* 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., * +#* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +#*************************************************************************** + +# A simple utility to read a list of files (names composed by numeric prescaler arguments) and compose a C source file defining data structures which hold the binary data read from those files. + +@speed_table = (); + +printf("/* This file was created automatically by %s. */\n\n", $0); +for $i ('rlink', 'st7') { + printf("#include \"$i.h\"\n"); +} +printf("\n"); + +for $prescaler (sort {$b <=> $a} @ARGV) { + my(@ary) = ( + byte_array_from_file(${prescaler} . "_init.dtc"), + byte_array_from_file(${prescaler} . "_call.dtc") + ); + + for $i (@ary) { + $i = sprintf("%d", $i); + } + $bytes = join(', ', @ary); + $bytes =~ s/(^|\s)(.{70}?\S*)/\2\n/go; # break up long lines + $bytes =~ s/\n +/\n/go; + $bytes =~ s/(^|\n)/\1\t/go; # format nicely + printf("static const u8 dtc_%d[] = {\n%s\n};\n\n", $prescaler, $bytes); + push(@speed_table, sprintf("\tdtc_%d, sizeof(dtc_%d), (ST7_FOSC * 2) / (1000 * %d), %d\n", $prescaler, $prescaler, $prescaler, $prescaler)); +} + +printf("const rlink_speed_table_t rlink_speed_table[] = {{\n%s}};\n\n", join("}, {\n", @speed_table)); +printf("const size_t rlink_speed_table_size = sizeof(rlink_speed_table) / sizeof(*rlink_speed_table);\n\n"); + + +sub byte_array_from_file { + my($filename) = @_; + + my(@array, $text, $i) = (); + + open(IN, '<', $filename) || die "$filename: $!"; + undef($/); + $text = <IN>; + close(IN); + + for($i = 0; $i < length($text); $i++) { + push(@array, ord(substr($text, $i, 1))); + } + + @array; +} |