; Master Slave
; Timer 0 nmra Disabled
; Timer 2 - -
-; Timer 1 1ms tick, int. low 1ms tick, int. low
-; CCP1 1ms tick, int. low 1ms tick, int. low
+; Timer 1 (1ms tick, int. low) (1ms tick, int. low)
+; CCP1 (1ms tick, int. low) (1ms tick, int. low)
; Timer 3 point fire timer point fire timer
; ECCP - -
+;
+; (...) indicates that this is a projected use, NYI
;----------------------------------------------------------------------
; Conventional routine names:
; and arranges for pins to be set in appropriate
; quiescent state. Configures pic built-in
; peripherals.
-;
-; <periph>_local_intr Low ISR service routine.
-; Checks for, and clears, any relevant interrupt,
-; and returns with `return'.
;
+; <periph>_local_intrl Low ISR service routine for peripheral (see below).
+;
; <periph>_master_do Called when an appropriate message has been
; received from the host.
;
+; <something>_intrl Low ISR service routine.
+; Checks for any relevant interrupt.
+; If not, just returns.
+; If found, services it and then does either
+; intrl_handled or intrl_handled_nostack
+; neither of which return; the latter is
+; faster but implies a promise
+;
;----------------------------------------------------------------------
; MACROS
;----------------------------------------
; For entering and leaving Low ISR, saving and restoring STATUS and W
+; See above under <something>_intrl, and {master,slave}_interrupt_low
enter_interrupt_low macro
mov_ff STATUS, isr_low_save_status
mov_wf isr_low_save_w
+ mov_ff STKPTR, isr_low_save_stkptr
endm
-return_interrupt_low macro
+intrl_handled_core macro ; for internal use only
mov_fw isr_low_save_w
mov_ff isr_low_save_status, STATUS
retfie
endm
+intrl_handled_nostack macro
+ pop ; undo the `call' from the original ISR
+ intrl_handled_core
+ endm
+
+intrl_handled macro
+ goto intrl_handled_routine
+ endm
+
;----------------------------------------
; For disabling all interrupts, to make a critical section:
; (for use from main program and Low ISR only)
;--------------------
extern i2cm_interrupt
+ extern i2cm_interrupt_definite
extern i2cs_interrupt
;
; Must be called by the main program's interrupt handler;
;
; For i2cm_interrupt, the main program's interrupt handler is
; responsible for saving W and the flags register and other
-; interrupt-related administrivia. For i2cs_interrupt, it must be the
-; only high-priority interrupt source and expects to be called from
-; the interrupt handler (and it will return; the caller must
-; retfie_r).
+; interrupt-related administrivia. i2cm_interrupt checks for
+; SSPIF and handles any interrupt. i2cm_interrupt_definite
+; should only be called if SSPIF is set and handles it. In
+; both cases the ISR returns with `return'.
+;
+; For i2cs_interrupt, it must be the only high-priority interrupt
+; source and expects to be called from the interrupt handler (and it
+; will return; the caller must retfie_r).
;
; If there is an i2c interrupt, the i2c?_interrupt will service it, taking
; any necessary action including calling appropriate