-
Notifications
You must be signed in to change notification settings - Fork 2.1k
I2C driver implementation (Master mode) for the SAMR21 #2016
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
Conversation
@thomaseichinger , Why did Travis CI build fail? |
@bapclenet cppcheck found some issues:
They are triggered since the variables in question are only assigned in the |
Travis fails because cppcheck complains. cpu/samd21/periph/i2c.c:52: style (unassignedVariable): Variable 'pin_scl' is not assigned a value.
cpu/samd21/periph/i2c.c:53: style (unassignedVariable): Variable 'pin_sda' is not assigned a value.
cpu/samd21/periph/i2c.c:55: style (unassignedVariable): Variable 'clock_source_speed' is not assigned a value. Cppcheck isn't smart regarding preprocessor defines and and if statements. You could try initializing with |
#define I2C_SDA PIN_PA16 | ||
#define I2C_SCL PIN_PA17 | ||
#define I2C_0_PINS (PORT_PA16 | PORT_PA17) | ||
#define I2C_0_REF_F (8000000UL) // Default Clock Source on reset OSC8M - 8MHz |
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.
Please align the defines and use /* C-style comments */
OT: cppcheck IS smart regarding preprocessor defines, checking every possible build path ;-). If you leave a variable unset in a possible build path it could lead to errors; if you do it intentionally you should very carefully reason why. |
port_group = &I2C_0_PORT; | ||
pin_scl = I2C_SDA; | ||
pin_sda = I2C_SCL; | ||
i2c_port = I2C_0_PINS; |
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.
assigning I2C_0_PINS
to i2c_port
is quite confusing. Maybe rename s/i2c_port/i2c_pins/ ?
@bapclenet Awesome work! Some first style comments above and please change to spaces instead of tabs for indentation. Will test it in the afternoon. |
@bapclenet Please rebase. Also you still have some tabs in your code. https://github.com/RIOT-OS/RIOT/wiki/Coding-conventions#indentation-and-braces |
How do I rebase? |
@bapclenet sorry that was wrong. |
Rebase done, thank you @BytesGalore! |
Travis failing is unrelated to this PR. Will be solved by #2064. |
@bapclenet 26 files changed...? This is not only a I2C PR anymore :-) |
A problem occured with my rebase apparently... I don't know how I did that. |
@haukepetersen could you take another look? |
code looks good to me, though I don't have an I2C device here for testing. I also kicked Travis once more. |
I have had a logic analyzer connected to it and it seems all right... |
I will test it with one of the ultrasonic sensors |
How do you test it ? Which test do you use ? I may have a look this
|
Two other questions : |
Hi! In #2179 is a test for the srf08 supersonic ranger which is an i2c device. The address is correct as the same application runs stable on stm32f4discovery. Also it runs stable for a while on samr21-xpro but then it gets stuck and one can see the debug message |
I tested this with the srf02 ultrasonic ranger and it seems to work stable. I assume i2c is fine. Do you have another i2c device to test with? |
Ok just do clarify the situation a bit: I tested this i2c implementation with tests/drivers_srf02 and tests/drivers_srf08 (PR #2179). For both sensors the i2c-based device drivers do work. But when testing the srf08 ranger, I got the problems described above, when I have a logic analyzer in parallel. These problems didn't occur when testing with srf02. However, I tried to reproduce this a several times and it occured again and again. |
Ok, so basically, you try watch the I2C frame with the logic analyzer ? |
Nothing more :-) ! I give my ACK for the functionality as this behavior is probably an electrical one. Good to here that is is also fine with your SI7013 |
Good to here that :-) What's wrong with Travis CI build? |
Code looks good to me and I also ACKed the functionality. As I am not too deep into that board, is someone else willing to click merge? |
Kicked Travis, will merge when passed. |
What should I change for Travis test to pass? |
@bapclenet Nothing, Travis seems to have some random fails. Built locally without errors so let's do this. ACK & Go |
cpu/samd21: I2C driver implementation (Master mode)
Implementation of the I2C driver (Master mode) for the SAMR21 including:
I do some "return;" when I detect an error which is not that good. Which solution do I have?