Browse Source

Implementation of I2C-master on an FT2232 for debugging FPGAs

master
Ivan Olenichev 3 years ago
parent
commit
a91958a068
  1. 36
      ft232_qt/ft232_qt.pro
  2. 336
      ft232_qt/ft232_qt.pro.user
  3. 216
      ft232_qt/ft232_reign.cpp
  4. 60
      ft232_qt/ft232_reign.h
  5. 276
      ft232_qt/ft232_reign.ui
  6. 59
      ft232_qt/ftdi_common.cpp
  7. 144
      ft232_qt/i2c.c
  8. 19
      ft232_qt/i2c.h
  9. 11
      ft232_qt/main.cpp

36
ft232_qt/ft232_qt.pro

@ -0,0 +1,36 @@
#-------------------------------------------------
#
# Project created by QtCreator 2018-09-26T00:17:40
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = ft232_qt
TEMPLATE = app
SOURCES += main.cpp\
ft232_reign.cpp \
i2c.c
HEADERS += ft232_reign.h \
i2c.h
FORMS += ft232_reign.ui
unix:!macx: LIBS += -L$$PWD/../libmpsse-1.3/src/ -lmpsse
INCLUDEPATH += $$PWD/../libmpsse-1.3/src
DEPENDPATH += $$PWD/../libmpsse-1.3/src
unix:!macx: PRE_TARGETDEPS += $$PWD/../libmpsse-1.3/src/libmpsse.a
unix:!macx: LIBS += -L$$PWD/../libftdi1/src/ -lftdi
INCLUDEPATH += $$PWD/../libftdi1/src
DEPENDPATH += $$PWD/../libftdi1/src
unix:!macx: PRE_TARGETDEPS += $$PWD/../libftdi1/src/libftdi.so

336
ft232_qt/ft232_qt.pro.user

@ -0,0 +1,336 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.0.2, 2018-11-01T21:22:44. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{9f5795d5-b622-4dd0-a24e-5a8fef00d441}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap"/>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{25311bd8-1f8c-4ae8-a25e-4d0e50893f82}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/t-bird/i2c_keyboard/ft232_qt/build-ft232_qt-Desktop-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Очистка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Отладка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/t-bird/i2c_keyboard/ft232_qt/build-ft232_qt-Desktop-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Очистка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Выпуск</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/t-bird/i2c_keyboard/ft232_qt/build-ft232_qt-Desktop-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Сборка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
<value type="QString">-w</value>
<value type="QString">-r</value>
</valuelist>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Очистка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Профилирование</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Установка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Локальная установка</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">ft232_qt</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/t-bird/i2c_keyboard/ft232_qt/ft232_qt/ft232_qt.pro</value>
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">ft232_qt.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/t-bird/i2c_keyboard/ft232_qt/build-ft232_qt-Desktop-Debug</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">18</value>
</data>
<data>
<variable>Version</variable>
<value type="int">18</value>
</data>
</qtcreator>

216
ft232_qt/ft232_reign.cpp

