Skip to content

Commit

Permalink
disabled line length check and relying on soft line wraps
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottGibb committed Nov 29, 2024
1 parent 8cd89db commit 69a57e0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .markdownlint.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "default": true, "line-length": { "line_length": 1000 } }
{ "default": true, "line-length": false }
59 changes: 8 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,71 +4,28 @@

## Summary

This is a platform agnostic Rust Driver for the TMAG52732 3 Axis I2C
Hall effect Sensor by Texas Instruments. The driver is based on the
[embedded-hal](https://github.com/rust-embedded/embedded-hal) traits.
For more information it is recommended to look at the docs using `cargo doc`
This is a platform agnostic Rust Driver for the TMAG52732 3 Axis I2C Hall effect Sensor by Texas Instruments. The driver is based on the [embedded-hal](https://github.com/rust-embedded/embedded-hal) traits. For more information it is recommended to look at the docs using `cargo doc`

## The Device

An extract taken from the [Texas Instruments Datasheet](./docs/tmag5273.pdf):
>The TMAG5273 is a low-power linear 3D Hall-effect
sensor designed for a wide range of industrial
and personal electronics applications. This device
integrates three independent Hall-effect sensors in
the X, Y, and Z axes. A precision analog signal-chain
along with an integrated 12-bit ADC digitizes
the measured analog magnetic field values. The
I2C interface, while supporting multiple operating
VCC ranges, ensures seamless data communication
with low-voltage microcontrollers. The device has an
integrated temperature sensor available for multiple
system functions, such as thermal budget check or
temperature compensation calculation for a given
magnetic field.The TMAG5273 can be configured through the I2C
interface to enable any combination of magnetic
axes and temperature measurements. Additionally,
the device can be configured to various power
options (including wake-up and sleep mode) allowing
designers to optimize system power consumption
based on their system-level needs. Multiple sensor
conversion schemes and I2C read frames help
optimize throughput and accuracy. A dedicated
INT pin can act as a system interrupt during
low power wake-up and sleep mode, and can also be used by a
microcontroller to trigger a new sensor conversion.An integrated
angle calculation engine (CORDIC)
provides full 360° angular position information for both
on-axis and off-axis angle measurement topologies.
The angle calculation is performed using two
user-selected magnetic axes. The device features
magnetic gain and offset correction to mitigate the
impact of system mechanical error sources.The TMAG5273 is
offered in four different factory-programmed I2C addresses.
The device also supports additional I2C addresses through the modification
of a user-configurable I2C address register. Each
orderable part can be configured to select one of two
magnetic field ranges that suits the magnet strength
and component placement during system calibration.
>The TMAG5273 is a low-power linear 3D Hall-effect sensor designed for a wide range of industrial and personal electronics applications. This device integrates three independent Hall-effect sensors in the X, Y, and Z axes. A precision analog signal-chain along with an integrated 12-bit ADC digitizes the measured analog magnetic field values. The I2C interface, while supporting multiple operating VCC ranges, ensures seamless data communication with low-voltage microcontrollers. The device has an integrated temperature sensor available for multiple system functions, such as thermal budget check or temperature compensation calculation for a given magnetic field.The TMAG5273 can be configured through the I2C interface to enable any combination of magnetic axes and temperature measurements. Additionally, the device can be configured to various power options (including wake-up and sleep mode) allowing designers to optimize system power consumption based on their system-level needs. Multiple sensor conversion schemes and I2C read frames help optimize throughput and accuracy. A dedicated INT pin can act as a system interrupt during low power wake-up and sleep mode, and can also be used by a microcontroller to trigger a new sensor conversion.An integrated angle calculation engine (CORDIC) provides full 360° angular position information for both
on-axis and off-axis angle measurement topologies. The angle calculation is performed using two user-selected magnetic axes. The device features magnetic gain and offset correction to mitigate the
impact of system mechanical error sources.The TMAG5273 is offered in four different factory-programmed I2C addresses. The device also supports additional I2C addresses through the modification
of a user-configurable I2C address register. Each orderable part can be configured to select one of two magnetic field ranges that suits the magnet strength and component placement during system calibration.

## Examples

Examples on how to use the driver across multiple platforms can be found [here](./examples/README.md)

## Architecture Diagrams

The rough architecture of the files and directories of the project can be seen in
the following plantUML diagram.
The rough architecture of the files and directories of the project can be seen in the following plantUML diagram.

![System Architecture](./docs/architecture.png)

As an application developer, you will spend most of your time working with the
TMAG5273 struct outlined in [lib.rs](./src/lib.rs). The device can initialised
by the `init_default` method and configuration can be done using the methods
outlined in [config.rs](./src/config.rs). However for fine grained control
of the device you can set and configure the raw registers outlined in the
folder [registers](./src/registers/). More information around the code can
be found using `cargo doc`.
As an application developer, you will spend most of your time working with the TMAG5273 struct outlined in [lib.rs](./src/lib.rs). The device can initialised by the `init_default` method and configuration can be done using the methods outlined in [config.rs](./src/config.rs). However for fine grained control of the device you can set and configure the raw registers outlined in the
folder [registers](./src/registers/). More information around the code can be found using `cargo doc`.

## Helper Utilities

Expand Down
41 changes: 12 additions & 29 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

## Summary

Within this directory are a set of examples for different platforms the goal
being to show the developer how to use the driver on each platform. The driver
should be platform agnostic and the API should be the same regardless of whether
you are on MCU or Linux/Mac. However what will change is the setup of the I2C bus.
Within this directory are a set of examples for different platforms the goal being to show the developer how to use the driver on each platform. The driver should be platform agnostic and the API should be the same regardless of whether you are on MCU or Linux/Mac. However what will change is the setup of the I2C bus.

When working on a desktop environment the sensor will be attached via
[FT232H Breakout Board](https://www.adafruit.com/product/2264)
When working on a desktop environment the sensor will be attached via [FT232H Breakout Board](https://www.adafruit.com/product/2264)

The different set ups are shown below in the architectural diagram:
![alt text](../docs/Example%20Setup.png)
Expand All @@ -17,8 +13,7 @@ The different set ups are shown below in the architectural diagram:

### How to Install (Desktop Linux)

When working with Desktop Linux you may find you need to install the following
in order to work with the [FT232H](https://www.adafruit.com/product/2264) breakout board.
When working with Desktop Linux you may find you need to install the following in order to work with the [FT232H](https://www.adafruit.com/product/2264) breakout board.

```bash
sudo apt update
Expand All @@ -37,17 +32,15 @@ If you are having trouble it may be worth looking into:

- [CircuitPython Libraries on Any Computer with FT232H](https://learn.adafruit.com/circuitpython-on-any-computer-with-ft232h/mac-osx)

or subsequently brew might not install correctly the libftdi library. It may be
worth unlinking and linking the library using the following command:
or subsequently brew might not install correctly the libftdi library. It may be worth unlinking and linking the library using the following command:

```bash
brew unlink libftdi && brew link libftdi
```

## Optional Dependencies

When listing usb devices you might find `lsusb` useful to which you will
need to do the following:
When listing usb devices you might find `lsusb` useful to which you will need to do the following:

### Linux

Expand All @@ -64,11 +57,7 @@ brew install lsusb

## How to Run

When running the examples you can choose whether or not you are using the default
features or not. The default in this case is using the [F232H breakout Board](https://www.adafruit.com/product/2264).
If for example you are on an embedded linux target such as [Raspberry Pi 4](https://thepihut.com/products/raspberry-pi-4-model-b?srsltid=AfmBOoolrtsYiOQS76-MPYKOBSdasCelv9UJTsQdYcnP0x3TWljbWtMN)
you can use the `rpi` feature that will use the on board i2c hardware.
This will swap the `setup_i2c` method and allow the examples to work as expected.
When running the examples you can choose whether or not you are using the default features or not. The default in this case is using the [F232H breakout Board](https://www.adafruit.com/product/2264). If for example you are on an embedded linux target such as [Raspberry Pi 4](https://thepihut.com/products/raspberry-pi-4-model-b?srsltid=AfmBOoolrtsYiOQS76-MPYKOBSdasCelv9UJTsQdYcnP0x3TWljbWtMN) you can use the `rpi` feature that will use the on board i2c hardware. This will swap the `setup_i2c` method and allow the examples to work as expected.

```bash
cargo build
Expand All @@ -78,33 +67,27 @@ cargo run --example example_1_basic_readings --no-default-features --features rp

### Running a BareMetal Example

As the library adheres to the [embedded-hal](https://docs.rs/embedded-hal/latest/embedded_hal/),
the library should be able to run in `no-std` environment. A
[esp32c3](https://github.com/esp-rs/esp-rust-board) example is shown [here](./esp32-c3/src/main.rs).
Due to it using a baremetal environment its recommended to go to that directory
and call `cargo run` from within it and flash the code on to the device.
As the library adheres to the [embedded-hal](https://docs.rs/embedded-hal/latest/embedded_hal/), the library should be able to run in `no-std` environment. A [esp32c3](https://github.com/esp-rs/esp-rust-board) example is shown [here](./esp32-c3/src/main.rs). Due to it using a baremetal environment its recommended to go to that directory and call `cargo run` from within it and flash the code on to the device.

### SparkFun Examples

The examples provided for `std` targets are heavily based off the corresponding
Arduino/C++ Library written by Sparkfun linked [here](https://github.com/sparkfun/SparkFun_TMAG5273_Arduino_Library).
The examples provided for `std` targets are heavily based off the corresponding Arduino/C++ Library written by Sparkfun linked [here](https://github.com/sparkfun/SparkFun_TMAG5273_Arduino_Library).

### F232H on MAC

When working with [FT32H](https://www.adafruit.com/product/2264), you must
find the right device id, this can be done by using `lsusb`:
When working with [FT32H](https://www.adafruit.com/product/2264), you must find the right device id, this can be done by using `lsusb`:

```bash
❯ lsusb
Bus 003 Device 001: ID 1e91:4002 1e91 OWC Thunderbolt 3 Dock SD Card Reader Serial: 000000001616
Bus 003 Device 002: ID 1e91:4001 1e91 OWC Thunderbolt 3 Audio Device
Bus 003 Device 002: ID 1e91:4001 1e91 OWC Thunderbolt 3 Audio Device
Bus 003 Device 007: ID 0403:6014 Future Technology Devices International Limited Composite Device # This is the device here!!
Bus 000 Device 001: ID 1d6b:XHCI
XHCI
XHCI
1100 Linux Foundation USB 3.1 Bus
1100 Linux Foundation USB 3.1 Bus
Bus 000 Device 001: ID 1d6b:1100
XHCI Linux Foundation USB 3.0 Bus
XHCI Linux Foundation USB 3.0 Bus
```

These numbers should match the numbers inside [here](../utils/src/lib.rs).
14 changes: 4 additions & 10 deletions utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@

## Summary

This internal crate is a utilities package designed for connecting the Embedded
Targets to the Library as such it is not to be used as part of the library.
This internal crate is a utilities package designed for connecting the Embedded Targets to the Library as such it is not to be used as part of the library.

The main thing this crate offers is a generic way of setting up the I2C Bus on
different Linux/MacOS targets. This is done through the `setup_i2c()` method
outlined in [lib.rs](./src/lib.rs).
The main thing this crate offers is a generic way of setting up the I2C Bus on different Linux/MacOS targets. This is done through the `setup_i2c()` method outlined in [lib.rs](./src/lib.rs).

### Features

This crates offers essentially two features:

- std: This pulls in the [ftdi-embedded-hal](https://github.com/ftdi-rs/ftdi-embedded-hal/tree/main)
crate which allows the user to use the [F232H Breakout Board](https://thepihut.com/products/adafruit-ft232h-breakout-general-purpose-usb-to-gpio-spi-i2c)
- std: This pulls in the [ftdi-embedded-hal](https://github.com/ftdi-rs/ftdi-embedded-hal/tree/main) crate which allows the user to use the [F232H Breakout Board](https://thepihut.com/products/adafruit-ft232h-breakout-general-purpose-usb-to-gpio-spi-i2c)

- rpi: This pulls both the [ftdi-embedded-hal](https://github.com/ftdi-rs/ftdi-embedded-hal/tree/main)
crate and the [rppal](https://github.com/golemparts/rppal) crate allowing the
user to select either I2C via hardware on the board or through the
[FT232H Breakout Board](https://thepihut.com/products/adafruit-ft232h-breakout-general-purpose-usb-to-gpio-spi-i2c).
crate and the [rppal](https://github.com/golemparts/rppal) crate allowing the user to select either I2C via hardware on the board or through the [FT232H Breakout Board](https://thepihut.com/products/adafruit-ft232h-breakout-general-purpose-usb-to-gpio-spi-i2c).

0 comments on commit 69a57e0

Please sign in to comment.