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   100077 use v5.26;
  2         13  
7 2     2   10 use Object::Pad 0.57;
  2         21  
  2         8  
8              
9             package Device::Chip::DAC7513 0.13;
10             class Device::Chip::DAC7513
11 2     2   859 :isa(Device::Chip::DAC75xx);
  2         3  
  2         72  
12              
13 2     2   276 use Future::AsyncAwait;
  2         5  
  2         6  
14              
15 2     2   75 use constant PROTOCOL => "SPI";
  2         3  
  2         423  
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 274 {
  1         2  
  1         1  
51             return (
52 1         5 max_bitrate => 30E6,
53             );
54             }
55              
56 3         3 async method _write ( $code )
  3         4  
  3         4  
57 3         5 {
58 3         8 await $self->protocol->write( pack "S>", $code );
59 3     3   5 }
60              
61             =head1 AUTHOR
62              
63             Paul Evans
64              
65             =cut
66              
67             0x55AA;