chiark / gitweb /
mangle i2clib into two copies, one for panic starting pan_...
authorian <ian>
Fri, 23 Dec 2005 02:56:24 +0000 (02:56 +0000)
committerian <ian>
Fri, 23 Dec 2005 02:56:24 +0000 (02:56 +0000)
detpic/.cvsignore
detpic/Makefile
detpic/detect.asm
detpic/final.inc
detpic/i2clib.asm
detpic/i2clib.incm
detpic/make-panicworthy [new file with mode: 0755]
detpic/morse.messages
detpic/panic.asm
detpic/program.asm
detpic/variables.asm

index 3e990c1112bebd109ac7e0a9913131e78cb79463..d3c835c93a505c38f90ffb854b87317660a9fc26 100644 (file)
@@ -18,3 +18,6 @@ t
 *.new
 *.tmp
 *+program.disasm
+i2clib+panic.asm
+i2clib+panic.inc
+i2clib+panic.mangles
index b42be349c397da101315626697e108e159bb8f60..7da6979eb8f0d4c641f1392a39308468a9b2bc6b 100644 (file)
@@ -3,7 +3,7 @@ CEBPIC=         ../cebpic/
 PICNOS=                0 1 2
 
 PROGRAMS=              program
-OBJS_program=          vectors.o panic.o routines-led.o i2clib.o       \
+OBJS_program=          vectors.o panic.o routines-led.o i2clib+panic.o \
                        misc.o detect.o variables.o points.o serout.o   \
                        syncwrite.o mascan.o energy.o                   \
                        reverse.o nmra-stream.o
@@ -16,7 +16,7 @@ INCLUDES=                                     \
                detect.inc                      \
                energy.fin                      \
                final.inc                       \
-               i2clib.inc                      \
+               i2clib+panic.inc                \
                i2clib.incm                     \
                misc.fin                        \
                mascan.fin                      \
@@ -39,6 +39,12 @@ include              $(CEBPIC)manypics.make
 syncwrite.asm: ../iwjpictest/syncwrite.asm
                cp $< $@
 
+i2clib+panic.%:        make-panicworthy i2clib+panic.mangles i2clib.%
+               ./$+ -Ii2clib.inc,i2clib+panic.inc $o
+
+i2clib+panic.mangles: make-panicworthy i2clib.inc i2clib.asm Makefile
+               ./$(filter-out Makefile, $+) -M $o
+
 %+clocks.inc:  make-clocks %.clocks
                ./$+ $(CLOCKS) $o
 
index f5b43b6c925313ac03afc1fc72ac10038e2c981d..f26a45b2211bd09fce67a1084d0c073988d1ebad 100644 (file)
@@ -176,8 +176,6 @@ near_i2csu code
 ;----------
 i2csu_read_begin
 ; called from High ISR, see i2clib.inc
-       bt_f_if1 picno,picno_panicd
-       bra     i2csu_read_begin_panicd
        bt_f_if1 idloc1,idloc1_boarddet
        bra     i2csu_read_begin_detectors
        bra     i2csu_read_begin_reversers
@@ -185,8 +183,6 @@ i2csu_read_begin
 ;----------
 i2csu_read_another
 ; called from High ISR, see i2clib.inc
-       bt_f_if1 picno,picno_panicd
-       bra     i2csu_read_another_panicd
        mov_fw  POSTINC2
        i2cs_read_data_macro
        mov_fw  outmsg_end
index 6e5ede9c959adc57beedb4ea239623023c1e37ad..5b31b799ae146c13f932ceaa46e63d98e1edf82f 100644 (file)
@@ -1,7 +1,7 @@
  include ../iwjpictest/syncwrite.inc
  include detect.inc
  include energy.fin
- include i2clib.inc
+ include i2clib+panic.inc
  include mascan.fin
  include misc.fin
  include nmra-stream.fin
index b6b8b94f526adeb0c4ba062ac017ea4b5877b6c0..e594532388740b06dd1212936d92ef0f858fb12b 100644 (file)
@@ -80,13 +80,6 @@ st_stopping  equ 0 ; Stopping
 
                code
 
-;----------
-i2cpanic macro morse_addr
-; Like panic but turns off the I2C controller
-       bc_f    SSPCON1, SSPEN
-       panic   morse_addr
-       endm
-
 ;----------
 slave2addr
 ; computes slave address in form suitable for use in i2c controller
index 344e217895cd0978682e2fa21feca0bcc9f31875..732cef4798d3ba39bc25e0f681b5496168a81f9d 100644 (file)
@@ -2,6 +2,13 @@
 ; MACROS FOR I2CLIB USERS
 ; see i2clib.inc
 
+;----------
+i2cpanic macro morse_addr
+; Like panic but turns off the I2C controller
+       bc_f    SSPCON1, SSPEN
+       panic   morse_addr
+       endm
+
 ;--------------------
 i2cs_read_data_macro macro
                mov_wf  SSPBUF
