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   538102 use v5.26;
  5         68  
7 5     5   24 use Object::Pad 0.57;
  5         57  
  5         28  
8              
9             package Device::Chip::MCP23S17 0.05;
10             class Device::Chip::MCP23S17
11 5     5   2433 :isa(Device::Chip::MCP23x17);
  5         10  
  5         167  
12              
13 5     5   725 use Future::AsyncAwait;
  5         10  
  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   212 use constant PROTOCOL => "SPI";
  5         21  
  5         1828  
28              
29             method SPI_options
30 5     5 0 1399 {
31             return (
32 5         27 mode => 0,
33             max_bitrate => 1E6,
34             );
35             }
36              
37 12         17 async method write_reg ( $reg, $data )
  12         18  
  12         19  
  12         14  
38 12         26 {
39 12         35 await $self->protocol->write( pack "C C a*", ( 0x20 << 1 ), $reg, $data );
40 12     12 0 331 }
41              
42 3         5 async method read_reg ( $reg, $len )
  3         6  
  3         6  
  3         4  
43 3         10 {
44 3         10 my $buf = await $self->protocol->readwrite( pack "C C a*", ( 0x20 << 1 ) | 1, $reg, "\x00" x $len );
45 3         9843 return substr $buf, 2;
46 3     3 0 11724 }
47              
48             =head1 AUTHOR
49              
50             Paul Evans
51              
52             =cut
53              
54             0x55AA;