-
Notifications
You must be signed in to change notification settings - Fork 2.1k
drivers/lis2dh12: add I2C mode #8419
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/lis2dh12: add I2C mode #8419
Conversation
the initialization order for the i2c mode was broken (see #8446), fixed now. |
1d4de88
to
f54e0cc
Compare
908500d
to
ee7592a
Compare
All dependencies are merged, ready for review and testing. |
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.
Tested with thingy52.
I had to add PSEUDOMODULES += lis2dh12_i2c
to the makefiles/pseudomodules.inc.mk
but after that everything worked.
I took me a little while to figure out how to flash and term in but I think #11341 helps with that.
Tested with the test/driver_lis2dh12 and with examples/default, both work and have expected values.
Maybe also rebase and fix the conflicts.
Maybe you want to have a look at #10793 ? |
@haukepetersen mind to rebase? I happen to have a board with this very sensor here. |
|
||
#ifndef MODULE_LIS2DH12_SPI | ||
/* in the current state, the I2C driver expects the bus to be acquired | ||
* before the init function is called, so we have to switch order */ |
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.
Is this still true?
static int _init_bus(const lis2dh12_t *dev) | ||
{ | ||
/* for I2C, we initialize the bus in master mode */ | ||
if (i2c_init_master(BUS, BUS_CLK) != BUS_OK) { |
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.
This function does not exist anymore.
Because we need that driver anyway, I have taken the liberty to rebase this to master and adopt it to the changes in the i2c API. See #12290 for the updated version. |
Contribution description
The PR adapts the
lis2dh12
driver to work also in I2C mode, which is the used configuration on thethingy52
.Issues/PRs references
rebased on cpu/nrf52: optimized I2C driver #8385thingy52