-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Bus.php
105 lines (93 loc) · 2.16 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
<?php
namespace I2C;
final class Bus {
/**
* Opens the I2C Bus.
*
* @param int $busId I2C bus id
* @param int $deviceAddress I2C device address
*
* @return void
*/
public function __construct(int $busId, int $deviceAddress) {}
/**
* Return the I2C bus id.
*
* @return int
*/
public function getBusId(): int {}
/**
* Return the Device Address.
*
* @return int
*/
public function getDeviceAddress(): int {}
/**
* Read from I2C bus.
*
* @return int
*/
public function read(): int {}
/**
* Read a byte from a register.
*
* @param int $regAddress Register address
*
* @return int
*/
public function readByte(int $regAddress): int {}
/**
* Read a word from a register.
*
* @param int $regAddress Register address
*
* @return int
*/
public function readWord(int $regAddress): int {}
/**
* Read a block of bytes up to $numBytes long from a register.
* Note: I2C specification limits block reads to 32 bytes in a single read.
*
* @param int $regAddress Register address
* @param int $numBytes Number of bytes to read from device
*
* @return int[]
*/
public function readBlock(int $regAddress, int $numBytes): array {}
/**
* Write to I2C bus.
*
* @param int $data Data to be written
*
* @return boolean
*/
public function write(int $data): bool {}
/**
* Write a byte on a register.
*
* @param int $regAddress Register address
* @param int $byte Byte value
*
* @return boolean
*/
public function writeByte(int $regAddress, int $byte): bool {}
/**
* Write a word on a register.
*
* @param int $regAddress Register address
* @param int $word Word value
*
* @return boolean
*/
public function writeWord(int $regAddress, int $word): bool {}
/**
* Write a block of bytes on a register.
* Note: I2C specification limits block writes to 32 bytes in a single write.
*
* @param int $regAddress Register address
* @param int[] $bytes Bytes to be sent
*
* @return boolean
*/
public function writeBlock(int $regAddress, int ...$bytes): bool {}
}