NAME
Device::FTDI::SPI
- use an FTDI chip to talk the SPI protocol
DESCRIPTION
This subclass of Device::FTDI::MPSSE provides helpers around the basic MPSSE to fully implement the SPI protocol.
CONSTRUCTOR
new
$spi = Device::FTDI::SPI->new( %args )
In addition to the arguments taken by "new" in Device::FTDI::MPSSE, this constructor also accepts:
- mode => INT
-
The required SPI mode. Should be 0, 1, 2, or 3.
- clock_rate => INT
-
Sets the initial value of the bit clock rate; as per "set_clock_rate".
METHODS
Any of the following methods documented with a trailing ->get
call return Future instances.
set_clock_rate
$i2c->set_clock_rate( $rate )->get
Sets the clock rate for data transfers, in units of bits per second.
set_spi_mode
$spi->set_spi_mode( $mode )->get
Sets the current SPI mode. This will affect the clock sense and the idle state of the CLK
pin.
assert_ss
release_ss
$spi->assert_ss->get
$spi->release_ss->get
Set the SS
GPIO pin to LOW or HIGH state respectively. Normally these methods would not be required, as "read", "write" and "readwrite" perform these steps automatically. However, they may be useful when combined with the lower-level "readwrite_bytes" in Device::FTDI::MPSSE method to split an SPI transaction over multiple method calls.
write
$spi->write( $bytes )->get
read
$bytes = $spi->read( $len )->get;
readwrite
$bytes_in = $spi->readwrite( $bytes_out )->get;
Performs a full SPI write, or read-and-write operation, consisting of asserting the SS
pin, transferring bytes, and deasserting it again.
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>