chiark / gitweb /
wip; before undo redo i2cs_interrupt
authorian <ian>
Sun, 13 Nov 2005 15:14:33 +0000 (15:14 +0000)
committerian <ian>
Sun, 13 Nov 2005 15:14:33 +0000 (15:14 +0000)
detpic/i2clib.asm

index f008d4d6ef37fa53547abb386d4c819523948371..e5f9cd3f3b88e7d6a3d86d2ca1ef2b371e2cf689 100644 (file)
@@ -14,8 +14,8 @@
 
 t              res     1
 
-st             res     1
-st_subsequent  equ     0
+st             res     1       ; bitmask:
+st_writing     equ     0
 
                code
 
@@ -58,6 +58,49 @@ i2cs_interrupt_wcolsspov_endif
 
 ; Find out what's just happened:
                mov_ff  SSPSTAT, t
+                       ; bits we want to check
+                       ;  80  60  20    10    08    04    02  01
+                       ;  SMP CKE D_A   P     S     R_W   UA  BF
+                       ;  set clr data? stop  start read? clr full?
+
+               bt_f_if1 t, I2C_START
+               bra     si_if_start
+
+si_if_notstart
+               ; So it should be stop
+               mov_fw  t
+               and_lw  0xdf ; ?D_A
+               xor_lw  0x90 ; SMP, !CKE, P; !S, !R_W, !UA, !BF
+               bra_nz  si_if_bad
+
+               ; Were we receiving ?
+               bt_f_if0 st, st_writing
+               return
+
+               ; Yes, we were receiving:
+               bc_f    st, st_writing
+               goto    i2csu_write_done
+               ; tail call; we couldn't do anything after that
+               ; anyway since it might well reenter us.
+
+si_if_start
+               bt_f_if1 t, BF
+               bra     si_if_bufferfull
+si_if_bufferempty
+               bt_f_if1 t, R_W ;read?
+               bra     si_if_bufferempty_reading
+si_if_bufferempty_notreading
+               ; So we think this is just a START (which we want to ignore)
+               mov_fw  t
+               and_lw  0xdf ; ?D_A
+               xor_lw  0x88 ; SMP, !CKE, !P; S, !R_W, !UA, !BF
+               bra_nz  si_if_bad
+
+               ; OK, ignore it
+               return
+
+
+               
 
 chkval macro mask, value, label
                mov_fw  t