Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
c8f9c50
Update mpsse.i
crossleyjo Oct 21, 2015
19072f5
Re-Enable flushing of ftdi buffers after read
olereinhardt Jul 5, 2016
169a90b
Fix start condition
olereinhardt Jul 5, 2016
f566194
Add timeout on read raw_read() oprations. Enhance error handling and …
olereinhardt Jul 6, 2016
bb7b989
Check for zero read at timeout instead of partial reads.
Jul 6, 2016
61580cc
Don't use install -D option as it does not exist on OS X
mringwal Aug 9, 2016
91794d0
Remove LDFLAGS from commands to build object files.
jhgit Feb 17, 2017
cc97da4
Don't build object files with the same filename for swig python object
jhgit Feb 17, 2017
a3525a5
include stdlib.h for malloc(3)
jhgit Feb 17, 2017
1754c6e
configure is autogenerated.
Nov 11, 2016
14913b1
Merge https://github.com/jhgit/libmpsse
l29ah May 22, 2017
e1c0226
Merge branch 'osx-install-fix' of https://github.com/mringwal/libmpsse
l29ah May 22, 2017
53b1fbb
Merge branch 'patch-1' of https://github.com/crossleyjo/libmpsse
l29ah May 22, 2017
62d3b61
+ .gitignore
l29ah May 22, 2017
c269efb
move README around for better visibility
l29ah May 22, 2017
7763126
Fix python3 compatibility. Still compatible with Python 2.7, untested…
DanielCasner Jul 6, 2015
c6271bc
Make mpsse.py compatible with python3
DanielCasner Jul 7, 2015
1ad4d5d
a better way to find the python headers is to ask python
l29ah May 22, 2017
2fada1f
python3'ify the configure script
l29ah May 22, 2017
1884dae
+ python-dependent generated files to .gitignore
l29ah May 22, 2017
9011c37
added -DLIBFTDI1 to fast.c compiler options
pat1 Dec 25, 2017
fb6abda
Merge pull request #1 from r-map/master
l29ah Dec 25, 2017
03d5890
migrate README to markown
bearsh Jan 24, 2018
175c089
Merge pull request #2 from bearsh/master
l29ah Jan 25, 2018
fdcede6
Define fast_rw_buf from code file not from header File. It should fix…
fletort Aug 20, 2015
3be0edc
update AC_INIT invocation
l29ah Apr 10, 2018
eaf067c
Fix FastTransfer
ivan-baldin Oct 5, 2015
fc8affc
fast.c: keeping the symbol space clean!
l29ah Apr 15, 2018
e681db9
convert sizes to size_t
l29ah May 3, 2018
148b070
use pointers to const memory for writes
l29ah May 3, 2018
37b065a
make -Wextra a default
l29ah May 3, 2018
e9c7935
python -> python2
l29ah May 5, 2018
8844087
add built examples to .gitignore
l29ah May 30, 2018
f5c40f2
release 1.3.2
l29ah May 30, 2018
13d262a
updated prerequisites in docs/INSTALL
l29ah Sep 14, 2018
1161a3b
support older build environments in CFLAGS
l29ah Sep 14, 2018
a2ba169
Extra whitespace cleanup in mpsse.c
Mar 25, 2019
6260cd8
Use nanosleep instead of usleep
Mar 25, 2019
fe90251
Major overhaul of the build system
maksymko Mar 27, 2019
d7b96d6
Fix configure.ac / INSTALL for building from scratch
sebastian-matuschka Jul 26, 2019
809adec
fixed the link to README.PYTHON.html
l29ah Sep 29, 2019
249fd23
link to the installation instructions in README
l29ah Sep 29, 2019
3fcacad
pylibmpsse wirte needs size; fix #9
elimohl Sep 29, 2019
d9365c9
Fixed mixed indentation
elimohl Oct 4, 2019
a7b353b
add config.h before includes for mpsse.h
derekolson Oct 4, 2019
fe0a0e1
+ travis-ci build
l29ah Oct 19, 2019
d648428
travis: utilize clang's static analyzer
l29ah Oct 19, 2019
6783a4e
docs: corrected python env vars
l29ah Nov 14, 2019
254ef9a
Mark headers as C for C++ programs using the library.
twasilczyk Mar 11, 2021
a01d511
Implement get_bits_high to fetch ACBUS pin states.
twasilczyk Mar 11, 2021
a833dd9
Fix build warning about incorrect memcpy use and update .gitignore.
Mar 16, 2021
f8108cd
Fix deprecation warnings by using the new flush functions
twasilczyk Mar 11, 2021
a757bdf
Implement OpenUsbDev to open a specific USB device by bus and address
Mar 11, 2021
f8ec860
Don't try to {un,}install the python wrapper if we weren't asked for it
l29ah Apr 8, 2021
9ea558c
make sure the header file mpsse.h is also installed
jaapcrezee Apr 14, 2021
4d3ab17
Implement get_bits_low.
Apr 16, 2021
bf2cafe
cleanup ftdi context if it was initialized
l29ah May 18, 2021
0b44e13
Revert "cleanup ftdi context if it was initialized"
l29ah May 18, 2021
8e1ce70
apparently we can cleanup regardless if libftdi opened its ctx
l29ah May 18, 2021
1cbd21e
Fix configure.ac: Don't check for python if we disable-python
Nov 25, 2022
2c91605
Make the mpsse supported device list external
stephendpmurphy Jan 28, 2022
af8c2f1
fixed warnings in examples
l29ah Nov 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
*.sw?
*.o
*.a
*.so
*.lo
*.la
src/Makefile
src/autom4te.cache
src/config.h
src/config.log
src/config.status
src/configure
src/mpsse_wrap.c
src/pylibmpsse.py

