line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public License |
2
|
|
|
|
|
|
|
# or the Artistic License (the same terms as Perl itself) |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# (C) Paul Evans, 2015-2023 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
1456914
|
use v5.26; |
|
6
|
|
|
|
|
59
|
|
7
|
6
|
|
|
6
|
|
32
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
184
|
|
8
|
6
|
|
|
6
|
|
31
|
use Object::Pad 0.800; |
|
6
|
|
|
|
|
43
|
|
|
6
|
|
|
|
|
261
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Device::Chip::MCP23S17 0.07; |
11
|
|
|
|
|
|
|
class Device::Chip::MCP23S17 |
12
|
5
|
|
|
5
|
|
2663
|
:isa(Device::Chip::MCP23x17); |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
171
|
|
13
|
|
|
|
|
|
|
|
14
|
6
|
|
|
6
|
|
1018
|
use Future::AsyncAwait; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
33
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
C - chip driver for a F |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 DESCRIPTION |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
This subclass of L provides the required methods to |
23
|
|
|
|
|
|
|
allow it to communicate with the SPI-attached F F version |
24
|
|
|
|
|
|
|
of the F family. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
6
|
|
|
6
|
|
313
|
use constant PROTOCOL => "SPI"; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
2986
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
method SPI_options |
31
|
5
|
|
|
5
|
0
|
1780
|
{ |
32
|
|
|
|
|
|
|
return ( |
33
|
5
|
|
|
|
|
29
|
mode => 0, |
34
|
|
|
|
|
|
|
max_bitrate => 1E6, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
12
|
|
|
|
|
18
|
async method write_reg ( $reg, $data ) |
|
12
|
|
|
|
|
20
|
|
|
12
|
|
|
|
|
21
|
|
|
12
|
|
|
|
|
15
|
|
39
|
12
|
|
|
|
|
25
|
{ |
40
|
12
|
|
|
|
|
45
|
await $self->protocol->write( pack "C C a*", ( 0x20 << 1 ), $reg, $data ); |
41
|
12
|
|
|
12
|
0
|
361
|
} |
42
|
|
|
|
|
|
|
|
43
|
3
|
|
|
|
|
6
|
async method read_reg ( $reg, $len ) |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
7
|
|
44
|
3
|
|
|
|
|
10
|
{ |
45
|
3
|
|
|
|
|
12
|
my $buf = await $self->protocol->readwrite( pack "C C a*", ( 0x20 << 1 ) | 1, $reg, "\x00" x $len ); |
46
|
3
|
|
|
|
|
11978
|
return substr $buf, 2; |
47
|
3
|
|
|
3
|
0
|
11654
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 AUTHOR |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Paul Evans |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
0x55AA; |