1 ;======================================================================
2 ; WAGGLE - SET PIN HIGH OR LOW
6 ;----------------------------------------
7 ; LOCAL WAGGLERS - Variables
11 waggle_lpins equ 0x3a0 ; has to be 0x?a0
12 waggle_lpins_section udata waggle_lpins
14 ; Each pair of bytes is:
15 ; bitmask containing only the relevant bit
18 ;----------------------------------------
19 ; MASTER - Access bank variables etc.
22 waggle_slave res 1 ; 11111111 000 SSSss
23 waggle_message res 1 ; ???????? 101 wwwwY
25 ;======================================================================
31 ; On master, called during serial receive, ie Low ISR
32 ; On slave, called during i2c receive, ie High ISR
33 ; W fire point msg undefined
35 ; on entry: ; W = 101 WWWWY
37 mov_wf t ; t = 101 WWWWY
40 mov_lfsr waggle_lpins | 0x01, 0
41 ; FSR0 = aaaa 000 00001
42 ior_wff FSR0L ; FSR0 = aaaa 101 WWWW1
43 ; *FSR0 = bbbb bbbb (one-bit mask)
44 mov_fw POSTDEC0 ; W = bbbb bbbb
46 bra_z waggle_nonexistent
48 mov_ff INDF0, FSR0L ; FSR0L = LAT*-addr
49 set_f FSR0H ; FSR0 = 1111 LAT*-addr
52 bt_f_if0 t, 0 ; test Y
72 ;----------------------------------------------------------------------
73 ; LOCAL WAGGLERS - INITIALISATION
75 ;----------------------------------------
77 outputs_local_init picno2wagglemap, maxwaggles, waggle_lpins, bkwaggleix2portnumbitnum
80 ;======================================================================
83 ; No serious initialisation needed;
84 ; we just pass on the commands as they come in.
86 wagglers_master_init @
90 ;----------------------------------------------------------------------
96 bt_f_if0 waggle_slave, 7
97 bra command_waggle_busy
99 mov_fw PREINC0 ; F0->[1], W = OSS wwwwV N = 0
100 bra_n command_waggle_badmsg
101 and_lw 0x1f ; W = 000 wwwwV
102 xor_wff INDF0 ; [1] = 0SS 00000
103 ior_lw 0xa0 ; W = 101 wwwwV
104 mov_wf waggle_message ; message = 101 wwwwV
106 rr_fw POSTDEC0 ; F0->[0], W = 00SS 0000
108 xor_wfw INDF0 ; W = 101S Tsss
109 xor_lw 0xa8 ; W = 000S Ssss
110 mov_wf waggle_slave ; slave = 000S Ssss
112 bra_z waggle_local_do
117 bt_f_if1 waggle_slave, 7
124 waggle_getwritebyte @
126 bra_n waggle_getwritebyte_ifidle
128 waggle_getwritebyte_ifidle
131 mov_lw 0x04 ; WAGGLED
133 ; actually it's not waggled until the slave acks it but
134 ; that's a foregone conclusion
136 mov_fw waggle_message
138 goto i2c_getwritebyte_yes
140 command_waggle_badmsg panic morse_AX
141 command_waggle_busy panic morse_AB
143 ;======================================================================