I2C driver for DS1339 RTC & LSM9DS1 & Flir Lepton
Rayman
Posts: 14,662
Finally able to test out the real time clock on my first P2 board.
This reads the time and displays over serial connection.
Optionally sets the time.
The driver was converted from Spin1. That was maybe a mistake. Took a long time to work the bugs out...
This code starts a new cog to do the bit-banging in assembly.
But, I'm thinking that Spin2 (especially with Fastspin) should be plenty fast enough to do this without starting a cog.
Also, if there's probably some smartpin mode that can do this in the background.
Still, I also want it to do the LSM9DS1 9dof chip. That one may need a cog to make sure no data from the stream is lost.
The P1 code worked for LSM9DS0. I'm hoping the interface is the same, but don't have it working yet...
Update: Now works with LSM9DS1 & Flir Lepton
Update2: Now works with PNut v34 and FastSpin 4.3.0 (but for the lam9ds1 you need to replace waitcnt with waitms on the last line of code for pnut)
This reads the time and displays over serial connection.
Optionally sets the time.
The driver was converted from Spin1. That was maybe a mistake. Took a long time to work the bugs out...
This code starts a new cog to do the bit-banging in assembly.
But, I'm thinking that Spin2 (especially with Fastspin) should be plenty fast enough to do this without starting a cog.
Also, if there's probably some smartpin mode that can do this in the background.
Still, I also want it to do the LSM9DS1 9dof chip. That one may need a cog to make sure no data from the stream is lost.
The P1 code worked for LSM9DS0. I'm hoping the interface is the same, but don't have it working yet...
Update: Now works with LSM9DS1 & Flir Lepton
Update2: Now works with PNut v34 and FastSpin 4.3.0 (but for the lam9ds1 you need to replace waitcnt with waitms on the last line of code for pnut)
Comments
I wasn't floating SDA in order to read the ack/nak bit correctly on write.
That's fixed now in updated post.
Note: This is running at 800 kHz. For 400 kHz change the 100 to 200 here at bottom of driver code:
Thats a nice board btw.
Updated top post.
But, it needs to be rewritten to use smartpins….
Haven't started on the video part yet.
Hoping can do the Flir 3.5 with higher resolution...
re:Thanks. I got it working with LSM9DS1 and Flir Lepton today.
That's great, I'm interested in the Flir Lepton as well. You did a really great job on your P2 board.
What brand soldering paste do you use with your T- 962-A ?
Think it was Chip Quick brand.
But, I've used others before... Doesn't seem to matter...
The no-clean leaded solder always seems to work well...
Tested with DS1339 RTC.
Need to make sure still works for 9DOF Mems and Flir Lepton.
Thanks Rayman, those are very useful modules, and I am sure the coding will be well appreciated.
Some of us like the BNO055 because it also does the 3D calculations and produces Euler angles and Quaternions. - any chance of cracking that interface/code?
There is some serious maths involved in calculating Euler angles and Quaternions from raw IMU readings.
I would rather focus my coding on controlling the platform than background maths coding.
But first, I think I'll try this Madgwick filter thing I found at Adafruit...
Looks fairly straightforward to implement...
The LSM9DS1 code needs some work first though.
Was adapting, LSM9DS0 driver, but there are some big differences to work out...
Did you ever post the driver for the Flir lepton? Which generation leptop did you use?
I've been playing with a purethermal board and also my friends board, both use STM32s to decode the "video over spi". I'm interested in hooking this up to the P2
I'm meaning to do this in FlexProp C this time.
But, maybe with the I2C in .spin2.
Been meaning to do the new Flir Lepton with higher resolution too.
Have all the bits and parts, just need to find time to put it all together...
Wasn't too hard to adapt, but I got hung up for a while on this business of P2 bit banging time difference between OUT and IN...
Had to insert some NOPs after SPI clock falling edge to get good data.
Think I'll see about showing this on VGA next.
Also, want to try with new higher resolution version.