Python wrapper around libFT4222.
Project description
python-ft4222
The FT4222H is a High/Full Speed USB2.0-to-Quad SPI/I2C device controller. This project provides (incomplete) python binding to LibFT4222 (user guide). It provides a similar api than LibFT4222 does.
The complete documentation can be found here
Example
I2C Master
import ft4222
import ft4222.I2CMaster
# list devices
nbDev = ft4222.createDeviceInfoList()
for i in range(nbDev):
print(ft4222.getDeviceInfoDetail(i, False))
# open device with default description 'FT4222 A'
dev = ft4222.openByDescription('FT4222 A')
# init i2c master, clock speed 100kHz
dev.i2cMaster_Init(100000)
# do a i2c transfers where full control is required
slave = 1 # address
# read one byte, don't stop
data = dev.i2cMaster_ReadEx(slave, ft4222.I2CMaster.Flag.REPEATED_START, 1)[0]
# read another 5 bytes
data += dev.i2cMaster_ReadEx(slave, ft4222.I2CMaster.Flag.NONE, 5)
# another byte, than stop
data += dev.i2cMaster_ReadEx(slave, ft4222.I2CMaster.Flag.STOP, 1)
GPIO
import time
import ft4222
from ft4222.GPIO import Dir, Port, Output
# open device with default description 'FT4222 A'
dev = ft4222.openByDescription('FT4222 A')
# use GPIO2 as gpio (not suspend out)
dev.setSuspendOut(False)
# use GPIO3 as gpio (not wakeup)
dev.setWakeUpInterrupt(False)
# init GPIO2 as output
dev.gpio_Init(gpio2 = Dir.OUTPUT)
# generate a square wave signal with GPIO2
while True:
dev.gpio_Write(Port.P2, output)
output = not output
time.sleep(0.1)
SPI Master and GPIO
The gpio used in this example indicate the duration of the whole spi transfer and is not used as chip/slave select.
import ft4222
from ft4222.SPIMaster import Mode, Clock, Cpha, Cpol, SlaveSelect
from ft4222.GPIO import Port, Dir
from time import sleep
# open 'device' with default description 'FT4222 A'
devA = ft4222.openByDescription('FT4222 A')
# and the second 'device' on the same chip
devB = ft4222.openByDescription('FT4222 B')
# init spi master
devA.spiMaster_Init(Mode.SINGLE, Clock.DIV_8, Cpha.CLK_LEADING, Cpol.IDLE_LOW, SlaveSelect.SS0)
# also use gpio
devB.gpio_Init(gpio0 = Dir.OUTPUT)
# generate data to send
data = bytes([x for x in range(256)]*4)
# set port0 1 (-> note this is *not* the spi chip select, the chip select (SS0) is generated by the spi core)
devB.gpio_Write(Port.P0, 1)
for _ in range(3)
# write data in a single write
devA.spiMaster_SingleWrite(data, True)
# wait a short while
sleep(0.5)
# set port0 0
devB.gpio_Write(Port.P0, 1)
Accessrights
Under Linux, the usb device is normally not accessibly by a normal user, therefor
a udev rule is required. Create or extend /etc/udev/rules.d/99-ftdi.rules
to
contain the following text:
# FTDI's ft4222 USB-I2C Adapter
SUBSYSTEM=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="601c", GROUP="plugdev", MODE="0666"
Requirements
Windows
MSVCR100.dll/MSVCP100.dll from Microsoft Visual C++ 2010 Redistributable Package need to be installed. Today, on most systems, these DLLs (or the package) should already be installed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for ft4222-1.6.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ba637e9c43c7aaa82915b06c4098ac885f2ae45152b1f01584307b8e6e5b005 |
|
MD5 | 313c9358e1f9d1e2248f7b8446dc4743 |
|
BLAKE2b-256 | 34e91b7413edffe98adc50c728225b874a0a2c4f8c618e152d8c75b8e79446b7 |
Hashes for ft4222-1.6.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f242776c497d49f0533c643138375a59fe1745c159e43ec55845fe59c1f17020 |
|
MD5 | fcb0abddf4f786d0181080428a011282 |
|
BLAKE2b-256 | 09a0ec82952bcf00d08d88d8eef7e3441789cea5738956b174283e2ba048c443 |
Hashes for ft4222-1.6.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea7fdf9f5757e981445bbf80669f4f059912963f5718d16736c0f2b341a05610 |
|
MD5 | 74227a9b2cbe90a854ccdad1dd0d06aa |
|
BLAKE2b-256 | 563e1b9b06446f0130679a50beecb78bee1cac7bd6632009c9d6764461ee5ded |
Hashes for ft4222-1.6.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37696c46340064e7518e4d77c8f8b044d72af26850f2e3370369201dd44b08b9 |
|
MD5 | 66ae0710bd141bb0f028cfbb01298565 |
|
BLAKE2b-256 | 35ecf0599c872170cabf65c3c0e2321ed06f30ab37690a2beb87549f78dea8c4 |
Hashes for ft4222-1.6.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb9752990913ee327ebf1279f4a4847b54cacbf95aa920d24f07cb687a77572b |
|
MD5 | 87674fa4eab073cd22a592ba306a991f |
|
BLAKE2b-256 | 948786489a5628386086b31b86253cd44ff8d8d782ec1da65002fa85ef16736d |
Hashes for ft4222-1.6.0-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 937124275e50adc87213fa3bda52e3ac08348454eee21b23e23ce4afd656035b |
|
MD5 | b4e9d49c41536c4ffce3b272538106e4 |
|
BLAKE2b-256 | 8d36e8cd8297888334f83cf7b36047c7d993b5c83b91153979f4f16777846b37 |
Hashes for ft4222-1.6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 886f3b53bad1dc238a3d6e5105b6d7442244ea854afea38daf84529491ad6e3d |
|
MD5 | a58c86b0828bf6768ceae0b5803c99c0 |
|
BLAKE2b-256 | ccf3058660fae276de636d5ed6bf399fdd186b9ff21cff0ff911b858a827a632 |
Hashes for ft4222-1.6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 719ec8f9c05636d8306a64f8f6f86dd9ec27d80afb3fc07e7d0b01c9b3d83d1e |
|
MD5 | e765ec956d42fbb86e1dff5bdf050f3b |
|
BLAKE2b-256 | 39d355d992ed90b3ffc3df59deec52a91e5cd07aad17a5821056e8b61799cef3 |
Hashes for ft4222-1.6.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1279115892441e4a2ab468429e5003c72f47423daa4d7179c0da4af3522c056a |
|
MD5 | 38bd10e36879928c6c767969b8d6481f |
|
BLAKE2b-256 | 8d273f2de224708bbed73d77f7a1022f0361cde72bec17fb7c2d1733e7785d03 |
Hashes for ft4222-1.6.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 324d6330d501bf6f7746aa1b81f9540a2b385e9318bd4e6e4f744d7107f90c67 |
|
MD5 | 201a814bf46e62a126c85b9d95a5f604 |
|
BLAKE2b-256 | 8929dca1b556c12686d2f8cb9dd129b81076a731cba5bfab9b5281d9b8cdeece |
Hashes for ft4222-1.6.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c713b6527513a77e674a6db60d97f67b18ce9f85727168ecbeef82557f2b2d1 |
|
MD5 | 10b99f2b7b5b62650f301d4e1c838d7c |
|
BLAKE2b-256 | 704b3ed3c75e244e96aced60fff8055f2769fbd2f07b366c8c3a4b09864a031f |
Hashes for ft4222-1.6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64c80402e19ada10f142cf9d5f5b343a121689b94dfc31fafc7864db13ac7f79 |
|
MD5 | 2cde2fc6f7a175b3a9e607a0e9199bf1 |
|
BLAKE2b-256 | 52e5cea0884e81a02b36612191837663ed84cce085ec8768f3809a5a2ccf4f29 |
Hashes for ft4222-1.6.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 395596fd03120015b7a049928ba31983f7e71596bcdb85bd78eff4293e955266 |
|
MD5 | 2672549d626ab4a6706565285414763f |
|
BLAKE2b-256 | f485e2fc6816bad45309f12fd570a072b1806130f533f140b1d41b178a933ea8 |
Hashes for ft4222-1.6.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4c8309bbc2d0cf2704dd8737bcf2a6ae27284f7cf45746e79d3dbd4810e0cb3 |
|
MD5 | 47b276f3d37467af82fb53807001674a |
|
BLAKE2b-256 | a6298a6fa3a7469cf4ebebb271c50c260ede6475aaa60895ea1040a3c15ab210 |
Hashes for ft4222-1.6.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31976a15a7cd649814887e3887480f3f625e82e7e2d354f33d582a0faf4c7689 |
|
MD5 | 38ab2d1b2906b96648e78fe46198dd2b |
|
BLAKE2b-256 | be467c9e35c8ab45ae09210ceec53f0a0a2b0a26cf45f734506ab0e9812f8ab3 |
Hashes for ft4222-1.6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a91689f9e44c6a8afedb6e5a11ba70d0c661e879607fd8635c76ebaa503cd90 |
|
MD5 | 196c5ab4140d36671cfed221c2634a64 |
|
BLAKE2b-256 | c997838f406972f353c079b505a4a07725f0ef51b14c90c2989a21f1daa59986 |
Hashes for ft4222-1.6.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06419df94566e5e62358f7d68055fd4155b916646ead2c479e75b964548714e3 |
|
MD5 | cb14e1ba8606f945ef30f096e511ba0e |
|
BLAKE2b-256 | f5961b418926b124da91d9a7daa9a6e653b0cd598f950bbd95579a268f4df7e0 |
Hashes for ft4222-1.6.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eeb1f8cf04262e2bcdaf159a767148a61ef91aa8b86950ae883bb8ba8f0e82da |
|
MD5 | 1e4a01e09cb0f36dc670a9b45b99991c |
|
BLAKE2b-256 | fcb0d03c5dfe3cdc0dd41b934f44813823c80931f0df2ec09d4c0c8b2656bb01 |
Hashes for ft4222-1.6.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4d6d21e8e00b9c5aabaff48489973cf45452cb88a9d6946eaa6aea1d48c0794 |
|
MD5 | af6d5b325f49d334dc6e02713e137e8f |
|
BLAKE2b-256 | 5fc490e57214d4fe0b30eabf8b0a36e6dd36c664e9a4f81d3fad557c56d4778b |
Hashes for ft4222-1.6.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3aae2cbd0a15f7dd9506971f32ab67dcf192c24b012258ccf2e0daeb099d8e5 |
|
MD5 | e3402c7280a87f36658ab599bd792ffe |
|
BLAKE2b-256 | caafadf9a9e8b56a9ff52f8b71358e0921c6ac5c95827a4b794a2f4278198a69 |
Hashes for ft4222-1.6.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de38894f69cd0253a4b683612006912c5d98fae94f07f910650ab5027dc3df8e |
|
MD5 | ec12975e43b280ecbe0efc9bb358443c |
|
BLAKE2b-256 | b61e84ff47c207418b665637a4027328fdf0e535690aea6655d6184fb1f18886 |
Hashes for ft4222-1.6.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0673a1420bd10b3dd782d307c60516bcd4ff24f7c27661b319c781e8a0618df |
|
MD5 | bc8966f4af190696ef913431e481c171 |
|
BLAKE2b-256 | 6bc89c58e7529198231b230aa3bc5cef6034edb30e8851dd9989e5dbfed06bc7 |
Hashes for ft4222-1.6.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dff18e3d95027fb7407748d9a92eece9a2e88c3f7521be59fc848fe32a3780f |
|
MD5 | b26938c7024bcf3b100960d5d4814d60 |
|
BLAKE2b-256 | e5d97215c0a1975e3bb89d2ddabaeb7b9d3fe6acd313d25f384dabe2a2b64bb9 |
Hashes for ft4222-1.6.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 376ddba0e44a24237d926bc28a519ef7877174726629c3335529f548a829e857 |
|
MD5 | 2475cf68c74cde9477306e21df0ce49f |
|
BLAKE2b-256 | 6138752253e1d4331d470825a38d7c19565577cd688bc75ac34e366c4df1785c |
Hashes for ft4222-1.6.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4b3ced3e5603f6bb22fcfcf9567a95ec47a93dd453a911e438c02d665bf657c |
|
MD5 | 43a38e0c30fb43965c8f9f14844ddb4d |
|
BLAKE2b-256 | 8b1cc8bba803a0dff13490f88ad74482f2b745b9eb0e31e9d19e242eac0d1b5c |
Hashes for ft4222-1.6.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.manylinux_2_24_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c28fb526ec98afefebb24f0e333bfef0def3ca46f8b4f84712c5e6e3c7e0fe9c |
|
MD5 | 0d92d77862097f9dc2ef056f869da18b |
|
BLAKE2b-256 | c59b1255d19bece85a3ecbfd4e14b823cb16ea5f3596dc02f3f4aa31eaa97691 |