From: ian Date: Mon, 26 Dec 2005 00:10:49 +0000 (+0000) Subject: incoming point commands and outgoing to slave; ping commands X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=7b8ff74afebbf0d9a36b307e6e5e5a6fe81d6ecc;p=trains.git incoming point commands and outgoing to slave; ping commands --- diff --git a/detpic/morse.messages b/detpic/morse.messages index 9491ae6..e4a33f4 100644 --- a/detpic/morse.messages +++ b/detpic/morse.messages @@ -30,6 +30,7 @@ HF ; host RS232 framing error HN ; host sent too much NMRA - buffers full HM ; host sent too much NMRA - ack count overflow HB ; data for host overran buffer +HP ; host sent >2-byte PING command # Regarding communications by master with slaves MX ; slave (or intern) sent bad extra byte @@ -95,3 +96,5 @@ PB points:pointmsg ; Firing point when already busy PI points:pointmsg,T3CON ; Unexpected Timer 3 interrupt PU points:pointmsg ; Firing nonexistent point PF ::t ; Flash mentions point not on board +PX ; Host sent >2-byte POINT command +PM ; Firing point when master/CDU busy diff --git a/detpic/points.asm b/detpic/points.asm index 7ca27a4..b7199bf 100644 --- a/detpic/points.asm +++ b/detpic/points.asm @@ -6,9 +6,10 @@ ;---------------------------------------- ; LOCAL POINTS - Variables, hardware, etc. ; -; Idle Firing -; Timer 3 Off On, counting up -; pointmsg undefined message from master +; Idle Idle Firing Charging +; (slave) (master) (master) +; Timer 3 Off Off On, counting up Off +; pointmsg undefined 0x00 message from master message ptix2latbit equ 0x300 ; has to be a multiple of 0x100 ptix2latbit_section udata ptix2latbit @@ -16,6 +17,7 @@ ptix2latbit_section udata ptix2latbit ; for unused point, 0x00 and 0x00 udata_acs +pointslave res 1 ; 00SS Sss0 ie slave*2 ! pointmsg res 1 ;====================================================================== @@ -233,6 +235,64 @@ point_timer_init_endif_masterslave ;====================================================================== +;---------------------------------------------------------------------- +command_point + ; FSR0 -> 1 0100 TTT O TTTTTTT + ; ie 1010 0SSS + ; OssT tttt + tst_f_ifnz pointmsg + bra command_point_busy + + swap_fw POSTINC0 ; W = 0SSS 1010 + and_lw 0x70 ; W = 0SSS 0000 + rr_w ; W = 00SS S000 + mov_wf pointslave ; pointslave = 00SS S000 + + mov_fw INDF0 ; W = OssT tttt N = O + bra_n command_point_badmsg + ; OK: ; W = 0ssT tttt + and_lw 0x1f ; W = 000T tttt + bs_w 7 ; W = 100T tttt + mov_wf pointmsg ; pointmsg = 100T tttt + + swap_fw INDF0 ; W = tttt 0ssT + and_lw 0x06 ; W = 0000 0ss0 + ior_wff pointslave ; pointslave = 00SS Sss0 + + rr_fw pointslave ; W = 000S SSss + bra_nz point_needwrite_yes + + mov_fw pointmsg + goto point_local_do + +command_point_badmsg panic morse_PX +command_point_busy panic morse_PB + +;---------- +points_needwrite + rr_fw pointslave ; W = 000S SSss + bt_f_if1 STATUS, Z ; nothing ? + return + ; we need to write something: +;... +;---------- +point_needwrite_yes + pop + goto i2c_needwrite + +;---------- +points_getwritebyte + rr_fw pointslave + xor_wfw cwslave + bt_f_if0 STATUS, Z ; right slave ? + return + ; yes: + mov_fw pointslave + goto i2c_getwritebyte_yes + +;====================================================================== +; CDU + near_gots code cdu_init panic morse_UCI @@ -240,4 +300,5 @@ cdu_init panic morse_UCI got_pointed panic morse_UCP +;====================================================================== include final.inc diff --git a/detpic/program.asm b/detpic/program.asm index bce6761..3a862fa 100644 --- a/detpic/program.asm +++ b/detpic/program.asm @@ -121,7 +121,7 @@ serialrx_if_multibyte add_wff PCL ; <--- here is zero - goto serialrx_bad ; 1 0000 xxx + goto serialrx_bad ; 1 0000 xxx goto command_ping ; 1 0001 xxx goto command_polarity ; 1 0010 xxx goto serialrx_bad ; 1 0011 xxx @@ -149,7 +149,16 @@ serialrx_bad ;-------------------- command_ping -command_point + mov_fw POSTINC0 + mov_ff INDF0, t + call serial_addbyte + mov_fw t + bra_n command_ping_bad + goto serial_addbyte_another + +command_ping_bad panic morse_HP + +;-------------------- command_crashed panic morse_UC