@ -0,0 +1,216 @@
#include "ft232_reign.h"
#include "ui_ft232_reign.h"
#include <i2c.h>
#include <qdatetime.h>
#include <qthread.h>
#define FTDI_ERROR(info) { toLog(info); return; }
QString last_write_data = "00";
QString hex_values[16] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" };
int tmr_on = 0;
ft232_reign::ft232_reign(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::ft232_reign)
{
ui->setupUi(this);
log = "";
tmr = new QTimer();
tmr->setInterval(500);
tmr->setSingleShot(false);
tmr->start();
QObject::connect(tmr, SIGNAL(timeout ()), this, SLOT(tmr_fxn()));
}
ft232_reign::~ft232_reign()
{
i2c_close();
delete ui;
}
void ft232_reign::on_pushButton_clicked()
{
//i2c_example();
//char desc[1024], serial[1024];
//i2c_open_index_port (0, desc, serial);
//if (bitbang_open (0, 1, 0) == 0)
// tmr_on = 1;
}
void ft232_reign::on_pushButton_2_clicked()
{
//i2c_example();
//bitbang_close();
//tmr_on = 0;
}
void ft232_reign::tmr_fxn()
{
//if (tmr_on == 0)
// return;
//char rd[10];
//bitbang_read(rd);
//qDebug ("Reading from FTDI bitbang: %x, %x, %x, %x", rd[0], rd[1], rd[2], rd[3]);
}
void ft232_reign::toLog(QString info)
{
log = QTime::currentTime().toString("HH:mm:ss") + "\t" + info + "\n" + log;
ui->log->setText("LOG\n\n" + log);
}
QString ft232_reign::char_to_str(char *data, int len)
{
QString str = "";
for (int i = 0; i < len; i++) {
if (data[i] == 0x00)
break;
str = str + data[i];
}
return str;
}
void ft232_reign::on_clr_log_clicked()
{
log = "";
ui->log->setText("LOG\n\n");
}
void ft232_reign::on_connect_clicked()
{
int result = 0;
if (ui->connect->text() == "Connect") {
res = i2c_open(ui->i2c_clk->value(), ui->i2c_index->value(), (ui->i2c_port->currentIndex() + 1));
qDebug ("Connecting to FTDI device, clk %d, index %d, port %d. RETURN %d", ui->i2c_clk->value(), ui->i2c_index->value(), (ui->i2c_port->currentIndex() + 1), res);
if (res == 0) {
ui->connect->setText("Disconnect");
toLog ("CONNECTING TO DEVICE OK, " + ui->i2c_port->currentText() + ", CLK " + QString::number(ui->i2c_clk->value()) + ", INDEX " + QString::number(ui->i2c_index->value()));
}
else {
FTDI_ERROR("ABORT_OPEN_CHANNEL, ERROR " + QString::number(res));
}
}
else {
i2c_close();
ui->connect->setText("Connect");
toLog ("DEVICE DISCONNECTED");
}
}
void ft232_reign::on_i2c_length_valueChanged(int arg1)
{
QString mask = "HH"; int last_mask_len; QString last_data;
for (int i = 1; i < arg1; i++)
mask = mask + " HH";
last_mask_len = ui->i2c_write_data->inputMask().length();
last_data = ui->i2c_write_data->text();
ui->i2c_write_data->setInputMask(mask);
if (last_mask_len < mask.length()) {
for (int i = 0; i < ((mask.length() - last_mask_len) / 3); i++)
last_data = last_data + " 00";
ui->i2c_write_data->setText(last_data);
}
}
void ft232_reign::on_i2c_write_data_textChanged(const QString &arg1)
{
if (arg1.length() != (3 * ui->i2c_length->value() - 1))
ui->i2c_write_data->setText(last_write_data);
else
last_write_data = ui->i2c_write_data->text();
}
void ft232_reign::on_i2c_write_clicked()
{
QString str = ui->i2c_write_data->text();
for (int i = 0; i < ui->i2c_length->value(); i++)
data[i] = str.mid(i*3, 2).toInt(NULL, 16);
res = i2c_tx (ui->i2c_adress->value(), (char*)data, ui->i2c_length->value(), 1, 1); //res = I2C_DeviceWrite(reign, ui->i2c_adress->value(), ui->i2c_length->value(), data, &transfer_len, 0x07);
if (res == 10/*FT_DEVICE_NOT_FOUND*/) {
toLog ("I2C DEVICE WITH ADRESS 0x" + QString::number(ui->i2c_adress->value(), 16) + " NOT ASK (TX)");
return;
}
if (res != 0/*FT_OK*/)
FTDI_ERROR("ABORT_TRANSMIT, ERROR " + QString::number(res));
str = "I2C TRANSMIT TO 0x" + QString::number(ui->i2c_adress->value(), 16) + " " + QString::number(ui->i2c_length->value()) + " BYTES:\t";
for (int i = 0; i < ui->i2c_length->value(); i++)
str = str + " " + QString::number(data[i], 16);
toLog(str);
}
void ft232_reign::on_i2c_read_clicked()
{
QString str;
res = i2c_rx (ui->i2c_adress->value(), (char*)data, ui->i2c_length->value(), 1, 1); //res = I2C_DeviceRead(reign, ui->i2c_adress->value(), ui->i2c_length->value(), data, &transfer_len, 0x0B);
if (res == 10/*FT_DEVICE_NOT_FOUND*/) {
toLog ("I2C DEVICE WITH ADRESS 0x" + QString::number(ui->i2c_adress->value(), 16) + " NOT ASK (RX)");
return;
}
if (res != 0/*FT_OK*/)
FTDI_ERROR("ABORT_RECEIVE, ERROR " + QString::number(res));
str = "I2C RECEIVE FROM 0x" + QString::number(ui->i2c_adress->value(), 16) + " " + QString::number(ui->i2c_length->value()) + " BYTES:\t";
for (int i = 0; i < ui->i2c_length->value(); i++)
str = str + " " + QString::number(data[i], 16);
toLog(str);
}
void ft232_reign::on_read_i2c_hid_desc_clicked()
{
toLog ("READING I2C HID DESCRIPTOR");
ui->i2c_length->setValue(2);
ui->i2c_write_data->setText("01 00");
on_i2c_write_clicked();
QThread::msleep(100);
ui->i2c_length->setValue(30);
on_i2c_read_clicked();
for (int i = 0; i < 30; i++) {
i2c_hid_descr[i] = data[i];
}
toLog ("------------------------------------------");
}
void ft232_reign::on_read_hid_report_desc_clicked()
{
toLog ("READING HID REPORT DESCRIPTOR");
ui->i2c_length->setValue(2);
QString reg = hex_values[(i2c_hid_descr[6]>>4) & 0xF] + hex_values[(i2c_hid_descr[6]>>0) & 0xF] + " " + \
hex_values[(i2c_hid_descr[7]>>4) & 0xF] + hex_values[(i2c_hid_descr[7]>>0) & 0xF];
ui->i2c_write_data->setText(reg);
on_i2c_write_clicked();
QThread::msleep(100);
ui->i2c_length->setValue((i2c_hid_descr[4] & 0xFF) + (i2c_hid_descr[5] & 0xFF) * 256);
on_i2c_read_clicked();
toLog ("------------------------------------------");
}
void ft232_reign::on_read_input_report_int_clicked()
{
toLog ("READING INPUT REPORT (INTERRUPT MODE)");
ui->i2c_length->setValue((i2c_hid_descr[10] & 0xFF) + (i2c_hid_descr[11] & 0xFF) * 256);
on_i2c_read_clicked();
toLog ("------------------------------------------");
}
void ft232_reign::on_read_input_report_cmd_clicked()
{
toLog ("READING INPUT REPORT (COMMAND MODE)");
ui->i2c_length->setValue(6);
QString reg = hex_values[(i2c_hid_descr[16]>>4) & 0xF] + hex_values[(i2c_hid_descr[16]>>0) & 0xF] + " " + \
hex_values[(i2c_hid_descr[17]>>4) & 0xF] + hex_values[(i2c_hid_descr[17]>>0) & 0xF];
reg = reg + " 10 02 "; // COMMAND OPCODE - 2 (INPUT REPORT REQUEST), TYPE 01 - INPUT
reg = reg + hex_values[(i2c_hid_descr[18]>>4) & 0xF] + hex_values[(i2c_hid_descr[18]>>0) & 0xF] + " " + \
hex_values[(i2c_hid_descr[19]>>4) & 0xF] + hex_values[(i2c_hid_descr[19]>>0) & 0xF];
ui->i2c_write_data->setText(reg);
on_i2c_write_clicked();
QThread::msleep(100);
ui->i2c_length->setValue((i2c_hid_descr[10] & 0xFF) + (i2c_hid_descr[11] & 0xFF) * 256);
on_i2c_read_clicked();
toLog ("------------------------------------------");
}

