chiark / gitweb /
pcb/points-pin-alloc: Initial checkin
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 4 Dec 2010 17:12:12 +0000 (17:12 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 4 Dec 2010 17:12:12 +0000 (17:12 +0000)
pcb/Makefile
pcb/points-pin-alloc-sheet [new file with mode: 0755]

index 765a594c26a71838c788f3436bb749a3b0e17a30..f025751da6aee8635bff56d16026b28cbcd17c83 100644 (file)
@@ -99,6 +99,12 @@ pcboprints:  reversers.oprints-l detectors.oprints-l
 %.net-spec:    generate-netspec.pl
                ./$< $@ $o
 
+points-pin-alloc.lout: points-pin-alloc-sheet detectors.net-spec reversers.net-spec
+               ./$< reversers:4 detectors:4 $o
+
+%.ps:          %.lout
+               lout -s $< $o
+
 tidy:
 
 clean:         tidy
diff --git a/pcb/points-pin-alloc-sheet b/pcb/points-pin-alloc-sheet
new file mode 100755 (executable)
index 0000000..2df6df1
--- /dev/null
@@ -0,0 +1,135 @@
+#!/usr/bin/perl -w
+
+use strict qw(refs vars);
+
+use POSIX;
+use IO::Handle;
+
+our @boards;
+foreach (@ARGV) {
+    m/^(\w+)\:(\d+)$/ or die "$_ ?";
+    foreach (my $i=0; $i<$2; $i++) { push @boards, $1; }
+}
+
+our @pins;
+our @pin2otherdesc;
+while (<DATA>) {
+    m/^(\d+)\t(\S.*\S)\s+/ or die;
+    push @pins, $1;
+    $pin2otherdesc[$1]= $2;
+}
+
+our %boardpin2point;
+foreach my $board (0..$#boards) {
+    my $bkind= $boards[$board];
+    next if exists $boardpin2point{$bkind};
+    open NI, "$bkind.net-info" or die "$bkind $!";
+    while (<NI>) {
+       next if m/^\#/;
+       while (s/\\\n$//) { $_ .= <NI>; }
+       next unless m/\S/;
+       chomp;
+       my ($netname, $type, $pins) = m/^(\w+)\s+(\w+)\s+(\S.*)?$/
+           or die "$_ ?";
+       next unless defined $pins;
+       $pins= " $pins ";
+       $pins =~ m/\sPIC-(\d+)\s/ or next;
+       my $pin= $1;
+       $netname= "__${netname}__";
+       $netname =~ m/__pt(\d+)__/ or next;
+       my $point= $1;
+       die "$netname $pin" unless defined $pin2otherdesc[$pin];
+       $boardpin2point{$bkind}[$pin]= $point;
+    }
+    NI->error and die "$bkind $!";
+    close NI;
+}
+
+print <<END;
+\@SysInclude { tbl }
+\@SysInclude { doc }
+\@Doc \@Text \@Begin
+END
+
+print "\@Tbl\n";
+
+my (@formats,@cells);
+my %formats;
+my $body='';
+my $cellix;
+my $nextformat= 'a';
+
+sub startrow () {
+    $cellix= "A";
+}
+
+sub endrow () {
+    my $format= join ' | ', @formats;
+    my $formatname= $formats{$format};
+    if (!defined $formatname) {
+       $formatname= $nextformat++;
+       $formats{$format}= $formatname;
+       print " ${formatname}format { $format }\n";
+    }
+    $body .= "\@Row${formatname}\n ".join("\n ", @cells)."\n";
+    @formats= @cells= ();
+}
+
+sub cell ($$) {
+    my ($fmt, $data) = @_;
+    my $ix= $cellix++; #"C".scalar @cells;
+    push @formats, '@Cell '.$fmt." $ix";
+    push @cells, "$ix { $data }";
+}
+
+startrow();
+cell('', '@B pin');
+cell('', '@B { alternative uses }');
+foreach my $board (0..$#boards) {
+    cell('', "$boards[$board]");
+}
+endrow();
+
+foreach my $pin (@pins) {
+    startrow();
+    cell('', $pin);
+    cell('', "\"$pin2otherdesc[$pin]\"");
+    foreach my $board (0..$#boards) {
+       my $point= $boardpin2point{$boards[$board]}[$pin];
+       if (!defined $point) {
+           cell('paint { lightgrey }', '');
+       } else {
+           cell('', "PT$point");
+       }
+    }
+    endrow();
+}
+print "{\n",$body,"}\n";
+
+print <<END;
+\@End \@Text
+END
+
+STDOUT->error and die $!;
+
+__DATA__
+40     (useable for point only)
+39     (useable for point only)
+38     Interrupt on change
+37     Interrupt on change
+36     GPIO
+35     External Interrupt 2
+34     External Interrupt 1
+33     External Interrupt 0
+30     ECCP1 PWM output D
+29     ECCP1 PWN output C
+28     ECCP1 PWN output B
+27     ECCP1 PWN output A
+26     RS232 RX
+25     RS232 TX
+24     GPIO
+22     Comparator 2 input
+2      Analogue in 0 / Comparator ref out
+3      Analogue in 1
+15     Timer 1 osc out / Timer 1,3 ext clock in
+16     Timer 1 osc in