Skip to content
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

sensors: lis2dh: fixes for Nordic use, add sample #19901

Merged
merged 3 commits into from
Oct 25, 2019

Conversation

pabigot
Copy link
Collaborator

@pabigot pabigot commented Oct 17, 2019

Rework the use of the I2C API so that functions that are not supported on Nordic are bypassed (#17801).

Add devicetree support for the LIS2DH12 on the Nordic Thingy:52 (nrf52_pca20020).

Add a sample that tests both polled and triggered readings.

Tested on nrf52_pca20020 and nucleo_l476rg+x_nucleo_iks01a2.

@zephyrbot
Copy link
Collaborator

zephyrbot commented Oct 17, 2019

All checks passed.

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

:board: stm32f3_disco
:goals: build
:compact:

Copy link
Contributor

Choose a reason for hiding this comment

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

I see the build part, but what about the flashing and running? Don't forget to mention you'll need to connect the board to your host computer and run a serial terminal program.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Huh. Copied that and most of the rest of the sample from lsm6dsl which apparently doesn't have that material.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@dbkinder Many if not most (sensor) samples have no more documentation than this; e.g.:

If there is a new expectation for how samples are to be documented, could you point me to a template I can copy? Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since you asked, there is a sample template in doc/templates/sample.tmpl. There's a comment in the samples/index.rst that points this template out but it's not obvious.

Sadly, not all samples follow this template, particularly the sensor samples that punt the issue with statements such as "Flash the binary to a board of choice with a sensor connected." but don't provide instructions on how to connect the sensor (or how to flash).

As we get new developers trying out Zephyr, we're getting more comments about incomplete documentation that I'm hoping we can resolve as new documentation shows up and we can eventually address in the documentation that's already included. If you'd like to help fix this situation, I'd appreciate your adding those instructions to your PR (and even others if you can). I'll approve this PR with those instructions missing for now if you're too busy.

@pabigot pabigot force-pushed the pr/20191017a branch 2 times, most recently from c9708e2 to 819a5b2 Compare October 18, 2019 12:54
Copy link
Collaborator

@avisconti avisconti left a comment

Choose a reason for hiding this comment

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

ok, thx

@@ -303,6 +305,21 @@ static inline int lis2dh_burst_write(struct device *dev, u8_t start_addr,

return lis2dh_spi_access(lis2dh, start_addr, buf, num_bytes);
#elif defined(DT_ST_LIS2DH_BUS_I2C)
/* NRF TWIM is default and does not support burst write. We
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a reference to issue #20154. in the comment block.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

The default I2C driver on Nordic platforms does not support the I2C
burst operations, so replace those calls with ones that work on the
platform.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
The Thingy:52 has a LIS2DH12 low-power accelerometer on the external
I2C bus.  Add the necessary description to devicetree.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Basic polled and triggered sampling of accelerometer data from
LIS2DH-compatible sensors.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
@galak galak merged commit be7a4bf into zephyrproject-rtos:master Oct 25, 2019
@pabigot pabigot deleted the pr/20191017a branch November 3, 2019 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants