-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Bus.php
157 lines (136 loc) · 2.74 KB
/
Bus.php
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
namespace SPI;
final class Bus {
/**
* Opens the SPI Bus.
*
* @param int $busId SPI bus id
* @param int $chipSelect
* @param int $mode SPI mode (SPI_MODE_0..3)
* @param int $bits Number of bits per word
* @param int $speed Bus speed in Hz
* @param int $delay Delay between sending each bit
*
* @return void
*/
public function __construct(
int $busId,
int $chipSelect,
int $mode = SPI\MODE_0,
int $bits = 8,
int $speed = 1000000,
int $delay = 0
) {}
/**
* Send the $bytes array to device.
*
* @param int[] $bytes Bytes to be sent
*
* @return void
*/
public function write(int ...$bytes): void {}
/**
* Read an array of up to $numBytes bytes from device.
*
* @param int $numBytes Number of bytes to read from bus
*
* @return int[]
*/
public function read(int $numBytes): array {}
/**
* Send the $bytes array to device and read back the same amount of bytes from it.
*
* @param int[] $bytes Bytes to be sent
*
* @return int[]
*/
public function transfer(int ...$bytes): array {}
/**
* Return the SPI bus id.
*
* @return int
*/
public function getBusId(): int {}
/**
* @return int
*/
public function getChipSelect(): int {}
/**
* Return the SPI mode.
*
* @return int
*/
public function getMode(): int {}
/**
* Return the number of bits per word.
*
* @return int
*/
public function getBitsPerWord(): int {}
/**
* Return the bus speed in Hz.
*
* @return int
*/
public function getSpeed(): int {}
/**
* Return the delay between sending each bit.
*
* @return int
*/
public function getDelay(): int {}
/**
* @return bool
*/
public function isChipSelectHigh(): bool {}
/**
* @param bool $enabled
*
* @return void
*/
public function setChipSelectHigh(bool $enabled): void {}
/**
* @return bool
*/
public function isLsbFirst(): bool {}
/**
* @param bool $enabled
*
* @return void
*/
public function setLsbFirst(bool $enabled): void {}
/**
* Return if SI/SO signals are shared.
*
* @return bool
*/
public function is3Wire(): bool {}
/**
* @param bool $enabled
*
* @return void
*/
public function set3Wire(bool $enabled): void {}
/**
* Return if is a loopback configuration.
*
* @return bool
*/
public function isLoop(): bool {}
/**
* @param bool $enabled
*
* @return void
*/
public function setLoop(bool $enabled): void {}
/**
* @return bool
*/
public function isChipSelectDisabled(): bool {}
/**
* @param bool $enabled
*
* @return void
*/
public function setChipSelectDisabled(bool $enabled): void {}
}