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, 2018-2023 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
36
|
use v5.26; |
|
3
|
|
|
|
|
11
|
|
7
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
110
|
|
8
|
3
|
|
|
3
|
|
19
|
use Object::Pad 0.800; |
|
3
|
|
|
|
|
20
|
|
|
3
|
|
|
|
|
114
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Device::Chip::DAC75xx 0.15; |
11
|
|
|
|
|
|
|
class Device::Chip::DAC75xx |
12
|
|
|
|
|
|
|
:isa(Device::Chip); |
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
1060
|
use Carp; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
233
|
|
15
|
3
|
|
|
3
|
|
21
|
use Future::AsyncAwait; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
20
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=encoding UTF-8 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 NAME |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
C - common chip driver for F-family DACs |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This L subclass provides a base class for specific chip drivers |
26
|
|
|
|
|
|
|
for chips in the F DAC 75xx family. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
The reader is presumed to be familiar with the general operation of this chip; |
29
|
|
|
|
|
|
|
the documentation here will not attempt to explain or define chip-specific |
30
|
|
|
|
|
|
|
concepts or features, only the use of this module to access them. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 METHODS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
The following methods documented in an C expression return L |
37
|
|
|
|
|
|
|
instances. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my %NAME_TO_POWERDOWN = ( |
42
|
|
|
|
|
|
|
normal => 0, |
43
|
|
|
|
|
|
|
"1k" => 1, |
44
|
|
|
|
|
|
|
"100k" => 2, |
45
|
|
|
|
|
|
|
"hiZ" => 3, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Chip has no config registers |
49
|
0
|
|
|
0
|
0
|
0
|
async method read_config () { return {} } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
50
|
0
|
|
|
0
|
0
|
0
|
async method change_config (%) { } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 write_dac |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
await $chip->write_dac( $dac, $powerdown ); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Writes a new value for the DAC output and powerdown state. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
C<$powerdown> is optional and will default to C if not provided. Must |
59
|
|
|
|
|
|
|
be one of the following four values |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
normal 1k 100k hiZ |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
6
|
|
|
|
|
11
|
async method write_dac ( $dac, $powerdown = undef ) |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
22
|
|
|
6
|
|
|
|
|
10
|
|
66
|
6
|
|
|
|
|
19
|
{ |
67
|
6
|
|
|
|
|
13
|
$dac &= 0x0FFF; |
68
|
|
|
|
|
|
|
|
69
|
6
|
|
|
|
|
9
|
my $pd = 0; |
70
|
6
|
100
|
33
|
|
|
29
|
$pd = $NAME_TO_POWERDOWN{$powerdown} // croak "Unrecognised powerdown state '$powerdown'" |
71
|
|
|
|
|
|
|
if defined $powerdown; |
72
|
|
|
|
|
|
|
|
73
|
6
|
|
|
|
|
30
|
await $self->_write( $pd << 12 | $dac ); |
74
|
6
|
|
|
6
|
1
|
28190
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 write_dac_ratio |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
await $chip->write_dac_ratio( $ratio ); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Writes a new value for the DAC output as a scaled ratio between 0.0 and 1.0. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
2
|
|
|
|
|
5
|
async method write_dac_ratio ( $ratio ) |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
4
|
|
85
|
2
|
|
|
|
|
9
|
{ |
86
|
2
|
|
|
|
|
8
|
await $self->write_dac( $ratio * 2**12 ); |
87
|
2
|
|
|
2
|
1
|
9580
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 AUTHOR |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Paul Evans |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
0x55AA; |