Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] I2C repeated start #81

Open
sajingeo opened this issue Dec 23, 2014 · 9 comments
Open

[API] I2C repeated start #81

sajingeo opened this issue Dec 23, 2014 · 9 comments

Comments

@sajingeo
Copy link

I was trying to implement a I2C Repeated start for a sensor, is there a way around it or is it a feature.

http://www.i2c-bus.org/repeated-start-condition/

@arfoll
Copy link
Contributor

arfoll commented Dec 26, 2014

We currently don't support that, it's done by using I2C_RDWR and we need to work out a sensible API for it to work on C/C++ as well python/js but should definately be do-able. As part of this we definately need to start using i2c.h:i2c_get_functionality() to make sure our bus supports all these 'fancy' features.

@sajingeo
Copy link
Author

sajingeo commented Jan 9, 2015

I looked at the i2c-dev that is being used, I don't think i2c-dev supports mixed transactions. We will have to use an i2c_msg struct to support repeated start, does it make sense? or is there a software I2C (bit banging) that would be easier to implement/ port.

@arfoll arfoll changed the title I2C repeated start Jan 12, 2015
@sajingeo
Copy link
Author

Hi, I have a temporary fix here https://github.com/sajingeo/i2crw and I have verified it works :) we still need to integrate it to MRAA.

@arfoll
Copy link
Contributor

arfoll commented Jan 14, 2015

Thanks that's really helpful, question is do we want to support just a simple Rx/Tx buf combination or do we want to be more flexible and let users construct their own i2c_msg? The first should be fairly easy, the second is much more complicated (especially when it comes to exposing this via SWIG).

@g-vidal
Copy link
Contributor

g-vidal commented Mar 2, 2016

Hi @sajingeo @arfoll ,
Thanks for your efforts !
Unfortunately I cannot understand most of the technical part of your discussion but if I may express the opinion of an end user, It is really needed to be able to use I2c sensors that require repeated start on an Edison breakout.
It is very frustrating to be unable to plug more than one sensor on the I2c bus ! From my experience only one sensor out of 3 standard ones (listed in upm lib) that I bought did not request repeated start which means that I cannot get the advantages of having an I2c bus. Of course I should have read more and I may change the sensors but that increases the cost and does not eliminate frustration... ;-(
I can help testing solutions but I do not know how to implement @sajingeo temporary fix. I am using the up-to-date git source of mraa and upm, I can make amendments in the code,compile and test it.
Let me know if I can do anything to help.
I am using python

@g-vidal
Copy link
Contributor

g-vidal commented May 2, 2017

Hi @arfoll and maybe @jontrulson
It seems that this "repeated start condition" is causing more and more trouble #547 #530(?). I am not able to propose a PR on this topic, I have found a workaround proposed by @tdicola for raspberries that works in some cases for me :
echo -n 1 > /sys/module/i2c_bcm2708/parameters/combined

Is there such a workaround for Edisons ?

This condition is not needed for all sensors and i have understood that it was complicated to implement it as a generic feature, Would-it be possible to get a function that could be called before the creation of the sensor with the upm init function. I am a python user and I would love to be able to write something like :

mraa.request_repeated_start(bus)
from upm import pyupm_tsl2561 as tsl2561
mytsl = tsl2561.TSL2561(bus1,addrtsl)

Is it possible ? Is it huge work ? Can anybody with skills please contribute ?
Thanks

@alext-mkrs
Copy link
Contributor

Hi @g-vidal, just for objectivity's sake - neither of the two issues you've mentioned has to do with repeated start. The "combined" thing doesn't exist on Edison, I think. So all this would need to be implemented from scratch. Can't comment on the amount of work, that would require some further analysis of specific use cases and API we want to expose.

@g-vidal
Copy link
Contributor

g-vidal commented Apr 2, 2018

Hi @alext-mkrs From what I have read here

In Linux kernel I2C read operations with repeated start condition are performed by default for combined (write/read) messages.

Which means that using combined is a trick to get repeated start by default. It is unfortunate that it does not exist in Edisons ;-(.

We have thrown away (not too far) all our repeated start devices but the question remains, are there any plans to add this option in mraa lib.

@alext-mkrs
Copy link
Contributor

No plans to the best of my knowledge - as there have been virtually no requests for that so far, aside from this one, which as we can see is not drawing too much community attention.

So... I'm sorry to say that, but this is still up for grabs for anyone who's willing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment