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

Add support for TMAG5170 3d Hall effect sensor #61346

Merged
merged 2 commits into from Sep 26, 2023

Conversation

morsisko
Copy link
Contributor

@morsisko morsisko commented Aug 9, 2023

Hello,

this pull request adds support for Texas Instruments' TMAG5170 high-precision, linear 3D Hall-effect sensor with SPI bus interface.
For now following features are implemented:

  • Reading 3 different magnetic channels
  • Reading temperature
  • Reading angular rotation of magnet
  • Data ready triggers
  • Various operating modes (continuous conversion, manual trigger)
  • Power management (deep sleep mode)
  • Error detection in TX/RX data using CRC
    Most of the configuration is done via devicetree and not Kconfig, this is because in my opinion this gives the end user more flexibility, as they can connect multiple TMAGs with different settings (for example one sensor with fast sampling, another one for slow and redundancy)

Also I'm not sure about the CRC. As for now Zephyr is missing CRC4, I've added two CRC4 algorithms. One that is specific to TMAG (crc4_ti) and another one that is generic. They would both work for this sensor, one is just faster. Not sure if I should leave the crc4_ti, or stick to crc4. Maybe I shouldn't touch the lib/os/crc library, instead implement the crc algorithm directly in the sensor driver code? I'm open for suggestions.

@morsisko
Copy link
Contributor Author

I would be thankful for a hint on how to resolve the unit tests issues. Did I forgot to add the sensor somewhere? The device tree error is unclear to me

@morsisko morsisko force-pushed the tmag5170_working branch 2 times, most recently from 927948c to 0b46a19 Compare August 15, 2023 17:49
MaureenHelm
MaureenHelm previously approved these changes Sep 21, 2023
Copy link
Member

@MaureenHelm MaureenHelm left a comment

Choose a reason for hiding this comment

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

Looks great, thank you. Please rebase and resolve the merge conflict

Add two new functions: crc4 for generic calculations
of CRC4, and crc4_ti which use look-up table for
faster calculations of CRC4 algortihms that base
on 0x03 polynomial.

Signed-off-by: Michal Morsisko <morsisko@gmail.com>
Introduce support for Texas Instruments TMAG5170
high-precision linear 3D Hall-effect SPI sensor.
This driver allows to configure measurements on
magnetic and temperature channels. It is also
possible to read rotation of the magnet.

Signed-off-by: Michal Morsisko <morsisko@gmail.com>
@morsisko
Copy link
Contributor Author

Conflicts has been resolved, PR is now rebased

@carlescufi carlescufi merged commit 8e32b5e into zephyrproject-rtos:main Sep 26, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Base OS Base OS Library (lib/os) area: Devicetree Binding PR modifies or adds a Device Tree binding area: Sensors Sensors platform: TI SimpleLink Texas Instruments SimpleLink MCU
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants