*.new
*.tmp
*+program.disasm
+i2clib+panic.asm
+i2clib+panic.inc
+i2clib+panic.mangles
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
detect.inc \
energy.fin \
final.inc \
- i2clib.inc \
+ i2clib+panic.inc \
i2clib.incm \
misc.fin \
mascan.fin \
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
;----------
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
;----------
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
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
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
; 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
--- /dev/null
+#!/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;
URM
UCI
UCP
+USP
# Messages for i2clib, S*
SM i2clib:st,:sspstat,:sspcon1,:sspcon2 ; m.,i., ctrlr bad state
clr_f STKPTR ; avoids stack overruns
clr_f panicst
- bs_f picno, picno_panicd
call panic_kill_hook
; MEMORY READOUT
;----------
-i2csu_write_panicd
+pan_i2csu_write_data
panicd_process_input_byte
; W instruction from host or master
tst_w_ifnz
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
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
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
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