Device::Chip - an abstraction of a hardware chip IO driver
Note: this document is currently under heavy development. Details will be added, changed, and evolved as it progresses. Be warned that currently anything may be changed from one version to the next.
This package describes an interface that classes can use to implement a driver to talk to a specific hardware chip or module. An instance implementing this interface would communicate with the actual hardware device via some instance of the related interface, Device::Chip::Adapter.
The documentation in this file is aimed primarily at users of
Device::Chip subclasses. For more information on authoring such a module, see instead Device::Chip::Authoring.
To actually use a chip driver to talk to a specific piece of hardware that is connected to the computer, an adapter must be supplied. This will be an instance of some class that satisfies the Device::Chip::Adapter interface. The chip driver will use this adapter instance to access the underlying hardware port used to electrically connect to the chip and communicate with it. This is supplied by invoking the "mount" method. For example:
my $chip = Device::Chip::MAX7219->new; my $adapter = Device::Chip::Adapter::FTDI->new; $chip->mount( $adapter )->get;
$chip = Device::Chip->new
Returns a new instance of a chip driver object.
The following methods documented with a trailing call to
->get return Future instances.
This allows them to easily be used as a simple synchronous method by using the trailing "get" in Future call. Alternatively, if the underlying adapter allows a fully asynchronous mode of operation, they can be combined in the usual ways for futures to provide more asynchronous use of the device.
$chip = $chip->mount( $adapter, %params )->get
Supplies the chip driver with the means to actually communicate with the connected device, via some electrical interface connected to the computer.
The parameters given in
%params will vary depending on the specific chip in question, and should be documented there.
$chip = $chip->mount_from_paramstr( $adapter, $paramstr )->get
A variant of "mount" that parses its options from the given string. This string should be a comma-separated list of parameters, where each is given as a name and value separated by equals sign. If there is no equals sign, the value is implied as
1, as a convenience for parameters that are simple boolean flags.
Paul Evans <email@example.com>