| 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 |
0000 | a .PROC 1 |
0000 | a(4EE90008): SUB SP, SP, 8H |
0001 | a(AFE00000): STR LNK, SP, 0H |
0002 | a(A0E00004): STR R0, SP, 4H |
0003 | b(5000FFD4): MOV R0, R0, FFFFFFD4H |
0004 | b(81E00004): LDR R1, SP, 4H |
0005 | b .PROC 2 |
0005 | b(A1000000): STR R1, R0, 0H |
| IF netEnable IN s THENc LED(55H) ELSEd LEDe(0) ENDf |
0006 | c(80E00004): LDR R0, SP, 4H |
0007 | c(40030004): ROR R0, R0, 4H |
0008 | c(E8000004): BPL 4 [000DH] |
0009 | d(40000055): MOV R0, R0, 55H |
000A | d(5100FFC4): MOV R1, R0, FFFFFFC4H |
000B | d(A0100000): STR R0, R1, 0H |
000C | e(E7000003): B 3 [0010H] |
000D | f(40000000): MOV R0, R0, 0H |
000E | f(5100FFC4): MOV R1, R0, FFFFFFC4H |
000F | f(A0100000): STR R0, R1, 0H |
| ENDg SPICtrl; |
0010 | g(8FE00000): LDR LNK, SP, 0H |
0011 | g(4EE80008): ADD SP, SP, 8H |
0012 | g(C700000F): B LNK |
| |
| PROCEDURE SPI(n: INTEGER); |
| BEGINh (*send (& rcv into shift reg) one byte or word, at current speed*) |
0013 | h(4EE90008): SUB SP, SP, 8H |
0014 | h(AFE00000): STR LNK, SP, 0H |
0015 | h(A0E00004): STR R0, SP, 4H |
| SYSTEM.PUT(spiData, n);i REPEAT UNTIL SYSTEM.BIT(spiCtrl, 0) (*wait until done*) |
0016 | i(5000FFD0): MOV R0, R0, FFFFFFD0H |
0017 | i(81E00004): LDR R1, SP, 4H |
0018 | i(A1000000): STR R1, R0, 0H |
| ENDj SPI; |
0019 | j(5000FFD4): MOV R0, R0, FFFFFFD4H |
001A | j(80000000): LDR R0, R0, 0H |
001B | j(40030001): ROR R0, R0, 1H |
001C | j(E8FFFFFC): BPL -4 [0019H] |
001D | j(8FE00000): LDR LNK, SP, 0H |
001E | j(4EE80008): ADD SP, SP, 8H |
001F | j(C700000F): B LNK |
| |
| PROCEDURE StartCmd(cmd: INTEGER); |
| BEGINk SPICtrl({netSelect})l;m SPI(cmd)n |
0020 | k(4EE90008): SUB SP, SP, 8H |
0021 | k(AFE00000): STR LNK, SP, 0H |
0022 | k(A0E00004): STR R0, SP, 4H |
0023 | l(40000002): MOV R0, R0, 2H |
0024 | m(F7FFFFDB): BL -37 [0000H] |
0025 | n(80E00004): LDR R0, SP, 4H |
| ENDo StartCmd; |
0026 | o(F7FFFFEC): BL -20 [0013H] |
0027 | o(8FE00000): LDR LNK, SP, 0H |
0028 | o(4EE80008): ADD SP, SP, 8H |
0029 | o(C700000F): B LNK |
| |
| PROCEDURE WriteReg1(reg, dat: INTEGER); (*disables radio!*) |
| BEGINp StartCmd(reg + 20H)q;r SPI(dat)s;t SPICtrl({})u (*W_REGISTER*) |
002A | p(4EE9000C): SUB SP, SP, CH |
002B | p(AFE00000): STR LNK, SP, 0H |
002C | p(A0E00004): STR R0, SP, 4H |
002D | p(A1E00008): STR R1, SP, 8H |
002E | q(80E00004): LDR R0, SP, 4H |
002F | q(40080020): ADD R0, R0, 20H |
0030 | r(F7FFFFEF): BL -17 [0020H] |
0031 | s(80E00008): LDR R0, SP, 8H |
0032 | t(F7FFFFE0): BL -32 [0013H] |
0033 | u(40000000): MOV R0, R0, 0H |
| ENDv WriteReg1; |
0034 | v(F7FFFFCB): BL -53 [0000H] |
0035 | v(8FE00000): LDR LNK, SP, 0H |
0036 | v(4EE8000C): ADD SP, SP, CH |
0037 | v(C700000F): B LNK |
| |
| PROCEDURE SubRcv(dst: INTEGER); |
| VAR i, dat: INTEGER; |
| BEGINw |
0038 | w(4EE90010): SUB SP, SP, 10H |
0039 | w(AFE00000): STR LNK, SP, 0H |
003A | w(A0E00004): STR R0, SP, 4H |
| StartCmd(061H)x;y (*R_RX_PAYLOAD, disables radio*) |
003B | x(40000061): MOV R0, R0, 61H |
003C | y(F7FFFFE3): BL -29 [0020H] |
| SPICtrl({netSelect, spiFast})z;a |
003D | z(40000006): MOV R0, R0, 6H |
003E | a(F7FFFFC1): BL -63 [0000H] |
| FOR i := 0 TOb SubPacket-4 BY 4 DO |
003F | b(40000000): MOV R0, R0, 0H |
| SPIc(-1)d;e SYSTEM.GET(spiData, dat);f SYSTEM.PUT(dst+i,g dat) |
0040 | c(4109001C): SUB R1, R0, 1CH |
0041 | c(EE00000E): BGT 14 [0050H] |
0042 | c(A0E00008): STR R0, SP, 8H |
0043 | d(5000FFFF): MOV R0, R0, FFFFFFFFH |
0044 | e(F7FFFFCE): BL -50 [0013H] |
0045 | f(5000FFD0): MOV R0, R0, FFFFFFD0H |
0046 | f(80000000): LDR R0, R0, 0H |
0047 | f(A0E0000C): STR R0, SP, CH |
0048 | g(80E00004): LDR R0, SP, 4H |
0049 | g(81E00008): LDR R1, SP, 8H |
004A | g(00080001): ADD R0, R0, R1 |
| ENDh;i |
004B | h(81E0000C): LDR R1, SP, CH |
004C | h(A1000000): STR R1, R0, 0H |
004D | i(80E00008): LDR R0, SP, 8H |
004E | i(40080004): ADD R0, R0, 4H |
004F | i(E7FFFFF0): B -16 [0040H] |
| SPICtrl({})j;k WriteReg1(7,l 40H)m;n (*done; STATUS <= clear RX_DR*) |
0050 | j(40000000): MOV R0, R0, 0H |
0051 | k(F7FFFFAE): BL -82 [0000H] |
0052 | l(40000007): MOV R0, R0, 7H |
0053 | m(41000040): MOV R1, R0, 40H |
0054 | n(F7FFFFD5): BL -43 [002AH] |
| SPICtrl({netEnable})o (*enable radio*) |
0055 | o(40000008): MOV R0, R0, 8H |
| ENDp SubRcv; |
0056 | p(F7FFFFA9): BL -87 [0000H] |
0057 | p(8FE00000): LDR LNK, SP, 0H |
0058 | p(4EE80010): ADD SP, SP, 10H |
0059 | p(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*) |
005A | q(4EE90024): SUB SP, SP, 24H |
005B | q(AFE00000): STR LNK, SP, 0H |
005C | q(A0E00004): STR R0, SP, 4H |
005D | q(A1E00008): STR R1, SP, 8H |
| StartCmd(0A0H)r;s (*W_TX_PAYLOAD*) |
005E | r(400000A0): MOV R0, R0, A0H |
005F | s(F7FFFFC0): BL -64 [0020H] |
| SPICtrl({netSelect, spiFast})t;u |
0060 | t(40000006): MOV R0, R0, 6H |
0061 | u(F7FFFF9E): BL -98 [0000H] |
| FOR i := 0 TOv SubPacket-4 BY 4 DO |
0062 | v(40000000): MOV R0, R0, 0H |
| SYSTEMw.GET(src+i,x dat);y SPI(dat)z |
0063 | w(4109001C): SUB R1, R0, 1CH |
0064 | w(EE00000B): BGT 11 [0070H] |
0065 | w(A0E0000C): STR R0, SP, CH |
0066 | x(80E00004): LDR R0, SP, 4H |
0067 | x(81E0000C): LDR R1, SP, CH |
0068 | x(00080001): ADD R0, R0, R1 |
0069 | y(80000000): LDR R0, R0, 0H |
006A | y(A0E00010): STR R0, SP, 10H |
006B | z(80E00010): LDR R0, SP, 10H |
| ENDa;b |
006C | a(F7FFFFA6): BL -90 [0013H] |
006D | b(80E0000C): LDR R0, SP, CH |
006E | b(40080004): ADD R0, R0, 4H |
006F | b(E7FFFFF3): B -13 [0063H] |
| SPICtrl({})c;d (*end W_TX_PAYLOAD command*) |
0070 | c(40000000): MOV R0, R0, 0H |
0071 | d(F7FFFF8E): BL -114 [0000H] |
| try := 0;e |
0072 | e(40000000): MOV R0, R0, 0H |
0073 | e(A0E0001C): STR R0, SP, 1CH |
| SPICtrl({netEnable, netSelect})f;g (*start xmit pulse, start NOP cmd*) |
0074 | f(4000000A): MOV R0, R0, AH |
0075 | g(F7FFFF8A): BL -118 [0000H] |
| REPEAT |
| t1 := Kernel.Time() +h Wait;i |
0076 | h .FIXUP P |
0076 | h(F7111076): BL MOD1 [Kernel] PROC17 |
0077 | i(40080032): ADD R0, R0, 32H |
0078 | i(A0E00018): STR R0, SP, 18H |
| REPEAT (*wait for sent or retransmits exceeded*); |
| SPI(0FFH)j;k SYSTEM.GET(spiData, status);l (*NOP*) |
0079 | j(400000FF): MOV R0, R0, FFH |
007A | k(F7FFFF98): BL -104 [0013H] |
007B | l(5000FFD0): MOV R0, R0, FFFFFFD0H |
007C | l(90000000): LDR R0, R0, 0H |
007D | l(B0E00021): STR R0, SP, 21H |
| res := status DIV 10H MODm 4;n |
007E | m(90E00021): LDR R0, SP, 21H |
007F | m(40020004): ASR R0, R0, 4H |
0080 | n(40040003): AND R0, R0, 3H |
0081 | n(A0E00014): STR R0, SP, 14H |
| SPICtrl({})o;p SPICtrl({netSelect})q (*end & restart NOP cmd, end =10us pulse on enable*) |
0082 | o(40000000): MOV R0, R0, 0H |
0083 | p(F7FFFF7C): BL -132 [0000H] |
0084 | q(40000002): MOV R0, R0, 2H |
| UNTILr res # 0;s |
0085 | r(F7FFFF7A): BL -134 [0000H] |
0086 | s(80E00014): LDR R0, SP, 14H |
0087 | s(E1FFFFF1): BEQ -15 [0079H] |
| IF res = 2 THENt WriteReg1(7,u 20H)v (*TX_DS: sent, ack received; reset it*) |
0088 | t(80E00014): LDR R0, SP, 14H |
0089 | t(40090002): SUB R0, R0, 2H |
008A | t(E9000004): BNE 4 [008FH] |
008B | u(40000007): MOV R0, R0, 7H |
008C | v(41000020): MOV R1, R0, 20H |
| ELSIFw resx = 1 THENy WriteReg1(7,z 10H)a;b INC(try);c (*MAX_RT: retransmits exceeded; reset it*) |
008D | w(F7FFFF9C): BL -100 [002AH] |
008E | x(E7000015): B 21 [00A4H] |
008F | y(80E00014): LDR R0, SP, 14H |
0090 | y(40090001): SUB R0, R0, 1H |
0091 | y(E9000012): BNE 18 [00A4H] |
0092 | z(40000007): MOV R0, R0, 7H |
0093 | a(41000010): MOV R1, R0, 10H |
0094 | b(F7FFFF95): BL -107 [002AH] |
0095 | c(80E0001C): LDR R0, SP, 1CH |
0096 | c(40080001): ADD R0, R0, 1H |
0097 | c(A0E0001C): STR R0, SP, 1CH |
| IF try = SendTries THENd res := 0 |
0098 | d(80E0001C): LDR R0, SP, 1CH |
0099 | d(40090032): SUB R0, R0, 32H |
009A | d(E9000003): BNE 3 [009EH] |
| ELSEe REPEATf UNTIL Kernel.Time() >=g t1;h |
009B | e(40000000): MOV R0, R0, 0H |
009C | e(A0E00014): STR R0, SP, 14H |
009D | f(E7000006): B 6 [00A4H] |
009E | g .FIXUP P |
009E | g(F7111028): BL MOD1 [Kernel] PROC17 |
009F | h(81E00018): LDR R1, SP, 18H |
00A0 | h(00090001): SUB R0, R0, R1 |
00A1 | h(E5FFFFFC): BLT -4 [009EH] |
| SPICtrl({netEnable, netSelect})i;j (*start xmit pulse, start NOP cmd again*) |
00A2 | i(4000000A): MOV R0, R0, AH |
00A3 | j(F7FFFF5C): BL -164 [0000H] |
| END |
| END |
| UNTIL res # 1;k |
00A4 | k(80E00014): LDR R0, SP, 14H |
00A5 | k(40090001): SUB R0, R0, 1H |
00A6 | k(E1FFFFCF): BEQ -49 [0076H] |
| timeout := (res # 2)l |
00A7 | l(80E00014): LDR R0, SP, 14H |
00A8 | l(40090002): SUB R0, R0, 2H |
| ENDm SubSnd; |
00A9 | m(E1000002): BEQ 2 [00ACH] |
00AA | m(40000001): MOV R0, R0, 1H |
00AB | m(E7000001): B 1 [00ADH] |
00AC | m(40000000): MOV R0, R0, 0H |
00AD | m(81E00008): LDR R1, SP, 8H |
00AE | m(B0100000): STR R0, R1, 0H |
00AF | m(8FE00000): LDR LNK, SP, 0H |
00B0 | m(4EE80024): ADD SP, SP, 24H |
00B1 | m(C700000F): B LNK |
| |
| PROCEDURE Flush(); |
| BEGINn StartCmd(0E1H)o;p SPICtrl({})q;r StartCmd(0E2H)s;t SPICtrl({})u |
00B2 | n(4EE90004): SUB SP, SP, 4H |
00B3 | n(AFE00000): STR LNK, SP, 0H |
00B4 | o(400000E1): MOV R0, R0, E1H |
00B5 | p(F7FFFF6A): BL -150 [0020H] |
00B6 | q(40000000): MOV R0, R0, 0H |
00B7 | r(F7FFFF48): BL -184 [0000H] |
00B8 | s(400000E2): MOV R0, R0, E2H |
00B9 | t(F7FFFF66): BL -154 [0020H] |
00BA | u(40000000): MOV R0, R0, 0H |
| (*FLUSH_TX, FLUSH_RX*) |
| ENDv Flush; |
00BB | v(F7FFFF44): BL -188 [0000H] |
00BC | v(8FE00000): LDR LNK, SP, 0H |
00BD | v(4EE80004): ADD SP, SP, 4H |
00BE | v(C700000F): B LNK |
| |
| PROCEDURE ResetRcv; |
| BEGINw SYSTEM.PUT(SYSTEM.ADR(rx),x 0);y rx.hd.len := 0;z rcvd := 0 |
00BF | w(4EE90004): SUB SP, SP, 4H |
00C0 | w(AFE00000): STR LNK, SP, 0H |
00C1 | x .FIXUP D |
00C1 | x(8D0000C1): LDR SB, MT, MOD0 [SCC] |
00C2 | x(40D8001C): ADD R0, SB, 1CH [data] |
00C3 | y(41000000): MOV R1, R0, 0H |
00C4 | y(A1000000): STR R1, R0, 0H |
00C5 | z(40000000): MOV R0, R0, 0H |
00C6 | z(A0D00020): STR R0, SB, 20H |
| ENDa ResetRcv; |
00C7 | a(40000000): MOV R0, R0, 0H |
00C8 | a(A0D00018): STR R0, SB, 18H |
00C9 | a(8FE00000): LDR LNK, SP, 0H |
00CA | a(4EE80004): ADD SP, SP, 4H |
00CB | a(C700000F): B LNK |
| |
| PROCEDURE Listen(b: BOOLEAN); |
| BEGINb |
00CC | b(4EE90008): SUB SP, SP, 8H |
00CD | b(AFE00000): STR LNK, SP, 0H |
00CE | b(A0E00004): STR R0, SP, 4H |
| WriteReg1(0,c 07EH + ORD(b))d;e (*CONFIG <= mask ints; EN_CRC(2 byte), PWR_UP, PRX/PTX*) |
00CF | c(40000000): MOV R0, R0, 0H |
00D0 | d(91E00004): LDR R1, SP, 4H |
00D1 | d(4200007E): MOV R2, R0, 7EH |
00D2 | d(01280001): ADD R1, R2, R1 |
00D3 | e(F7FFFF56): BL -170 [002AH] |
| WriteReg1(7,f 70H)g;h (*STATUS <= clear ints*) |
00D4 | f(40000007): MOV R0, R0, 7H |
00D5 | g(41000070): MOV R1, R0, 70H |
00D6 | h(F7FFFF53): BL -173 [002AH] |
| IF b THENi SPICtrl({netEnable})j ENDk (*turn radio on*) |
00D7 | i(90E00004): LDR R0, SP, 4H |
00D8 | i(E1000002): BEQ 2 [00DBH] |
00D9 | j(40000008): MOV R0, R0, 8H |
00DA | k(F7FFFF25): BL -219 [0000H] |
| ENDl Listen; |
00DB | l(8FE00000): LDR LNK, SP, 0H |
00DC | l(4EE80008): ADD SP, SP, 8H |
00DD | l(C700000F): B LNK |
| |
| PROCEDURE Start*(filt: BOOLEAN); |
| VAR n: INTEGER; |
| BEGINm filter := filt;n Adr := 0;o |
00DE | m .PROC 4 |
00DE | m(4EE9000C): SUB SP, SP, CH |
00DF | m(AFE00000): STR LNK, SP, 0H |
00E0 | m(A0E00004): STR R0, SP, 4H |
00E1 | n(90E00004): LDR R0, SP, 4H |
00E2 | n .FIXUP D |
00E2 | n(8D000021): LDR SB, MT, MOD0 [SCC] |
00E3 | n(B0D00014): STR R0, SB, 14H [data] |
00E4 | o(40000000): MOV R0, R0, 0H |
00E5 | o(B0D00015): STR R0, SB, 15H |
| SYSTEM.GET(swi, n);p n := n DIV 4 MODq 10H *r 10 +s 5;t |
00E6 | p(5000FFC4): MOV R0, R0, FFFFFFC4H |
00E7 | p(80000000): LDR R0, R0, 0H |
00E8 | p(A0E00008): STR R0, SP, 8H |
00E9 | q(80E00008): LDR R0, SP, 8H |
00EA | q(40020002): ASR R0, R0, 2H |
00EB | r(4004000F): AND R0, R0, FH |
00EC | s(400A000A): MUL R0, R0, AH |
00ED | t(40080005): ADD R0, R0, 5H |
00EE | t(A0E00008): STR R0, SP, 8H |
| WriteReg1(5,u n)v;w (*RF_CH <= channel: 5, 15, 25...*) |
00EF | u(40000005): MOV R0, R0, 5H |
00F0 | v(81E00008): LDR R1, SP, 8H |
00F1 | w(F7FFFF38): BL -200 [002AH] |
| WriteReg1(6,x 07H)y;z (*RF_SETUP <= 1Mb for better range, 0dBm*) |
00F2 | x(40000006): MOV R0, R0, 6H |
00F3 | y(41000007): MOV R1, R0, 7H |
00F4 | z(F7FFFF35): BL -203 [002AH] |
| WriteReg1(11H,a SubPacket)b;c (*RX_PW_P0 <= pipe 0 payload width*) |
00F5 | a(40000011): MOV R0, R0, 11H |
00F6 | b(41000020): MOV R1, R0, 20H |
00F7 | c(F7FFFF32): BL -206 [002AH] |
| Flush();d Listen(TRUE)e;f ResetRcv |
00F8 | d(F7FFFFB9): BL -71 [00B2H] |
00F9 | e(40000001): MOV R0, R0, 1H |
00FA | f(F7FFFFD1): BL -47 [00CCH] |
| ENDg Start; |
00FB | g(F7FFFFC3): BL -61 [00BFH] |
00FC | g(8FE00000): LDR LNK, SP, 0H |
00FD | g(4EE8000C): ADD SP, SP, CH |
00FE | g(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*) |
00FF | h .PROC 5 |
00FF | h(4EE90044): SUB SP, SP, 44H |
0100 | h(AFE00000): STR LNK, SP, 0H |
0101 | h(A0E00004): STR R0, SP, 4H |
0102 | h(A1E00008): STR R1, SP, 8H |
0103 | h(A2E0000C): STR R2, SP, CH |
0104 | h(A3E00010): STR R3, SP, 10H |
| i := Kernel.Time() +i Wait;j |
0105 | i .FIXUP P |
0105 | i(F7111067): BL MOD1 [Kernel] PROC17 |
0106 | j(40080032): ADD R0, R0, 32H |
0107 | j(A0E00018): STR R0, SP, 18H |
| REPEAT SPICtrl({netEnable, netSelect})k;l SPI(0FFH)m;n SPICtrl({netEnable})o (*NOP*) |
0108 | k(4000000A): MOV R0, R0, AH |
0109 | l(F7FFFEF6): BL -266 [0000H] |
010A | m(400000FF): MOV R0, R0, FFH |
010B | n(F7FFFF07): BL -249 [0013H] |
010C | o(40000008): MOV R0, R0, 8H |
| UNTILp Kernel.Time() >=q i;r |
010D | p(F7FFFEF2): BL -270 [0000H] |
010E | q .FIXUP P |
010E | q(F7111009): BL MOD1 [Kernel] PROC17 |
010F | r(81E00018): LDR R1, SP, 18H |
0110 | r(00090001): SUB R0, R0, R1 |
0111 | r(E5FFFFF6): BLT -10 [0108H] |
| IF Adr = 0 THENs Adr := i MOD 100H ENDt; |
0112 | s .FIXUP D |
0112 | s(8D000030): LDR SB, MT, MOD0 [SCC] |
0113 | s(90D00015): LDR R0, SB, 15H [data] |
0114 | s(E9000004): BNE 4 [0119H] |
0115 | t(80E00018): LDR R0, SP, 18H |
0116 | t(400400FF): AND R0, R0, FFH |
0117 | t .FIXUP D |
0117 | t(8D000005): LDR SB, MT, MOD0 [SCC] |
0118 | t(B0D00015): STR R0, SB, 15H [data] |
| Listen(FALSE)u;v |
0119 | u(40000000): MOV R0, R0, 0H |
011A | v(F7FFFFB1): BL -79 [00CCH] |
| head.sadr := Adr;w head.valid := TRUE;x |
011B | w .FIXUP D |
011B | w(8D000004): LDR SB, MT, MOD0 [SCC] |
011C | w(90D00015): LDR R0, SB, 15H [data] |
011D | w(81E00004): LDR R1, SP, 4H |
011E | w(B0100002): STR R0, R1, 2H |
011F | x(40000001): MOV R0, R0, 1H |
0120 | x(81E00004): LDR R1, SP, 4H |
0121 | x(B0100000): STR R0, R1, 0H |
| SYSTEM.COPY(SYSTEM.ADR(head),y SYSTEM.ADR(payload),z HdrSize DIV 4);a |
0122 | y(80E00004): LDR R0, SP, 4H |
0123 | z(41E80024): ADD R1, SP, 24H |
0124 | a(42000002): MOV R2, R0, 2H |
0125 | a(83000000): LDR R3, R0, 0H |
0126 | a(40080004): ADD R0, R0, 4H |
0127 | a(A3100000): STR R3, R1, 0H |
0128 | a(41180004): ADD R1, R1, 4H |
0129 | a(42290001): SUB R2, R2, 1H |
012A | a(E9FFFFFA): BNE -6 [0125H] |
| i := HdrSize;b off := 0;c len := head.len;d |
012B | b(40000008): MOV R0, R0, 8H |
012C | b(A0E00018): STR R0, SP, 18H |
012D | c(40000000): MOV R0, R0, 0H |
012E | c(A0E0001C): STR R0, SP, 1CH |
012F | d(80E00004): LDR R0, SP, 4H |
0130 | d(80000004): LDR R0, R0, 4H |
0131 | d(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; |
0132 | e(80E00014): LDR R0, SP, 14H |
0133 | e(40090000): SUB R0, R0, 0H |
0134 | f(E6000019): BLE 25 [014EH] |
0135 | g(80E00018): LDR R0, SP, 18H |
0136 | g(40090020): SUB R0, R0, 20H |
0137 | h(ED000016): BGE 22 [014EH] |
0138 | i(80E00018): LDR R0, SP, 18H |
0139 | i(41090020): SUB R1, R0, 20H |
013A | i(DA10B01C): BLCC MT [trap=1, pos=4272] |
013B | i(00E80000): ADD R0, SP, R0 |
013C | j(81E0001C): LDR R1, SP, 1CH |
013D | j(82E00010): LDR R2, SP, 10H |
013E | j(02190002): SUB R2, R1, R2 |
013F | j(DA10BC1C): BLCC MT [trap=1, pos=4284] |
0140 | j(82E0000C): LDR R2, SP, CH |
0141 | j(01280001): ADD R1, R2, R1 |
0142 | k(91100000): LDR R1, R1, 0H |
0143 | k(B1000024): STR R1, R0, 24H |
0144 | l(80E00018): LDR R0, SP, 18H |
0145 | l(40080001): ADD R0, R0, 1H |
0146 | l(A0E00018): STR R0, SP, 18H |
0147 | m(80E0001C): LDR R0, SP, 1CH |
0148 | m(40080001): ADD R0, R0, 1H |
0149 | m(A0E0001C): STR R0, SP, 1CH |
014A | n(80E00014): LDR R0, SP, 14H |
014B | n(40090001): SUB R0, R0, 1H |
014C | n(A0E00014): STR R0, SP, 14H |
014D | n(E7FFFFE4): B -28 [0132H] |
| WHILE i < SubPacket DOo payload[i]p := 0;q INC(i) ENDr; |
014E | o(80E00018): LDR R0, SP, 18H |
014F | o(40090020): SUB R0, R0, 20H |
0150 | o(ED00000A): BGE 10 [015BH] |
0151 | p(80E00018): LDR R0, SP, 18H |
0152 | p(41090020): SUB R1, R0, 20H |
0153 | p(DA11031C): BLCC MT [trap=1, pos=4355] |
0154 | p(00E80000): ADD R0, SP, R0 |
0155 | q(41000000): MOV R1, R0, 0H |
0156 | q(B1000024): STR R1, R0, 24H |
0157 | r(80E00018): LDR R0, SP, 18H |
0158 | r(40080001): ADD R0, R0, 1H |
0159 | r(A0E00018): STR R0, SP, 18H |
015A | r(E7FFFFF3): B -13 [014EH] |
| SubSnd(SYSTEM.ADR(payload),s timeout)t;u |
015B | s(40E80024): ADD R0, SP, 24H |
015C | t(41E80020): ADD R1, SP, 20H |
015D | u(F7FFFEFC): BL -260 [005AH] |
| WHILE ~timeout &v (wlen # 0)x DOy i := 0;z (*send the rest*) |
015E | v(90E00020): LDR R0, SP, 20H |
015F | w(E9000031): BNE 49 [0191H] |
0160 | x(80E00014): LDR R0, SP, 14H |
0161 | y(E100002F): BEQ 47 [0191H] |
0162 | z(40000000): MOV R0, R0, 0H |
0163 | z(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; |
0164 | a(80E00014): LDR R0, SP, 14H |
0165 | a(40090000): SUB R0, R0, 0H |
0166 | b(E6000019): BLE 25 [0180H] |
0167 | c(80E00018): LDR R0, SP, 18H |
0168 | c(40090020): SUB R0, R0, 20H |
0169 | d(ED000016): BGE 22 [0180H] |
016A | e(80E00018): LDR R0, SP, 18H |
016B | e(41090020): SUB R1, R0, 20H |
016C | e(DA11B11C): BLCC MT [trap=1, pos=4529] |
016D | e(00E80000): ADD R0, SP, R0 |
016E | f(81E0001C): LDR R1, SP, 1CH |
016F | f(82E00010): LDR R2, SP, 10H |
0170 | f(02190002): SUB R2, R1, R2 |
0171 | f(DA11BD1C): BLCC MT [trap=1, pos=4541] |
0172 | f(82E0000C): LDR R2, SP, CH |
0173 | f(01280001): ADD R1, R2, R1 |
0174 | g(91100000): LDR R1, R1, 0H |
0175 | g(B1000024): STR R1, R0, 24H |
0176 | h(80E00018): LDR R0, SP, 18H |
0177 | h(40080001): ADD R0, R0, 1H |
0178 | h(A0E00018): STR R0, SP, 18H |
0179 | i(80E0001C): LDR R0, SP, 1CH |
017A | i(40080001): ADD R0, R0, 1H |
017B | i(A0E0001C): STR R0, SP, 1CH |
017C | j(80E00014): LDR R0, SP, 14H |
017D | j(40090001): SUB R0, R0, 1H |
017E | j(A0E00014): STR R0, SP, 14H |
017F | j(E7FFFFE4): B -28 [0164H] |
| WHILE i < SubPacket DOk payload[i]l := 0;m INC(i) ENDn; |
0180 | k(80E00018): LDR R0, SP, 18H |
0181 | k(40090020): SUB R0, R0, 20H |
0182 | k(ED00000A): BGE 10 [018DH] |
0183 | l(80E00018): LDR R0, SP, 18H |
0184 | l(41090020): SUB R1, R0, 20H |
0185 | l(DA12061C): BLCC MT [trap=1, pos=4614] |
0186 | l(00E80000): ADD R0, SP, R0 |
0187 | m(41000000): MOV R1, R0, 0H |
0188 | m(B1000024): STR R1, R0, 24H |
0189 | n(80E00018): LDR R0, SP, 18H |
018A | n(40080001): ADD R0, R0, 1H |
018B | n(A0E00018): STR R0, SP, 18H |
018C | n(E7FFFFF3): B -13 [0180H] |
| SubSnd(SYSTEM.ADR(payload),o timeout)p |
018D | o(40E80024): ADD R0, SP, 24H |
018E | p(41E80020): ADD R1, SP, 20H |
| ENDq; |
018F | q(F7FFFECA): BL -310 [005AH] |
0190 | q(E7FFFFCD): B -51 [015EH] |
| Listen(TRUE)r |
0191 | r(40000001): MOV R0, R0, 1H |
| ENDs SendPacket; |
0192 | s(F7FFFF39): BL -199 [00CCH] |
0193 | s(8FE00000): LDR LNK, SP, 0H |
0194 | s(4EE80044): ADD SP, SP, 44H |
0195 | s(C700000F): B LNK |
| |
| PROCEDURE Available*(): INTEGER; |
| BEGINt (*packet already rcvd*) |
0196 | t .PROC 6 |
0196 | t(4EE90004): SUB SP, SP, 4H |
0197 | t(AFE00000): STR LNK, SP, 0H |
| RETURN rx.hd.len - rcvd |
| ENDu Available; |
0198 | u .FIXUP D |
0198 | u(8D00007D): LDR SB, MT, MOD0 [SCC] |
0199 | u(80D00020): LDR R0, SB, 20H [data] |
019A | u(81D00018): LDR R1, SB, 18H |
019B | u(00090001): SUB R0, R0, R1 |
019C | u(8FE00000): LDR LNK, SP, 0H |
019D | u(4EE80004): ADD SP, SP, 4H |
019E | u(C700000F): B LNK |
| |
| PROCEDURE Receive*(VAR x: BYTE); |
| BEGINv (*packet already rcvd*) |
019F | v .PROC 7 |
019F | v(4EE90008): SUB SP, SP, 8H |
01A0 | v(AFE00000): STR LNK, SP, 0H |
01A1 | v(A0E00004): STR R0, SP, 4H |
| IF rcvd < rx.hd.len THENw x := rx.dat[rcvd]x;y INC(rcvd) ELSEz xa := 0 ENDb |
01A2 | w .FIXUP D |
01A2 | w(8D00000A): LDR SB, MT, MOD0 [SCC] |
01A3 | w(80D00018): LDR R0, SB, 18H [data] |
01A4 | w(81D00020): LDR R1, SB, 20H |
01A5 | w(00090001): SUB R0, R0, R1 |
01A6 | w(ED00000D): BGE 13 [01B4H] |
01A7 | x .FIXUP D |
01A7 | x(8D000005): LDR SB, MT, MOD0 [SCC] |
01A8 | x(80D00018): LDR R0, SB, 18H [data] |
01A9 | x(41090218): SUB R1, R0, 218H |
01AA | x(DA13531C): BLCC MT [trap=1, pos=4947] |
01AB | x(00D80000): ADD R0, SB, R0 |
01AC | y(90000024): LDR R0, R0, 24H |
01AD | y(81E00004): LDR R1, SP, 4H |
01AE | y(B0100000): STR R0, R1, 0H |
01AF | z(40D80018): ADD R0, SB, 18H |
01B0 | z(81000000): LDR R1, R0, 0H |
01B1 | z(41180001): ADD R1, R1, 1H |
01B2 | z(A1000000): STR R1, R0, 0H |
01B3 | a(E7000003): B 3 [01B7H] |
01B4 | b(40000000): MOV R0, R0, 0H |
01B5 | b(81E00004): LDR R1, SP, 4H |
01B6 | b(B0100000): STR R0, R1, 0H |
| ENDc Receive; |
01B7 | c(8FE00000): LDR LNK, SP, 0H |
01B8 | c(4EE80008): ADD SP, SP, 8H |
01B9 | c(C700000F): B LNK |
| |
| PROCEDURE Rcvd(time: INTEGER): BOOLEAN; |
| VAR status, fifoStatus: BYTE; rcvd: BOOLEAN; |
| BEGINd time := time + Kernel.Time();e |
01BA | d(4EE9000C): SUB SP, SP, CH |
01BB | d(AFE00000): STR LNK, SP, 0H |
01BC | d(A0E00004): STR R0, SP, 4H |
01BD | e .FIXUP P |
01BD | e(F71110AF): BL MOD1 [Kernel] PROC17 |
01BE | e(81E00004): LDR R1, SP, 4H |
01BF | e(00180000): ADD R0, R1, R0 |
01C0 | e(A0E00004): STR R0, SP, 4H |
| REPEAT |
| SPICtrl({netEnable, netSelect})f;g SPI(17H)h;i (*R_REGISTER FIFO_STATUS*) |
01C1 | f(4000000A): MOV R0, R0, AH |
01C2 | g(F7FFFE3D): BL -451 [0000H] |
01C3 | h(40000017): MOV R0, R0, 17H |
01C4 | i(F7FFFE4E): BL -434 [0013H] |
| SYSTEM.GET(spiData, status);j SPI(-1)k;l SYSTEM.GET(spiData, fifoStatus);m SPICtrl({netEnable})n;o |
01C5 | j(5000FFD0): MOV R0, R0, FFFFFFD0H |
01C6 | j(90000000): LDR R0, R0, 0H |
01C7 | j(B0E00008): STR R0, SP, 8H |
01C8 | k(5000FFFF): MOV R0, R0, FFFFFFFFH |
01C9 | l(F7FFFE49): BL -439 [0013H] |
01CA | m(5000FFD0): MOV R0, R0, FFFFFFD0H |
01CB | m(90000000): LDR R0, R0, 0H |
01CC | m(B0E00009): STR R0, SP, 9H |
01CD | n(40000008): MOV R0, R0, 8H |
01CE | o(F7FFFE31): BL -463 [0000H] |
| rcvd := ODD(status DIV 40H)p ORq ~rODD(fifoStatus) (*RX_DR (data ready) or RX FIFO not empty*) |
01CF | p(90E00008): LDR R0, SP, 8H |
01D0 | p(40020006): ASR R0, R0, 6H |
01D1 | q(40040001): AND R0, R0, 1H |
01D2 | r(E9000003): BNE 3 [01D6H] |
| UNTILs rcvd OR (tKernel.Time() >=u time)v;w |
01D3 | s(90E00009): LDR R0, SP, 9H |
01D4 | s(40040001): AND R0, R0, 1H |
01D5 | s(E9000002): BNE 2 [01D8H] |
01D6 | s(40000001): MOV R0, R0, 1H |
01D7 | s(E7000001): B 1 [01D9H] |
01D8 | s(40000000): MOV R0, R0, 0H |
01D9 | s(B0E0000A): STR R0, SP, AH |
01DA | t(90E0000A): LDR R0, SP, AH |
01DB | t(E9000004): BNE 4 [01E0H] |
01DC | u .FIXUP P |
01DC | u(F711101F): BL MOD1 [Kernel] PROC17 |
01DD | v(81E00004): LDR R1, SP, 4H |
01DE | v(00090001): SUB R0, R0, R1 |
01DF | w(E5FFFFE1): BLT -31 [01C1H] |
| RETURN rcvd |
| ENDx Rcvd; |
01E0 | x(90E0000A): LDR R0, SP, AH |
01E1 | x(8FE00000): LDR LNK, SP, 0H |
01E2 | x(4EE8000C): ADD SP, SP, CH |
01E3 | x(C700000F): B LNK |
| |
| PROCEDURE ReceiveHead*(VAR head: Header); (*actually, recv whole packet*) |
| VAR adr, n: INTEGER; |
| BEGINy head.valid := FALSE;z |
01E4 | y .PROC 8 |
01E4 | y(4EE90014): SUB SP, SP, 14H |
01E5 | y(AFE00000): STR LNK, SP, 0H |
01E6 | y(A0E00004): STR R0, SP, 4H |
01E7 | y(A1E00008): STR R1, SP, 8H |
01E8 | z(40000000): MOV R0, R0, 0H |
01E9 | z(81E00004): LDR R1, SP, 4H |
01EA | z(B0100000): STR R0, R1, 0H |
| IF Rcvd(0)a THENb |
01EB | a(40000000): MOV R0, R0, 0H |
01EC | b(F7FFFFCD): BL -51 [01BAH] |
01ED | b(40090000): SUB R0, R0, 0H |
01EE | b(E1000048): BEQ 72 [0237H] |
| ResetRcv;c adr := SYSTEM.ADR(rx);d SubRcv(adr)e;f |
01EF | c(F7FFFECF): BL -305 [00BFH] |
01F0 | d .FIXUP D |
01F0 | d(8D000049): LDR SB, MT, MOD0 [SCC] |
01F1 | d(40D8001C): ADD R0, SB, 1CH [data] |
01F2 | d(A0E0000C): STR R0, SP, CH |
01F3 | e(80E0000C): LDR R0, SP, CH |
01F4 | f(F7FFFE43): BL -445 [0038H] |
| n := (rx.hd.len + HdrSize -g 1)h DIV SubPacket;i |
01F5 | g .FIXUP D |
01F5 | g(8D000005): LDR SB, MT, MOD0 [SCC] |
01F6 | g(80D00020): LDR R0, SB, 20H [data] |
01F7 | g(40080008): ADD R0, R0, 8H |
01F8 | h(40090001): SUB R0, R0, 1H |
01F9 | i(40020005): ASR R0, R0, 5H |
01FA | i(A0E00010): STR R0, SP, 10H |
| IF (rx.hd.len <= MaxPayload)j |
01FB | j(80D00020): LDR R0, SB, 20H |
01FC | j(40090200): SUB R0, R0, 200H |
| & (k(rx.hd.dadr = 0FFH)l OR ~mfilter ORn (oAdr = 0)p OR (qrx.hd.dadr = Adr)r) THENs |
01FD | k(EE000027): BGT 39 [0225H] |
01FE | l .FIXUP D |
01FE | l(8D000009): LDR SB, MT, MOD0 [SCC] |
01FF | l(90D0001D): LDR R0, SB, 1DH [data] |
0200 | l(400900FF): SUB R0, R0, FFH |
0201 | m(E100000B): BEQ 11 [020DH] |
0202 | n .FIXUP D |
0202 | n(8D000004): LDR SB, MT, MOD0 [SCC] |
0203 | n(90D00014): LDR R0, SB, 14H [data] |
0204 | o(E1000008): BEQ 8 [020DH] |
0205 | p .FIXUP D |
0205 | p(8D000003): LDR SB, MT, MOD0 [SCC] |
0206 | p(90D00015): LDR R0, SB, 15H [data] |
0207 | q(E1000005): BEQ 5 [020DH] |
0208 | r .FIXUP D |
0208 | r(8D000003): LDR SB, MT, MOD0 [SCC] |
0209 | r(90D0001D): LDR R0, SB, 1DH [data] |
020A | r(91D00015): LDR R1, SB, 15H |
020B | r(00090001): SUB R0, R0, R1 |
020C | s(E9000018): BNE 24 [0225H] |
| WHILE (n > 0)t & Rcvdu(Wait)v DOw |
020D | t(80E00010): LDR R0, SP, 10H |
020E | t(40090000): SUB R0, R0, 0H |
020F | u(E600000D): BLE 13 [021DH] |
0210 | v(40000032): MOV R0, R0, 32H |
0211 | w(F7FFFFA8): BL -88 [01BAH] |
0212 | w(40090000): SUB R0, R0, 0H |
0213 | w(E1000009): BEQ 9 [021DH] |
| INC(adr, SubPacket);x SubRcv(adr)y;z DEC(n) |
0214 | x(80E0000C): LDR R0, SP, CH |
0215 | x(40080020): ADD R0, R0, 20H |
0216 | x(A0E0000C): STR R0, SP, CH |
0217 | y(80E0000C): LDR R0, SP, CH |
0218 | z(F7FFFE1F): BL -481 [0038H] |
| ENDa; |
0219 | a(80E00010): LDR R0, SP, 10H |
021A | a(40090001): SUB R0, R0, 1H |
021B | a(A0E00010): STR R0, SP, 10H |
021C | a(E7FFFFF0): B -16 [020DH] |
| rx.hd.valid := (n = 0)b |
021D | b(80E00010): LDR R0, SP, 10H |
| ELSEc WHILEd Rcvd(Wait)e DOf SubRcv(adr)g ENDh; ResetRcv (*discard packet*) |
021E | c(E9000002): BNE 2 [0221H] |
021F | c(40000001): MOV R0, R0, 1H |
0220 | c(E7000001): B 1 [0222H] |
0221 | c(40000000): MOV R0, R0, 0H |
0222 | c .FIXUP D |
0222 | c(8D00001A): LDR SB, MT, MOD0 [SCC] |
0223 | c(B0D0001C): STR R0, SB, 1CH [data] |
0224 | d(E7000008): B 8 [022DH] |
0225 | e(40000032): MOV R0, R0, 32H |
0226 | f(F7FFFF93): BL -109 [01BAH] |
0227 | f(40090000): SUB R0, R0, 0H |
0228 | f(E1000003): BEQ 3 [022CH] |
0229 | g(80E0000C): LDR R0, SP, CH |
022A | h(F7FFFE0D): BL -499 [0038H] |
022B | h(E7FFFFF9): B -7 [0225H] |
| ENDi; |
022C | i(F7FFFE92): BL -366 [00BFH] |
| head := rx.hd |
| ENDj |
022D | j(80E00004): LDR R0, SP, 4H |
022E | j .FIXUP D |
022E | j(8D00000C): LDR SB, MT, MOD0 [SCC] |
022F | j(41D8001C): ADD R1, SB, 1CH [data] |
0230 | j(42000002): MOV R2, R0, 2H |
0231 | j(83100000): LDR R3, R1, 0H |
0232 | j(41180004): ADD R1, R1, 4H |
0233 | j(A3000000): STR R3, R0, 0H |
0234 | j(40080004): ADD R0, R0, 4H |
0235 | j(42290001): SUB R2, R2, 1H |
0236 | j(E9FFFFFA): BNE -6 [0231H] |
| ENDk ReceiveHead; |
0237 | k(8FE00000): LDR LNK, SP, 0H |
0238 | k(4EE80014): ADD SP, SP, 14H |
0239 | k(C700000F): B LNK |
| |
| PROCEDURE Skip*(m: INTEGER); |
| VAR dmy: BYTE; |
| BEGINl WHILE m # 0 DOm Receive(dmy)n;o DEC(m) ENDp |
023A | l .PROC 9 |
023A | l(4EE9000C): SUB SP, SP, CH |
023B | l(AFE00000): STR LNK, SP, 0H |
023C | l(A0E00004): STR R0, SP, 4H |
023D | m(80E00004): LDR R0, SP, 4H |
023E | m(E1000006): BEQ 6 [0245H] |
023F | n(40E80008): ADD R0, SP, 8H |
0240 | o(F7FFFF5E): BL -162 [019FH] |
0241 | p(80E00004): LDR R0, SP, 4H |
0242 | p(40090001): SUB R0, R0, 1H |
0243 | p(A0E00004): STR R0, SP, 4H |
0244 | p(E7FFFFF8): B -8 [023DH] |
| ENDq Skip; |
0245 | q(8FE00000): LDR LNK, SP, 0H |
0246 | q(4EE8000C): ADD SP, SP, CH |
0247 | q(C700000F): B LNK |
| |
| PROCEDURE Stop*; |
| BEGINr SPICtrl({})s;t Flush();u ResetRcv |
0248 | r .PROC 10 |
0248 | r .COMMAND Stop |
0248 | r(4EE90004): SUB SP, SP, 4H |
0249 | r(AFE00000): STR LNK, SP, 0H |
024A | s(40000000): MOV R0, R0, 0H |
024B | t(F7FFFDB4): BL -588 [0000H] |
024C | u(F7FFFE65): BL -411 [00B2H] |
| ENDv Stop; |
024D | v(F7FFFE71): BL -399 [00BFH] |
024E | v(8FE00000): LDR LNK, SP, 0H |
024F | v(4EE80004): ADD SP, SP, 4H |
0250 | v(C700000F): B LNK |
| |
| BEGINw Start(TRUE)x |
0251 | w .PROC 0 |
0251 | w .ENTRYPOINT |
0251 | w(4EE90004): SUB SP, SP, 4H |
0252 | w(AFE00000): STR LNK, SP, 0H |
0253 | x(40000001): MOV R0, R0, 1H |
| ENDy SCC.z |
0254 | y(F7FFFE89): BL -375 [00DEH] |
0255 | z(8FE00000): LDR LNK, SP, 0H |
0256 | z(4EE80004): ADD SP, SP, 4H |
0257 | z(C700000F): B LNK |