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

drivers: serial: lis3mdl: support for SPI #75858

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DeMurlot
Copy link

This pull request add two things to the lis3mdl driver

  • support for usage through SPI
  • Kconfig option to enable die temperature reading

The first part is heavily inspired by the lsm6dsl's way of supporting both I2C and SPI.

@DeMurlot
Copy link
Author

The current Kconfig default is to disable support for die temperature measurement and breaks backwards comparability. Should I enable it by default?

Copy link

Hello @DeMurlot, and thank you very much for your first pull request to the Zephyr project!
Our Continuous Integration pipeline will execute a series of checks on your Pull Request commit messages and code, and you are expected to address any failures by updating the PR. Please take a look at our commit message guidelines to find out how to format your commit messages, and at our contribution workflow to understand how to update your Pull Request. If you haven't already, please make sure to review the project's Contributor Expectations and update (by amending and force-pushing the commits) your pull request if necessary.
If you are stuck or need help please join us on Discord and ask your question there. Additionally, you can escalate the review when applicable. 😊

@jeppenodgaard
Copy link
Collaborator

The current Kconfig default is to disable support for die temperature measurement and breaks backwards comparability. Should I enable it by default?

I think it is safest to keep it as is.

If it is changed I think that change should have its own commit, and maybe probably be mentioned in the 4.0 migration guide.

@jeppenodgaard
Copy link
Collaborator

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.

The first commit looks ok a part a couple of comments


__ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL);

/* fetch magnetometer sample */
if (i2c_burst_read_dt(&config->i2c, LIS3MDL_REG_SAMPLE_START,
(uint8_t *)buf, 8) < 0) {
(uint8_t *)buf, 6) < 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

But where are you reading the two temperature bytes? I see nothing under ifdefs here below...

@@ -85,11 +91,12 @@ int lis3mdl_sample_fetch(const struct device *dev, enum sensor_channel chan)
LOG_DBG("Failed to fetch temperature sample.");
return -EIO;
}
drv_data->temp_sample = sys_le16_to_cpu(buf[3]);
Copy link
Collaborator

@avisconti avisconti Aug 7, 2024

Choose a reason for hiding this comment

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

where did you read these two bytes?

EDIT:
Sorry, I saw the code

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.

maybe we could move to stmemsc directly instead of introducing hw_tf?

@@ -0,0 +1,8 @@
# Copyright (c) 2017, Linaro Limited
Copy link
Collaborator

Choose a reason for hiding this comment

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

2024 and maybe not Linaro

Copy link
Author

Choose a reason for hiding this comment

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

fixed, thank you

@@ -0,0 +1,8 @@
# Copyright (c) 2017, Linaro Limited
Copy link
Collaborator

Choose a reason for hiding this comment

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

2024 and Linaro?

Copy link
Author

Choose a reason for hiding this comment

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

fixed

static struct lis3mdl_data lis3mdl_data_##inst; \
static struct lis3mdl_config lis3mdl_config_##inst = \
LIS3MDL_CONFIG_I2C(inst); \
LIS3MDL_DEVICE_INIT(inst)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this macro is common between i2c and spi, so maybe you can call only once in LIS3MDL_DEFINE() as some other st driver do.

Copy link
Author

Choose a reason for hiding this comment

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

done

.bus_init = lis3mdl_i2c_init, \
.bus_cfg.i2c = I2C_DT_SPEC_INST_GET(inst), \
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, irq_gpios), \
(LIS3MDL_CFG_IRQ(inst)), ()) \
Copy link
Collaborator

Choose a reason for hiding this comment

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

same for i2c and spi. Maybe call only once?

@avisconti
Copy link
Collaborator

@DeMurlot I guess you may also want to add the spi test for the sensor in tests/drivers/build_all/sensor/

DeMurlot added 2 commits September 16, 2024 23:56
The LIS3MDL sensor driver is slowed down by an additional
transaction to fetch the die temperature. This commit allowes to
enable/disable this via a KConfig option. Default is enables in
order to preserve backwards compatability.

Signed-off-by: De Murlot <demurlotpierre@gmail.com>
The LIS3MDL sensor driver does not support SPI.
This commit adds support for usage through SPI.

Signed-off-by: De Murlot <demurlotpierre@gmail.com>
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Nov 16, 2024
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