;====================================================================== ; SERIAL PORT - TRANSMISSION TO HOST include common.inc code ;---------------------------------------- serial_addbyte ; W byte to xmit to host trashed ; FSR0 any set for serial_addbyte_another ; outbuf, outmsg_* buffer not full adjusted appropriately ; STATUS any trashed ; all others any not interfered with ; mov_lfsr outbuf, 0 mov_ff outmsg_end, FSR0L bs_f PIR1, TXIE ; ensure we get interrupted and try to xmit ;... 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 ; STATUS any trashed ; all others any not interfered with ; mov_wf POSTINC0 bc_f FSR0L, 7 mov_fw FSR0L mov_wf outmsg_end cmp_fw_ifne outmsg_begin return ; too many panic morse_HB ;---------------------------------------------------------------------- serialtx_intrl bt_f_if1 INTCON, RBIF rcall portb_read ; check flow control ; are we ready to transmit ? bt_f_if0 PIR1, TXIF return bt_f_if0 PIR1, TXIE return mov_lfsr outbuf, 0 mov_fw outmsg_begin mov_wf FSR0L xor_wfw outmsg_end bra_z tx_bufempty mov_fw INDF0 mov_wf TXREG bra_n tx_justsent_noacknmra ; we've just sent the last byte of some message: ; maybe we push an NMRADONE message on the front mov_fw acknmra bra_nz tx_acknmra_insert tx_justsent_noacknmra inc_f outmsg_begin bc_f outmsg_begin, outbuf_szln2 call led_green ; we're transmitting goto i2c_consider_restartread tx_bufempty ; maybe we send an NMRADONE mov_fw acknmra bra_nz tx_acknmra_send ; nothing at all to do: bc_f PIR1, TXIE goto led_black ; we're not transmitting tx_acknmra_insert sub_wff acknmra ; we're acking these now mov_wf INDF0 ; write it over the message we just sent goto led_green tx_acknmra_send sub_wff acknmra ; we're acking these now mov_wf TXREG goto led_green ;---------------------------------------- portb_read ; W undefined value from PORTB mov_fw PORTB bc_f INTCON, RBIF bt_w_if0 p0_rs232_fcin >> 4 bra tx_fcdisable ; tx enable: bs_f PIR1, TXIE bc_f INTCON, RBIE return tx_fcdisable bc_f PIR1, TXIE bs_f INTCON, RBIE goto led_red ; flow control forces us not to transmit ;---------------------------------------------------------------------- serialtxfc_init bs_f INTCON, RBIE bc_f INTCON2, RBIP rcall portb_read return ;---------------------------------------------------------------------- serialtxbuf_init clr_f outmsg_end clr_f outmsg_begin mov_lw b'00001001' goto serial_addbyte ;====================================================================== include final.inc