chiark / gitweb /
points wip
authorian <ian>
Sun, 4 Dec 2005 23:26:35 +0000 (23:26 +0000)
committerian <ian>
Sun, 4 Dec 2005 23:26:35 +0000 (23:26 +0000)
cebpic/morse.messages
detpic/common.inc
detpic/detect.asm
detpic/misc.asm
detpic/morse.messages
detpic/pindata.inc
detpic/points.asm
detpic/reverse.asm
detpic/slave.asm
detpic/test-sofar.asm

index 0dd18ef2d4b4e03edf42b5d83800c9f086120a50..f5b1dbc4959953a517580ad7b981ab0f8d8f8e9c 100644 (file)
@@ -15,6 +15,8 @@
 # buffer space somewhere so that each one is read once and that value
 # remembered.
 
+UP             ; unimplemented point timer setting
+
 # Main message listing.  Kept sorted by morse for easy reference.
 IH     INTCON,INTCON3,PIR1,PIR2,PIR3 ; Interrupt source not found (high pri.)
 IL     INTCON,INTCON3,PIR1,PIR2,PIR3 ; Interrupt source not found (low pri.)
index 21409b7a7b7bcc672305def2ade0257952a23788..ebf3de5d649576943786e3aeb480a445c1e1ca62 100644 (file)
@@ -67,7 +67,7 @@ clock equ -1
 ;  Timer 2             -                       -
 ;  Timer 1             1ms tick, int. low      1ms tick, int. low
 ;  CCP1                        1ms tick, int. low      1ms tick, int. low
-;  Timer 3             -                       -
+;  Timer 3             point fire timer        point fire timer
 ;  ECCP                        -                       -
 
 ;----------------------------------------------------------------------
index 72cdad1200c5898754bf7e07cc9a58253e08a4e0..7abdf2501852f30e76e4f0ef7b8b11d84d8efe9e 100644 (file)
@@ -49,6 +49,7 @@
 ; Master may also write to slave.  Every written byte is independent:
 ;
 ;      11RRRRRR        Set reverse to RRRRRR, see reverse.asm
+;      100PPPPP        Fire point PPPPP
 
 ;======================================================================
 ; variables and memory organisation
index d42c3065d8b61ffed68e1e4ace24a5e590cc56c3..5eeca037dcab05a0881d62a7d10df33baebbad15 100644 (file)
@@ -4,6 +4,7 @@
  include common.inc
  code
 
+;----------
 read_pic_no
 ; read pic no from ID locations and return it
 ;      W               undefined               pic number from ID loc 0
@@ -20,6 +21,7 @@ read_pic_no
        mov_fw  TABLAT
        return
 
+;----------
 init_read_idlocs
 ; read id locations and store in canonical place
 ;      W               undefined               undefined
@@ -36,6 +38,7 @@ init_read_idlocs
 
        return
 
+;----------
 init_bitnum2bit
 ; populate bitnum2bit
        mov_lw  0x80
@@ -46,4 +49,10 @@ init_bitnum2bit_loop
        bra_nn  init_bitnum2bit_loop
        return
 
+;----------
+common_init
+       call    bitnum2bit_init
+       call    points_init
+       return
+
  include final.inc
index 8f5cd899c66a79b7948d47910d87a4e0e04f4f5f..e1888f2540d66dacf8af2a41e249c25998ac0b21 100644 (file)
@@ -30,6 +30,9 @@ TI4                           ; for iwj
 TI5                            ; for iwj
 X      test-sofar:ch           ; bad character received from host
 
+# Unimplemented things
+UP             ; unimplemented point timer setting
+
 ZM     i2clib:st,:sspstat,:sspcon1,:sspcon2 ; for testing
 ZS     i2clib:st,:sspstat,:sspcon1,:st_orig ; for testing
 
@@ -50,5 +53,7 @@ DQ    FSR2L,:outmsg_end               ; previous slave read incomplete
 DR     FSR2L,:outmsg_end               ; slave read overrun
 
 # Messages for specific peripherals
-PS     FSR0L                           ; POLARITY message too short
-PL     FSR0L                           ; POLARITY message too long
+RS     FSR0L                           ; POLARITY message too short
+RL     FSR0L                           ; POLARITY message too long
+
+PB     points:pointmsg                 ; Firing point when already busy
index d0c85bab11eb1ddc393b52a2a1b7de82594722f3..e8ce55ded260070b0aa0dac27f2c1694e1e4a114 100644 (file)
@@ -1,5 +1,7 @@
 ;======================================================================
 
+       radix dec
+
 picno2ptmap            equ     0x6100
 bkptix2portnumbitnum   equ     0x6000
 pic2detinfo            equ     0x6040
@@ -7,3 +9,6 @@ picno2revbits           equ     0x6080
 
 maxpic_ln2             equ     5
 maxpic                 equ     1 << maxpic_ln2
+
+maxpoint_ln2           equ     5
+maxpoint               equ     1 << maxpoint_ln2
index f58745cbcfb2f846444e4e8a03593d03b53cda8d..51b203cdc5e18ad94ee170a8d88798f042bccb9c 100644 (file)
@@ -1,5 +1,119 @@
 ;======================================================================
 ; POINTS
