LSM9DS1 example from ST's C driver library working with Fastspin's FlexC
Rayman
Posts: 14,646
Here's another example of how nice Fastspin's FlexC C compiler is to work with...
The LSM9DS1 is a 9DOF MEMS device from ST with 3-axis accelerometer, 3-axis gyro and 3-axis magnetometer, all in one device.
By just adding in P2 specific i2c code got the code ST's C library to run.
There are a lot of other driver that that will presumable also work: https://github.com/STMicroelectronics/STMems_Standard_C_drivers
One great thing is that I was able to use the Spin2 i2c driver from OBEX (Thanks @JonnyMac !).
Being able to use .Spin2 code directly as if it were a C++ class is a really, really nice feature of FlexC.
The self-test code just says some stuff and then pass at the end. But, the "lsm9ds1_read_data_polling_P2.c" example is perfect for my needs.
Gives floating point output in units of mg, mdps and mG (Screenshot attached).
It runs very fast, I had to put in a pause so I could actually read the output in between samples...
Code attached.
The LSM9DS1 is a 9DOF MEMS device from ST with 3-axis accelerometer, 3-axis gyro and 3-axis magnetometer, all in one device.
By just adding in P2 specific i2c code got the code ST's C library to run.
There are a lot of other driver that that will presumable also work: https://github.com/STMicroelectronics/STMems_Standard_C_drivers
One great thing is that I was able to use the Spin2 i2c driver from OBEX (Thanks @JonnyMac !).
Being able to use .Spin2 code directly as if it were a C++ class is a really, really nice feature of FlexC.
The self-test code just says some stuff and then pass at the end. But, the "lsm9ds1_read_data_polling_P2.c" example is perfect for my needs.
Gives floating point output in units of mg, mdps and mG (Screenshot attached).
It runs very fast, I had to put in a pause so I could actually read the output in between samples...
Code attached.
zip
66K
Comments
Here's a screen shot of a part the code that I added to read and write over I2C using the Spin2 object.
VS has really cool features like "peak definition" and great search options that save a lot of time figuring things out...