Skip to content

Latest commit

 

History

History
322 lines (206 loc) · 7.92 KB

FtdiI2cBus.rst

File metadata and controls

322 lines (206 loc) · 7.92 KB

FtdiI2cBus

Description

The FtdiI2cBus object is an I2cBus <object_I2cBus> implementation to communicate with an FT232H-based IC2 bus via USB. In addition to reading and writing to the I2C bus it allows controlling the GPIO lines of the FT232H chip.

› Inherits

I2cBus <object_I2cBus>

Overview

Properties

  • channel <property_FtdiI2cBus_channel>
  • error <property_FtdiI2cBus_error>
  • errorString <property_FtdiI2cBus_errorString>
  • gpioPinStates <property_FtdiI2cBus_gpioPinStates>
  • latency <property_FtdiI2cBus_latency>
  • useFastOperations <property_FtdiI2cBus_useFastOperations>
  • I2cBus.devices <property_I2cBus_devices>
  • I2cBus.speed <property_I2cBus_speed>
  • Object.objectId <property_Object_objectId>
  • Object.parent <property_Object_parent>

Methods

  • pollGpioPinStates() <method_FtdiI2cBus_pollGpioPinStates>
  • readGpioPin() <method_FtdiI2cBus_readGpioPin>
  • writeGpioPin() <method_FtdiI2cBus_writeGpioPin>
  • Object.deserializeProperties() <method_Object_deserializeProperties>
  • Object.fromJson() <method_Object_fromJson>
  • Object.serializeProperties() <method_Object_serializeProperties>
  • Object.toJson() <method_Object_toJson>

Signals

  • errorOccurred() <signal_FtdiI2cBus_errorOccurred>
  • I2cBus.devicesDataChanged() <signal_I2cBus_devicesDataChanged>
  • Object.completed() <signal_Object_completed>

Enumerations

  • Error <enum_FtdiI2cBus_Error>

Properties

single: channel

channel

This property holds the I2C channel to operate on. Usually only one device with one channel is connected so the default value can be used.

› Type

UnsignedInteger

› Default

0

› Signal

channelChanged()

› Attributes

Writable

single: error

error

This property holds the most recently occurred error or FtdiI2cBus.NoError <enumitem_FtdiI2cBus_NoError> if no error occurred. If the same error occurs multiple times this property does not change. Use the errorOccurred() <signal_FtdiI2cBus_errorOccurred> signal to detect multiple occurrences of the same error.

› Type

Error <enum_FtdiI2cBus_Error>

› Signal

errorChanged()

› Attributes

Readonly

single: errorString

errorString

This property holds the current human readable error string corresponding to the current value in the error <property_FtdiI2cBus_error> property. It may include additional information such as failure reasons or locations.

› Type

String

› Signal

errorStringChanged()

› Attributes

Readonly

single: gpioPinStates

gpioPinStates

This property holds the states of the 12 GPIOs pins while each pin is represented by one bit.

› Type

UnsignedInteger

› Signal

gpioPinStatesChanged()

› Attributes

Readonly, Requires Polling <object_Polling>

single: latency

latency

This property holds the value for the FTDI latency timer in the range of [1..255]. The latency timer inside the FTDI device is used to flush small transmit buffers. Without this timer the host would not receive any data until the transmit buffer of the device is full (64 bytes). This allows the device to be better optimized for protocols requiring faster response times from short data packets.

› Type

UnsignedInteger

› Default

16

› Signal

latencyChanged()

› Attributes

Writable

single: useFastOperations

useFastOperations

This property holds whether to use MPSSE fast read/write operations. Disable if you encounter communication problems.

› Type

Boolean

› Default

true

› Signal

useFastOperationsChanged()

› Attributes

Writable

Methods

single: pollGpioPinStates

pollGpioPinStates()

This method polls the gpioPinStates <property_FtdiI2cBus_gpioPinStates> property. It is called automatically when using a Polling <object_Polling> property modifier on this property and usually does not have to be called manually.

single: readGpioPin

readGpioPin(SignedInteger pin)

This method reads the specified GPIO pin. This method is provided for convenience only. Consider a declarative approach by polling and evaluating the gpioPinStates <property_FtdiI2cBus_gpioPinStates> property.

› Returns

Boolean

single: writeGpioPin

writeGpioPin(SignedInteger pin, Boolean state)

This method sets the specified GPIO pin to the specified state.

› Returns

Boolean

Signals

single: errorOccurred

errorOccurred()

This signal is emitted whenever an error has occurred, regardless of whether the error <property_FtdiI2cBus_error> property has changed or not. In contrast to the change notification signal of the error <property_FtdiI2cBus_error> property this signal is also emitted several times if a certain error occurs several times in succession.

Enumerations

single: Error

Error

This enumeration describes all errors which can occur in FtdiI2cBus objects. The most recently occurred error is stored in the error <property_FtdiI2cBus_error> property.

single: FtdiI2cBus.NoError

single: FtdiI2cBus.DeviceOpenError

single: FtdiI2cBus.ReadError

single: FtdiI2cBus.WriteError

single: FtdiI2cBus.GpioReadError

single: FtdiI2cBus.GpioWriteError

Name Value Description
FtdiI2cBus.NoError 0 No error occurred or was detected.
FtdiI2cBus.DeviceOpenError 1 Device could not be opened.
FtdiI2cBus.ReadError 2 Failed to read the specified number of bytes from configured address.
FtdiI2cBus.WriteError 3 Failed to write the specified number of bytes to configured address.
FtdiI2cBus.GpioReadError 4 Failed to read GPIO states.
FtdiI2cBus.GpioWriteError 5 Failed to write GPIO states.

Example

import InCore.Foundation 2.5
import InCore.IO 2.5

Application {
    FtdiI2cBus {
        Polling on gpioPinStates { }

        // read lower 8 GPIO channels
        onGpioPinStatesChanged: console.log("GPIO 1-8:", gpioPinStates & 0xff)

        // switch on LED attached to GPIO 13
        onCompleted:  writeGpioPin(13, 1)
    }
}