AnalogConverters.pm untested

filter: Statementstmt 0.0% 0 / 6 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 2 Podpod n/a totaltotal 0.0% 0 / 8 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
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 package Device::Chip::AnalogConverters 0.16;
7  
8 use v5.26;
9 use warnings;
10  
11 =head1 NAME
12  
13 C<Device::Chip::AnalogConverters> - a collection of chip drivers
14  
15 =head1 DESCRIPTION
16  
17 This distribution contains a number of L<Device::Chip> drivers for various ADC
18 and DAC chips.
19  
20 =cut
21  
22 =head1 ADCs
23  
24 =over 2
25  
26 =item *
27  
28 L<Device::Chip::ADC121Sx>
29  
30 =item *
31  
32 L<Device::Chip::ADS1115>
33  
34 =item *
35  
36 L<Device::Chip::LTC2400>
37  
38 =item *
39  
40 L<Device::Chip::MCP3221>
41  
42 =item *
43  
44 L<Device::Chip::MAX11200>
45  
46 =item *
47  
48 L<Device::Chip::MAX1166x>
49  
50 =back
51  
52 =head2 SUGGESTED ADC METHODS
53  
54 =head3 trigger
55  
56 await $chip->trigger( %args );
57  
58 Optional. This method asks the chip to begin taking a reading.
59  
60 =head3 read_adc
61  
62 $value = await $chip->read_adc;
63  
64 Obtains the most recent reading performed by the chip, as a plain integer
65 value. This may be signed or unsigned, scaled to whatever precision the chip
66 works at.
67  
68 =head3 read_adc_voltage
69  
70 $voltage = await $chip->read_adc_voltage;
71  
72 If the chip contains an internal reference, or in some other way the scale is
73 known by the driver, this method should be provided that converts the result
74 of L</read_adc> into an actual signed voltage.
75  
76 =head3 read_adc_ratio
77  
78 $ratio = await $chip->read_adc_ratio;
79  
80 If the chip (driver) does not have a reference to scale convert the output
81 directly to a voltage level, then this method should be provided instead that
82 merely scales the raw reading down by a factor such that the returned value is
83 a floating-point number between 0 and 1 for unipolar (single-ended unsigned)
84 readings, or between -1 and 1 for bipolar (differential signed) readings.
85  
86 =cut
87  
88 =head1 DACs
89  
90 =over 2
91  
92 =item *
93  
94 L<Device::Chip::AD5691R>
95  
96 =item *
97  
98 L<Device::Chip::DAC7513>
99  
100 =item *
101  
102 L<Device::Chip::DAC7571>
103  
104 =item *
105  
106 L<Device::Chip::MCP4725>
107  
108 =back
109  
110 =head2 SUGGESTED DAC METHODS
111  
112 =head3 write_dac
113  
114 await $chip->write_dac( $value );
115  
116 Sets the value of the DAC's output as a plain integer value. This may be
117 signed or unsigned, scaled to whatever precision the chip works at.
118  
119 =head3 write_dac_voltage
120  
121 await $chip->write_dac_voltage( $voltage );
122  
123 If the chip contains an internal reference, or in some other way the scale is
124 known by the driver, this method should be provided that converts the given
125 voltage into a raw value to invoke L</write_dac> with.
126  
127 =head3 write_dac_ratio
128  
129 await $chip->write_dac_ratio( $ratio );
130  
131 If the chip (driver) does not have a reference to scale convert a given
132 voltage to a DAC code value, then this method should be provided instead that
133 takes a given ratio, as a floating-point number between 0 and 1 for unipolar
134 (single-ended unsigned) outputs or between -1 and 1 for bipolar (differential
135 signed) outputs, and scales it by a suitable factor.
136  
137 =cut
138  
139 =head1 AUTHOR
140  
141 Paul Evans <leonerd@leonerd.org.uk>
142  
143 =cut
144  
145 0x55AA;