+
+;                      Idle            Firing
+;      Timer 3         Off             On, counting up
+;      pointmsg        undefined       message from master
+
+ udata_acs
+pointmsg               res     1
+
+ udata 0x300
+ptix2latbit    res     maxpoint * 2    ; bit and LAT*
+
+ code
+
+pt_timer13_prescale equ 0
+pt_timer13_inithigh equ 0
+
+;----------
+point_timer_init
+       mov_lw  (1<<RD16) | (1<<T3ECCP1) | pt_timer13_prescale ; Fcy; !TMR3ON
+       mov_wf  T3CON
+       bc_f    PIR2, TMR3IF
+       bs_f    PIE2, TMR3IE
+       bc_f    IPR2, TMR3IP
+       mov_lw  pt_timer13_inithigh
+       mov_wf  TMR3H ; we just leave this here, since we never read TMR3L
+       return
+
+;----------
+point_do_here
+; On slave, called during i2c receive, ie High ISR
+; On master, called during serial receive, ie Low ISR
+;              W       fire point msg          undefined
+       bt_f_if1 T3CON, TMR3ON
+       bra     point_clash
+
+       mov_wf  pointmsg        ; pointmsg = SS zz zz pp  pp pp pp pp
+       rcall   point_set_pin
+
+       set_f   TMR3L
+       bs_f    T3CON, TMR3ON
+       panic   morse_UP
+       return
+
+;----------
+; Sets the pin appropriately:
+;      If we were idle, sets it H (to fire) unless pt0 in which case L
+;      If we were firing, sets it L (to stop) unless pt0 in which case H
+point_set_pin
+       mov_lw  ptix2lat >> 8
+       mov_wf  FSR0H           ; FSR0H -> table
+       rl_w    pointmsg        ; W = point addr, Z iff pt0
+       mov_wf  FSR0L           ; FSR0 -> &LAT*   [Z still iff pt0]
+       bt_f_if1 T3CON, TMR3ON  ; Were we firing ?   [Z still iff pt0]
+       btg_f   STATUS, Z       ; Z iff (pt0 xor were_firing)
+       bra_z   point_set_pin_l
+point_set_pin_h
+       mov_fw  POSTINC0        ; W = bit, FSR0 -> &LAT*
+       mov_ff  INDF0, FSR0L    ; W = bit, FSR0L -> LAT*
+       set_f   FSR0H           ; FSR0 -> LAT*, W = bit (still)
+       ior_wff INDF0           ; pin = H
+       return
+
+point_set_pin_l
+       com_fw  POSTINC0        ; W = ~bit, FSR0 -> &LAT*
+       mov_ff  INDF0, FSR0L    ; W = ~bit, FSR0L -> LAT*
+       set_f   FSR0H           ; FSR0 -> LAT*, W = bit (still)
+       ior_wff INDF0           ; pin = H
+       return
+
+;----------
+point_clash
+       panic   morse_PB
+
+
+
+
+       bt_f_if0 
+
+
+       
+
+       bra_z   point_do_if_pt0
+point_do_ifnot_pt0
+       rcall   point_pin_h
+point_do_endif_pt0_set_timer
+       mov_lw  
+
+point_do_if_pt0
+       rcall   point_pin_l
+       
+       
+
+point_pin_l
+       
+
+       rl_w
+       
+       bt_f_if0
+
+       add_lw  (ptix2lat >> 8) - 0x80
+
+
+
+; We use FSR1 so we have to save it
+       mov_ff  FSR1L, fsr1l_save ; we assume FSR1H is zero, since on
+                               ; W     SS zz zz pp  pp pp pp pp
+
+;----------------------------------------------------------------------
+points_init
+; Initialises tables for points
+; Clears TRIS* bits for all points and sets each pin to `not triggering'
+points_init
+
+
 ;
 ; Expected layout of data at data_points in flash:
 ;      4 bytes for each point number
 ;              bytes 1-3 are not defined if number is not assigned
 ; address of data_points is guaranteed to be multiple of 256
 
+
+
+
+
  udata_acs
 
  udata 0x300
index 0a86fc1ffa8cf0e2492c5a06cfe3eb33be07db94..2e0a5a10e72dc59c257bacda3697a1e8a7a7888a 100644 (file)
@@ -89,7 +89,7 @@ board_next_none
 
 ;----------
 polarity_do_here
-;              W       here polarity           SS SS v3 v0  v2 v1 v5 v4
+;              W       here polarity msg       SS SS v3 v0  v2 v1 v5 v4
        mov_wf  input           ; input =       SS SS v3 v0  v2 v1 v5 v4
 
        mov_wf  LATE            ; W =           kk kk kk kk  kk kk o5 o4
index 662797e3ba4ac011aa50c35f628091960d66fe65..ecfcee3ffc1cc33a0baf0defe9d36e3d9bf4f76f 100644 (file)
 ;      picno, idloc1           containing correct values read from flash
 
 slave
-       call    det_slave_init
-
        mov_fw  picno
        call    i2cs_init
+       call    common_init
+       call    det_slave_init
+
        mov_lw  (1<<GIEH) | (1<<GIEL)
        mov_wf  INTCON
 
index de5c5532ec5e907e2695a78ae4132f6afd333758..f2e722c75fac21f807ff58dbe19c0454fcce48c5 100644 (file)
@@ -91,6 +91,7 @@ vector_reset
        bs_f    RCON, IPEN      ; interrupt priorities
 
        call    init_read_idlocs
+
        tst_f_ifnz picno
        goto    slave
        bra     master