|
arduino-emulator
|
Implementation of I2C communication for FTDI FT2232HL using MPSSE mode. More...
#include <HardwareI2C_FTDI.h>
Public Member Functions | |
| HardwareI2C_FTDI (int channel=0) | |
| Constructor for FTDI I2C interface. | |
| ~HardwareI2C_FTDI () | |
| Destructor - closes FTDI connection. | |
| int | available () override |
| Get the number of bytes available for reading. | |
| void | begin () override |
| Initialize I2C as master (same as begin()). | |
| bool | begin (int vendor_id=0x0403, int product_id=0x6010, const char *description=nullptr, const char *serial=nullptr) |
| Initialize the I2C interface. | |
| void | begin (uint8_t address) override |
| Initialize I2C as slave (not supported by FTDI). | |
| void | beginTransmission (uint8_t address) override |
| Begin transmission to an I2C slave device. | |
| void | end () override |
| Close the I2C interface and cleanup resources. | |
| uint8_t | endTransmission (bool stopBit=true) override |
| End transmission and send data to slave device. | |
| uint8_t | endTransmission (void) override |
| End transmission and send data to slave device (with stop condition). | |
| void | flush () override |
| Flush the output buffer (no-op for I2C). | |
| void | onReceive (void(*function)(int)) override |
| Register a function to be called when data is received as a slave. | |
| void | onRequest (void(*function)(void)) override |
| Register a function to be called when master requests data from slave. | |
| operator bool () | |
| Boolean conversion operator. | |
| int | peek () override |
| Peek at the next byte without removing it from buffer. | |
| int | read () override |
| Read a byte from the receive buffer. | |
| size_t | requestFrom (uint8_t address, size_t quantity) override |
| size_t | requestFrom (uint8_t address, size_t quantity, bool stopBit=true) override |
| Request data from an I2C slave device. | |
| void | setClock (uint32_t freq) override |
| Set the I2C clock frequency. | |
| size_t | write (const uint8_t *data, size_t len) override |
| Write multiple bytes to the I2C bus. | |
| size_t | write (uint8_t data) override |
| Write a single byte to the I2C bus. | |
Public Member Functions inherited from arduino::Stream | |
| bool | find (char target) |
| bool | find (const char *target) |
| bool | find (const char *target, size_t length) |
| bool | find (const uint8_t *target) |
| bool | find (const uint8_t *target, size_t length) |
| bool | findUntil (const char *target, const char *terminator) |
| bool | findUntil (const char *target, size_t targetLen, const char *terminate, size_t termLen) |
| bool | findUntil (const uint8_t *target, const char *terminator) |
| bool | findUntil (const uint8_t *target, size_t targetLen, const char *terminate, size_t termLen) |
| unsigned long | getTimeout (void) |
| float | parseFloat (LookaheadMode lookahead=SKIP_ALL, char ignore=NO_IGNORE_CHAR) |
| long | parseInt (LookaheadMode lookahead=SKIP_ALL, char ignore=NO_IGNORE_CHAR) |
| size_t | readBytes (char *buffer, size_t length) |
| size_t | readBytes (uint8_t *buffer, size_t length) |
| size_t | readBytesUntil (char terminator, char *buffer, size_t length) |
| size_t | readBytesUntil (char terminator, uint8_t *buffer, size_t length) |
| String | readString () |
| String | readStringUntil (char terminator) |
| void | setTimeout (unsigned long timeout) |
Public Member Functions inherited from arduino::Print | |
| virtual int | availableForWrite () |
| void | clearWriteError () |
| int | getWriteError () |
| size_t | print (char) |
| size_t | print (const __FlashStringHelper *) |
| size_t | print (const char[]) |
| size_t | print (const Printable &) |
| size_t | print (const String &) |
| size_t | print (double, int=2) |
| size_t | print (int, int=DEC) |
| size_t | print (long long, int=DEC) |
| size_t | print (long, int=DEC) |
| size_t | print (unsigned char, int=DEC) |
| size_t | print (unsigned int, int=DEC) |
| size_t | print (unsigned long long, int=DEC) |
| size_t | print (unsigned long, int=DEC) |
| size_t | println (char) |
| size_t | println (const __FlashStringHelper *) |
| size_t | println (const char[]) |
| size_t | println (const Printable &) |
| size_t | println (const String &s) |
| size_t | println (double, int=2) |
| size_t | println (int, int=DEC) |
| size_t | println (long long, int=DEC) |
| size_t | println (long, int=DEC) |
| size_t | println (unsigned char, int=DEC) |
| size_t | println (unsigned int, int=DEC) |
| size_t | println (unsigned long long, int=DEC) |
| size_t | println (unsigned long, int=DEC) |
| size_t | println (void) |
| size_t | write (const char *buffer, size_t size) |
| size_t | write (const char *str) |
Protected Member Functions | |
| bool | configureMPSSE () |
| Configure FTDI device for I2C MPSSE mode. | |
| uint8_t | receiveByteSendAck (bool send_ack) |
| Receive a byte over I2C and send ACK/NACK. | |
| int | receiveData (uint8_t *data, size_t length) |
| Receive raw data from FTDI device. | |
| bool | sendByteCheckAck (uint8_t data) |
| Send a byte over I2C and check for ACK. | |
| int | sendData (const uint8_t *data, size_t length) |
| Send raw data to FTDI device. | |
| bool | sendRepeatedStart () |
| Send I2C repeated start condition. | |
| bool | sendStart () |
| Send I2C start condition. | |
| bool | sendStop () |
| Send I2C stop condition. | |
| bool | setClockFrequency (uint32_t frequency) |
| Set the I2C clock frequency. | |
| bool | setLineStates (bool sda_state, bool scl_state) |
| Set the state of SDA and SCL lines. | |
Protected Member Functions inherited from arduino::Stream | |
| int | findMulti (struct MultiTarget *targets, int tCount) |
| float | parseFloat (char ignore) |
| long | parseInt (char ignore) |
| int | peekNextDigit (LookaheadMode lookahead, bool detectDecimal) |
| int | timedPeek () |
| int | timedRead () |
Protected Member Functions inherited from arduino::Print | |
| void | setWriteError (int err=1) |
Protected Attributes | |
| uint8_t | current_slave_address = 0 |
| int | ftdi_channel = 0 |
| struct ftdi_context * | ftdi_context = nullptr |
| uint32_t | i2c_clock_frequency = 100000 |
| bool | is_open = false |
| uint8_t | rx_buffer [32] |
| size_t | rx_buffer_index = 0 |
| size_t | rx_buffer_length = 0 |
| uint8_t | tx_buffer [32] |
| size_t | tx_buffer_length = 0 |
Protected Attributes inherited from arduino::Stream | |
| unsigned long | _startMillis |
| unsigned long | _timeout |
Static Protected Attributes | |
| static const uint8_t | I2C_DATA_SHIFT_IN = 0x24 |
| static const uint8_t | I2C_DATA_SHIFT_OUT = 0x11 |
| static const uint8_t | I2C_DATA_SHIFT_OUT_IN = 0x31 |
| static const uint8_t | I2C_GET_DATA_BITS_HIGH_BYTE = 0x83 |
| static const uint8_t | I2C_GET_DATA_BITS_LOW_BYTE = 0x81 |
| static const uint8_t | I2C_SET_DATA_BITS_HIGH_BYTE = 0x82 |
| static const uint8_t | I2C_SET_DATA_BITS_LOW_BYTE = 0x80 |
| static const uint8_t | SCL_BIT = 0 |
| static const uint8_t | SDA_IN_BIT = 2 |
| static const uint8_t | SDA_OUT_BIT = 1 |
Implementation of I2C communication for FTDI FT2232HL using MPSSE mode.
This class provides an interface to the I2C bus on FTDI FT2232HL devices using the Multi-Protocol Synchronous Serial Engine (MPSSE) mode. The FT2232HL can operate in MPSSE mode to provide I2C master functionality.
Pin mapping for I2C on FT2232HL (Channel A):
The class inherits from HardwareI2C and implements all required methods for I2C communication, including device addressing, data transfer, and bus management.
| arduino::HardwareI2C_FTDI::HardwareI2C_FTDI | ( | int | channel = 0 | ) |
Constructor for FTDI I2C interface.
| channel | FTDI channel to use (0 for Channel A, 1 for Channel B) |
Get the number of bytes available for reading.
Implements arduino::Stream.
|
inlineoverridevirtual |
Initialize I2C as master (same as begin()).
Implements arduino::HardwareI2C.
| bool arduino::HardwareI2C_FTDI::begin | ( | int | vendor_id = 0x0403, |
| int | product_id = 0x6010, |
||
| const char * | description = nullptr, |
||
| const char * | serial = nullptr |
||
| ) |
Initialize the I2C 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) |
Initialize I2C as slave (not supported by FTDI).
| address | Slave address (ignored) |
Implements arduino::HardwareI2C.
Begin transmission to an I2C slave device.
| address | 7-bit slave address |
Implements arduino::HardwareI2C.
|
protected |
Configure FTDI device for I2C MPSSE mode.
|
overridevirtual |
Close the I2C interface and cleanup resources.
Implements arduino::HardwareI2C.
End transmission and send data to slave device.
| stopBit | Whether to send stop condition (default: true) |
Implements arduino::HardwareI2C.
End transmission and send data to slave device (with stop condition).
Implements arduino::HardwareI2C.
Flush the output buffer (no-op for I2C).
Reimplemented from arduino::Print.
Register a function to be called when data is received as a slave.
| function | Callback function (not supported by FTDI master-only mode) |
Implements arduino::HardwareI2C.
Register a function to be called when master requests data from slave.
| function | Callback function (not supported by FTDI master-only mode) |
Implements arduino::HardwareI2C.
|
inline |
Boolean conversion operator.
Peek at the next byte without removing it from buffer.
Implements arduino::Stream.
Read a byte from the receive buffer.
Implements arduino::Stream.
Receive a byte over I2C and send ACK/NACK.
| send_ack | Whether to send ACK (true) or NACK (false) |
Receive raw data from FTDI device.
| data | Pointer to receive buffer |
| length | Number of bytes to receive |
Implements arduino::HardwareI2C.
|
overridevirtual |
Request data from an I2C slave device.
| address | 7-bit slave address |
| quantity | Number of bytes to request |
| stopBit | Whether to send stop condition (default: true) |
Implements arduino::HardwareI2C.
Send a byte over I2C and check for ACK.
| data | Byte to send |
Send raw data to FTDI device.
| data | Pointer to data buffer |
| length | Number of bytes to send |
|
protected |
Send I2C repeated start condition.
|
protected |
Send I2C start condition.
|
protected |
Send I2C stop condition.
Set the I2C clock frequency.
| freq | Frequency in Hz (default: 100000 for 100kHz) |
Implements arduino::HardwareI2C.
Set the I2C clock frequency.
| frequency | Clock frequency in Hz |
Set the state of SDA and SCL lines.
| sda_state | State of SDA line (true = high, false = low) |
| scl_state | State of SCL line (true = high, false = low) |
Write multiple bytes to the I2C bus.
| data | Pointer to data buffer |
| len | Number of bytes to write |
Reimplemented from arduino::Print.
Write a single byte to the I2C bus.
| data | Byte to write |
Implements arduino::Print.