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. |
dylad
left a comment
There was a problem hiding this comment.
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.
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.
| i2c_acquire(I2C); | ||
|
|
||
| /* Read control register */ | ||
| i2c_read_regs(I2C, ADDR, ADS101X_CONF_ADDR, ®s, 2); |
|
|
||
| i2c_acquire(I2C); | ||
|
|
||
| i2c_read_regs(I2C, ADDR, ADS101X_CONF_ADDR, ®s, 2); |
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.
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.
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.
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.
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.
| /* | ||
| * Copyright (C) 2017 OTA keys S.A. | ||
| * 2018 Matthew Blue <matthew.blue.neuro@gmail.com> | ||
| * 2018 Acutam Automation, LLC |
There was a problem hiding this comment.
unrelated, and unclear why? Here and other files
There was a problem hiding this comment.
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.
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. |
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