From: ian Date: Thu, 22 Dec 2005 13:22:46 +0000 (+0000) Subject: i2c read events supposedly done; now try to compile X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=f23e3aa85730269f4fee267b7f50cc07ecad78c2;p=trains.git i2c read events supposedly done; now try to compile --- diff --git a/detpic/Makefile b/detpic/Makefile index 04dc7d5..1d8b12c 100644 --- a/detpic/Makefile +++ b/detpic/Makefile @@ -4,7 +4,7 @@ PICNOS= 0 1 2 PROGRAMS= program OBJS_program= vectors.o panic.o routines-led.o i2clib.o \ - misc.o detect.o variables.o points.o \ + misc.o detect.o variables.o points.o serout.o \ syncwrite.o reverse.o nmra-stream.o mascan.o XCODEN_program= morse XCODE1_program= ours+pindata @@ -27,6 +27,7 @@ INCLUDES= \ program.fin \ reverse.fin \ routines-led.fin \ + serout.fin \ vectors.fin \ VARSFILES= variables diff --git a/detpic/mascan.asm b/detpic/mascan.asm index 65a16f1..23e80e2 100644 --- a/detpic/mascan.asm +++ b/detpic/mascan.asm @@ -3,6 +3,7 @@ include common.inc +;---------------------------------------------------------------------- udata_acs b res 1 ; byte just read @@ -10,20 +11,11 @@ cslot res 1 ; current slave in slave table, points to flags byte cbyte res 1 ; one of the following: ; 0000 0000 we're expecting the first byte - ; - ; M0BB 0001 we have rec - ; M0BB 0001 we have rec - - ; MM zz B2 B1 zz zz zz II - ; - ; main byte from slave -; M0BB0000 - ; where M is 1 iff we're expecting an `extra byte' - ; otherwise NN is the detection byte we're expecting - -sc res 1 -sc_extra equ 7 ; we're + ; M0B1 0000 we're expecting more detection byte 1 + ; M010 0000 we're expecting more detection byte 2 + ; 1000 0000 we're expecting an extra byte +;---------------------------------------------------------------------- slavetable_section udata 0x280 ste_szln2 equ 3 @@ -42,6 +34,7 @@ stf_detect equ 7 code ;====================================================================== +; HANDLING OF I2C EVENTS ;---------------------------------------- i2cm_intrl @@ -52,6 +45,16 @@ i2cm_intrl call i2cm_interrupt_definite intrl_handled_nostack +;---------------------------------------- +i2cmu_done panic morse_MD + +;---------------------------------------- +i2cmu_write_next_byte + panic morse_UI + +;====================================================================== +; PROCESSING OF INCOMING BYTES + ;---------------------------------------- i2cmu_read_got_byte ; Beforehand At call @@ -117,32 +120,6 @@ read_got_detectbyte_something ior_wff FSR1L ; FSR1L -> detmsgh return ; to addmsgs_ -;---------- -read_prep_detectbyte -; W adjusted detbase l -; cbyte set for next byte to read -; b received byte -; FSR1 -> lastd -; TOS -> goto addmsgs_ -; NOS return address for i2cmu_read_got_byte - mov_wf t ; t = adj.detbasel - mov_fw b ; W = ?d??dddd - xor_wfw INDF1 ; lastd = ?C??CCCC, Z iff same - bra_nz read_got_detectbyte_something - xor_wfw INDF1 ; lastd = ?d??dddd - ; there's nothing to do - pop -;... -;---------------------------------------- -i2c_arrange_next_byte - tst_f_ifnz cbyte - goto i2cm_read_another -;... -;---------------------------------------- -i2c_arrange_something -; figure out what to do next - which pic to address, etc. - panic morse_UG - ;---------------------------------------- read_got_notfirst bt_f_if1 cbyte, 4 @@ -154,7 +131,7 @@ read_got_notfirst bt_f_if0 b, 7 ; any more ? bc_f cbyte, 7 bc_f b, 7 - call process_got_extra + rcall process_got_extra bra i2c_arrange_next_byte ;---------------------------------------- @@ -169,7 +146,36 @@ loopback_read_byte bra_z slave_got_aargh panic morse_MX -;======================================== +;---------- +read_prep_detectbyte +; W adjusted detbase l +; cbyte set for next byte to read +; b received byte +; FSR1 -> lastd +; TOS -> goto addmsgs_ +; NOS return address for i2cmu_read_got_byte + mov_wf t ; t = adj.detbasel + mov_fw b ; W = ?d??dddd + xor_wfw INDF1 ; lastd = ?C??CCCC, Z iff same + bra_nz read_got_detectbyte_something + xor_wfw INDF1 ; lastd = ?d??dddd + ; there's nothing to do + pop +;... +;---------------------------------------- +i2c_arrange_next_byte + tst_f_ifnz cbyte + goto i2cm_read_another +;... +;====================================================================== +; DECIDING WHICH SLAVE TO ADDRESS +;... +i2c_arrange_something +; figure out what to do next - which pic to address, etc. + panic morse_UG + +;====================================================================== +; GENERATION OF DETECTION MESSAGES FOR HOST - MAD BT_F_IF1 TABLES addmsg_testbit macro bit bt_f_if1 w, bit @@ -239,70 +245,13 @@ addmsg mov_fw INDF1 ; W = 1 001 0 SSS mov_wf u ; u = 1 001 0 SSS mov_fw b ; W = ?d??dddd -stuff here - and_wfw INDF0 ; W = .....d.. - - xor_wfw - - bt_w_if1 INDF1, - - - - -read_got_detectbyte_allsame - mov_wf INDF1 ; lastd = ?d??dddd - - pop ; skip return address -read_done_byte - - - - and_lw 0x80 ; W = M0BB0000 / M0000000 ie M0BB0000 - - ; this is a first (head) byte from a detectors board: - - - and_lw 0xb0 ; W = M0BB0000 - -read_got_ - mov_fw b - xor_wf PREINC1, - - mov_wf b - - mov_ - and_lw - - - ; W = b = MdBBdddd / - and_wfw INDF1 ; flags, = 10110000 / 10000000 - mov_wf cbyte ; cbyte = M0BB0000 / M0000000 - - bt_f_ - - - - bt_f_if1 cbyte, 4 - bra read_got_moredet1 - bt_f_if1 cbyte, 5 - bra read_got_moredet2 - - - mov_fw cbyte - - bra_n read_got_extra - bra_nz read_got_moredet - - bt_f_if1 sc, sc_extra - bra got_read_extra - -got_read_extra - panic morse_UX - -;---------------------------------------- -i2cmu_done -i2cmu_write_next_byte - panic morse_UI + and_wfw INDF0 ; W = .....d.., Z iff detect + bt_f_if1 STATUS, Z + bs_f u, 3 ; u = 1 001 Y SSS + mov_fw u + rcall serial_addbyte + mov_fw t + goto serial_addbyte_another ;====================================================================== include final.inc diff --git a/detpic/morse.messages b/detpic/morse.messages index cd704f3..85c1c53 100644 --- a/detpic/morse.messages +++ b/detpic/morse.messages @@ -27,10 +27,12 @@ HW ::t ; host sent message which was too long HO ; host RS232 read overrun HF ; host RS232 framing error HN ; host sent too much NMRA - buffers full +HB ; data for host overran buffer # Regarding communications by master with slaves MX ; slave (or intern) sent bad extra byte MR mascan::b,mascan::cslot ; reversers set byte with zz bit set +MD ; i2cmu_done ! # Problematic interrupts IH INTCON,INTCON3,PIR1,PIR2,PIR3 ; Interrupt source not found (high pri.) diff --git a/detpic/serout.asm b/detpic/serout.asm new file mode 100644 index 0000000..cd5e845 --- /dev/null +++ b/detpic/serout.asm @@ -0,0 +1,30 @@ +;====================================================================== + +;---------------------------------------- +serial_addbyte +; W byte for transmission to host trashed +; FSR0 any set for serial_addbyte_another +; outmsg_* buffer not full adjusted appropriately +; STATUS any trashed +; all others any not interfered with +; + mov_lfsr outbuf, 0 + mov_ff outmsg_end, FSR0L +;... +serial_addbyte_another +; W byte for transmission to host trashed +; FSR0 from serial_addbyte[_another] set for serial_addbyte_another +; outmsg_* buffer not full adjusted appropriately +; STATUS any trashed +; all others any not interfered with +; + mov_wf POSTIN0C + bc_f FSR0L, 7 + mov_fw FSR0L + mov_wf outmsg_end + xor_wfw outmsg_begin + bra_z serial_addbyte_toomany + return + +;----- +serial_addbyte_toomany panic morse_HB diff --git a/detpic/serout.fin b/detpic/serout.fin new file mode 100644 index 0000000..ea60779 --- /dev/null +++ b/detpic/serout.fin @@ -0,0 +1,2 @@ + extern serial_addbyte + extern serial_addbyte_another diff --git a/detpic/variables.asm b/detpic/variables.asm index 9dfca82..b176240 100644 --- a/detpic/variables.asm +++ b/detpic/variables.asm @@ -15,6 +15,7 @@ t res 1 ; general temporary u res 1 ; general temporary (another) t_dolocal res 1 ; temporary for _local_do outmsg_end res 1 ; first empty byte in outbuf +outmsg_begin res 1 ; first full byte in outbuf isr_low_save_w res 1 ; see {enter,return}_interrupt_low isr_low_save_status res 1 ; in common.inc