Conversation
smlng
commented
May 31, 2017
- rework driver interface
- adapt test
- add saul support -> i.e., for pba-d-01-kw2x
| enum { | ||
| MPL3115A2_OK, /**< all good */ | ||
| MPL3115A2_ERROR_I2C, /**< I2C communication failed */ | ||
| MPL3115A2_ERROR_DEV, /**< Device MAG3110 not found */ |
There was a problem hiding this comment.
note to self: typo /MAG3110/MPL3115A2/
| /**@}*/ | ||
|
|
||
| /** | ||
| * @brief MAG3110 configuration |
944f748 to
7aa65e2
Compare
|
see #7152, too |
3d70f6b to
a3df41f
Compare
|
anybody willing to review, this is would finally resolve (and close) issue #7152 |
0c139df to
fe8509c
Compare
aabadie
left a comment
There was a problem hiding this comment.
Quick review: see comments below.
drivers/include/mpl3115a2.h
Outdated
| * | ||
| * The driver will initialize the sensor for pressure measurement. The | ||
| * conversion duration depends on oversample ratio. After initialization | ||
| * the sensor can be set activ to run periodic measurements. The oversample |
drivers/include/mpl3115a2.h
Outdated
| * | ||
| * @return 0 on success | ||
| * @return -1 on error | ||
| * @return 0 (MPL3115A2_OK) on success |
There was a problem hiding this comment.
You can use MPL3115A2 on success (no need to specify 0)
drivers/include/mpl3115a2.h
Outdated
| * @return 0 on success | ||
| * @return -1 on error | ||
| * @return 0 (MPL3115A2_OK) on success | ||
| * @return -1 (MPL3115A2_ERROR_I2C) on error |
There was a problem hiding this comment.
same as above: -MPL3115A2_ERROR_I2C on error
drivers/include/mpl3115a2.h
Outdated
| * | ||
| * @return 0 on success | ||
| * @return -1 on error | ||
| * @return 0 (MPL3115A2_OK) on success |
drivers/include/mpl3115a2.h
Outdated
| * | ||
| * @return 0 on success | ||
| * @return 0 (MPL3115A2_OK) on success | ||
| * @return -1 on error |
There was a problem hiding this comment.
no enum value for this case ?
| #define MPL3115A2_PARAM_ADDR (MPL3115A2_I2C_ADDRESS) | ||
| #endif | ||
| #ifndef MPL3115A2_PARAMS_DEFAULT | ||
| #define MPL3115A2_PARAMS_DEFAULT { .i2c = MPL3115A2_PARAM_I2C, \ |
There was a problem hiding this comment.
extra spaces before .i2c, one is enough
| /* Release the bus for other threads. */ | ||
| i2c_release(BUS); | ||
| LOG_ERROR("mpl3115a2_init: I2C error!\n"); | ||
| return -MPL3115A2_ERROR_I2C; |
There was a problem hiding this comment.
Maybe a specific enum for I2C read error could be used ?
| if (i2c_write_regs(BUS, ADDR, MPL3115A2_CTRL_REG1, ®, 1) != 1) { | ||
| i2c_release(BUS); | ||
| LOG_ERROR("mpl3115a2_init: failed to set sample rate!\n"); | ||
| return -MPL3115A2_ERROR_CNF; |
There was a problem hiding this comment.
If the I2C read error code is kept, this one could be renamed to MPL3115A2_ERROR_WRITE. What do you think ?
drivers/mpl3115a2/mpl3115a2_saul.c
Outdated
| */ | ||
|
|
||
| /** | ||
| * @ingroup driver_mpl3115a2 |
drivers/include/mpl3115a2.h
Outdated
| * @return 0 (MPL3115A2_OK) on success | ||
| * @return -1 on error | ||
| */ | ||
| int mpl3115a2_set_standby(mpl3115a2_t *dev); |
There was a problem hiding this comment.
Please make the device descriptors const when needed/possible.
27a7fb2 to
86a4b80
Compare
86a4b80 to
38125db
Compare
|
@aabadie: I addressed your comments. |
drivers/include/mpl3115a2.h
Outdated
| * @name Oversample Ratio configuration | ||
| * @{ | ||
| */ | ||
| #define MPL3115A2_OS_RATIO_1 (0x00) /**< Oversample Ratio 1, conversion time 6 ms */ |
There was a problem hiding this comment.
Maybe this can be in a anonymous enum?
drivers/include/mpl3115a2.h
Outdated
| } mpl3115a2_t; | ||
| i2c_t i2c; /**< I2C bus the device is connected to */ | ||
| uint8_t addr; /**< I2C bus address of the device */ | ||
| uint8_t rate; /**< sampling rate */ |
There was a problem hiding this comment.
is it oversample ratio ? I would call it oversampling ratio btw
0a6072c to
9d950f9
Compare
|
@aabadie happy? Regarding your comment on i2c read/write errors and matching return value, we don't have that for any other i2c driver. I see you point that this distinction might be useful, however, IMO we should generalize i2c error codes for return anyway - that is: define them in the i2c header file instead of redefinition for each and every driver. |
9d950f9 to
8453274
Compare
8453274 to
addf643
Compare
Yes ! |
|
There are lots of things that could be improved/modified with drivers implementation. |
|
and go! |
yes, I2C is missing a major overhaul - though, @haukepetersen is/was already working on this |