-
Notifications
You must be signed in to change notification settings - Fork 1
/
PIO.exp
58 lines (53 loc) · 1.1 KB
/
PIO.exp
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
MODULE PIO;
IMPORT SYSTEM;
CONST
gpio = -32;
gpoc = -28;
PROCEDURE del(i : INTEGER);
BEGIN
REPEAT
DEC(i)
UNTIL i = 0
END del;
PROCEDURE Send*(x : LONGINT);
VAR
i: INTEGER;
BEGIN
FOR i := 0 TO 7 DO
SYSTEM.PUT(gpio, x MOD 2+2);
del(60);
SYSTEM.PUT(gpio, x MOD 2);
del(25);
x := x DIV 2
END;
SYSTEM.PUT(gpio, 0);
del(100)
END Send;
PROCEDURE Receive*(VAR x : LONGINT);
VAR
i: INTEGER;
x0: INTEGER;
BEGIN
x0 := 0;
REPEAT
UNTIL ~ SYSTEM.BIT(gpio, 2);
FOR i := 0 TO 7 DO
SYSTEM.PUT(gpio, 2);
del(60);
IF SYSTEM.BIT(gpio, 2) THEN
x0 := x0+0100H
END;
SYSTEM.PUT(gpio, 0);
del(25);
x0 := ROR(x0, 1)
END;
x := x0
END Receive;
PROCEDURE Reset*;
BEGIN
SYSTEM.PUT(gpio, 0);
SYSTEM.PUT(gpoc, 3)
END Reset;
BEGIN
Reset()
END PIO.