diff --git a/detpic/make-panicworthy b/detpic/make-panicworthy
new file mode 100755 (executable)
index 0000000..9f127cf
--- /dev/null
@@ -0,0 +1,55 @@
+#!/usr/bin/perl -n
+BEGIN {
+    while (@ARGV && $ARGV[$#ARGV] =~ m/^\-/) {
+       $_= pop;
+       if (m/^-M$/) { $manglout= 1; }
+       elsif (m/^-I(\S+),(\S+)$/) { $mapinclude{$1}= $2; }
+       else { die "$_ ?"; }
+    }
+}
+$l= $_;
+$pfx= 'pan_';
+$pcode= '';
+sub endsection () {
+    return unless defined $codesection;
+    print(";{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{\n",
+         $codesection,
+         ";}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}\n")
+       or die $!
+           unless $manglout;
+    undef $codesection;
+}
+sub mangle ($) {
+    print ";#MANGLE# $1\n"
+       or die $!
+           if $manglout;
+}
+if (m/^(\w*)\s+code\b/) {
+    endsection();
+    $codesection= "$pfx$_";
+} elsif (m/^\s+(?:include|end|udata(?:_acs)?)\b/) {
+    endsection();
+} elsif (m/^(\w+)\s+macro\b/) {
+    $inmacro++;
+} elsif (m/^\w*\s+endm\b/) {
+    $inmacro--;
+} elsif (m/^(\w*)\s+(?:equ)\b/) {
+} elsif (m/^\s+extern\s+(\w+)\b/) {
+    mangle($1);
+    print " extern $pfx$1;##\n" or die $!
+       unless $manglout;
+} elsif (!$inmacro && defined $codesection) {
+    if (!s/^\;/;\#\#/) {
+       mangle($1) if m/^(\w+)\b/;
+       s/\b(\w+)\b/ $mangle{$1} ? "$pfx$1" : $1 /ge;
+    }
+    $codesection .= $_;
+} elsif (m/^\;\#MANGLE\# (\w+)$/) {
+    $mangle{$1}= 1;
+    $l= '';
+}
+if (m/^\s+include\s+(\S+)\s+$/ && exists $mapinclude{$1}) {
+    $l= " include $mapinclude{$1}\n";
+}    
+print $l or die $!
+    unless $manglout;
index 277d0530be002195338ed126da02eb26350fc83e..96592f6e43112155cddcbdb294d21df57ba731a6 100644 (file)
@@ -63,6 +63,7 @@ UEC
 URM
 UCI
 UCP
+USP
 
 # Messages for i2clib, S*
 SM     i2clib:st,:sspstat,:sspcon1,:sspcon2 ; m.,i., ctrlr bad state
index 151d0bcf9b9c109d0af3ba7da4c8752584e83556..6b08ea0d3fdb8e5f4ba8660baa00deaee8de3030 100644 (file)
@@ -96,7 +96,6 @@ stacksave_loop
 
        clr_f    STKPTR         ; avoids stack overruns
        clr_f   panicst
-       bs_f    picno, picno_panicd
 
        call    panic_kill_hook
 
@@ -342,7 +341,7 @@ waiting_done_if_master
 ; MEMORY READOUT
 
 ;----------
-i2csu_write_panicd
+pan_i2csu_write_data
 panicd_process_input_byte
 ;              W       instruction from host or master
        tst_w_ifnz
@@ -392,8 +391,13 @@ panic_crashread_commanded
        bs_f    panicst, panicst_acked ; since we were asked to
        panic   morse_E
 
+
+;----------
+pan_i2csu_write_begin
+       return
+
 ;----------
-i2csu_read_begin_panicd
+pan_i2csu_read_begin
        mov_lw  0x80 ; M0000000
        bt_f_if0 panicst, panicst_acked
        goto    i2cs_read_data
@@ -403,13 +407,19 @@ i2csu_read_panicd_ok
        goto    i2cs_read_data
 
 ;----------
-i2csu_read_another_panicd
+pan_i2csu_read_another
        bt_f_if1 panicst, panicst_acked
        bra     i2csu_read_panicd_ok
        ; not ok
        mov_lw  0x0b ; AARGH
        goto    i2cs_read_data
 
+;----------
+pan_i2cmu_read_got_byte
+pan_i2cmu_write_next_byte
+pan_i2cmu_done
+       i2cpanic morse_USP
+
 near_gots code
 ;----------
 got_aargh
index 1638d7676c6d12b01cd11198e8b76edaa0cc0ea6..ce3bb5917262cb4c7590096b8288ca40224a6c12 100644 (file)
@@ -197,9 +197,6 @@ near_local_do code
 i2csu_write_data
        call    led_green
 
-       bt_f_if1 picno,picno_panicd
-       goto    i2csu_write_panicd
-
        bt_w_if0 7
        bra     i2csu_write_if_special
        bt_w_if1 6
index e70fae2a40cdd4c0e1ad3b484f44d9c7008dc345..e0380c87af1c2bfadd7c48c07a9b409b3377192a 100644 (file)
@@ -4,7 +4,6 @@
 
  udata_acs
 picno          res     1       ; from first idlocs byte
-picno_panicd   equ     7       ;  this bit set if we panic
 
 idloc1         res     1       ; from 2nd idlocs byte; bit 7 is master:
 idloc1_master  equ     7