-
Notifications
You must be signed in to change notification settings - Fork 2k
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
sys/arduino: Added Wire (I2C) interface #10592
Conversation
Cool! I'll try to have a closer look and test this soon(ish). |
5d1dbbf
to
9ae0c73
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some minor stuff, otherwise looks good ... needs testing though
Let's pickup the game again. I had an email conversation with someone who was asking whether it is possible to use Arduino driver libraries for I2C sensors in RIOT. Having the Wire interface library would be a step in this direction. In addition to the wire library, we need a common approach to automatically import Arduino libraries as packages. I'll think about such an approach as soon as I have some time left. |
@cladmi When I was trying to rebase this, I ran into conflicts since the make system has been changed with PR #7654. With this PR, I tried to define a pseudomodule arduino_lib so that it became possible not only to compile a complete sketch but also some Arduino libraries. Do have any idea, how I could do the same with the new make system as defined in PR #7654? |
Is the following the behavior your want? If somebody wants the sketch, it does not use your lib. If this is the case, I think the current So either rename it to That depends on what is wanted to give as an interface to users. Currently there was an automatic Depending on the naming wanted, I can do the change. |
@cladmi Thanks for explaination. I will restructure the PR a bit. I will leave this PR for the implemenation of Wire (I2C) implentation and will prepare a new PR for the make system. |
9ae0c73
to
404caf7
Compare
@cladmin The situation was the following: You have a directory with an Arduino application, for example
In this case, the make system expects a file with extension However, when you have an Arduino library, the directory usually contains only a
The compilation of such a directory requires same compiler configuration as for an Arduino application using So the idea was just to declare a pseudomodule
which enables module Therefore I used the following construct in former - $(shell $(RIOTTOOLS)/arduino/pre_build.sh $(SRCDIR) $(APPDIR) $(SKETCHES))
+ # run the Arduino pre-build script if Arduino module is not used as library
+ ifeq (, $(filter arduino_lib, $(USEMODULE)))
+ $(shell $(RIOTTOOLS)/arduino/pre_build.sh $(SRCDIR) $(APPDIR) $(SKETCHES))
+ endif and in + ifneq (, $(filter arduino_lib, $(USEMODULE)))
+ USEMODULE += arduino
+ endif It would be really cool if it would be possible to import Arduino libraries as packages and to compile them since there are thousands of drivers available for Arduino IDE. |
404caf7
to
1c4615b
Compare
@gschorcht: You didn't have reacted to some open comments of @smlng yet. Otherwise, I'd test and (hopefully) ACK. |
@smlng Could you approve this PR? All your change request were addressed, either changed or you gave thumbs up for the comment. |
9ffa8be
to
4cc7fa5
Compare
code-wise this looks good to me, can somebody tests this please? |
@maribu Could you test it? If you don't have LIS3DH at hand, just tell me what other I2C device you have and I can prepare a test. |
Sorry, not yet. I do not have a LIS3DH. I have BME280, BME680, SHT30, and VL53L0X at hands. |
I have attached a test application with an Arduino library for SHT31D, which also works for SHT30. I tested it with For the test you have to merge this PR and PR #12180 into a test branch in which you extract also the attached archive. |
Tested on an Arduino Nano: Output of the terminal with incorrect I2C address:
Capture with logic analyzer (still incorrect I2C address): Output of the terminal with I2C address matching device:
So: Errors seem to be correctly reported to the libraries (first try with incorrect address) and with correct address it worked as advertised. |
@smlng: I'd say squash, let Murdock run once more and than it could be merged from my point of view. |
please squash |
39c8f44
to
3fc2c60
Compare
Squashed @maribu @smlng @haukepetersen Just for the sake of completeness.
But the only method from We should have this in mind and should implement further functions if there is any request for them. Furthermore, |
@gschorcht: Thanks for pointing that out. +1 for not increasing the problem space of this PR. If there really is need for also using the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK. If the pointer with the Stream
API did not raise any new concern, I'd say merge!
As I said, I have never seen problems with the |
OK, no one complaint. Let's merge! |
@gschorcht: Thanks for this PR. A lot of students are familiar with Arduino. A feature rich compatibility layer could make it easier to get them on board 👍 |
@maribu Thanks for your support. Lets's hope we get merged your SPI and the |
Contribution description
This PR provides an implementation of the Arduino
Wire
library.Testing procedure
See PR #12518
Issues/PRs references
The changes in PR #7654 might require changes of the handling of the pseudomodule
arduino_lib
.