File Coverage

blib/lib/Device/Chip/DAC7513.pm
Criterion Covered Total %
statement 24 24 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 31 32 96.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, 2020-2022 -- leonerd@leonerd.org.uk
5              
6 2     2   133665 use v5.26;
  2         24  
7 2     2   11 use Object::Pad 0.57;
  2         32  
  2         11  
8              
9             package Device::Chip::DAC7513 0.14;
10             class Device::Chip::DAC7513
11 2     2   1113 :isa(Device::Chip::DAC75xx);
  2         5  
  2         61  
12              
13 2     2   300 use Future::AsyncAwait;
  2         4  
  2         18  
14              
15 2     2   90 use constant PROTOCOL => "SPI";
  2         4  
  2         544  
16              
17             =encoding UTF-8
18              
19             =head1 NAME
20              
21             C - chip driver for F
22              
23             =head1 SYNOPSIS
24              
25             use Device::Chip::DAC7513;
26             use Future::AsyncAwait;
27              
28             my $chip = Device::Chip::DAC7513->new;
29             await $chip->mount( Device::Chip::Adapter::...->new );
30              
31             # Presuming Vcc = 5V
32             await $chip->write_dac_ratio( 1.23 / 5 );
33             print "Output is now set to 1.23V\n";
34              
35             =head1 DESCRIPTION
36              
37             This L subclass provides specific communication to a
38             F F attached to a computer via an SPI adapter.
39              
40             The reader is presumed to be familiar with the general operation of this chip;
41             the documentation here will not attempt to explain or define chip-specific
42             concepts or features, only the use of this module to access them.
43              
44             This class is derived from L, and inherits the methods
45             defined there.
46              
47             =cut
48              
49             sub SPI_options ( $, %params )
50 1     1 0 430 {
  1         2  
  1         2  
51             return (
52 1         7 max_bitrate => 30E6,
53             );
54             }
55              
56 3         4 async method _write ( $code )
  3         6  
  3         4  
57 3         7 {
58 3         9 await $self->protocol->write( pack "S>", $code );
59 3     3   6 }
60              
61             =head1 AUTHOR
62              
63             Paul Evans
64              
65             =cut
66              
67             0x55AA;