SCC

Used Exports

BUILTINS: BOOLEAN BYTE DEC INC INTEGER LED ODD ORD SET
Kernel: Time
SYSTEM: ADR BIT COPY GET PUT

MODULE SCC; (*NW 13.11.87 / 22.8.90 Ceres-2; nRF24L01+ version PR 21.7.13 / 23.12.13*)
.MODULE SCC (KEY BC919698, VERSION 1, SIZE 00000BE0)
.IMPORT Kernel (KEY 97E012DD)
.TYPEDESC 00000020 FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF
.DATA 228H
.FIXUP T 0H
IMPORT SYSTEM, Kernel;
CONST
swi = -60; spiData = -48; spiCtrl = -44;
netSelect = 1; spiFast = 2; netEnable = 3;
HdrSize = 8; MaxPayload = 512; SubPacket = 32; Wait = 50; SendTries = 50;
MaxPacket = (HdrSize + MaxPayload + SubPacket-1) DIV SubPacket *
SubPacket;
TYPE Header* =
RECORD valid*: BOOLEAN;
dadr*, sadr*, typ*: BYTE;
len*: INTEGER (*of data following header*)
END ;
VAR
filter*: BOOLEAN; Adr*: BYTE; rcvd: INTEGER;
rx: RECORD
hd: Header;
dat: ARRAY MaxPacket-HdrSize OF BYTE
END;
PROCEDURE SPICtrl(s: SET);
BEGINa SYSTEM.PUT(spiCtrl, s);b
0000a .PROC 1
0000a(4EE90008): SUB SP, SP, 8H
0001a(AFE00000): STR LNK, SP, 0H
0002a(A0E00004): STR R0, SP, 4H
0003b(5000FFD4): MOV R0, R0, FFFFFFD4H
0004b(81E00004): LDR R1, SP, 4H
0005b .PROC 2
0005b(A1000000): STR R1, R0, 0H
IF netEnable IN s THENc LED(55H) ELSEd LEDe(0) ENDf
0006c(80E00004): LDR R0, SP, 4H
0007c(40030004): ROR R0, R0, 4H
0008c(E8000004): BPL 4 [000DH]
0009d(40000055): MOV R0, R0, 55H
000Ad(5100FFC4): MOV R1, R0, FFFFFFC4H
000Bd(A0100000): STR R0, R1, 0H
000Ce(E7000003): B 3 [0010H]
000Df(40000000): MOV R0, R0, 0H
000Ef(5100FFC4): MOV R1, R0, FFFFFFC4H
000Ff(A0100000): STR R0, R1, 0H
ENDg SPICtrl;
0010g(8FE00000): LDR LNK, SP, 0H
0011g(4EE80008): ADD SP, SP, 8H
0012g(C700000F): B LNK
PROCEDURE SPI(n: INTEGER);
BEGINh (*send (& rcv into shift reg) one byte or word, at current speed*)
0013h(4EE90008): SUB SP, SP, 8H
0014h(AFE00000): STR LNK, SP, 0H
0015h(A0E00004): STR R0, SP, 4H
SYSTEM.PUT(spiData, n);i REPEAT UNTIL SYSTEM.BIT(spiCtrl, 0) (*wait until done*)
0016i(5000FFD0): MOV R0, R0, FFFFFFD0H
0017i(81E00004): LDR R1, SP, 4H
0018i(A1000000): STR R1, R0, 0H
ENDj SPI;
0019j(5000FFD4): MOV R0, R0, FFFFFFD4H
001Aj(80000000): LDR R0, R0, 0H
001Bj(40030001): ROR R0, R0, 1H
001Cj(E8FFFFFC): BPL -4 [0019H]
001Dj(8FE00000): LDR LNK, SP, 0H
001Ej(4EE80008): ADD SP, SP, 8H
001Fj(C700000F): B LNK
PROCEDURE StartCmd(cmd: INTEGER);
BEGINk SPICtrl({netSelect})l;m SPI(cmd)n
0020k(4EE90008): SUB SP, SP, 8H
0021k(AFE00000): STR LNK, SP, 0H
0022k(A0E00004): STR R0, SP, 4H
0023l(40000002): MOV R0, R0, 2H
0024m(F7FFFFDB): BL -37 [0000H]
0025n(80E00004): LDR R0, SP, 4H
ENDo StartCmd;
0026o(F7FFFFEC): BL -20 [0013H]
0027o(8FE00000): LDR LNK, SP, 0H
0028o(4EE80008): ADD SP, SP, 8H
0029o(C700000F): B LNK
PROCEDURE WriteReg1(reg, dat: INTEGER); (*disables radio!*)
BEGINp StartCmd(reg + 20H)q;r SPI(dat)s;t SPICtrl({})u (*W_REGISTER*)
002Ap(4EE9000C): SUB SP, SP, CH
002Bp(AFE00000): STR LNK, SP, 0H
002Cp(A0E00004): STR R0, SP, 4H
002Dp(A1E00008): STR R1, SP, 8H
002Eq(80E00004): LDR R0, SP, 4H
002Fq(40080020): ADD R0, R0, 20H
0030r(F7FFFFEF): BL -17 [0020H]
0031s(80E00008): LDR R0, SP, 8H
0032t(F7FFFFE0): BL -32 [0013H]
0033u(40000000): MOV R0, R0, 0H
ENDv WriteReg1;
0034v(F7FFFFCB): BL -53 [0000H]
0035v(8FE00000): LDR LNK, SP, 0H
0036v(4EE8000C): ADD SP, SP, CH
0037v(C700000F): B LNK
PROCEDURE SubRcv(dst: INTEGER);
VAR i, dat: INTEGER;
BEGINw
0038w(4EE90010): SUB SP, SP, 10H
0039w(AFE00000): STR LNK, SP, 0H
003Aw(A0E00004): STR R0, SP, 4H
StartCmd(061H)x;y (*R_RX_PAYLOAD, disables radio*)
003Bx(40000061): MOV R0, R0, 61H
003Cy(F7FFFFE3): BL -29 [0020H]
SPICtrl({netSelect, spiFast})z;a
003Dz(40000006): MOV R0, R0, 6H
003Ea(F7FFFFC1): BL -63 [0000H]
FOR i := 0 TOb SubPacket-4 BY 4 DO
003Fb(40000000): MOV R0, R0, 0H
SPIc(-1)d;e SYSTEM.GET(spiData, dat);f SYSTEM.PUT(dst+i,g dat)
0040c(4109001C): SUB R1, R0, 1CH
0041c(EE00000E): BGT 14 [0050H]
0042c(A0E00008): STR R0, SP, 8H
0043d(5000FFFF): MOV R0, R0, FFFFFFFFH
0044e(F7FFFFCE): BL -50 [0013H]
0045f(5000FFD0): MOV R0, R0, FFFFFFD0H
0046f(80000000): LDR R0, R0, 0H
0047f(A0E0000C): STR R0, SP, CH
0048g(80E00004): LDR R0, SP, 4H
0049g(81E00008): LDR R1, SP, 8H
004Ag(00080001): ADD R0, R0, R1
ENDh;i
004Bh(81E0000C): LDR R1, SP, CH
004Ch(A1000000): STR R1, R0, 0H
004Di(80E00008): LDR R0, SP, 8H
004Ei(40080004): ADD R0, R0, 4H
004Fi(E7FFFFF0): B -16 [0040H]
SPICtrl({})j;k WriteReg1(7,l 40H)m;n (*done; STATUS <= clear RX_DR*)
0050j(40000000): MOV R0, R0, 0H
0051k(F7FFFFAE): BL -82 [0000H]
0052l(40000007): MOV R0, R0, 7H
0053m(41000040): MOV R1, R0, 40H
0054n(F7FFFFD5): BL -43 [002AH]
SPICtrl({netEnable})o (*enable radio*)
0055o(40000008): MOV R0, R0, 8H
ENDp SubRcv;
0056p(F7FFFFA9): BL -87 [0000H]
0057p(8FE00000): LDR LNK, SP, 0H
0058p(4EE80010): ADD SP, SP, 10H
0059p(C700000F): B LNK
PROCEDURE SubSnd(src: INTEGER; VAR timeout: BOOLEAN);
VAR i, dat, res, t1, try: INTEGER; x, status: BYTE;
BEGINq (*already in xmit mode*)
005Aq(4EE90024): SUB SP, SP, 24H
005Bq(AFE00000): STR LNK, SP, 0H
005Cq(A0E00004): STR R0, SP, 4H
005Dq(A1E00008): STR R1, SP, 8H
StartCmd(0A0H)r;s (*W_TX_PAYLOAD*)
005Er(400000A0): MOV R0, R0, A0H
005Fs(F7FFFFC0): BL -64 [0020H]
SPICtrl({netSelect, spiFast})t;u
0060t(40000006): MOV R0, R0, 6H
0061u(F7FFFF9E): BL -98 [0000H]
FOR i := 0 TOv SubPacket-4 BY 4 DO
0062v(40000000): MOV R0, R0, 0H
SYSTEMw.GET(src+i,x dat);y SPI(dat)z
0063w(4109001C): SUB R1, R0, 1CH
0064w(EE00000B): BGT 11 [0070H]
0065w(A0E0000C): STR R0, SP, CH
0066x(80E00004): LDR R0, SP, 4H
0067x(81E0000C): LDR R1, SP, CH
0068x(00080001): ADD R0, R0, R1
0069y(80000000): LDR R0, R0, 0H
006Ay(A0E00010): STR R0, SP, 10H
006Bz(80E00010): LDR R0, SP, 10H
ENDa;b
006Ca(F7FFFFA6): BL -90 [0013H]
006Db(80E0000C): LDR R0, SP, CH
006Eb(40080004): ADD R0, R0, 4H
006Fb(E7FFFFF3): B -13 [0063H]
SPICtrl({})c;d (*end W_TX_PAYLOAD command*)
0070c(40000000): MOV R0, R0, 0H
0071d(F7FFFF8E): BL -114 [0000H]
try := 0;e
0072e(40000000): MOV R0, R0, 0H
0073e(A0E0001C): STR R0, SP, 1CH
SPICtrl({netEnable, netSelect})f;g (*start xmit pulse, start NOP cmd*)
0074f(4000000A): MOV R0, R0, AH
0075g(F7FFFF8A): BL -118 [0000H]
REPEAT
t1 := Kernel.Time() +h Wait;i
0076h .FIXUP P
0076h(F7111076): BL MOD1 [Kernel] PROC17
0077i(40080032): ADD R0, R0, 32H
0078i(A0E00018): STR R0, SP, 18H
REPEAT (*wait for sent or retransmits exceeded*);
SPI(0FFH)j;k SYSTEM.GET(spiData, status);l (*NOP*)
0079j(400000FF): MOV R0, R0, FFH
007Ak(F7FFFF98): BL -104 [0013H]
007Bl(5000FFD0): MOV R0, R0, FFFFFFD0H
007Cl(90000000): LDR R0, R0, 0H
007Dl(B0E00021): STR R0, SP, 21H
res := status DIV 10H MODm 4;n
007Em(90E00021): LDR R0, SP, 21H
007Fm(40020004): ASR R0, R0, 4H
0080n(40040003): AND R0, R0, 3H
0081n(A0E00014): STR R0, SP, 14H
SPICtrl({})o;p SPICtrl({netSelect})q (*end & restart NOP cmd, end =10us pulse on enable*)
0082o(40000000): MOV R0, R0, 0H
0083p(F7FFFF7C): BL -132 [0000H]
0084q(40000002): MOV R0, R0, 2H
UNTILr res # 0;s
0085r(F7FFFF7A): BL -134 [0000H]
0086s(80E00014): LDR R0, SP, 14H
0087s(E1FFFFF1): BEQ -15 [0079H]
IF res = 2 THENt WriteReg1(7,u 20H)v (*TX_DS: sent, ack received; reset it*)
0088t(80E00014): LDR R0, SP, 14H
0089t(40090002): SUB R0, R0, 2H
008At(E9000004): BNE 4 [008FH]
008Bu(40000007): MOV R0, R0, 7H
008Cv(41000020): MOV R1, R0, 20H
ELSIFw resx = 1 THENy WriteReg1(7,z 10H)a;b INC(try);c (*MAX_RT: retransmits exceeded; reset it*)
008Dw(F7FFFF9C): BL -100 [002AH]
008Ex(E7000015): B 21 [00A4H]
008Fy(80E00014): LDR R0, SP, 14H
0090y(40090001): SUB R0, R0, 1H
0091y(E9000012): BNE 18 [00A4H]
0092z(40000007): MOV R0, R0, 7H
0093a(41000010): MOV R1, R0, 10H
0094b(F7FFFF95): BL -107 [002AH]
0095c(80E0001C): LDR R0, SP, 1CH
0096c(40080001): ADD R0, R0, 1H
0097c(A0E0001C): STR R0, SP, 1CH
IF try = SendTries THENd res := 0
0098d(80E0001C): LDR R0, SP, 1CH
0099d(40090032): SUB R0, R0, 32H
009Ad(E9000003): BNE 3 [009EH]
ELSEe REPEATf UNTIL Kernel.Time() >=g t1;h
009Be(40000000): MOV R0, R0, 0H
009Ce(A0E00014): STR R0, SP, 14H
009Df(E7000006): B 6 [00A4H]
009Eg .FIXUP P
009Eg(F7111028): BL MOD1 [Kernel] PROC17
009Fh(81E00018): LDR R1, SP, 18H
00A0h(00090001): SUB R0, R0, R1
00A1h(E5FFFFFC): BLT -4 [009EH]
SPICtrl({netEnable, netSelect})i;j (*start xmit pulse, start NOP cmd again*)
00A2i(4000000A): MOV R0, R0, AH
00A3j(F7FFFF5C): BL -164 [0000H]
END
END
UNTIL res # 1;k
00A4k(80E00014): LDR R0, SP, 14H
00A5k(40090001): SUB R0, R0, 1H
00A6k(E1FFFFCF): BEQ -49 [0076H]
timeout := (res # 2)l
00A7l(80E00014): LDR R0, SP, 14H
00A8l(40090002): SUB R0, R0, 2H
ENDm SubSnd;
00A9m(E1000002): BEQ 2 [00ACH]
00AAm(40000001): MOV R0, R0, 1H
00ABm(E7000001): B 1 [00ADH]
00ACm(40000000): MOV R0, R0, 0H
00ADm(81E00008): LDR R1, SP, 8H
00AEm(B0100000): STR R0, R1, 0H
00AFm(8FE00000): LDR LNK, SP, 0H
00B0m(4EE80024): ADD SP, SP, 24H
00B1m(C700000F): B LNK
PROCEDURE Flush();
BEGINn StartCmd(0E1H)o;p SPICtrl({})q;r StartCmd(0E2H)s;t SPICtrl({})u
00B2n(4EE90004): SUB SP, SP, 4H
00B3n(AFE00000): STR LNK, SP, 0H
00B4o(400000E1): MOV R0, R0, E1H
00B5p(F7FFFF6A): BL -150 [0020H]
00B6q(40000000): MOV R0, R0, 0H
00B7r(F7FFFF48): BL -184 [0000H]
00B8s(400000E2): MOV R0, R0, E2H
00B9t(F7FFFF66): BL -154 [0020H]
00BAu(40000000): MOV R0, R0, 0H
(*FLUSH_TX, FLUSH_RX*)
ENDv Flush;
00BBv(F7FFFF44): BL -188 [0000H]
00BCv(8FE00000): LDR LNK, SP, 0H
00BDv(4EE80004): ADD SP, SP, 4H
00BEv(C700000F): B LNK
PROCEDURE ResetRcv;
BEGINw SYSTEM.PUT(SYSTEM.ADR(rx),x 0);y rx.hd.len := 0;z rcvd := 0
00BFw(4EE90004): SUB SP, SP, 4H
00C0w(AFE00000): STR LNK, SP, 0H
00C1x .FIXUP D
00C1x(8D0000C1): LDR SB, MT, MOD0 [SCC]
00C2x(40D8001C): ADD R0, SB, 1CH [data]
00C3y(41000000): MOV R1, R0, 0H
00C4y(A1000000): STR R1, R0, 0H
00C5z(40000000): MOV R0, R0, 0H
00C6z(A0D00020): STR R0, SB, 20H
ENDa ResetRcv;
00C7a(40000000): MOV R0, R0, 0H
00C8a(A0D00018): STR R0, SB, 18H
00C9a(8FE00000): LDR LNK, SP, 0H
00CAa(4EE80004): ADD SP, SP, 4H
00CBa(C700000F): B LNK
PROCEDURE Listen(b: BOOLEAN);
BEGINb
00CCb(4EE90008): SUB SP, SP, 8H
00CDb(AFE00000): STR LNK, SP, 0H
00CEb(A0E00004): STR R0, SP, 4H
WriteReg1(0,c 07EH + ORD(b))d;e (*CONFIG <= mask ints; EN_CRC(2 byte), PWR_UP, PRX/PTX*)
00CFc(40000000): MOV R0, R0, 0H
00D0d(91E00004): LDR R1, SP, 4H
00D1d(4200007E): MOV R2, R0, 7EH
00D2d(01280001): ADD R1, R2, R1
00D3e(F7FFFF56): BL -170 [002AH]
WriteReg1(7,f 70H)g;h (*STATUS <= clear ints*)
00D4f(40000007): MOV R0, R0, 7H
00D5g(41000070): MOV R1, R0, 70H
00D6h(F7FFFF53): BL -173 [002AH]
IF b THENi SPICtrl({netEnable})j ENDk (*turn radio on*)
00D7i(90E00004): LDR R0, SP, 4H
00D8i(E1000002): BEQ 2 [00DBH]
00D9j(40000008): MOV R0, R0, 8H
00DAk(F7FFFF25): BL -219 [0000H]
ENDl Listen;
00DBl(8FE00000): LDR LNK, SP, 0H
00DCl(4EE80008): ADD SP, SP, 8H
00DDl(C700000F): B LNK
PROCEDURE Start*(filt: BOOLEAN);
VAR n: INTEGER;
BEGINm filter := filt;n Adr := 0;o
00DEm .PROC 4
00DEm(4EE9000C): SUB SP, SP, CH
00DFm(AFE00000): STR LNK, SP, 0H
00E0m(A0E00004): STR R0, SP, 4H
00E1n(90E00004): LDR R0, SP, 4H
00E2n .FIXUP D
00E2n(8D000021): LDR SB, MT, MOD0 [SCC]
00E3n(B0D00014): STR R0, SB, 14H [data]
00E4o(40000000): MOV R0, R0, 0H
00E5o(B0D00015): STR R0, SB, 15H
SYSTEM.GET(swi, n);p n := n DIV 4 MODq 10H *r 10 +s 5;t
00E6p(5000FFC4): MOV R0, R0, FFFFFFC4H
00E7p(80000000): LDR R0, R0, 0H
00E8p(A0E00008): STR R0, SP, 8H
00E9q(80E00008): LDR R0, SP, 8H
00EAq(40020002): ASR R0, R0, 2H
00EBr(4004000F): AND R0, R0, FH
00ECs(400A000A): MUL R0, R0, AH
00EDt(40080005): ADD R0, R0, 5H
00EEt(A0E00008): STR R0, SP, 8H
WriteReg1(5,u n)v;w (*RF_CH <= channel: 5, 15, 25...*)
00EFu(40000005): MOV R0, R0, 5H
00F0v(81E00008): LDR R1, SP, 8H
00F1w(F7FFFF38): BL -200 [002AH]
WriteReg1(6,x 07H)y;z (*RF_SETUP <= 1Mb for better range, 0dBm*)
00F2x(40000006): MOV R0, R0, 6H
00F3y(41000007): MOV R1, R0, 7H
00F4z(F7FFFF35): BL -203 [002AH]
WriteReg1(11H,a SubPacket)b;c (*RX_PW_P0 <= pipe 0 payload width*)
00F5a(40000011): MOV R0, R0, 11H
00F6b(41000020): MOV R1, R0, 20H
00F7c(F7FFFF32): BL -206 [002AH]
Flush();d Listen(TRUE)e;f ResetRcv
00F8d(F7FFFFB9): BL -71 [00B2H]
00F9e(40000001): MOV R0, R0, 1H
00FAf(F7FFFFD1): BL -47 [00CCH]
ENDg Start;
00FBg(F7FFFFC3): BL -61 [00BFH]
00FCg(8FE00000): LDR LNK, SP, 0H
00FDg(4EE8000C): ADD SP, SP, CH
00FEg(C700000F): B LNK
PROCEDURE SendPacket*(VAR head: Header; dat: ARRAY OF BYTE);
VAR len, i, off: INTEGER; timeout: BOOLEAN; payload: ARRAY SubPacket
OF BYTE;
BEGINh (*let any receive ack finish before turning radio off*)
00FFh .PROC 5
00FFh(4EE90044): SUB SP, SP, 44H
0100h(AFE00000): STR LNK, SP, 0H
0101h(A0E00004): STR R0, SP, 4H
0102h(A1E00008): STR R1, SP, 8H
0103h(A2E0000C): STR R2, SP, CH
0104h(A3E00010): STR R3, SP, 10H
i := Kernel.Time() +i Wait;j
0105i .FIXUP P
0105i(F7111067): BL MOD1 [Kernel] PROC17
0106j(40080032): ADD R0, R0, 32H
0107j(A0E00018): STR R0, SP, 18H
REPEAT SPICtrl({netEnable, netSelect})k;l SPI(0FFH)m;n SPICtrl({netEnable})o (*NOP*)
0108k(4000000A): MOV R0, R0, AH
0109l(F7FFFEF6): BL -266 [0000H]
010Am(400000FF): MOV R0, R0, FFH
010Bn(F7FFFF07): BL -249 [0013H]
010Co(40000008): MOV R0, R0, 8H
UNTILp Kernel.Time() >=q i;r
010Dp(F7FFFEF2): BL -270 [0000H]
010Eq .FIXUP P
010Eq(F7111009): BL MOD1 [Kernel] PROC17
010Fr(81E00018): LDR R1, SP, 18H
0110r(00090001): SUB R0, R0, R1
0111r(E5FFFFF6): BLT -10 [0108H]
IF Adr = 0 THENs Adr := i MOD 100H ENDt;
0112s .FIXUP D
0112s(8D000030): LDR SB, MT, MOD0 [SCC]
0113s(90D00015): LDR R0, SB, 15H [data]
0114s(E9000004): BNE 4 [0119H]
0115t(80E00018): LDR R0, SP, 18H
0116t(400400FF): AND R0, R0, FFH
0117t .FIXUP D
0117t(8D000005): LDR SB, MT, MOD0 [SCC]
0118t(B0D00015): STR R0, SB, 15H [data]
Listen(FALSE)u;v
0119u(40000000): MOV R0, R0, 0H
011Av(F7FFFFB1): BL -79 [00CCH]
head.sadr := Adr;w head.valid := TRUE;x
011Bw .FIXUP D
011Bw(8D000004): LDR SB, MT, MOD0 [SCC]
011Cw(90D00015): LDR R0, SB, 15H [data]
011Dw(81E00004): LDR R1, SP, 4H
011Ew(B0100002): STR R0, R1, 2H
011Fx(40000001): MOV R0, R0, 1H
0120x(81E00004): LDR R1, SP, 4H
0121x(B0100000): STR R0, R1, 0H
SYSTEM.COPY(SYSTEM.ADR(head),y SYSTEM.ADR(payload),z HdrSize DIV 4);a
0122y(80E00004): LDR R0, SP, 4H
0123z(41E80024): ADD R1, SP, 24H
0124a(42000002): MOV R2, R0, 2H
0125a(83000000): LDR R3, R0, 0H
0126a(40080004): ADD R0, R0, 4H
0127a(A3100000): STR R3, R1, 0H
0128a(41180004): ADD R1, R1, 4H
0129a(42290001): SUB R2, R2, 1H
012Aa(E9FFFFFA): BNE -6 [0125H]
i := HdrSize;b off := 0;c len := head.len;d
012Bb(40000008): MOV R0, R0, 8H
012Cb(A0E00018): STR R0, SP, 18H
012Dc(40000000): MOV R0, R0, 0H
012Ec(A0E0001C): STR R0, SP, 1CH
012Fd(80E00004): LDR R0, SP, 4H
0130d(80000004): LDR R0, R0, 4H
0131d(A0E00014): STR R0, SP, 14H
WHILE (len > 0)e & (fi < SubPacket)g DOh payload[i]i := dat[off]j;k INC(i);l INC(off);m DEC(len) ENDn;
0132e(80E00014): LDR R0, SP, 14H
0133e(40090000): SUB R0, R0, 0H
0134f(E6000019): BLE 25 [014EH]
0135g(80E00018): LDR R0, SP, 18H
0136g(40090020): SUB R0, R0, 20H
0137h(ED000016): BGE 22 [014EH]
0138i(80E00018): LDR R0, SP, 18H
0139i(41090020): SUB R1, R0, 20H
013Ai(DA10B01C): BLCC MT [trap=1, pos=4272]
013Bi(00E80000): ADD R0, SP, R0
013Cj(81E0001C): LDR R1, SP, 1CH
013Dj(82E00010): LDR R2, SP, 10H
013Ej(02190002): SUB R2, R1, R2
013Fj(DA10BC1C): BLCC MT [trap=1, pos=4284]
0140j(82E0000C): LDR R2, SP, CH
0141j(01280001): ADD R1, R2, R1
0142k(91100000): LDR R1, R1, 0H
0143k(B1000024): STR R1, R0, 24H
0144l(80E00018): LDR R0, SP, 18H
0145l(40080001): ADD R0, R0, 1H
0146l(A0E00018): STR R0, SP, 18H
0147m(80E0001C): LDR R0, SP, 1CH
0148m(40080001): ADD R0, R0, 1H
0149m(A0E0001C): STR R0, SP, 1CH
014An(80E00014): LDR R0, SP, 14H
014Bn(40090001): SUB R0, R0, 1H
014Cn(A0E00014): STR R0, SP, 14H
014Dn(E7FFFFE4): B -28 [0132H]
WHILE i < SubPacket DOo payload[i]p := 0;q INC(i) ENDr;
014Eo(80E00018): LDR R0, SP, 18H
014Fo(40090020): SUB R0, R0, 20H
0150o(ED00000A): BGE 10 [015BH]
0151p(80E00018): LDR R0, SP, 18H
0152p(41090020): SUB R1, R0, 20H
0153p(DA11031C): BLCC MT [trap=1, pos=4355]
0154p(00E80000): ADD R0, SP, R0
0155q(41000000): MOV R1, R0, 0H
0156q(B1000024): STR R1, R0, 24H
0157r(80E00018): LDR R0, SP, 18H
0158r(40080001): ADD R0, R0, 1H
0159r(A0E00018): STR R0, SP, 18H
015Ar(E7FFFFF3): B -13 [014EH]
SubSnd(SYSTEM.ADR(payload),s timeout)t;u
015Bs(40E80024): ADD R0, SP, 24H
015Ct(41E80020): ADD R1, SP, 20H
015Du(F7FFFEFC): BL -260 [005AH]
WHILE ~timeout &v (wlen # 0)x DOy i := 0;z (*send the rest*)
015Ev(90E00020): LDR R0, SP, 20H
015Fw(E9000031): BNE 49 [0191H]
0160x(80E00014): LDR R0, SP, 14H
0161y(E100002F): BEQ 47 [0191H]
0162z(40000000): MOV R0, R0, 0H
0163z(A0E00018): STR R0, SP, 18H
WHILE (len > 0)a & (bi < SubPacket)c DOd payload[i]e := dat[off]f;g INC(i);h INC(off);i DEC(len) ENDj;
0164a(80E00014): LDR R0, SP, 14H
0165a(40090000): SUB R0, R0, 0H
0166b(E6000019): BLE 25 [0180H]
0167c(80E00018): LDR R0, SP, 18H
0168c(40090020): SUB R0, R0, 20H
0169d(ED000016): BGE 22 [0180H]
016Ae(80E00018): LDR R0, SP, 18H
016Be(41090020): SUB R1, R0, 20H
016Ce(DA11B11C): BLCC MT [trap=1, pos=4529]
016De(00E80000): ADD R0, SP, R0
016Ef(81E0001C): LDR R1, SP, 1CH
016Ff(82E00010): LDR R2, SP, 10H
0170f(02190002): SUB R2, R1, R2
0171f(DA11BD1C): BLCC MT [trap=1, pos=4541]
0172f(82E0000C): LDR R2, SP, CH
0173f(01280001): ADD R1, R2, R1
0174g(91100000): LDR R1, R1, 0H
0175g(B1000024): STR R1, R0, 24H
0176h(80E00018): LDR R0, SP, 18H
0177h(40080001): ADD R0, R0, 1H
0178h(A0E00018): STR R0, SP, 18H
0179i(80E0001C): LDR R0, SP, 1CH
017Ai(40080001): ADD R0, R0, 1H
017Bi(A0E0001C): STR R0, SP, 1CH
017Cj(80E00014): LDR R0, SP, 14H
017Dj(40090001): SUB R0, R0, 1H
017Ej(A0E00014): STR R0, SP, 14H
017Fj(E7FFFFE4): B -28 [0164H]
WHILE i < SubPacket DOk payload[i]l := 0;m INC(i) ENDn;
0180k(80E00018): LDR R0, SP, 18H
0181k(40090020): SUB R0, R0, 20H
0182k(ED00000A): BGE 10 [018DH]
0183l(80E00018): LDR R0, SP, 18H
0184l(41090020): SUB R1, R0, 20H
0185l(DA12061C): BLCC MT [trap=1, pos=4614]
0186l(00E80000): ADD R0, SP, R0
0187m(41000000): MOV R1, R0, 0H
0188m(B1000024): STR R1, R0, 24H
0189n(80E00018): LDR R0, SP, 18H
018An(40080001): ADD R0, R0, 1H
018Bn(A0E00018): STR R0, SP, 18H
018Cn(E7FFFFF3): B -13 [0180H]
SubSnd(SYSTEM.ADR(payload),o timeout)p
018Do(40E80024): ADD R0, SP, 24H
018Ep(41E80020): ADD R1, SP, 20H
ENDq;
018Fq(F7FFFECA): BL -310 [005AH]
0190q(E7FFFFCD): B -51 [015EH]
Listen(TRUE)r
0191r(40000001): MOV R0, R0, 1H
ENDs SendPacket;
0192s(F7FFFF39): BL -199 [00CCH]
0193s(8FE00000): LDR LNK, SP, 0H
0194s(4EE80044): ADD SP, SP, 44H
0195s(C700000F): B LNK
PROCEDURE Available*(): INTEGER;
BEGINt (*packet already rcvd*)
0196t .PROC 6
0196t(4EE90004): SUB SP, SP, 4H
0197t(AFE00000): STR LNK, SP, 0H
RETURN rx.hd.len - rcvd
ENDu Available;
0198u .FIXUP D
0198u(8D00007D): LDR SB, MT, MOD0 [SCC]
0199u(80D00020): LDR R0, SB, 20H [data]
019Au(81D00018): LDR R1, SB, 18H
019Bu(00090001): SUB R0, R0, R1
019Cu(8FE00000): LDR LNK, SP, 0H
019Du(4EE80004): ADD SP, SP, 4H
019Eu(C700000F): B LNK
PROCEDURE Receive*(VAR x: BYTE);
BEGINv (*packet already rcvd*)
019Fv .PROC 7
019Fv(4EE90008): SUB SP, SP, 8H
01A0v(AFE00000): STR LNK, SP, 0H
01A1v(A0E00004): STR R0, SP, 4H
IF rcvd < rx.hd.len THENw x := rx.dat[rcvd]x;y INC(rcvd) ELSEz xa := 0 ENDb
01A2w .FIXUP D
01A2w(8D00000A): LDR SB, MT, MOD0 [SCC]
01A3w(80D00018): LDR R0, SB, 18H [data]
01A4w(81D00020): LDR R1, SB, 20H
01A5w(00090001): SUB R0, R0, R1
01A6w(ED00000D): BGE 13 [01B4H]
01A7x .FIXUP D
01A7x(8D000005): LDR SB, MT, MOD0 [SCC]
01A8x(80D00018): LDR R0, SB, 18H [data]
01A9x(41090218): SUB R1, R0, 218H
01AAx(DA13531C): BLCC MT [trap=1, pos=4947]
01ABx(00D80000): ADD R0, SB, R0
01ACy(90000024): LDR R0, R0, 24H
01ADy(81E00004): LDR R1, SP, 4H
01AEy(B0100000): STR R0, R1, 0H
01AFz(40D80018): ADD R0, SB, 18H
01B0z(81000000): LDR R1, R0, 0H
01B1z(41180001): ADD R1, R1, 1H
01B2z(A1000000): STR R1, R0, 0H
01B3a(E7000003): B 3 [01B7H]
01B4b(40000000): MOV R0, R0, 0H
01B5b(81E00004): LDR R1, SP, 4H
01B6b(B0100000): STR R0, R1, 0H
ENDc Receive;
01B7c(8FE00000): LDR LNK, SP, 0H
01B8c(4EE80008): ADD SP, SP, 8H
01B9c(C700000F): B LNK
PROCEDURE Rcvd(time: INTEGER): BOOLEAN;
VAR status, fifoStatus: BYTE; rcvd: BOOLEAN;
BEGINd time := time + Kernel.Time();e
01BAd(4EE9000C): SUB SP, SP, CH
01BBd(AFE00000): STR LNK, SP, 0H
01BCd(A0E00004): STR R0, SP, 4H
01BDe .FIXUP P
01BDe(F71110AF): BL MOD1 [Kernel] PROC17
01BEe(81E00004): LDR R1, SP, 4H
01BFe(00180000): ADD R0, R1, R0
01C0e(A0E00004): STR R0, SP, 4H
REPEAT
SPICtrl({netEnable, netSelect})f;g SPI(17H)h;i (*R_REGISTER FIFO_STATUS*)
01C1f(4000000A): MOV R0, R0, AH
01C2g(F7FFFE3D): BL -451 [0000H]
01C3h(40000017): MOV R0, R0, 17H
01C4i(F7FFFE4E): BL -434 [0013H]
SYSTEM.GET(spiData, status);j SPI(-1)k;l SYSTEM.GET(spiData, fifoStatus);m SPICtrl({netEnable})n;o
01C5j(5000FFD0): MOV R0, R0, FFFFFFD0H
01C6j(90000000): LDR R0, R0, 0H
01C7j(B0E00008): STR R0, SP, 8H
01C8k(5000FFFF): MOV R0, R0, FFFFFFFFH
01C9l(F7FFFE49): BL -439 [0013H]
01CAm(5000FFD0): MOV R0, R0, FFFFFFD0H
01CBm(90000000): LDR R0, R0, 0H
01CCm(B0E00009): STR R0, SP, 9H
01CDn(40000008): MOV R0, R0, 8H
01CEo(F7FFFE31): BL -463 [0000H]
rcvd := ODD(status DIV 40H)p ORq ~rODD(fifoStatus) (*RX_DR (data ready) or RX FIFO not empty*)
01CFp(90E00008): LDR R0, SP, 8H
01D0p(40020006): ASR R0, R0, 6H
01D1q(40040001): AND R0, R0, 1H
01D2r(E9000003): BNE 3 [01D6H]
UNTILs rcvd OR (tKernel.Time() >=u time)v;w
01D3s(90E00009): LDR R0, SP, 9H
01D4s(40040001): AND R0, R0, 1H
01D5s(E9000002): BNE 2 [01D8H]
01D6s(40000001): MOV R0, R0, 1H
01D7s(E7000001): B 1 [01D9H]
01D8s(40000000): MOV R0, R0, 0H
01D9s(B0E0000A): STR R0, SP, AH
01DAt(90E0000A): LDR R0, SP, AH
01DBt(E9000004): BNE 4 [01E0H]
01DCu .FIXUP P
01DCu(F711101F): BL MOD1 [Kernel] PROC17
01DDv(81E00004): LDR R1, SP, 4H
01DEv(00090001): SUB R0, R0, R1
01DFw(E5FFFFE1): BLT -31 [01C1H]
RETURN rcvd
ENDx Rcvd;
01E0x(90E0000A): LDR R0, SP, AH
01E1x(8FE00000): LDR LNK, SP, 0H
01E2x(4EE8000C): ADD SP, SP, CH
01E3x(C700000F): B LNK
PROCEDURE ReceiveHead*(VAR head: Header); (*actually, recv whole packet*)
VAR adr, n: INTEGER;
BEGINy head.valid := FALSE;z
01E4y .PROC 8
01E4y(4EE90014): SUB SP, SP, 14H
01E5y(AFE00000): STR LNK, SP, 0H
01E6y(A0E00004): STR R0, SP, 4H
01E7y(A1E00008): STR R1, SP, 8H
01E8z(40000000): MOV R0, R0, 0H
01E9z(81E00004): LDR R1, SP, 4H
01EAz(B0100000): STR R0, R1, 0H
IF Rcvd(0)a THENb
01EBa(40000000): MOV R0, R0, 0H
01ECb(F7FFFFCD): BL -51 [01BAH]
01EDb(40090000): SUB R0, R0, 0H
01EEb(E1000048): BEQ 72 [0237H]
ResetRcv;c adr := SYSTEM.ADR(rx);d SubRcv(adr)e;f
01EFc(F7FFFECF): BL -305 [00BFH]
01F0d .FIXUP D
01F0d(8D000049): LDR SB, MT, MOD0 [SCC]
01F1d(40D8001C): ADD R0, SB, 1CH [data]
01F2d(A0E0000C): STR R0, SP, CH
01F3e(80E0000C): LDR R0, SP, CH
01F4f(F7FFFE43): BL -445 [0038H]
n := (rx.hd.len + HdrSize -g 1)h DIV SubPacket;i
01F5g .FIXUP D
01F5g(8D000005): LDR SB, MT, MOD0 [SCC]
01F6g(80D00020): LDR R0, SB, 20H [data]
01F7g(40080008): ADD R0, R0, 8H
01F8h(40090001): SUB R0, R0, 1H
01F9i(40020005): ASR R0, R0, 5H
01FAi(A0E00010): STR R0, SP, 10H
IF (rx.hd.len <= MaxPayload)j
01FBj(80D00020): LDR R0, SB, 20H
01FCj(40090200): SUB R0, R0, 200H
& (k(rx.hd.dadr = 0FFH)l OR ~mfilter ORn (oAdr = 0)p OR (qrx.hd.dadr = Adr)r) THENs
01FDk(EE000027): BGT 39 [0225H]
01FEl .FIXUP D
01FEl(8D000009): LDR SB, MT, MOD0 [SCC]
01FFl(90D0001D): LDR R0, SB, 1DH [data]
0200l(400900FF): SUB R0, R0, FFH
0201m(E100000B): BEQ 11 [020DH]
0202n .FIXUP D
0202n(8D000004): LDR SB, MT, MOD0 [SCC]
0203n(90D00014): LDR R0, SB, 14H [data]
0204o(E1000008): BEQ 8 [020DH]
0205p .FIXUP D
0205p(8D000003): LDR SB, MT, MOD0 [SCC]
0206p(90D00015): LDR R0, SB, 15H [data]
0207q(E1000005): BEQ 5 [020DH]
0208r .FIXUP D
0208r(8D000003): LDR SB, MT, MOD0 [SCC]
0209r(90D0001D): LDR R0, SB, 1DH [data]
020Ar(91D00015): LDR R1, SB, 15H
020Br(00090001): SUB R0, R0, R1
020Cs(E9000018): BNE 24 [0225H]
WHILE (n > 0)t & Rcvdu(Wait)v DOw
020Dt(80E00010): LDR R0, SP, 10H
020Et(40090000): SUB R0, R0, 0H
020Fu(E600000D): BLE 13 [021DH]
0210v(40000032): MOV R0, R0, 32H
0211w(F7FFFFA8): BL -88 [01BAH]
0212w(40090000): SUB R0, R0, 0H
0213w(E1000009): BEQ 9 [021DH]
INC(adr, SubPacket);x SubRcv(adr)y;z DEC(n)
0214x(80E0000C): LDR R0, SP, CH
0215x(40080020): ADD R0, R0, 20H
0216x(A0E0000C): STR R0, SP, CH
0217y(80E0000C): LDR R0, SP, CH
0218z(F7FFFE1F): BL -481 [0038H]
ENDa;
0219a(80E00010): LDR R0, SP, 10H
021Aa(40090001): SUB R0, R0, 1H
021Ba(A0E00010): STR R0, SP, 10H
021Ca(E7FFFFF0): B -16 [020DH]
rx.hd.valid := (n = 0)b
021Db(80E00010): LDR R0, SP, 10H
ELSEc WHILEd Rcvd(Wait)e DOf SubRcv(adr)g ENDh; ResetRcv (*discard packet*)
021Ec(E9000002): BNE 2 [0221H]
021Fc(40000001): MOV R0, R0, 1H
0220c(E7000001): B 1 [0222H]
0221c(40000000): MOV R0, R0, 0H
0222c .FIXUP D
0222c(8D00001A): LDR SB, MT, MOD0 [SCC]
0223c(B0D0001C): STR R0, SB, 1CH [data]
0224d(E7000008): B 8 [022DH]
0225e(40000032): MOV R0, R0, 32H
0226f(F7FFFF93): BL -109 [01BAH]
0227f(40090000): SUB R0, R0, 0H
0228f(E1000003): BEQ 3 [022CH]
0229g(80E0000C): LDR R0, SP, CH
022Ah(F7FFFE0D): BL -499 [0038H]
022Bh(E7FFFFF9): B -7 [0225H]
ENDi;
022Ci(F7FFFE92): BL -366 [00BFH]
head := rx.hd
ENDj
022Dj(80E00004): LDR R0, SP, 4H
022Ej .FIXUP D
022Ej(8D00000C): LDR SB, MT, MOD0 [SCC]
022Fj(41D8001C): ADD R1, SB, 1CH [data]
0230j(42000002): MOV R2, R0, 2H
0231j(83100000): LDR R3, R1, 0H
0232j(41180004): ADD R1, R1, 4H
0233j(A3000000): STR R3, R0, 0H
0234j(40080004): ADD R0, R0, 4H
0235j(42290001): SUB R2, R2, 1H
0236j(E9FFFFFA): BNE -6 [0231H]
ENDk ReceiveHead;
0237k(8FE00000): LDR LNK, SP, 0H
0238k(4EE80014): ADD SP, SP, 14H
0239k(C700000F): B LNK
PROCEDURE Skip*(m: INTEGER);
VAR dmy: BYTE;
BEGINl WHILE m # 0 DOm Receive(dmy)n;o DEC(m) ENDp
023Al .PROC 9
023Al(4EE9000C): SUB SP, SP, CH
023Bl(AFE00000): STR LNK, SP, 0H
023Cl(A0E00004): STR R0, SP, 4H
023Dm(80E00004): LDR R0, SP, 4H
023Em(E1000006): BEQ 6 [0245H]
023Fn(40E80008): ADD R0, SP, 8H
0240o(F7FFFF5E): BL -162 [019FH]
0241p(80E00004): LDR R0, SP, 4H
0242p(40090001): SUB R0, R0, 1H
0243p(A0E00004): STR R0, SP, 4H
0244p(E7FFFFF8): B -8 [023DH]
ENDq Skip;
0245q(8FE00000): LDR LNK, SP, 0H
0246q(4EE8000C): ADD SP, SP, CH
0247q(C700000F): B LNK
PROCEDURE Stop*;
BEGINr SPICtrl({})s;t Flush();u ResetRcv
0248r .PROC 10
0248r .COMMAND Stop
0248r(4EE90004): SUB SP, SP, 4H
0249r(AFE00000): STR LNK, SP, 0H
024As(40000000): MOV R0, R0, 0H
024Bt(F7FFFDB4): BL -588 [0000H]
024Cu(F7FFFE65): BL -411 [00B2H]
ENDv Stop;
024Dv(F7FFFE71): BL -399 [00BFH]
024Ev(8FE00000): LDR LNK, SP, 0H
024Fv(4EE80004): ADD SP, SP, 4H
0250v(C700000F): B LNK
BEGINw Start(TRUE)x
0251w .PROC 0
0251w .ENTRYPOINT
0251w(4EE90004): SUB SP, SP, 4H
0252w(AFE00000): STR LNK, SP, 0H
0253x(40000001): MOV R0, R0, 1H
ENDy SCC.z
0254y(F7FFFE89): BL -375 [00DEH]
0255z(8FE00000): LDR LNK, SP, 0H
0256z(4EE80004): ADD SP, SP, 4H
0257z(C700000F): B LNK