|
arduino-emulator
|
Implementation of SPI communication for FTDI FT2232HL using MPSSE mode. More...
#include <HardwareSPI_FTDI.h>
Public Member Functions | |
| HardwareSPI_FTDI (int channel=0) | |
| Constructor for FTDI SPI interface. | |
| ~HardwareSPI_FTDI () override | |
| Destructor - closes FTDI connection. | |
| void | attachInterrupt () override |
| Attach interrupt (not implemented for FTDI). | |
| void | begin () override |
| bool | begin (int vendor_id, int product_id, const char *description=nullptr, const char *serial=nullptr) |
| Initialize the SPI interface. | |
| void | beginTransaction (SPISettings settings) override |
| Begin an SPI transaction with specific settings. | |
| void | detachInterrupt () override |
| Detach interrupt (not implemented for FTDI). | |
| void | end () override |
| Close the SPI interface and cleanup resources. | |
| void | endTransaction (void) override |
| End the current SPI transaction. | |
| void | notUsingInterrupt (int interruptNumber) override |
| Unregister interrupt usage (not implemented for FTDI). | |
| operator bool () | |
| Boolean conversion operator. | |
| uint8_t | transfer (uint8_t data) override |
| Transfer a single byte over SPI. | |
| void | transfer (void *buf, size_t count) override |
| Transfer a buffer of data over SPI. | |
| uint16_t | transfer16 (uint16_t data) override |
| Transfer a 16-bit value over SPI. | |
| void | usingInterrupt (int interruptNumber) override |
| Register interrupt usage (not implemented for FTDI). | |
Protected Member Functions | |
| bool | configureMPSSE () |
| Configure FTDI device for MPSSE mode. | |
| uint8_t | getMPSSECommand (bool read_enable, bool write_enable) |
| Get MPSSE command byte based on current SPI settings. | |
| int | receiveData (uint8_t *data, size_t length) |
| Receive raw data from FTDI device. | |
| int | sendData (const uint8_t *data, size_t length) |
| Send raw data to FTDI device. | |
| bool | setClockFrequency (uint32_t frequency) |
| Set the SPI clock frequency. | |
Protected Attributes | |
| BitOrder | current_bit_order = MSBFIRST |
| uint32_t | current_clock = 1000000 |
| SPIMode | current_mode = SPI_MODE0 |
| int | ftdi_channel = 0 |
| struct ftdi_context * | ftdi_context = nullptr |
| bool | is_open = false |
Static Protected Attributes | |
| static const uint8_t | CMD_BITMODE = 0x02 |
| static const uint8_t | CMD_DO_READ = 0x20 |
| static const uint8_t | CMD_DO_WRITE = 0x10 |
| static const uint8_t | CMD_LSB = 0x08 |
| static const uint8_t | CMD_READ_NEG = 0x04 |
| static const uint8_t | CMD_WRITE_NEG = 0x01 |
| static const uint8_t | CMD_WRITE_TMS = 0x40 |
Implementation of SPI communication for FTDI FT2232HL using MPSSE mode.
This class provides an interface to the SPI bus on FTDI FT2232HL devices using the Multi-Protocol Synchronous Serial Engine (MPSSE) mode. The FT2232HL can operate both channels in MPSSE mode, allowing for high-speed SPI communication.
Pin mapping for SPI on FT2232HL (Channel A):
The class inherits from HardwareSPI and implements all required methods for SPI communication, including data transfer, transaction management, and configuration.
| arduino::HardwareSPI_FTDI::HardwareSPI_FTDI | ( | int | channel = 0 | ) |
Constructor for FTDI SPI interface.
| channel | FTDI channel to use (0 for Channel A, 1 for Channel B) |
|
overridevirtual |
Attach interrupt (not implemented for FTDI).
Implements arduino::HardwareSPI.
|
inlineoverridevirtual |
Implements arduino::HardwareSPI.
| bool arduino::HardwareSPI_FTDI::begin | ( | int | vendor_id, |
| int | product_id, | ||
| const char * | description = nullptr, |
||
| const char * | serial = nullptr |
||
| ) |
Initialize the SPI interface.
| vendor_id | USB vendor ID (default: 0x0403) |
| product_id | USB product ID (default: 0x6010 for FT2232HL) |
| description | Device description string (optional) |
| serial | Device serial number (optional) |
|
overridevirtual |
Begin an SPI transaction with specific settings.
| settings | SPI settings (clock, bit order, mode) |
Implements arduino::HardwareSPI.
|
protected |
Configure FTDI device for MPSSE mode.
|
overridevirtual |
Detach interrupt (not implemented for FTDI).
Implements arduino::HardwareSPI.
|
overridevirtual |
Close the SPI interface and cleanup resources.
Implements arduino::HardwareSPI.
End the current SPI transaction.
Implements arduino::HardwareSPI.
|
protected |
Get MPSSE command byte based on current SPI settings.
| read_enable | Enable reading data |
| write_enable | Enable writing data |
Unregister interrupt usage (not implemented for FTDI).
| interruptNumber | Interrupt number (ignored) |
Implements arduino::HardwareSPI.
|
inline |
Boolean conversion operator.
Receive raw data from FTDI device.
| data | Pointer to receive buffer |
| length | Number of bytes to receive |
Send raw data to FTDI device.
| data | Pointer to data buffer |
| length | Number of bytes to send |
Set the SPI clock frequency.
| frequency | Clock frequency in Hz |
Transfer a single byte over SPI.
| data | Byte to send |
Implements arduino::HardwareSPI.
Transfer a buffer of data over SPI.
| buf | Buffer containing data to send (will be overwritten with received data) |
| count | Number of bytes to transfer |
Implements arduino::HardwareSPI.
Transfer a 16-bit value over SPI.
| data | 16-bit value to send |
Implements arduino::HardwareSPI.
Register interrupt usage (not implemented for FTDI).
| interruptNumber | Interrupt number (ignored) |
Implements arduino::HardwareSPI.