60
ft232_qt/ft232_reign.h

@ -0,0 +1,60 @@
#ifndef FT232_REIGN_H
#define FT232_REIGN_H
#include <QMainWindow>
#include <qtimer.h>
namespace Ui {
class ft232_reign;
}
class ft232_reign : public QMainWindow
{
Q_OBJECT
public:
explicit ft232_reign(QWidget *parent = 0);
~ft232_reign();
public slots:
void tmr_fxn();
private slots:
void toLog(QString info);
QString char_to_str(char *data, int len);
void on_clr_log_clicked();
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void on_connect_clicked();
void on_i2c_length_valueChanged(int arg1);
void on_i2c_write_data_textChanged(const QString &arg1);
void on_i2c_write_clicked();
void on_i2c_read_clicked();
void on_read_i2c_hid_desc_clicked();
void on_read_hid_report_desc_clicked();
void on_read_input_report_int_clicked();
void on_read_input_report_cmd_clicked();
private:
Ui::ft232_reign *ui;
QString log;
int res;
unsigned char data[1001];
unsigned char i2c_hid_descr[30];
QTimer *tmr;
};
#endif // FT232_REIGN_H

276
ft232_qt/ft232_reign.ui

@ -0,0 +1,276 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ft232_reign</class>
<widget class="QMainWindow" name="ft232_reign">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>627</width>
<height>671</height>
</rect>
</property>
<property name="windowTitle">
<string>ft232_reign</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QSpinBox" name="i2c_index">
<property name="geometry">
<rect>
<x>280</x>
<y>0</y>
<width>81</width>
<height>27</height>
</rect>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Device index.&lt;/p&gt;&lt;p&gt;If only one device is connected, set zero.&lt;/p&gt;&lt;p&gt;If two or more devices are connected, index can be zero or non zero.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="prefix">
<string>Index </string>
</property>
<property name="maximum">
<number>10</number>
</property>
</widget>
<widget class="QSpinBox" name="i2c_clk">
<property name="geometry">
<rect>
<x>90</x>
<y>0</y>
<width>181</width>
<height>27</height>
</rect>
</property>
<property name="suffix">
<string> Hz</string>
</property>
<property name="prefix">
<string>Clockrate </string>
</property>
<property name="maximum">
<number>1000000</number>
</property>
<property name="value">
<number>100000</number>
</property>
<property name="displayIntegerBase">
<number>10</number>
</property>
</widget>
<widget class="QComboBox" name="i2c_port">
<property name="geometry">
<rect>
<x>10</x>
<y>0</y>
<width>71</width>
<height>27</height>
</rect>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="frame">
<bool>true</bool>
</property>
<item>
<property name="text">
<string>Port A</string>
</property>
</item>
<item>
<property name="text">
<string>Port B</string>
</property>
</item>
<item>
<property name="text">
<string>Port C</string>
</property>
</item>
<item>
<property name="text">
<string>Port D</string>
</property>
</item>
</widget>
<widget class="QPushButton" name="connect">
<property name="geometry">
<rect>
<x>370</x>
<y>0</y>
<width>241</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Connect</string>
</property>
</widget>
<widget class="QTextBrowser" name="log">
<property name="geometry">
<rect>
<x>10</x>
<y>210</y>
<width>601</width>
<height>381</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="i2c_write_data">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>601</width>
<height>27</height>
</rect>
</property>
</widget>
<widget class="QSpinBox" name="i2c_length">
<property name="geometry">
<rect>
<x>140</x>
<y>80</y>
<width>141</width>
<height>27</height>
</rect>
</property>
<property name="prefix">
<string>Length </string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget>
<widget class="QSpinBox" name="i2c_adress">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>121</width>
<height>27</height>
</rect>
</property>
<property name="prefix">
<string>Adress 0x</string>
</property>
<property name="maximum">
<number>127</number>
</property>
<property name="value">
<number>52</number>
</property>
<property name="displayIntegerBase">
<number>16</number>
</property>
</widget>
<widget class="QPushButton" name="i2c_write">
<property name="geometry">
<rect>
<x>290</x>
<y>80</y>
<width>99</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>TX</string>
</property>
</widget>
<widget class="QPushButton" name="i2c_read">
<property name="geometry">
<rect>
<x>400</x>
<y>80</y>
<width>99</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>RX</string>
</property>
</widget>
<widget class="QPushButton" name="read_i2c_hid_desc">
<property name="geometry">
<rect>
<x>10</x>
<y>130</y>
<width>151</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Read I2C HID Desc</string>
</property>
</widget>
<widget class="QPushButton" name="read_hid_report_desc">
<property name="geometry">
<rect>
<x>180</x>
<y>130</y>
<width>181</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Read HID Report Desc</string>
</property>
</widget>
<widget class="QPushButton" name="read_input_report_int">
<property name="geometry">
<rect>
<x>380</x>
<y>130</y>
<width>231</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Read Input Report (Interrupt)</string>
</property>
</widget>
<widget class="QPushButton" name="read_input_report_cmd">
<property name="geometry">
<rect>
<x>380</x>
<y>160</y>
<width>231</width>
<height>27</height>
</rect>
</property>
<property name="text">
<string>Read Input Report (Command)</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>627</width>
<height>25</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

