Example usage of ISM330DHCX sensor and some of its internal features.
It was my experiment with some concepts, never intended to publish. Later I decided to finish it. I mostly code bare-metal stuff in C but here for reasons I don't remember is C++.
- Fully developed I2C with DMA (DMA for reading), safety-focused with error detection, write verification, retries, bus ownership and bus recovery.
- Data noise reduction with offset calibration, noise threshold, kalman filter.
- Interrupt-driven measurment of gyroscope data for proper integration with internal timer to compute d_t.
- Non-blocking state machine for Reading gyroscope, accelerometer and sensor fusion.
- Tap detection and pedometer.
- I think my read->update->verify mechanism can be done differently. Manually setting clear mask manually is annoying.
- Ownership mechanism isn't fully developed as it doesn't make sense with a single device on a bus.I could use function pointers for callback routine.
- Recovery mechanism could include reinitialisation of peripheral devices on I2C bus. Currently if we cut off power supply from ISM330 it stops working because its settings are restarted.
Unfortunately, Finite State Machine and Machine Learning Core is not included in this repository. Maybe I will do them in future.
Sensor's documentation: https://www.st.com/resource/en/datasheet/ism330dhcx.pdf
- STM32F446RE
- Adafruit ISM330DHCX module
Interrupt pin INT1 is connected to Pin C12. SDL and SDA are connected to I2C1 via D15/D14 on Arduino-like pins.
- In root CMakeLists.txtchange the CMSIS directory or copy CMSIS toCMSISfolder. Furthermore, if you have a different board you must update the files, see the structure ofSTM32F446REfolder.
- CMake build: run make init-linuxormake init-windows.
- Compile: run make compile. The binaries will be inbinfolder.
- Upload: run make upload. Remember to set the ST-Link directory if you are using windows. Remember to change the file name in makefile if you change project name in CMake.