-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Add vl53l1x support #15566
Add vl53l1x support #15566
Conversation
Found the following issues, please fix and resubmit: License issuesIn most cases you do not need to do anything here, especially if the files
|
e71cac7
to
86d1487
Compare
samples/sensor/vl53l1x/README.rst
Outdated
|
||
Overview | ||
******** | ||
This sample periodically measures distance between vl53l1x sensor |
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.
measures the distance between the VL53L1X sensor and a target
samples/sensor/vl53l1x/README.rst
Outdated
******** | ||
This sample periodically measures distance between vl53l1x sensor | ||
and target. The result is displayed on the console. | ||
It also shows how we can use the vl53l1x as a proximity sensor. |
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.
VL53L1X
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.
Thank you! Already changed.
86d1487
to
418b6f4
Compare
* This file is part of VL53L1 Core and is dual licensed, | ||
* either 'STMicroelectronics | ||
* Proprietary license' | ||
* or 'BSD 3-clause "New" or "Revised" License' , at your option. |
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.
Please review https://docs.zephyrproject.org/latest/contribute/index.html#contributing-non-apache-2-0-licensed-components and fill out the README template.
cc: @avisconti
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.
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.
@avisconti Thanks!
I have a question that those code under ext/hal/st/ comes from ST. Can I modify the copyright part as vl53l0x does?
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.
@overheat
For the ext part yes. You may refer to the existing VL53L0X for reference.
For the driver/sensor/vl53l1x you may change/add ur name and 2019 in the copyright section.
I think you may need to change CODEOWNER to cover that code. You should be the owner for the driver, while I think that someone from ST should for what concern the ext part (maybe myself or @erwango)
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.
@avisconti Thank you! I will update it. I will put you the CODEOWNER for the ext part, is that alright?
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.
@overheat
OK, fine.
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.
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.
So, at the end I think that you won't need to change CODEOWNERS at all.
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.
I'm not sure if it is possible to reuse some code for both VL53L0 and VL53L1 sensor. Nor if it is useful.
Maybe separating them is the right strategy. Pls add some comments to this.
If separation is required you may still want to adapt the copyright date.
* This file is part of VL53L1 Core and is dual licensed, | ||
* either 'STMicroelectronics | ||
* Proprietary license' | ||
* or 'BSD 3-clause "New" or "Revised" License' , at your option. |
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.
|
||
# | ||
# Copyright (c) 2017 STMicroelectronics | ||
# |
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.
I guess here you may want to add a new copyright (2019).
Anyway, I was thinking whether we ca re-use same driver structure for both VL53L0X and VL53L1X. They seem
similar.
|
||
VL53L1_Error VL53L1_WriteMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, | ||
uint32_t count) | ||
{ |
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.
As I was saying before do you think it is possible to re-use same routine for both VL53L1 and VL53L0?
Maybe using ifdef for the difference.
} | ||
|
||
VL53L1_Error VL53L1_ReadMulti(VL53L1_DEV Dev, uint16_t index, uint8_t *pdata, | ||
uint32_t count) |
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.
Same here.
What is the difference with VL53L0?
index is on 16-bit instead of 8-bit?
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.
Yes, the VL53L1 index is on 16-bit instead of 8-bit
I have thought about re-use same driver but looks the internal implication is different between vl53l1x and vl53l0x, as you already have seen the "index"(register address) length is not the same. Also, those API related to interrupt and threshold and so on. So there should be lots of ifdef, if we want to merge those drivers.
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.
I have thought about re-use same driver but looks the internal implication is different between vl53l1x and vl53l0x, as you already have seen the "index"(register address) length is not the same. Also, those API related to interrupt and threshold and so on. So there should be lots of ifdef, if we want to merge those drivers together.
Yes, yes. In fact my initial idea was to re-use same driver, but the more I was going deep thru the review the less I found it applicable. So at the end I left it as a comment from your side.
@avisconti @MaureenHelm @dbkinder I have modified. Please review. Thanks! |
da8c77c
to
27f64fd
Compare
Well, if I'm getting the change I guess this is not what we were expecting. You can take as an example the PR #14111 and especially the 52bc149 commit. You will see commit 52bc149f0787e51a3ee44ad7833fec50cb0e34a1
Moreover, I also added a new README file: ext/hal/st/stmemsc/README (see again #14111) So, to summarize, you have to keep the ext code original, then add a README file as I did, then Instead, what I asked you to change is the copyright of the drivers/sensor/vl53l1x driver. Does it make sense to you? |
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.
Doc changes look OK, thanks.
27f64fd
to
0df07f8
Compare
@avisconti Thank you for your patience. I have restored the ext code back to ST code original and add a README file, also modify the info in the commit msg. meanwhile, change the copyright of the drivers/sensor/vl53l1x driver. |
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.
We are almost done. See my latest comment here about using 'imply' in Kconfig for NEWLIB_LIBC.
Moreover, can you squash together the related commits?
At the end I think that you should have only 3 commits:
- ext: Add official ST library for vl53l1x
- drivers: sensor: Add vl53l1x time of flight sensor driver
- samples: sensor: Add vl53l1x time of flight sensor sample
Does it make sense?
ext/hal/st/lib/sensor/vl53l1x/README
Outdated
|
||
In order to use this library, you have to : | ||
* define CONFIG_HAS_STLIB and CONFIG_VL53L1X | ||
* use NEWLIB_LIBC in prj.conf (needed for abs function) |
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.
I'm currently adding a similar external hal from ST Microelectronics for other sensors. I also need to
define NEWLIB_LIBC, but instead of letting the user to define it in prj.conf I used imply in Kconfig of the external
code. Have you considered to do the same?
See #14111 and in particular a40e62975 commit.
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.
yes, sound better.
wait a moment, I will push again.
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.
OK, just remember to squash together similar commits as I was saying before.
I suggest to save the branch before squashing just in case
This package contains platform independent drivers written in C language for STMicroelectronics ToF sensors VL53L1X. The aim of this package is to provide a common, clean and stable interface to get ranging data. Library is located in ext/hal/st/lib/sensor/vl53l1x Origin: ST Microelectronics License: BSD-3-Clause URL: http://www.st.com/en/embedded-software/stsw-img007.html Commit: v2.3.3 Purpose: provide a common and stable i/f to get ranging data Maintained-by: ST Microelectronics Signed-off-by: Aaron Tsui <[email protected]>
Contains vl53l1x driver itself and the adaptation layer, which is implemented in the driver as it is Zephyr specific. Support its own thread (minimum latency) or share a system-wide thread (less memory) to fetch data. Also, need to clear interrupt flag after every measurement on vl53l1x. Add dts yaml file as dts/bindings/sensor/st,vl53l1x.yaml Signed-off-by: Aaron Tsui <[email protected]>
0df07f8
to
c3bd67e
Compare
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.
Good job!
c3bd67e
to
66d27b8
Compare
Fix minor bugs. |
vl53l1x time of flight (TOF) sensor sample, fetching proximity and distance data in every second. Add overlay file for nucleo_f401re to make this sample works out-of-box. Signed-off-by: Aaron Tsui <[email protected]>
66d27b8
to
f91f0ca
Compare
@avisconti yes, should I wait until that PR merged then re-trigger this CI check again? Sent with GitHawk |
Maybe you can get my commit (c18747f) from my remote repo on github, rebase on top of it and re-push everything: git add remote avisconti https://github.com/avisconti/zephyr.git I think it is important to know if it is fixing or not. |
The LL_I2S_ReadReg() function returns uint32_t, while %d requires 'int' as a type. Signed-off-by: Armando Visconti <[email protected]>
Done, let's see what happen. |
@avisconti it works. I will push again when #15857 be merged. Sent with GitHawk |
superseeded by #18772 |
VL53L1X time of flight (TOF) sensor supporting
https://www.st.com/en/imaging-and-photonics-solutions/vl53l1x.html
The vl53l1 library
To ease the usage of its vl53l1x time of flight sensor, STMicroelectronics provides this library, which is made of 2 parts :
The vl53l1x driver
Contains vl53l1x driver itself and the adaptation layer, which is implemented in the driver as it is Zephyr specific.
The vl53l1x sample
vl53l1x sensor sample, fetching proximity and distance data in every second.
Misc
documentation and overlay file