Skip to content

drivers/mpl3115a2: rework#7120

Merged
aabadie merged 3 commits intoRIOT-OS:masterfrom
smlng:drivers/mpl3115a2/rework
Jun 29, 2017
Merged

drivers/mpl3115a2: rework#7120
aabadie merged 3 commits intoRIOT-OS:masterfrom
smlng:drivers/mpl3115a2/rework

Conversation

@smlng
Copy link
Copy Markdown
Member

@smlng smlng commented May 31, 2017

  • rework driver interface
  • adapt test
  • add saul support -> i.e., for pba-d-01-kw2x

@smlng smlng added Area: drivers Area: Device drivers Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels May 31, 2017
@smlng smlng self-assigned this May 31, 2017
@smlng smlng requested a review from PeterKietzmann May 31, 2017 20:20
@smlng smlng added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jun 1, 2017
enum {
MPL3115A2_OK, /**< all good */
MPL3115A2_ERROR_I2C, /**< I2C communication failed */
MPL3115A2_ERROR_DEV, /**< Device MAG3110 not found */
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self: typo /MAG3110/MPL3115A2/

/**@}*/

/**
* @brief MAG3110 configuration
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to self: typo again

@smlng smlng force-pushed the drivers/mpl3115a2/rework branch 2 times, most recently from 944f748 to 7aa65e2 Compare June 1, 2017 07:45
@smlng smlng added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jun 2, 2017
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 9, 2017

see #7152, too

@smlng smlng requested a review from aabadie June 13, 2017 14:27
@smlng smlng force-pushed the drivers/mpl3115a2/rework branch 5 times, most recently from 3d70f6b to a3df41f Compare June 15, 2017 09:21
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 15, 2017

anybody willing to review, this is would finally resolve (and close) issue #7152

@smlng smlng force-pushed the drivers/mpl3115a2/rework branch 2 times, most recently from 0c139df to fe8509c Compare June 15, 2017 13:16
@smlng smlng added this to the Release 2017.07 milestone Jun 20, 2017
Copy link
Copy Markdown
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick review: see comments below.

*
* 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

active

*
* @return 0 on success
* @return -1 on error
* @return 0 (MPL3115A2_OK) on success
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use MPL3115A2 on success (no need to specify 0)

* @return 0 on success
* @return -1 on error
* @return 0 (MPL3115A2_OK) on success
* @return -1 (MPL3115A2_ERROR_I2C) on error
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above: -MPL3115A2_ERROR_I2C on error

*
* @return 0 on success
* @return -1 on error
* @return 0 (MPL3115A2_OK) on success
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above

*
* @return 0 on success
* @return 0 (MPL3115A2_OK) on success
* @return -1 on error
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a specific enum for I2C read error could be used ?

if (i2c_write_regs(BUS, ADDR, MPL3115A2_CTRL_REG1, &reg, 1) != 1) {
i2c_release(BUS);
LOG_ERROR("mpl3115a2_init: failed to set sample rate!\n");
return -MPL3115A2_ERROR_CNF;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the I2C read error code is kept, this one could be renamed to MPL3115A2_ERROR_WRITE. What do you think ?

*/

/**
* @ingroup driver_mpl3115a2
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

drivers_mpl3115a2

* @return 0 (MPL3115A2_OK) on success
* @return -1 on error
*/
int mpl3115a2_set_standby(mpl3115a2_t *dev);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the device descriptors const when needed/possible.

@smlng smlng force-pushed the drivers/mpl3115a2/rework branch 2 times, most recently from 27a7fb2 to 86a4b80 Compare June 25, 2017 08:04
@smlng smlng force-pushed the drivers/mpl3115a2/rework branch from 86a4b80 to 38125db Compare June 25, 2017 08:05
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 26, 2017

@aabadie: I addressed your comments.

Copy link
Copy Markdown
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @smlng.
I made another pass of review and have new comments.

* @name Oversample Ratio configuration
* @{
*/
#define MPL3115A2_OS_RATIO_1 (0x00) /**< Oversample Ratio 1, conversion time 6 ms */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this can be in a anonymous enum?

} 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 */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it oversample ratio ? I would call it oversampling ratio btw

@smlng smlng force-pushed the drivers/mpl3115a2/rework branch 2 times, most recently from 0a6072c to 9d950f9 Compare June 26, 2017 18:30
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 29, 2017

@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.

@smlng smlng force-pushed the drivers/mpl3115a2/rework branch from 9d950f9 to 8453274 Compare June 29, 2017 07:52
@smlng smlng force-pushed the drivers/mpl3115a2/rework branch from 8453274 to addf643 Compare June 29, 2017 07:57
@kaspar030 kaspar030 changed the title drivers, mpl3115a2: rework drivers/mpl3115a2: rework Jun 29, 2017
@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Jun 29, 2017

@aabadie happy?

Yes !

@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Jun 29, 2017

There are lots of things that could be improved/modified with drivers implementation.

Copy link
Copy Markdown
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@aabadie
Copy link
Copy Markdown
Contributor

aabadie commented Jun 29, 2017

and go!

@aabadie aabadie merged commit 7251448 into RIOT-OS:master Jun 29, 2017
@smlng
Copy link
Copy Markdown
Member Author

smlng commented Jun 29, 2017

There are lots of things that could be improved/modified with drivers implementation.

yes, I2C is missing a major overhaul - though, @haukepetersen is/was already working on this

@smlng smlng deleted the drivers/mpl3115a2/rework branch June 29, 2017 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: drivers Area: Device drivers CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants