# Unimplemented things
UEC
+UEP
UER
# Messages for i2clib, S*
PB points:pointmsg ; Firing point when already busy
PI points:pointmsg,T3CON ; Unexpected Timer 3 interrupt
PU points:pointmsg ; Firing nonexistent point
+PC ; Firing point when CDU empty
PS points:pointslave,points:pointmsg ; Firing point on nonexistent board
PF ::t ; Flash mentions point not on board
PX ; Host sent >2-byte POINT command
PM ; Firing point when master/CDU busy
-PC ; POINTED when already charging
+PQ ; POINTED when already charging
PA ; POINTED when already firing
-PQ ; we're confused about CDU charged
; M Firing Counting up 100PPPPP 0000 0000 0x00
; M Telling Off 100PPPPP 00SS Sss0 0x00
; M Told Off 100PPPPP 0000 0000 0x00
-; M Charging Off 100PPPPP 0000 0000 >0
+; M Charging Off 00000000 0000 0000 >0
;
; notes: firing see ie, slave*2 Counts down
; timeout detect.asm in ticks
+;
+; cducharging only counts if the cdu is enabled
+; (according to CDU Enable LAT bit)
cdu_timeout equ 200 ; ms
tst_f_ifnz pointmsg
bra command_point_busy
+ tst_f_ifnz cducharging
+ bra command_point_cduempty
+
swap_fw POSTINC0 ; W = 0SSS 1010
and_lw 0x70 ; W = 0SSS 0000
rr_w ; W = 00SS S000
command_point_badmsg panic morse_PX
command_point_busy panic morse_PB
+command_point_cduempty panic morse_PC
;----------
command_point_ifslave
cdu_init
clr_f pointslave
clr_f pointmsg
- clr_f cducharging
+;...
+;-----
+cdu_offp
+cdu_panichook
+ pin_l p0_cdu_enable
+;...
+;-----
+cdu_discharged
+ mov_lw cdu_timeout / 10 ; time in ms, converted to 10ms ticks
+ mov_wf cducharging
+ return
+
+;--------------------
+cdu_on
+ pin_h p0_cdu_enable
return
;--------------------
cdu_tick
+ bt_f_if0 LATB, p0_cdu_enable >> 4
+ return
+
tst_f_ifnz cducharging
dec_f_ifnz cducharging ; so, decrement only if it was nonzero
return ; return if we either didn't decrement,
; or didn't reach zero
- bt_f_if0 pointmsg, 7
- bra cdu_charged_not_charging
- ; ok:
-
- clr_f pointmsg
; cducharging is already zero, from above
mov_lw b'00101000' ; CHARGED
goto serial_addbyte
-cdu_charged_not_charging panic morse_PQ
-
near_gots code
;--------------------
got_pointed
tst_f_ifnz cducharging
bra pointed_already_charging
+
bt_f_if0 pointmsg, 7
bra pointed_butnot_firing
- mov_lw cdu_timeout / 10 ; time in ms, converted to 10ms ticks
- mov_wf cducharging
+
+ clr_f pointmsg
+ call cdu_discharged
mov_lw b'00100000' ; POINTED
goto serial_addbyte
pointed_butnot_firing panic morse_PA
-pointed_already_charging panic morse_PC
+pointed_already_charging panic morse_PQ
;======================================================================
include final.inc