59
ft232_qt/ftdi_common.cpp

@ -0,0 +1,59 @@
/*!
* \file ftdi_common.c
*
* \author FTDI
* \date 20110321
*
* Copyright ? 2000-2014 Future Technology Devices International Limited
*
*
* THIS SOFTWARE IS PROVIDED BY FUTURE TECHNOLOGY DEVICES INTERNATIONAL LIMITED ``AS IS'' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FUTURE TECHNOLOGY DEVICES INTERNATIONAL LIMITED
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
*
* Project: libMPSSE
* Module: Common
*
* Rivision History:
* 0.1 - initial version
*/
/******************************************************************************/
/* Include files */
/******************************************************************************/
#include "ftdi_infra.h" /*Common prrtable infrastructure(datatypes, libraries, etc)*/
#include "ftdi_common.h" /*Common across I2C, SPI, JTAG modules*/
/******************************************************************************/
/* Macro defines */
/******************************************************************************/
/******************************************************************************/
/* Local function declarations */
/******************************************************************************/
/******************************************************************************/
/* Global variables */
/******************************************************************************/
/******************************************************************************/
/* Public function definations */
/******************************************************************************/

144
ft232_qt/i2c.c

@ -0,0 +1,144 @@
#include <stdio.h>
#include <stdlib.h>
#include <mpsse.h>
#include <../libftdi1/src/ftdi.h>
struct vid_pid supported_devices[] = {
{ 0x0403, 0x6010, "FT2232 Future Technology Devices International, Ltd" },
{ 0x0403, 0x6011, "FT4232 Future Technology Devices International, Ltd" },
{ 0x0403, 0x6014, "FT232H Future Technology Devices International, Ltd" },
/* These devices are based on FT2232 chips, but have not been tested. */
{ 0x0403, 0x8878, "Bus Blaster v2 (channel A)" },
{ 0x0403, 0x8879, "Bus Blaster v2 (channel B)" },
{ 0x0403, 0xBDC8, "Turtelizer JTAG/RS232 Adapter A" },
{ 0x0403, 0xCFF8, "Amontec JTAGkey" },
{ 0x0403, 0x8A98, "TIAO Multi Protocol Adapter"},
{ 0x15BA, 0x0003, "Olimex Ltd. OpenOCD JTAG" },
{ 0x15BA, 0x0004, "Olimex Ltd. OpenOCD JTAG TINY" },
{ 0, 0, NULL }
};
struct mpsse_context *i2c_dev = NULL;
char i2c_adress;
int i;
struct ftdi_context *ftdi;
int f;//,i;
int i2c_open (int clockrate, int index, int port)
// PORT A - 1, PORT B - 2, ANY PORT - 0
// CLOCKRATE IN HERZ
// INDEX IS FOR SITUATION WHEN NO ONE FTDI MPSSE DEVICE IS CONNECTED TO PC (IF ONE DEVICE IS CONNECTED PLEASE SET INDEX TO ZERO, IF MULTIPLE DEVICES - INDEX MAY BE NOT ZERO)
{
i2c_dev = OpenIndex(0x0403, 0x6010, I2C, clockrate, MSB, port, NULL, NULL, index);
if (i2c_dev->open)
return 0; // ALL OK, RETURN ZERO
// NOT OK, CLOSING AND RETURNING NON-ZERO
Close(i2c_dev);
i2c_dev = NULL;
return 1;
}
void i2c_close ()
{
Close(i2c_dev);
i2c_dev = NULL;
}
int i2c_tx (char adress, char* data, int len, int stt, int stp)
{
if ((i2c_dev == NULL) || (i2c_dev->open == 0))
return 1; // NO OPENED DEVICE
if (stt)
Start (i2c_dev);
i2c_adress = (adress << 1) & (~0x01) ;
Write (i2c_dev, &i2c_adress, 1);
if (GetAck (i2c_dev) != ACK) {
if (stp)
Stop (i2c_dev);
return 10; // NO ACK ADRESS
}
Write (i2c_dev, data, len);
i = GetAck(i2c_dev);
if (stp)
Stop (i2c_dev);
if (i != ACK)
return 11; // NO ACK DATA
return 0;
}
int i2c_rx (char adress, char* data, int len, int stt, int stp)
{
char* temp_data;
if ((i2c_dev == NULL) || (i2c_dev->open == 0))
return 1;
if (stt)
Start (i2c_dev);
i2c_adress = (adress << 1) | (0x01) ;
Write (i2c_dev, &i2c_adress, 1);
if (GetAck (i2c_dev) != ACK) {
if (stp)
Stop (i2c_dev);
return 10; // NO ACK ADRESS
}
SendAcks (i2c_dev); // SEND ACKS WHEN DATA PROCESSING
temp_data = Read (i2c_dev, len);
/* Tell libmpsse to send NACKs after reading data */
SendNacks(i2c_dev);
/* Read in one dummy byte, with a NACK */
Read(i2c_dev, 1);
if (stp)
Stop (i2c_dev);
if (data) {
for (int i = 0; i < len; i++)
data[i] = temp_data[i];
free(temp_data);
return 0; // ALL GOOD
}
return 12; // UNKNOWN ERROR, NO DATA
}
int bitbang_open (int index, int port, int mask)
{
if ((ftdi = ftdi_new()) == 0)
{
fprintf(stderr, "ftdi_new failed\n");
return EXIT_FAILURE;
}
f = ftdi_usb_open_desc_index (ftdi, 0x0403, 0x6010, NULL, NULL, index);
if (f < 0 && f != -5)
{
fprintf(stderr, "unable to open ftdi device: %d (%s)\n", f, ftdi_get_error_string(ftdi));
ftdi_free(ftdi);
return 2;
}
f = ftdi_set_interface(ftdi, port);
if (f < 0 && f != -5)
{
fprintf(stderr, "unable to open ftdi device: %d (%s)\n", f, ftdi_get_error_string(ftdi));
ftdi_free(ftdi);
return 3;
}
ftdi_set_bitmode(ftdi, mask, BITMODE_BITBANG);
return 0;
}
void bitbang_close ()
{
ftdi_disable_bitbang(ftdi);
ftdi_usb_close(ftdi);
ftdi_free(ftdi);
}
int bitbang_read (char* pins)
{
return ftdi_read_pins(ftdi, pins);
}

19
ft232_qt/i2c.h

@ -0,0 +1,19 @@
#ifdef __cplusplus
extern "C" {
int i2c_open (int clockrate, int index, int port);
// PORT A - 1, PORT B - 2, ANY PORT - 0
// CLOCKRATE IN HERZ
// INDEX IS FOR SITUATION WHEN NO ONE FTDI MPSSE DEVICE IS CONNECTED TO PC (IF ONE DEVICE IS CONNECTED PLEASE SET INDEX TO ZERO, IF MULTIPLE DEVICES - INDEX MAY BE NOT ZERO)
void i2c_close ();
int i2c_tx (char adress, char* data, int len, int stt, int stp);
int i2c_rx (char adress, char* data, int len, int stt, int stp);
int bitbang_open (int index, int port, int mask);
void bitbang_close ();
int bitbang_read (char* pins);
}
#endif

11
ft232_qt/main.cpp

@ -0,0 +1,11 @@
#include "ft232_reign.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
ft232_reign w;
w.show();
return a.exec();
}
Loading…
Cancel
Save