17 Oct 2021 23:46:56 UTC
- Distribution: Device-Chip
- Module version: 0.20
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (2)
- Testers (109 / 1 / 35)
- KwaliteeBus factor: 1
- 83.66% Coverage
- License: perl_5
- Perl: v5.26.0
- Activity24 month
- Download (33.94KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionPEVANS Paul Evans
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::Chipsubclasses. 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; await $chip->mount( $adapter );
$chip = Device::Chip->new
Returns a new instance of a chip driver object.
The following methods documented in an
awaitexpression 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 = await $chip->mount( $adapter, %params );
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
%paramswill vary depending on the specific chip in question, and should be documented there.
$chip = await $chip->mount_from_paramstr( $adapter, $paramstr );
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>