The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Device::Chip::MAX11200 - chip driver for MAX11200

SYNOPSIS

   use Device::Chip::MAX11200;
   use Future::AsyncAwait;

   my $chip = Device::Chip::MAX11200->new;
   await $chip->mount( Device::Chip::Adapter::...->new );

   await $chip->trigger;

   printf "The reading is %d\n", await $chip->read_adc;

DESCRIPTION

This Device::Chip subclass provides specific communications to a Maxim MAX11200 or MAX11210 chip.

The reader is presumed to be familiar with the general operation of this chip; the documentation here will not attempt to explain or define chip-specific concepts or features, only the use of this module to access them.

METHODS

The following methods documented in an await expression return Future instances.

init

   await $chip->init;

Performs startup self-calibration by setting NOSCG and NOSCO to zero then requesting a calibration cycle.

read_status

   $status = await $chip->read_status;

Returns a HASH reference containing the chip's current status.

   RDY   => 0 | 1
   MSTAT => 0 | 1
   UR    => 0 | 1
   OR    => 0 | 1
   RATE  => 1 | 2.5 | 5 | 10 | 15 | 30 | 60 | 120
   SYSOR => 0 | 1

read_config

   $config = await $chip->read_config;

Returns a HASH reference containing the chip's current configuration.

   SCYCLE => 0 | 1
   FORMAT => "TWOS_COMP" | "OFFSET"
   SIGBUF => 0 | 1
   REFBUF => 0 | 1
   EXTCLK => 0 | 1
   UB     => "UNIPOLAR" | "BIPOLAR"
   LINEF  => "60Hz" | "50Hz"
   NOSCO  => 0 | 1
   NOSCG  => 0 | 1
   NOSYSO => 0 | 1
   NOSYSG => 0 | 1
   DGAIN  => 1 2 4 8 16  # only valid for the MAX11210

change_config

   await $chip->change_config( %changes );

Changes the configuration. Any field names not mentioned will be preserved at their existing values.

selfcal

   await $chip->selfcal;

Requests the chip perform a self-calibration.

syscal_offset

   await $chip->syscal_offset;

Requests the chip perform the offset part of system calibration.

syscal_gain

   await $chip->syscal_gain;

Requests the chip perform the gain part of system calibration.

trigger

   await $chip->trigger( $rate );

Requests the chip perform a conversion of the input level, at the given rate (which must be one of the values specified for the RATE configuration option); defaulting to the value of "default_trigger_rate" if not defined. Once the conversion is complete it can be read using the read_adc method.

default_trigger_rate

   $rate = $chip->default_trigger_rate
   $chip->default_trigger_rate = $new_rate

Lvalue accessor for the default trigger rate if "trigger" is invoked without one. Initialised to 120.

read_adc

   $value = await $chip->read_adc;

Reads the most recent reading from the result register on the tip. This method should be called after a suitable delay after the "trigger" method when in single cycle mode, or at any time when in continuous mode.

The reading is returned directly from the chip as a plain 24-bit integer, either signed or unsigned as per the FORMAT configuration.

read_adc_ratio

   $ratio = await $chip->read_adc_ratio;

Converts a reading obtained by "read_adc" into a ratio between -1 and 1, taking into account the current mode setting of the chip.

write_gpios

   await $chip->write_gpios( $values, $direction );

read_gpios

   $values = await $chip->read_gpios;

Sets or reads the values of the GPIO pins as a 4-bit integer. Bits in the $direction should be high to put the corresponding pin into output mode, or low to put it into input mode.

As an alternative to these methods, see instead "gpio_adapter".

Calibration Registers

   $value = await $chip->read_selfcal_offset;
   $value = await $chip->read_selfcal_gain;
   $value = await $chip->read_syscal_offset;
   $value = await $chip->read_syscal_gain;

   await $chip->write_selfcal_offset( $value );
   await $chip->write_selfcal_gain( $value );
   await $chip->write_syscal_offset( $value );
   await $chip->write_syscal_gain( $value );

Reads or writes the values of the calibration registers, as plain 24-bit integers.

as_gpio_adapter

   $adapter = $chip->as_gpio_adapter

Returns an instance implementing the Device::Chip::Adapter interface, allowing access to the four GPIO pins via the standard adapter API.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>