| 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 | ▶ | use v5.26; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 2 | ▶ | use Object::Pad 0.800; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | package Device::Chip::DAC7571 0.16; | ||||||||||||
| 11 | class Device::Chip::DAC7571 | ||||||||||||
| 12 | 1 | ▶ | :isa(Device::Chip::DAC75xx); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | |||||||||||||
| 14 | 2 | ▶ | use Future::AsyncAwait; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | |||||||||||||
| 16 | 2 | ▶ | use constant PROTOCOL => "I2C"; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | |||||||||||||
| 18 | =encoding UTF-8 | ||||||||||||
| 19 | |||||||||||||
| 20 | =head1 NAME | ||||||||||||
| 21 | |||||||||||||
| 22 | C<Device::Chip::DAC7571> - chip driver for F<DAC7571> | ||||||||||||
| 23 | |||||||||||||
| 24 | =head1 SYNOPSIS | ||||||||||||
| 25 | |||||||||||||
| 26 | use Device::Chip::DAC7571; | ||||||||||||
| 27 | use Future::AsyncAwait; | ||||||||||||
| 28 | |||||||||||||
| 29 | my $chip = Device::Chip::DAC7571->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<Device::Chip> subclass provides specific communication to a | ||||||||||||
| 39 | F<Texas Instruments> F<DAC7571> attached to a computer via an I²C 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<Device::Chip::DAC75xx>, and inherits the methods | ||||||||||||
| 46 | defined there. | ||||||||||||
| 47 | |||||||||||||
| 48 | =cut | ||||||||||||
| 49 | |||||||||||||
| 50 | =head1 MOUNT PARAMETERS | ||||||||||||
| 51 | |||||||||||||
| 52 | =head2 addr | ||||||||||||
| 53 | |||||||||||||
| 54 | The I²C address of the device. Can be specified in decimal, octal or hex with | ||||||||||||
| 55 | leading C<0> or C<0x> prefixes. | ||||||||||||
| 56 | |||||||||||||
| 57 | =cut | ||||||||||||
| 58 | |||||||||||||
| 59 | 1 | ▶ | sub I2C_options ( $, %params ) | ||||||||||
|
Subroutine
I2C_options: called CC=3 SCAR=11.7
Pod
undocumented
| |||||||||||||
| 60 | { | ||||||||||||
| 61 | 1 | ▶ | my $addr = delete $params{addr} // 0x4C; | ||||||||||
|
Condition50%1/2
delete $params{"addr"} // 76
MC/DC0%0/1
delete $params{"addr"} // 76
delete $params{"addr"}
Truth table50%1/2
A
A= delete $params{"addr"}
| |||||||||||||
| 62 | 1 | ▶ | $addr = oct $addr if $addr =~ m/^0/; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 63 | |||||||||||||
| 64 | return ( | ||||||||||||
| 65 | 1 | addr => $addr, | |||||||||||
| 66 | max_bitrate => 400E3, | ||||||||||||
| 67 | ); | ||||||||||||
| 68 | } | ||||||||||||
| 69 | |||||||||||||
| 70 | 3 | ▶ | async method _write ( $code ) | ||||||||||
|
Subroutine
_write: called CC=1 SCAR=0.0
| |||||||||||||
| 71 | 3 | { | |||||||||||
| 72 | 3 | await $self->protocol->write( pack "S>", $code ); | |||||||||||
| 73 | 2 | } | |||||||||||
| 74 | |||||||||||||
| 75 | =head1 AUTHOR | ||||||||||||
| 76 | |||||||||||||
| 77 | Paul Evans <leonerd@leonerd.org.uk> | ||||||||||||
| 78 | |||||||||||||
| 79 | =cut | ||||||||||||
| 80 | |||||||||||||
| 81 | 2 | 0x55AA; | |||||||||||