aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/gen-stellaris-part-header.pl73
1 files changed, 53 insertions, 20 deletions
diff --git a/contrib/gen-stellaris-part-header.pl b/contrib/gen-stellaris-part-header.pl
index 24ddcb12..0cc567f7 100755
--- a/contrib/gen-stellaris-part-header.pl
+++ b/contrib/gen-stellaris-part-header.pl
@@ -7,13 +7,13 @@ $comment = "// Autogenerated by contrib/gen-stellaris-part-header.pl
// From Stellaris Firmware Development Package revision";
$struct_header = "static struct {
- uint32_t partno;
+ uint8_t class;
+ uint8_t partno;
const char *partname;
-} StellarisParts[] =
-{
+} StellarisParts[] = {
";
-$struct_footer = "\t{0,\"Unknown part\"}\n};\n";
+$struct_footer = "\t{0xFF, 0x00, \"Unknown Part\"}\n};\n";
$#ARGV == 1 || die "Usage: $0 <inc directory> <output file>\n";
-d $ARGV[0] || die $ARGV[0]." is not a directory\n";
@@ -26,13 +26,11 @@ opendir(DIR, $dir) || die "can't open $dir: $!";
@files = readdir(DIR);
closedir(DIR);
-@short_files = sort(grep(/lm3s...\.h/, @files));
-@long_files = sort(grep(/lm3s....\.h/, @files));
+@header_files = sort(grep(/lm.+\.h/, @files));
$ver = 0;
$new_struct = $struct_header;
-process_file(@short_files);
-process_file(@long_files);
+process_file(@header_files);
$new_struct .= $struct_footer;
$dump = "$comment $ver\n$new_struct";
@@ -51,7 +49,7 @@ close(OUTPUT);
sub process_file {
foreach $h_file (@_) {
- ($base) = ($h_file =~ m/lm3s(.{3,4})\.h/ig);
+ ($base) = ($h_file =~ m/lm..(.{3,7})\.h/ig);
$base = uc($base);
local($/, *FILE);
open(FILE, "$dir/$h_file");
@@ -66,22 +64,39 @@ sub process_file {
$ver = $1;
}
}
- if ($content =~ /SYSCTL_DID1_VER_[^M]\s+0x(\S+)/) {
- $did1_ver = hex($1);
+
+ if ($content =~ /SYSCTL_DID0_CLASS_[^M].+?0x(\S+)/s) {
+ $class = hex($1) >> 16;
} else {
- print STDERR "$h_file is missing SYSCTL_DID1_VER\n";
- $did1_ver = 255;
- $invalid = 1;
+ # attempt another way to get class
+ if ($content =~ /\s(\S+)-class/) {
+ $class = getclass($1);
+ if ($class eq 0xFF) {
+ print STDERR "$h_file unknown class\n";
+ $invalid = 1;
+ }
+ } else {
+ print STDERR "$h_file is missing SYSCTL_DID0_CLASS_\n";
+ $class = 0;
+ $invalid = 1;
+ }
}
- if ($content =~ /SYSCTL_DID1_PRTNO_$base\s+0x(\S+)/) {
+
+ if ($content =~ /SYSCTL_DID1_PRTNO_$base.+0x(\S+)/) {
$prtno = hex($1);
+ $base = "LM3S" . $base;
} else {
- print STDERR "$h_file is missing SYSCTL_DID1_PRTNO\n";
- $prtno = 0;
- $invalid = 1;
+ # LM4F have a changed header
+ if ($content =~ /SYSCTL_DID1_PRTNO_LM4F$base.+?0x(\S+)/s) {
+ $prtno = hex($1);
+ $base = "LM4F" . $base;
+ } else {
+ print STDERR "$h_file is missing SYSCTL_DID1_PRTNO\n";
+ $prtno = 0;
+ $invalid = 1;
+ }
}
- $id = ($did1_ver | $prtno) >> 16;
- $new_member = sprintf "{0x%04X,\"LM3S%s\"},", $id, $base;
+ $new_member = sprintf "{0x%02X, 0x%02X, \"%s\"},", $class, $prtno >> 16, $base;
if ($invalid == 1) {
#$new_struct .= "\t//$new_member\t// Invalid\n";
} else {
@@ -89,3 +104,21 @@ sub process_file {
}
}
}
+
+sub getclass {
+ $class = $_[0];
+ if ($class =~ /Sandstorm/i) {
+ return 0;
+ } elsif ($class =~ /Fury/i) {
+ return 1;
+ } elsif ($class =~ /DustDevil/i) {
+ return 3;
+ } elsif ($class =~ /Tempest/i) {
+ return 4;
+ } elsif ($class =~ /Blizzard/i) {
+ return 5;
+ } elsif ($class =~ /Firestorm/i) {
+ return 6;
+ }
+ return 0xFF;
+}