-
Notifications
You must be signed in to change notification settings - Fork 13
/
testrpi.pas
executable file
·127 lines (120 loc) · 6.46 KB
/
testrpi.pas
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
(*Simple Test program, which is using rpi_hal.
Compile it on rpi with '#fpc testrpi.' and run it '#./testrpi'
If you use Lazarus, then modify the Lazarus IDE compiler options:
Project -> Project Options ... -> Compiler Options -> Other and add: -dUseCThreads
pls. see http://forum.lazarus.freepascal.org/index.php/topic,20991.30.html, post from katonacs73 *)
program testrpi; // V5.0
uses rpi_hal,pfio;
const piggyback=1; piface=2; bidir=3; board_installed=0; //board_installed=piggyback;
begin
if RPI_HW_Start([InitHaltOnError,InitGPIO,InitSPI,InitI2C]) then
begin
writeln('Show CPU-Info, RPI-HW-Info and Registers:');
rpi_show_all_info;
case board_installed of
piggyback : begin
writeln('Test SPI Read function. (piggy back board with installed RFM22B Module is required!)');
SPI_Test;
end;
piface : begin
writeln('Test SPI function. (PiFace board needs to be installed)');
pfio_init(0); // PiFace MCP23S17SP on Adr. 0 (A2 A1 A0 pins set to GND)
pfio_test(0);
end;
bidir: begin
Test_BiDirectionDevice_in_UserSpace;
end;
end; // case
end else writeln('ERROR, something went wrong with RPI_HW_Start');
end.
(*
Show CPU-Info, RPI-HW-Info and Registers:
rpi Snr : 0000000123456789
rpi HW : BCM2709
rpi proc : 0
rpi rev : rev3;1GB;PI2B;a01041;40
rpi mips : 38.40
rpi Freq : 600000;600000;900000;Hz
GPIOBase : 0003F200 PageSize: 4096 GPIO-Map-ptr: 0x76F3A000
Adr(1F-0): FEDC BA98 7654 3210 FEDC BA98 7654 3210
GPFSEL0 : 0010 0100 1000 0000 0000 1001 0000 0000 P09:A0 P08:A0 P07:A0 P06:IN P05:IN P04:IN P03:A0 P02:A0 P01:IN P00:IN
GPFSEL1 : 0000 0000 0000 0010 0100 0000 0010 0100 P19:IN P18:IN P17:IN P16:IN P15:A0 P14:A0 P13:IN P12:IN P11:A0 P10:A0
GPFSEL2 : 0000 0000 0000 0000 0000 0000 0000 0000 P29:IN P28:IN P27:IN P26:IN P25:IN P24:IN P23:IN P22:IN P21:IN P20:IN
GPFSEL3 : 0000 0001 0000 0000 0000 0000 0100 1000 P39:IN P38:OUT P37:IN P36:IN P35:IN P34:IN P33:IN P32:OUT P31:OUT P30:IN
GPFSEL4 : 0011 1111 0010 0010 0100 0000 0000 1100 P49:A3 P48:A3 P47:OUT P46:IN P45:A0 P44:A0 P43:IN P42:IN P41:OUT P40:A0
GPFSEL5 : 0000 0000 0000 0000 0000 1111 1111 1111 P59:IN P58:IN P57:IN P56:IN P55:IN P54:IN P53:A3 P52:A3 P51:A3 P50:A3
Reg[6] : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPSET0 : 0110 0111 0111 0000 0110 1001 0110 1111 0x6770696F
GPSET1 : 0110 0111 0111 0000 0110 1001 0110 1111 0x6770696F
Reg[9] : 0110 0111 0111 0000 0110 1001 0110 1111 0x6770696F
GPCLR0 : 0110 0111 0111 0000 0110 1001 0110 1111 0x6770696F
GPCLR1 : 0110 0111 0111 0000 0110 1001 0110 1111 0x6770696F
Reg[12] : 0110 0111 0111 0000 0110 1001 0110 1111 0x6770696F
GPLEV0 : 1011 0000 0000 0000 1100 0001 1111 1111 0xB000C1FF
GPLEV1 : 0000 0000 0011 1110 0101 1100 0001 1100 0x003E5C1C
Reg[15] : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPEDS0 : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPEDS1 : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
Reg[18] : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPREN0 : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPREN1 : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
Reg[21] : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPFEN0 : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPFEN1 : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
Reg[24] : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPHEN0 : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPHEN1 : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
Reg[27] : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPLEN0 : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPLEN1 : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
Reg[30] : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPAREN0 : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPAREN1 : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
Reg[33] : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPAFEN0 : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPAFEN1 : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
Reg[36] : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPPUD0 : 0000 0000 0000 0000 0000 0000 0000 0010 0x00000002
GPPUDCLK0: 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
GPPUDCLK1: 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
Reg[40] : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
Reg[41] : 1111 1111 1111 1111 1111 1111 1111 1111 0xFFFFFFFF
PWMBase : 0003F20C PageSize: 4096 PWM-Map-ptr: 0x76F39000
Adr(1F-0): FEDC BA98 7654 3210 FEDC BA98 7654 3210
PWMCTL : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
PWMSTA : 0000 0000 0000 0000 0000 0000 0000 0010 0x00000002
PWMDMAC : 0000 0000 0000 0000 0000 0111 0000 0111 0x00000707
Reg[3] : 0111 0000 0111 0111 0110 1101 0011 0000 0x70776D30
PWM0RNG : 0000 0000 0000 0000 0000 0000 0010 0000 0x00000020
PWM0DAT : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
PWM0FIF : 0111 0000 0111 0111 0110 1101 0011 0000 0x70776D30
Reg[7] : 0111 0000 0111 0111 0110 1101 0011 0000 0x70776D30
PWM1RNG : 0000 0000 0000 0000 0000 0000 0010 0000 0x00000020
PWM1DAT : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
CLKBase : 0003F101 PageSize: 4096 CLK-Map-ptr: 0x76F38000
Adr(1F-0): FEDC BA98 7654 3210 FEDC BA98 7654 3210
Reg[40] : 0000 0000 0000 0000 0000 0010 0000 0000 0x00000200
Reg[41] : 0000 0000 0000 0000 0000 0000 0000 0000 0x00000000
PIN Header (BCM2709 rev3;1GB;PI2B;a01041;40):
Signal DIR V Pin Pin V DIR Signal
3.3V 1 || 2 5V
I2C SDA1 A0 3 || 4 5V
I2C SCL1 A0 5 || 6 GND
GPIO04 IN H 7 || 8 A0 TxD0
GND 9 || 10 A0 RxD0
GPIO17 IN L 11 || 12 L IN GPIO18
GPIO27 IN L 13 || 14 GND
GPIO22 IN L 15 || 16 L IN GPIO23
3.3V 17 || 18 L IN GPIO24
SPI0 MOSI A0 19 || 20 GND
SPI0 MISO A0 21 || 22 L IN GPIO25
SPI0 SCLK A0 23 || 24 A0 SPI0 CE0/
GND 25 || 26 A0 SPI0 CE1/
ID SD 27 || 28 ID SC
GPIO05 IN H 29 || 30 GND
GPIO06 IN H 31 || 32 L IN GPIO12
GPIO13 IN L 33 || 34 GND
GPIO19 IN L 35 || 36 L IN GPIO16
GPIO26 IN L 37 || 38 L IN GPIO20
GND 39 || 40 L IN GPIO21
*)