Skip to content

Add MPSSEChip class for handling communication with MPSSE-supporting devices

Daniel Joseph Antrim requested to merge dantrim/labRemote:add_mppse_chip into devel

Overview

This MR adds two new classes to libDevCom: MPSSEChip and FT232H.h.

The class MPSSEChip essentially wraps the C library libmpsse which handles the communication with the MPSSE devices connected to the host PC over USB. Note that libmpsse is an abstraction over libftdi, and provides methods for handling I2C and SPI communication using libftdi. The idea is that any new device we wish to support in libDevCom that has an MPSSE engine to support PC host-to-device communication, that it's implementation should inherit from MPSSEChip. In this way, the MPSSEChip instance will represent the primary on the serial communication bus that performs reads and writes from/to the secondary devices on the bus.

The idea is that MPSSEChip supports the basic MPSSE communication methods, and those devices inheriting from MPSSEChip implement their specific functionality within their own class methods. For example, an inheriting class would provide specific pin mappings and purpose for the GPIO pins on the MPSSE chip package being used, and implement specific behavior/functions related to those.

The class FT232H is an implementation of an MPSSEChip. Right now it has no methods of its own.

Update of I2CFTDICom

The I2CFTDICom class no longer exposes the C library libmpsse, but instead holds an std::shared_ptr<MPSSEChip> instance that gets set to the specific one in its constructor.

The I2C communication methods I2CFTDICom::write_block and I2CFTDICom::read_block then use the MPSSEChip instance to handle the MPSSE commands.

This fixes the issues referenced in !127 (closed), in which it is noticed that the previous instance of I2CFTDICom prevented interfacing to an I2C bus containing multiple I2C secondary devices since in that case I2CFTDICom represented both the I2C primary (via it's ownership of the MPSSE device) and the I2C secondary (via it's ownership of the I2C secondary bus address).

Example Usage

Here is an example of setting up an FT232H instance, for communication over an I2C bus on which there are multiple (two) I2C secondaries with bus addresses 0x1 and 0x2,

#include "I2CFTDICom.h"
#include "FT232H.h"
...
std::shared_ptr<FT232H> ft232( new FT232H( MPSSEChip::Protocol::I2C, MPSSEChip::Speed::FOUR_HUNDRED_KHZ, MPSSEChip::Endianness::MSBFirst) );
std::unique_ptr<I2CFTDICom> i2c_com0( new I2CFTDICom(ft232, 0x1) );
std::unique_ptr<I2CFTDICom> i2c_com1( new I2CFTDICom(ft232, 0x2) );
...

This would then be followed by using the I2CFTDICom instances for specific devices (e.g. ADCs).

Example Programs

An additional example is added under src/libDevCom/examples/ftdi_adc_example.cpp, which provides a complete example illustrating the usage with AD7998 devices.

The example src/libDevCom/examples/tempsensor_monitor.cpp has also been modified to reflect the updated FTDI interface.

Documentation

Doxygen doc strings are added to the MPSSEChip declaration.

Merge request reports

Loading