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
|
|
108519
|
use v5.26; |
|
2
|
|
|
|
|
18
|
|
7
|
2
|
|
|
2
|
|
9
|
use Object::Pad 0.57; |
|
2
|
|
|
|
|
21
|
|
|
2
|
|
|
|
|
20
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Device::Chip::DAC7571 0.13; |
10
|
|
|
|
|
|
|
class Device::Chip::DAC7571 |
11
|
1
|
|
|
1
|
|
455
|
:isa(Device::Chip::DAC75xx); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
374
|
use Future::AsyncAwait; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
2
|
|
75
|
use constant PROTOCOL => "I2C"; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
577
|
|
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::DAC7571; |
26
|
|
|
|
|
|
|
use Future::AsyncAwait; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $chip = Device::Chip::DAC7571->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 I²C 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
|
|
|
|
|
|
|
=head1 MOUNT PARAMETERS |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 addr |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
The I²C address of the device. Can be specified in decimal, octal or hex with |
54
|
|
|
|
|
|
|
leading C<0> or C<0x> prefixes. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub I2C_options ( $, %params ) |
59
|
1
|
|
|
1
|
0
|
310
|
{ |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1
|
|
60
|
1
|
|
50
|
|
|
5
|
my $addr = delete $params{addr} // 0x4C; |
61
|
1
|
50
|
|
|
|
5
|
$addr = oct $addr if $addr =~ m/^0/; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
return ( |
64
|
1
|
|
|
|
|
5
|
addr => $addr, |
65
|
|
|
|
|
|
|
max_bitrate => 400E3, |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
3
|
|
|
|
|
5
|
async method _write ( $code ) |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
4
|
|
70
|
3
|
|
|
|
|
5
|
{ |
71
|
3
|
|
|
|
|
8
|
await $self->protocol->write( pack "S>", $code ); |
72
|
3
|
|
|
3
|
|
4
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHOR |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Paul Evans |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
0x55AA; |