File Coverage

blib/lib/Device/Chip/MCP23S17.pm
Criterion Covered Total %
statement 31 31 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 0 3 0.0
total 39 42 92.8


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-2021 -- leonerd@leonerd.org.uk
5              
6 5     5   558447 use v5.26;
  5         58  
7 5     5   25 use Object::Pad 0.57;
  5         60  
  5         22  
8              
9             package Device::Chip::MCP23S17 0.06;
10             class Device::Chip::MCP23S17
11 5     5   2480 :isa(Device::Chip::MCP23x17);
  5         10  
  5         184  
12              
13 5     5   713 use Future::AsyncAwait;
  5         9  
  5         17  
14              
15             =head1 NAME
16              
17             C - chip driver for a F
18              
19             =head1 DESCRIPTION
20              
21             This subclass of L provides the required methods to
22             allow it to communicate with the SPI-attached F F version
23             of the F family.
24              
25             =cut
26              
27 5     5   215 use constant PROTOCOL => "SPI";
  5         11  
  5         1963  
28              
29             method SPI_options
30 5     5 0 1615 {
31             return (
32 5         24 mode => 0,
33             max_bitrate => 1E6,
34             );
35             }
36              
37 12         26 async method write_reg ( $reg, $data )
  12         20  
  12         21  
  12         15  
38 12         25 {
39 12         39 await $self->protocol->write( pack "C C a*", ( 0x20 << 1 ), $reg, $data );
40 12     12 0 314 }
41              
42 3         6 async method read_reg ( $reg, $len )
  3         5  
  3         5  
  3         5  
43 3         8 {
44 3         25 my $buf = await $self->protocol->readwrite( pack "C C a*", ( 0x20 << 1 ) | 1, $reg, "\x00" x $len );
45 3         10936 return substr $buf, 2;
46 3     3 0 9963 }
47              
48             =head1 AUTHOR
49              
50             Paul Evans
51              
52             =cut
53              
54             0x55AA;