Comments (5)
On further investigation, this could be fixed by a sequence of reads like this:
Read(any amount of data);
...
Read(any amount of data);
SetAck(1);
Read(less than or equal to I2C_TRANSFER_SIZE);
Stop();
The condition is that we don't Read() more than I2C_TRANSFER_SIZE bytes in the
last Read() call, otherwise the build_block_buffer() will NACK the peripheral
before all the data is read. It seems that for I2C transfers, Read() and/or
build_block_buffer() should somehow be made aware that this will be the last
read before Stop(), so that they can NACK the final chunk. One possible (ugly)
hack is to increase I2C_TRANSFER_SIZE to a maximum value needed, so that there
is only one chunk of data read and then NACK the last byte in chunk every time.
Original comment by [email protected]
on 28 Feb 2012 at 10:18
from libmpsse.
I'll double check this on the scope when I get a chance, but the following
*should* work:
Read(all data except the last byte);
SetAck(0);
Read(1);
Stop();
Passing a 1 to SetAck enables ACKs, while passing a 0 disables ACKs (aka,
enables NACKs). This is a bit confusing as it is the reverse of the logic
levels used on the bus, so perhaps this should be changed.
Let me know if the above works for you, or if you still have problems.
Original comment by [email protected]
on 5 Mar 2012 at 1:42
from libmpsse.
Yes, that sequence is ok. Once I grasped the logic of it, it worked as
advertised.
I think an update to i2ceeprom example would go a long way towards explaining
this, including the ACK/NACK logic. As it stands now, the example reads in all
the data and then attempts to Stop(), without toggling the Ack before the last
byte. This does leave peripherals in a rather unfortunate state of still trying
to clock out data.
Thank you for your assistance and a very good library!
Original comment by [email protected]
on 5 Mar 2012 at 6:51
from libmpsse.
Yes, EEPROMs are pretty forgiving while other I2C devices aren't. Looking over
this I also noticed that the documentation in README.I2C is wrong as well, so
I'll be sure to update that. Sorry for the confusion!
Original comment by [email protected]
on 6 Mar 2012 at 1:32
from libmpsse.
Updated I2C examples and documentation. Also updated SetAck such that passing
it a 1 sends NACKs and passing it a 0 sends ACKs; this corresponds with the ACK
bit actually sent on the bus, as well as the ACK status returned by GetAck.
Thanks!
Original comment by [email protected]
on 9 Mar 2012 at 2:57
- Changed state: Fixed
from libmpsse.
Related Issues (20)
- WritePins always fails HOT 2
- Patch for /trunk/src/mpsse.i HOT 1
- make install command does not work at MinGW
- Failed to initialize MPSSE: device not found
- Erronous start condition if using GPIO on low bits in i2c mode
- pyswig versions of functions leaked into C library (libmpsse.a/.so)
- FastTransfer always fails
- Problems with the Setup
- How to address i2c slaves HOT 1
- I2C Read gives one bad bit, but only rarely
- SetDirection in MPSSE mode
- FIXED Apple OS X library compilation and installation with libftdi1 from MacPorts
- where is pylibmpsse ? HOT 1
- I2C eeprom python script available HOT 1
- Patch for /trunk/src/mpsse.c
- Different names of values in examples/spiflash.py
- i2c ACK bit not read properly
- trouble running spiflash -p (likely an install issue)
- SPI_ReadWrite returned unexpected result HOT 2
- open usb-serial port
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libmpsse.