use strict;
+#
# Parse MPASM include files to extract SDCC header/device library files
# This script is (c) 2007 by Raphael Neider <rneider AT web.de>,
# it is licensed under the terms of the GPL v2.
# 2. mv picDEVICE.h $SDCC/device/include/pic16
# 3. mv picDEVICE.c $SDCC/device/lib/pic16/libdev
# 4. add DEVICE to $SDCC/device/lib/pic16/pics.all (and .build)
-# 5. adjust $SDCC/device/lib/pic16/libio/*.ignore if the device
-# does not support ADC, I2C, or USART
+# 5. either
+# (a) adjust $SDCC/device/lib/pic16/libio/*.ignore
+# if the device does not support ADC, I2C, or USART
+# OR
+# (b) adjust $SDCC/device/include/pic16/adc.h
+# adding the new device to the correct ADC style class
# 6. edit $SDCC/device/include/pic16/pic18fregs.h
-# 7. edit $SDCC/src/pic16/devices.inc
+# 7. edit $SDCC/device/include/pic16/pic16devices.txt
#
# The file format of steps 6 and 7 is self explanatory, in most
# if not all cases you can copy and paste another device's records
# and adjust them to the newly added device.
#
+# Please try to add device families (with a common datasheet) rather
+# than a single device and use the .h and .c files of the largest
+# device for all (using #include "largest.c" and #include "largest.h").
+#
my $SCRIPT = $0;
$SCRIPT =~ s/.*\///g; # remove path prefix
$proc = uc($proc);
print HEADER <<"HEREDOC"
-/*
+/*
* $header - device specific declarations
*
* This file is part of the GNU PIC library for SDCC,
print LIBRARY <<HEREDOC
HEREDOC
-;
+;
close HEADER;
close LIBRARY;
}
chomp;
s/\s+/ /g;
next if (/^\s*$/);
-
+
if (/IFNDEF _*(18.*[0-9]+)/i) {
$processor = lc($1);
- LOG "Found processor: $processor.\n";
+ #LOG "Found processor: $processor.\n";
setup($processor);
next;
}
my $addr = oct("0x" . $2);
#LOG sprintf("Found device ID $1 at 0x%X.\n", $addr);
if ($state != 6) {
- print "\n// device IDs\n";
+ #print "\n// device IDs\n";
$state = 6;
}
DEFINE ($1, sprintf ("0x%X", $addr));
my $addr = oct("0x" . $2);
#LOG sprintf("Found ID location: $1 at 0x%X.\n", $addr);
if ($state != 5) {
- print "\n// ID locations\n";
+ #print "\n// ID locations\n";
$state = 5;
}
DEFINE ($1, sprintf ("0x%X", $addr));
# extract configuration bits
if (/Configuration Bits/i) {
$state = 3;
- printf "\n\n// Configuration Bits\n";
+ #print "\n\n// Configuration Bits\n";
header "\n\n// Configuration Bits\n";
next;
}
if ($state == 3 and /(_\w+) EQU H'([0-9a-f]+)/i) {
$name = $1;
my $addr = oct("0x" . $2);
+ # convert to double underscore form for SDCC internal consistency
+ $name =~ s/^_//g;
+ $name = "__".$name;
#LOG sprintf("Found config word $1 at 0x%X.\n", $addr);
DEFINE ($name, sprintf ("0x%X", $addr));
next;
if (($state == 3 or $state == 4) and /;--+ ((\w+) Options) --/i) {
$name = uc($2);
$state = 4;
- print "\n// $1\n";
+ #print "\n// $1\n";
header "\n// $1\n";
next;
}
);
next;
} elsif ($state == 2 and /(\w+) EQU ([0-9]+)/i) {
- print "@@@@ FOUND $1 $2 for $name\n";
+ #print "@@@@ FOUND $1 $2 for $name\n";
my $bit = 0+$2;
#LOG "Found bit declaration: $1 as bit $bit in reg $name.\n";
push @{$sfrs->{"$name"}->{"bit$bit"}}, $1;
}
# unknown/unhandled line
- print "// $_\n";
+ #print "// $_\n";
}
header "\n";
header sprintf ("extern __sfr __at (0x%03X) %s;\n", $idx, $reg);
library sprintf ( "__sfr __at (0x%03X) %s;\n", $idx, $reg);
- print sprintf ("$reg @ %X (<= %d bit names)\n", $sfrs->{"$reg"}->{"addr"}, $names);
+ #print sprintf ("$reg @ %X (<= %d bit names)\n", $sfrs->{"$reg"}->{"addr"}, $names);
if ($names > 0) {
header sprintf ("typedef union {\n");