-
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
drivers/ads101x: update I2C API #9165
Conversation
I may need to rebase this on new_i2c_if |
Hi @ZetaR60 |
f2894ab
to
27b43dd
Compare
@dylad I just had to rebase this on new_i2c_if, because switching it over brought a bunch of stuff from master with it. Should be good now. |
Should be up to date again. |
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.
Changes look good but I'm not convinced by the NOSTOP flag. I don't think they are required.
drivers/ads101x/ads101x.c
Outdated
if (i2c_init_master(i2c, I2C_SPEED) < 0) { | ||
|
||
/* Register read test */ | ||
if (i2c_read_regs(i2c, addr, ADS101X_CONF_ADDR, ®s, 2, I2C_NOSTOP) |
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.
I don't see any reason here to have a NOSTOP flag. (same at other place in the code)
It's not forbidden to read some regs send a STOP and then send data into another register.
@@ -127,22 +134,21 @@ int ads101x_read_raw(const ads101x_t *dev, int16_t *raw) | |||
i2c_acquire(I2C); | |||
|
|||
/* Read control register */ | |||
i2c_read_regs(I2C, ADDR, ADS101X_CONF_ADDR, ®s, 2); |
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.
NOSTOP required ?
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.
why should it be required?
@@ -103,7 +110,7 @@ int ads101x_set_mux_gain(const ads101x_t *dev, uint8_t mux_gain) | |||
|
|||
i2c_acquire(I2C); | |||
|
|||
i2c_read_regs(I2C, ADDR, ADS101X_CONF_ADDR, ®s, 2); |
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.
NOSTOP required ?
drivers/ads101x/ads101x.c
Outdated
i2c_write_regs(i2c, addr, ADS101X_CONF_ADDR, ®s, 2); | ||
i2c_read_regs(i2c, addr, ADS101X_CONF_ADDR, ®s, 2); | ||
/* Register write test */ | ||
if (i2c_write_regs(i2c, addr, ADS101X_CONF_ADDR, ®s, 2, I2C_NOSTOP) |
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.
same here, is the NOSTOP really useful ?
NOSTOPs removed. |
@ZetaR60 , I'll push an atmega_common api update (WIP) soon. So you'll be able to test. |
@ZetaR60 you can try with this branch https://github.com/mali/RIOT/tree/atmega_new_i2c_if |
@mali I am not seeing the changes to periph/i2c.c: https://github.com/mali/RIOT/blob/atmega_new_i2c_if/cpu/atmega_common/periph/i2c.c |
Oups .. sorry, it seems I've done something wrong :-/ |
It's repaired ! see also #9252 |
b8dc0a3
to
c27f689
Compare
I tried tests/driver_ads101x with #9252 and got this error (debug enabled for ads101x and gpio.c):
I will continue investigation tomorrow. |
The specific NACK received is 0x20. I have not been able to track down the problem yet. The odd thing is that trunk has almost the same execution path as the new code, but trunk works fine and the new code is failing. The main difference is moving i2c_init, but moving this back to ads101x.c does not fix the problem. |
drivers/ads101x/ads101x.c
Outdated
if (i2c_init_master(i2c, I2C_SPEED) < 0) { | ||
|
||
/* Register read test */ | ||
if (i2c_read_regs(i2c, addr, ADS101X_CONF_ADDR, ®s, 2, 0x0) |
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.
I mostly saw a simple 0
for the flags in other places, IMHO we should stick to one style.
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.
I use 0 for defaults that are numerical, 0x0 for bit fields, and NULL for pointers. This is consistent with my prior work. IMO asking for developers to conform to a community standard for such detailed stylistic choices is burdensome without significant benefit.
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.
agreed, maybe the (most) correct way would be to use the I2C_FLAG_NONE
to explicitly state that no flag should be set or used here. But we could leave that to a cleanup PR over all drivers and stuff later on.
@@ -1,6 +1,6 @@ | |||
/* | |||
* Copyright (C) 2017 OTA keys S.A. | |||
* 2018 Matthew Blue <[email protected]> | |||
* 2018 Acutam Automation, LLC |
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.
unrelated, and unclear why? Here and other files
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.
I have transferred my copyrights on RIOT code from myself (Matthew Blue) to my company (Acutam Automation, LLC). I figured it was a minor enough change that it did not require a separate PR, or detailed explanation.
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.
ah okay, sorry was confused by GitHub username vs author name, never mind.
@ZetaR60 atmega I2C driver has been merge, do you think you can re-test this PR ? |
6a3dd3d
to
fa183d0
Compare
Rebased to pick up ATmega changes. |
Everything looks okay. Let me know when to squash.
|
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
Please squash
d2631ed
to
8ab0579
Compare
Squashed. Thanks for the help! |
Here we go ! |
drivers/ads101x: update I2C API
drivers/ads101x: update I2C API
This is a WIP update to ads101x's I2C API usage. Currently untested due to lack of API update to atmega_common. See also: #6577 and #9162