Skip to content

Conversation

@VynDragon
Copy link
Contributor

@VynDragon VynDragon commented Nov 6, 2024

This Introduces a driver for the i2c interface of Phosense XBR818.
XBR818 is a 10.525Ghz Radar chip with in-built movement detection algorithm.

Copy link
Member

@jilaypandya jilaypandya left a comment

Choose a reason for hiding this comment

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

@VynDragon
Copy link
Contributor Author

VynDragon commented Nov 7, 2024

add an entry to the build_all test https://github.com/zephyrproject-rtos/zephyr/blob/main/tests/drivers/build_all/sensor/i2c.dtsi

Addressed all the comments, can you confirm what i've added to i2c.dtsi is correct? Thanks.

Edit: I'm not sure what is causing the build failure, the changes I made shouldn't affect this, unless unknown vendor prefix breaks the test (which it shouldnt do knowing the majority of vendors are not in that list and i was told it's only a copy of the linux one, so we cant add to it).

@jilaypandya
Copy link
Member

(which it shouldnt do knowing the majority of vendors are not in that list and i was told it's only a copy of the linux one, so we cant add to it)

Try adding the vendor name over here
https://github.com/zephyrproject-rtos/zephyr/blob/main/dts/bindings/vendor-prefixes.txt

@VynDragon
Copy link
Contributor Author

Try adding the vendor name over here https://github.com/zephyrproject-rtos/zephyr/blob/main/dts/bindings/vendor-prefixes.txt

Done, but I am concerned it isn't fine, though maybe I misunderstand something.

@VynDragon
Copy link
Contributor Author

check error now is relevant to additional sensor attributes, not sure what to do given this is a pattern that exists in other drivers, maybe I am not doing it how it's supposed to be?
image
image

@jilaypandya
Copy link
Member

jilaypandya commented Nov 14, 2024

give it a try with parenthesis

#define foo (SENSOR_ATTR_PRIV_START + 1 )

Copy link
Member

@jilaypandya jilaypandya left a comment

Choose a reason for hiding this comment

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

I believe you need to refactor the files in drivers/sensor/<vendor_name>/

@VynDragon
Copy link
Contributor Author

I believe you need to refactor the files in drivers/sensor/<vendor_name>/

I dont think so, looks to be only if there is more than one sensor of the vendor (eg sensor/bosch folder vs sensor/mhz19b or sensor/hp206c for example)

@VynDragon
Copy link
Contributor Author

VynDragon commented Nov 15, 2024

Found a couple more cases of variable possibly spending longer time on stack than needed so i removed the init at 0 for them too.

@VynDragon
Copy link
Contributor Author

Rebased on latest main.

Copy link
Contributor

@yperess yperess left a comment

Choose a reason for hiding this comment

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

One more nit that I missed on the first pass, should be simple enough to update, then I think the driver looks ready.

@mbolivar
Copy link
Contributor

No objections to the vendor-prefixes.txt change. I don't see anything else for me to review here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
test_i2c_xbr818: xrb818@aa {
test_i2c_xbr818: xbr818@aa {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

i believe this is actually a violation of our coding guidelines (rule 10.3, casting enum essential type to int essential type). I think the proper solution is:

Suggested change
switch ((int)attr) {
switch ((enum sensor_attribute_xbr818)attr) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
switch ((int)attr) {
switch ((enum sensor_attribute_xbr818)attr) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This does not in the other direction this time (SENSOR_ATTR_SAMPLING_FREQUENCY case value '0' not in enumerated type 'enum sensor_attribute_xbr818'

Copy link
Contributor

Choose a reason for hiding this comment

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

Eh, right 😐
Guess this pattern might be better then

if (attr == SENSOR_ATTR_LOWER_THRESH) {
. Definitely more than one driver that's probably non conforming in-tree though...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@VynDragon VynDragon force-pushed the xbr818 branch 2 times, most recently from 1fb13b3 to 42d4704 Compare February 1, 2025 13:09
@VynDragon VynDragon requested review from kartben and yperess February 2, 2025 11:39
kartben
kartben previously approved these changes Feb 2, 2025
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noticed this, val1 can also be negative, so you should add || val->val1 < 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 252 to 257
Copy link
Contributor

Choose a reason for hiding this comment

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

Can just return xbr818_disable_i2c(dev); here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

This Introduces a driver for the i2c interface of Phosense XBR818.
XBR818 is a 10.525Ghz Radar chip with builtin detection algorithm.

Signed-off-by: Camille BAUD <[email protected]>
Copy link
Contributor

@rruuaanng rruuaanng left a comment

Choose a reason for hiding this comment

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

Thank you for taking my advice!

@kartben
Copy link
Contributor

kartben commented Feb 11, 2025

@MaureenHelm can you have a look please? PR has gone through quite a few iterations so I'm hopeful it's good to go :)

return ret;
}

static const struct sensor_driver_api xbr818_api = {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
static const struct sensor_driver_api xbr818_api = {
static DEVICE_API(sensor, xbr818_api) = {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I submit a fix commit for this given this was merged before i had the time to update it?

Copy link
Contributor

Choose a reason for hiding this comment

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

This would be great :)
Given feature freeze is in less than 24 hours I wanted to make sure this got in (and so did @MaureenHelm by not making that comment a blocker)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is at #85762

@kartben kartben merged commit 6376866 into zephyrproject-rtos:main Feb 14, 2025
24 checks passed
@VynDragon VynDragon deleted the xbr818 branch February 14, 2025 16:25
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.

9 participants