sens0: Simple sensor device interface #9075
Closed
jnohlgard wants to merge 7 commits intoRIOT-OS:masterfrom
Closed
sens0: Simple sensor device interface #9075jnohlgard wants to merge 7 commits intoRIOT-OS:masterfrom
jnohlgard wants to merge 7 commits intoRIOT-OS:masterfrom
Conversation
b9a4036 to
9d8ab38
Compare
Member
Author
|
I have prepared an auto init implementation which uses xfa (#7523) for the device configuration instances, but let's merge this without auto init first to ease review. |
c29f7ef to
c5ba2b1
Compare
added 7 commits
June 1, 2018 17:28
The sens0 driver provides an easy way to interface with sensors when the application only requires a basic measurement functionality.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you want me to ignore this issue, please mark it with the "State: don't stale" label. Thank you for your contributions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contribution description
Provide an easy way to interface new sensors without writing a lot of boilerplate code.
This driver provides a basic polled interface for digital sensors, currently only I2C is supported, but it will be a small effort to add SPI support later.
The output format from the sens0 read API was chosen as
phydat_t, which makes this a good match for using with SAUL.An example application is provided in tests/driver_sens0. The example application is configured for the onboard accelerometer on FRDM-K64F, and an optional external FRDM-STBC-AGM01 IMU 9DOF shield.
This driver is meant to only provide a basic polled read functionality of digital sensors and will not support interrupts, FIFOs, caching, or other more advanced features, which are usually more difficult to generalize into a generic interface like this.
Background
Three important observations:
Interfacing with a basic digital sensor in RIOT today requires writing or copying a whole bunch of boilerplate code, just to get some readings from the sensor. The Sens0 driver is meant to eliminate as much as possible of the boilerplate and leaving the developer to only create a simple hardware specification, which contains information about what registers to write during init, where to find the output, and how to parse the raw output into something usable. This will obviously limit the functionality compared to writing a specific driver from the ground up, but it also takes a lot less time to configure.
As an example, I wrote the fully working FXAS21002C hardware interface specification in some 15 minutes, without any prior experience with that particular sensor.