Skip to content

Latest commit

 

History

History
94 lines (61 loc) · 3.71 KB

README.md

File metadata and controls

94 lines (61 loc) · 3.71 KB

Examples

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.

When working on a desktop environment the sensor will be attached via FT232H Breakout Board

The different set ups are shown below in the architectural diagram:

alt text

Installation

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 breakout board.

sudo apt update
sudo apt install libftdi1 libftdi1-dev

How to Install (MacOS)

When working with MacOS you will need to install the following packages:

brew install libftdi

If you are having trouble it may be worth looking into:

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

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:

Linux

sudo apt update
sudo apt install lsusb

MacOS

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. If for example you are on an embedded linux target such as Raspberry Pi 4 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.

cargo build
cargo run --example example_1_basic_readings # Choose your example to run here
cargo run --example example_1_basic_readings --no-default-features --features rpi # Run on Raspberry Pi using I2C

Running a BareMetal Example

As the library adheres to the embedded-hal, the library should be able to run in no-std environment. A esp32c3 example is shown here. 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.

F232H on MAC

When working with FT32H, you must find the right device id, this can be done by using lsusb:

❯ 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 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
Bus 000 Device 001: ID 1d6b:1100
XHCI Linux Foundation USB 3.0 Bus

These numbers should match the numbers inside here.