File Coverage

blib/lib/Device/Chip/DAC7513.pm
Criterion Covered Total %
statement 27 27 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 35 36 97.2


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