chiark / gitweb /
Send HELLO as a result of all slaves being online. Do not crash if slave is slow...
[trains.git] / detpic / serout.asm
index e0835c4b868d353dced83c071c2530eda429319a..16e545fa6074d456d7c7f9cfa757c000f0d6bccf 100644 (file)
@@ -11,7 +11,7 @@
 addbyte_toomany panic morse_HB
 
 ;----------------------------------------
-serial_addbyte
+serial_addbyte @
 ;  W                   byte to xmit to host    trashed
 ;  FSR0                        any                     set for serial_addbyte_another
 ;  outbuf, outmsg_*    buffer not full         adjusted appropriately
@@ -22,7 +22,7 @@ serial_addbyte
        mov_ff  outmsg_end, FSR0L
 ;...
 ;----------------------------------------
-serial_addbyte_another
+serial_addbyte_another @
 ;  W                   byte to xmit to host    trashed
 ;  FSR0                        from _addbyte[_another] updated for ..._another again
 ;  outbuf, outmsg_*    buffer not full         adjusted appropriately
@@ -37,7 +37,7 @@ serial_addbyte_another
        bra_z   addbyte_toomany
        ; no, we're ok:
 
-       bt_f_if1 INTCON, TXIE
+       bt_f_if1 PIE1, TXIE
        return ; don't bother messing about if tx is already enabled
 
 ; we fall through to portb_read to reenable TXIE if appropriate
@@ -47,7 +47,7 @@ serial_addbyte_another
 
 ;...
 ;----------------------------------------
-portb_read
+portb_read @
 ;
 ;  W                   undefined       value from PORTB
 ;  TXIE                        any             enabled iff host allows us to xmit
@@ -60,20 +60,21 @@ portb_read
        mov_fw  PORTB
        bc_f    INTCON, RBIF
 
-       bt_w_if0  p0_rs232_fcin >> 4
+       bt_w_if1  p0_rs232_fcin >> 4
        bra     txfc_disable
        ; tx enable:
 
-       bs_f    PIR1, TXIE
+       call    led_green ; we're transmitting
+       bs_f    PIE1, TXIE
        return
 
 ;----------
 txfc_disable
-       bc_f    PIR1, TXIE
+       bc_f    PIE1, TXIE
        goto    led_red ; flow control forces us not to transmit
 
 ;----------------------------------------------------------------------
-serialtxfc_intrl
+serialtxfc_intrl @
        bt_f_if0 INTCON, RBIF
        return
        ; yes, it's us:
@@ -82,7 +83,7 @@ serialtxfc_intrl
        intrl_handled_nostack
 
 ;----------------------------------------------------------------------
-serialtxfc_init
+serialtxfc_init @
        bc_f    INTCON2, RBIP
        bs_f    INTCON, RBIE
        rcall   portb_read
@@ -93,11 +94,11 @@ serialtxfc_init
 ; ACTUAL TRANSMISSION
 
 ;----------------------------------------------------------------------
-serialtx_intrl
+serialtx_intrl @
        ; are we ready to transmit ?
        bt_f_if0 PIR1, TXIF
        return
-       bt_f_if0 PIR1, TXIE
+       bt_f_if0 PIE1, TXIE
        return
        ; yes, it's us:
 
@@ -119,7 +120,6 @@ tx_justsent_noacknmra
        bc_f    outmsg_begin, outbuf_szln2
        call    i2c_consider_restartread
 tx_alliswell
-       call    led_green ; we're transmitting
        intrl_handled_nostack
 
 ;----------
@@ -140,16 +140,15 @@ tx_bufempty
        mov_fw  acknmra
        bra_nz  tx_acknmra_send
        ; nothing at all to do:
-       bc_f    PIR1, TXIE
+       bc_f    PIE1, TXIE
        call    led_black ; we're not transmitting
        intrl_handled_nostack
 
 ;----------------------------------------------------------------------
-serialtxbuf_init
+serialtxbuf_init @
        clr_f   outmsg_end
        clr_f   outmsg_begin
-       mov_lw  b'00001001'
-       goto    serial_addbyte
+       return
 
 ;======================================================================
   include final.inc