libftdi Archives

Subject: Re: C library wrapper around libftdi

From: cheffner <cheffner@xxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 14 Nov 2011 08:17:29 -0800 (PST)
pbhat wrote:
> 
> Hello,
> 
> I'm looking for a C wrapper library around libftdi, for I2C protocol. Does
> anyone know of such a library?
> 
> I would like to make function calls like 
> 
> read_data(unsigned int slave_addr, char *buf, int buf_size, int
> *bytes_read);
> write_data(unsigned int slave_addr, char *buf, int buf_size);
> 
> I would like to run this in a 64-bit Linux environment.
> 

I've just  http://libmpsse.googlecode.com released  an open-source libmpsse
library for Linux that supports SPI and I2C. There are APIs available for C
and Python.


pbhat wrote:
> 
> without having to handle the lower level aspects of I2C communication,
> such as Start/Stop sequences, setting mode bits, etc.
> 

It really isn't practical for read/write functions to automatically send
start/re-start/stop signals as some devices need you to send re-start
signals or you may need to check the ACK bits before sending more data but
without sending a stop signal. But in libmpsse sending start and stop
signals is just a call to Start() and Stop(), so it's pretty simple.

Likewise, libmpsse won't know when it is appropriate to set things like the
read and write bits in a control command. For example, to read data from an
EEPROM chip you have to first write the starting address to the EEPROM chip,
then send the read command. But this will not necessarily be the same for
other types of I2C devices. With that said, it would be simple for you to
write wrapper functions that are specific to the device you are trying to
talk to.


pbhat wrote:
> 
> I would like to run this in a 64-bit Linux environment. 
> 

I don't see any reason why libmpsse would not work in 64-bit Linux, but I've
only tested it in 32-bit so take that with a grain of salt. :)

--
View this message in context: 
http://libftdi.141977.n3.nabble.com/C-library-wrapper-around-libftdi-tp3428558p3507248.html
Sent from the libFTDI mailing list archive at Nabble.com.

--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread