chiark / gitweb /
new low-priority interrupt arrangements
[trains.git] / detpic / program.asm
1 ;======================================================================
2 ; MAIN PROGRAM AND GLUE
3
4  include common.inc
5  code
6
7 ;----------
8 vector_reset
9
10  set_f qqTRISA
11  set_f qqTRISB
12  set_f qqTRISC
13  set_f qqTRISD
14  set_f qqTRISE
15  mov_lw 0xaa
16  mov_wf qqLATA
17  mov_wf qqLATB
18  mov_wf qqLATC
19  mov_wf qqLATD
20  mov_wf qqLATE
21
22         clr_f   INTCON
23         bs_f    RCON, IPEN      ; interrupt priorities
24
25         call    idlocs_init
26
27         tst_f_ifnz picno
28         goto    slave
29         bra     master
30
31 ;----------
32 i2cm_intrl
33 ; handles i2c interrupt using i2cm_interrupt[_definite],
34 ; according to the rules for <something>_intrl.
35         bt_f_if0 PIR1, SSPIF
36         return
37         call    i2cm_interrupt_definite
38         intrl_handled_nostack
39
40 ;----------
41 intrl_handled_routine
42         mov_ff  isr_low_save_stkptr, STKPTR
43         intrl_handled_core
44
45 ;======================================================================
46 ; MASTER/SLAVE deviations
47
48 ;----------
49 message_for_master
50 ; Either transmits the message to the master, or if we are the master,
51 ; handles it as an incoming message from the notional `slave 0'.
52 ;  W            message         unchanged
53 ;  GIEH         set             set
54         bt_f_if1 idloc1,idloc1_master
55         goto    loopback_read_byte
56         goto    slave_add_short_message
57
58 ;======================================================================
59 ; UNIMPLEMENTED STUFF
60
61 ;----------
62 loopback_read_byte
63         panic   morse_UL
64
65  include final.inc