gy-521/README.md

62 lines
1.5 KiB
Markdown
Raw Permalink Normal View History

2023-09-01 01:22:53 +00:00
# gy-521 Driver
2023-08-30 05:43:48 +00:00
2023-09-01 01:22:53 +00:00
The gy-521 module is usally interfaced with via TWI/I2C. The actual chip that
is used in the module is the mpu6050 ic.
2023-08-30 05:43:48 +00:00
2023-09-01 01:22:53 +00:00
This driver doesn't make any assumptions about the platform it will run
on beyond that it supports "stdlib.h" and "inttypes.h".
2023-08-30 05:43:48 +00:00
2023-09-01 01:22:53 +00:00
The interface handles all the register and bitshift operations in the
the backgorund. The module uses getters and setters to abstract the
actual data. This prevents the end user from trying to directly use the
structures data when it is volatile and may be setup to update in a ISR.
2023-08-30 05:43:48 +00:00
2023-09-01 01:22:53 +00:00
## PINs
2023-08-30 05:43:48 +00:00
2023-09-01 01:22:53 +00:00
- VCC: 3.3v
- GND: ground or 0v
- SCL: TWI clock
- SDA: TWI data
- XDA:
- XCL:
- AD0: changes the TWI address when pulled high.
- INT: interrupt pin
2023-08-30 05:43:48 +00:00
## Running and building the project
2023-09-01 01:22:53 +00:00
The project uses CMake along with cmocka for unit testing.
2023-08-30 05:43:48 +00:00
```sh
# change into the build dir
cd ./build
# generate the make files and make everything.
cmake ../ -DUNIT_TESTING=ON; make all;
# Run the tests
ctest
```
## RoadMap
2023-09-01 01:22:53 +00:00
- add in functions for interrupt driven updates.
- add functions for configuration of module.
- add functions to save configurations in memory.
- add functions to load saved configs
2023-08-31 03:16:54 +00:00
2023-09-07 05:56:14 +00:00
###Mocking the TWI/I2C
The twi needs to be mocked or faked correctly to make the testing
of the functions doable.
The best way I can find to handle this is with a buffer of twi data
that simulate registers that the program reads/writes to.
This is handled by using function pointers for the tx and rx of i2c/twi data.
2023-08-31 03:16:54 +00:00
2023-08-30 05:43:48 +00:00