src/examples/bitbang
src/examples/ds1305
src/examples/gpio
src/examples/i2ceeprom
src/examples/spiflash
src/examples/spiflashfast

.deps*
.libs*
Makefile
Makefile.in
aclocal.m4
ar-lib
autoscan.log
build
build/*
compile
config.guess
config.sub
configure.scan
depcomp
install-sh
libtool
ltmain.sh
m4
m4/*
missing
mpsse_wrap_python.c
py-compile
pyswig_*.c
config.h.in
stamp-h1
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: c
compiler:
- gcc
- clang
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq libftdi-dev swig
script:
- cd src && autoreconf --install && ./configure && scan-build make
88 changes: 85 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,86 @@
libmpsse
========
# ABOUT

[![Build Status](https://travis-ci.org/l29ah/libmpsse.svg?branch=master)](https://travis-ci.org/l29ah/libmpsse)

Libmpsse is a library for interfacing with SPI/I2C devices via FTDI's FT-2232 family of USB to serial
chips. Additionally, it provides control over the GPIO pins on the FTDI chips and supports a raw
bitbang mode as well. Based around the libftdi library, it is written in C and includes a Python wrapper
courtesy of swig.

See [INSTALL](docs/INSTALL) for the installation instructions.

# LIBRARY API

In version 1.0 libmpsse was modified to support multiple simultaneous FTDI chips inside a single process,
which required a change to the API. Thus, the API for libmpsse versions prior to 1.0 are not compatible with
the API for versions 1.0 and later.

The C and Python APIs are very similar, although the Python API has been made more "pythonic". Specifically,
in Python:

1. MPSSE is the name of the Python class, not of a method or function as it is in C. The class
constructor takes the same arguments as the MPSSE function in C. If you wish to instead use
the Open method to open a given device, simply do not specify these arguments when calling
the class constructor.

2. Due to its object-oriented nature, each class instance in Python internally handles the MPSSE
context pointer; thus, none of the Python methods in the MPSSE class require this argument.

3. Size parameters required by the C functions are not used by the corresponding Python methods.

4. Besides the above described differences, all Python methods have a 1:1 compatibility with their
respective C functions. However, in Python the class constructor (MPSSE) and Open method have
sensible defaults for several of their arguments so not all arguments are required.

See the [README.C](docs/README.C) and [README.PYTHON.html](docs/README.PYTHON.html) files for more details.

# CODE EXAMPLES

There are SPI and I2C code examples for both C and Python in the `src/examples` directory. After installing
libmpsse, the C examples can be built by running:

$ make example-code

There are more detailed descriptions of the SPI and I2C APIs in [README.SPI](docs/README.SPI) and [README.I2C](docs/README.I2C) files.

# BUILDING APPLICATIONS

To build applications in Python, you must import the `mpsse` module:

from mpsse import *

To build applications in C, you must include the `mpsse.h` header file:

#include <mpsse.h>

...and also link your program against the *libmpsse* library:

$ gcc test.c -o test -lmpsse

# PHYSICAL CONNECTIONS

In order to speak to SPI or I2C devices, you must establish the proper physical connections between the target
device and your FTDI chip. The exact pin out of your target device and FTDI chip will differ based on the chips
in question, and the appropriate data sheets for each device should be referenced for this information.

Included in the docs directory is the FTDI MPSSE Basics application note (AN 135). Section 2 of this document
covers all of the pin configurations for each FTDI chip, as well as example diagrams regarding the physical
connections between the FTDI chip and your target device.

# KNOWN BUGS

The following are known bugs in libmpsse:

- In SPI, the Transfer method fails if transfering large data chunks. Use the Read/Write functions
for transferring large chunks of data (~1MB or more).

# KNOWN LIMITATIONS

Libmpsse supports all four SPI modes as well as I2C. However, due to the design of the FTDI MPSSE implementation,
there are some limitations:

- All protocols support master mode only.
- SPI modes 1 and 3 are only partially supported; see the README.SPI for more information.
- In I2C, the SCL and SDA pins are open drain, but the MPSSE implementation explicitly drives these lines high.
Although this is usually fine, it means that some I2C features, such as clock stretching, are not supported.

Open source library for SPI/I2C control via FTDI chips
13 changes: 6 additions & 7 deletions docs/INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ PREREQUISITES
Libmpsse is currently supported on the Linux and OSX platforms.

Libmpsse requires swig as well as the libftdi and python development packages.
These can typically be installed by your Linux distro's package manager, such as:
These can typically be installed by your Linux distro's package manager, for Debian:

# apt-get install swig libftdi-dev python-dev
# apt-get install swig libftdi-dev python-dev autoconf automake libtool

For OSX, you will likely need to at least install libftdi from source. Note that
libftdi also requires the libusb-0.1 (not libusb-1.0) library.
For OSX, you will likely need to at least install libftdi from source.

INSTALLATION

With the required prerequisites installed, libmpsse can be built and installed:

$ autoreconf --install
$ ./configure
$ make
# make install
Expand All @@ -23,12 +23,11 @@ INSTALLATION
may set the following environment variables:

SWIG - Path to the swig binary
PYDEV - Path to the python include directory where the python header files are located
PYLIB - Path to the python library directory where python modules should be installed
PYTHON - Path to the python binary

Example:

$ PYDEV=/usr/local/include/python2.6/ ./configure
$ PYTHON=/usr/bin/python3 ./configure
$ make
# make install

Expand Down
82 changes: 0 additions & 82 deletions docs/README

This file was deleted.

File renamed without changes.
47 changes: 47 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
SUBDIRS = . examples

AM_CFLAGS = -Wall -Wextra -fPIC -fno-strict-aliasing -g -O2 $(CFLAGS)
AM_CPPFLAGS = $(PYTHON_INCLUDE) $(CPPFLAGS)

ACLOCAL_AMFLAGS = -I m4

if BUILD_PYTHON_WRAPPERS
PYTHON_MPSSE_LA = libMpssePython.la
PYLIBMPSSE = pylibmpsse.py
CREATE_LINK = $(LN_S) ${prefix}/lib/libMpssePython.so.0.0.0 ${pythondir}/_pylibmpsse.so
else !BUILD_PYTHON_WRAPPERS
PYTHON_MPSSE_LA =
PYLIBMPSSE =
CREATE_LINK = true
endif !BUILD_PYTHON_WRAPPERS

lib_LTLIBRARIES = libmpsse.la $(PYTHON_MPSSE_LA)
libmpsse_la_SOURCES = mpsse.c support.c fast.c

include_HEADERS = mpsse.h

EXTRA_DIST = mpsse.i
python_PYTHON = mpsse.py $(PYLIBMPSSE)

libMpssePython_la_SOURCES = mpsse_wrap_python.c pyswig_mpsse.c pyswig_support.c
BUILT_SOURCES = pyswig_support.c pyswig_mpsse.c
CLEANFILES = pyswig_mpsse.c pyswig_support.c mpsse_wrap_python.c
libMpssePython_la_CPPFLAGS = -DSWIGPYTHON $(AM_CPPFLAGS)

mpsse_wrap_python.c: mpsse.i
$(SWIG) -python -o $@ $<

pyswig_mpsse.c: mpsse.c
cp -f $< $@

pyswig_support.c: support.c
cp -f $< $@

if BUILD_PYTHON_WRAPPERS
install-exec-hook:
-rm ${pythondir}/_pylibmpsse.so
$(CREATE_LINK)

uninstall-hook:
-rm ${pythondir}/_pylibmpsse.so
endif BUILD_PYTHON_WRAPPERS
76 changes: 0 additions & 76 deletions src/Makefile.in

This file was deleted.

Loading