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.

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 CS pin, transferring bytes, and deasserting it again.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>