-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblcksqnc.asm
More file actions
108 lines (94 loc) · 4.93 KB
/
blcksqnc.asm
File metadata and controls
108 lines (94 loc) · 4.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
;**********************************************************************
; *
; Description: Controller for multiple aspect colour light signal and *
; occupation block with positional train detector at *
; block exit. *
; *
; This is a generic specialisation to test common code. *
; *
; Author: Chris White (whitecf69@gmail.com) *
; *
; Copyright (C) 2018 by Monitor Computing Services Limited, licensed *
; under CC BY-NC-SA 4.0. To view a copy of this license, visit *
; https://creativecommons.org/licenses/by-nc-sa/4.0/ *
; *
; This program is distributed in the hope that it will be useful, but *
; WITHOUT ANY WARRANTY; without even the implied warranty of *
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
; *
;**********************************************************************
; *
; +---+ +---+ *
; Warning 2 Aspect <- RA2|1 |_| 18|RA1 -> Warning 1 Aspect *
; Clear Aspect <- RA3|2 17|RA0 -> Stop Aspect *
; !Detecting <-> RA4|3 16| *
; |4 15| *
; |5 14| *
; !Latch Signal On -> RB0|6 13|RB7 <-> Next / <- !Inhibit *
; !Line reversed -> RB1|7 12|RB6 <-> Previous *
; Line bidirectional -> RB2|8 11|RB5 -> !Emitter *
; Normal speed -> RB3|9 10|RB4 <- Sensor *
; +---------+ *
; *
;**********************************************************************
;**********************************************************************
; Configuration directives and constant definitions
;**********************************************************************
#include "blcksqnc_def.inc"
; Aspect output constants
STPMSK EQU B'00000001' ; Mask for stop aspect output bit
WR1MSK EQU B'00000010' ; Mask for warning 1 aspect output bit
WR2MSK EQU B'00000100' ; Mask for warning 2 aspect output bit
CLRMSK EQU B'00001000' ; Mask for clear aspect output bit
BLANKMSK EQU B'00000000' ; Mask for blank aspect output
;**********************************************************************
; Variable registers
;**********************************************************************
#include "blcksqnc_ram.inc"
afterRAM
endc
endRAM EQU afterRAM - 1
#if RAM_End < endRAM
error "This program ran out of RAM!"
#endif
;**********************************************************************
; EEPROM initialisation
;**********************************************************************
#include "blcksqnc_rom.inc"
;**********************************************************************
; Code
;**********************************************************************
; Include serial link interface macros
; - Serial link bit timing is performed by link service routines
#define CLKD_SERIAL
#include "utility_pic/asyn_srl.inc"
#include "utility_pic/link_hd.inc"
#include "blcksqnc_cod.inc"
;**********************************************************************
; Subroutine to return aspect output value in accumulator
;**********************************************************************
GetAspectOutput
movf aspVal,W ; Get output value, may contain spurious bits
andlw ASPMSK ; Isolate aspect value
btfsc STATUS,Z
retlw STPMSK
xorlw ASPCLR
btfsc STATUS,Z
retlw CLRMSK
movlw HALFSEC
andwf secCount,W ; Test for flashing aspect blanking period
movlw WR2MSK
btfss aspVal,ASPW2FLG
movlw WR1MSK
btfsc nxtCntlr,SPDFLG ; Skip if next signal not at normal speed ...
return ; ... else display warning aspect
btfss STATUS,Z ; Skip if aspect blanking period ...
return ; ... else display warning aspect
retlw BLANKMSK ; Blank aspect display
;**********************************************************************
; End of source code
;**********************************************************************
#if CodeEnd < $
error "This program is just too big!"
#endif
end ; directive 'end of program'