MCP23S17.pm

filter: Statementstmt 100% 38 / 38 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 3 totaltotal 94.0% 47 / 50 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« MCP23x17.pm ↑ Summary
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 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use Object::Pad 0.800;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 package Device::Chip::MCP23S17 0.07;
11 class Device::Chip::MCP23S17
12 5 ▶ :isa(Device::Chip::MCP23x17);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 6 ▶use Future::AsyncAwait;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 =head1 NAME
17  
18 C<Device::Chip::MCP23S17> - chip driver for a F<MCP23S17>
19  
20 =head1 DESCRIPTION
21  
22 This subclass of L<Device::Chip::MCP23x17> provides the required methods to
23 allow it to communicate with the SPI-attached F<Microchip> F<MCP23S17> version
24 of the F<MCP23x17> family.
25  
26 =cut
27  
28 6 ▶use constant PROTOCOL => "SPI";
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 method SPI_options
31 5 ▶{
Subroutine SPI_options: called CC=1 SCAR=0.0
Pod undocumented
32 return (
33 5 mode => 0,
34 max_bitrate => 1E6,
35 );
36 6 }
37  
38 12 ▶async method write_reg ( $reg, $data )
Subroutine write_reg: called CC=1 SCAR=0.0
Pod undocumented
39 12 {
40 12 await $self->protocol->write( pack "C C a*", ( 0x20 << 1 ), $reg, $data );
41 6 }
42  
43 3 ▶async method read_reg ( $reg, $len )
Subroutine read_reg: called CC=1 SCAR=0.0
Pod undocumented
44 3 {
45 3 my $buf = await $self->protocol->readwrite( pack "C C a*", ( 0x20 << 1 ) | 1, $reg, "\x00" x $len );
46 3 return substr $buf, 2;
47 6 }
48  
49 =head1 AUTHOR
50  
51 Paul Evans <leonerd@leonerd.org.uk>
52  
53 =cut
54  
55 6 0x55AA;
« MCP23x17.pm ↑ Summary